Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

81 feature frontend for engine configuration group5 #111

Open
wants to merge 113 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
44026ce
class and fields defined
DenFlyvendeGed Oct 26, 2023
6aa3d5a
Made general Dialog component
tr0ub1eM4k3r Oct 30, 2023
e2236b9
created EngineStore
DenFlyvendeGed Oct 31, 2023
5d34b62
Made EngineSeperate component
SolarEarth37 Oct 31, 2023
9b02fbd
Engine store functions implemented
DenFlyvendeGed Oct 31, 2023
5417b3b
added function comments
DenFlyvendeGed Oct 31, 2023
49c641c
Updated syntax
DenFlyvendeGed Nov 2, 2023
ca19632
Merge branch '80-Create-class-for-engines-group5' of https://github.c…
tr0ub1eM4k3r Nov 2, 2023
4e1536a
updated getEngine
DenFlyvendeGed Nov 2, 2023
1973926
fixed overflow
DenFlyvendeGed Nov 2, 2023
0265823
added tests
DenFlyvendeGed Nov 2, 2023
3178c69
created more test cases
DenFlyvendeGed Nov 2, 2023
4380085
Merge branch 'main' of https://github.com/ECDAR-AAU-SW-P5/Ecdar-GUI-W…
DenFlyvendeGed Nov 2, 2023
24a2647
Formated
DenFlyvendeGed Nov 2, 2023
9db7a9a
Cleanup
DenFlyvendeGed Nov 2, 2023
31ae3b4
Added adding and deleting engines from the view
tr0ub1eM4k3r Nov 2, 2023
19fa937
Merge branch '80-Create-class-for-engines-group5' of https://github.c…
tr0ub1eM4k3r Nov 3, 2023
478e504
Made DTO for engines
tr0ub1eM4k3r Nov 6, 2023
31c5647
Merge branch '81-feature-frontend-for-engine-configuration-group5' of…
tr0ub1eM4k3r Nov 7, 2023
b8fb464
Made engineDTO work
tr0ub1eM4k3r Nov 7, 2023
d2389a3
Added functionality for saving engines in the ui
tr0ub1eM4k3r Nov 7, 2023
5245406
Made general css for the Engine UI
SolarEarth37 Nov 8, 2023
d72a5ca
Made CSS for engine delete button and UI
SolarEarth37 Nov 9, 2023
999e3ff
Added Google icons to deletion UI
SolarEarth37 Nov 9, 2023
4c6bc54
lint fixes
tr0ub1eM4k3r Nov 9, 2023
afd67e8
Merge branch '81-feature-frontend-for-engine-configuration-group5' of…
tr0ub1eM4k3r Nov 9, 2023
14dc709
lint changes
tr0ub1eM4k3r Nov 9, 2023
168e77c
Fixed delete UI buttons
SolarEarth37 Nov 9, 2023
1f29530
Merge branches '81-feature-frontend-for-engine-configuration-group5' …
SolarEarth37 Nov 9, 2023
d211c16
Fixed issue where deleted engine will get added
tr0ub1eM4k3r Nov 9, 2023
f9f7395
Made you unable to delete the last engine
tr0ub1eM4k3r Nov 9, 2023
168c025
made dialog backdrop
tr0ub1eM4k3r Nov 9, 2023
cce7526
Merge branch 'main' of
tr0ub1eM4k3r Nov 9, 2023
6b99890
Made engineUI openable from the topbar
tr0ub1eM4k3r Nov 9, 2023
389bb2f
Incorporated global CSS in Engine UI
SolarEarth37 Nov 9, 2023
061216e
typo
DenFlyvendeGed Nov 13, 2023
be42942
Merge branch '80-Create-class-for-engines-group5' of https://github.c…
tr0ub1eM4k3r Nov 13, 2023
e100fa0
Fixed lint issues
tr0ub1eM4k3r Nov 13, 2023
3e3766f
Merge branch 'main' of https://github.com/ECDAR-AAU-SW-P5/Ecdar-GUI-W…
tr0ub1eM4k3r Nov 13, 2023
8c8f31d
Removed unnecessary code
tr0ub1eM4k3r Nov 13, 2023
9874b23
Changed file names to be more style guide fitting
tr0ub1eM4k3r Nov 13, 2023
962b49e
Made ports min and max
tr0ub1eM4k3r Nov 13, 2023
ae08857
Added comments for functions
tr0ub1eM4k3r Nov 13, 2023
f61833c
Changed naming of interface
tr0ub1eM4k3r Nov 13, 2023
3bbd132
Changed spelling
tr0ub1eM4k3r Nov 16, 2023
d7113a5
Added increased usability when deleing engnies
tr0ub1eM4k3r Nov 16, 2023
f8d8311
Added issue with deleting the last engine
tr0ub1eM4k3r Nov 16, 2023
b591e72
Merge branch 'main' of https://github.com/ECDAR-AAU-SW-P5/Ecdar-GUI-Web
tr0ub1eM4k3r Nov 16, 2023
ad14aeb
lint
tr0ub1eM4k3r Nov 16, 2023
4f2feb0
Rename iEngineStorageObject.ts to IEngineStorageObject.ts
tr0ub1eM4k3r Nov 16, 2023
8d5e4b2
Rename iEngineUIComponent.ts to IEngineUIComponent.ts
tr0ub1eM4k3r Nov 16, 2023
daaa6c6
Rename iModalComponent.ts to IModalComponent.ts
tr0ub1eM4k3r Nov 16, 2023
e2501ad
Fixed no prompt when closing with unsaved data
tr0ub1eM4k3r Nov 16, 2023
b544cfa
Merge branch '81-feature-frontend-for-engine-configuration-group5' of…
tr0ub1eM4k3r Nov 16, 2023
afa9281
Added highlighting of misinformation
tr0ub1eM4k3r Nov 17, 2023
6fc9979
Added interface for the IEngineSeperateComponent
tr0ub1eM4k3r Nov 17, 2023
b000929
Merge branch 'main' of https://github.com/ECDAR-AAU-SW-P5/Ecdar-GUI-W…
tr0ub1eM4k3r Nov 20, 2023
d27fd6d
Changed static implementation of the EngineStorage
tr0ub1eM4k3r Nov 20, 2023
438ebef
lint
tr0ub1eM4k3r Nov 20, 2023
08e50aa
Added functionality for closing Modal
tr0ub1eM4k3r Nov 20, 2023
8e39a30
Set ModalCloseOnBackdrop to false if not defined
tr0ub1eM4k3r Nov 20, 2023
58ab0d9
Changed Button component to be more flexible
tr0ub1eM4k3r Nov 21, 2023
9b8b4ee
Merged main
tr0ub1eM4k3r Nov 21, 2023
3c42222
Moved tabindex
tr0ub1eM4k3r Nov 21, 2023
0c022e6
Moved validation helper functions to own file
tr0ub1eM4k3r Nov 21, 2023
8532817
Merge branch 'main' into 81-feature-frontend-for-engine-configuration…
DenFlyvendeGed Nov 22, 2023
fa02996
Merge branch 'main' of https://github.com/ECDAR-AAU-SW-P5/Ecdar-GUI-W…
tr0ub1eM4k3r Nov 29, 2023
8626b21
Delete yarn-error.log
tr0ub1eM4k3r Dec 5, 2023
88ca945
Fixed issues with useBundle implementation
tr0ub1eM4k3r Dec 5, 2023
b5b738f
Merge branch '81-feature-frontend-for-engine-configuration-group5' of…
tr0ub1eM4k3r Dec 5, 2023
ee1aa88
Merge branch 'main' into 81-feature-frontend-for-engine-configuration…
tr0ub1eM4k3r Dec 5, 2023
964abd8
Changed color to css variable
tr0ub1eM4k3r Dec 5, 2023
6b9b213
Box size changes due to font change
SolarEarth37 Dec 6, 2023
642ebaa
Fixed issue with error screen on engineUI
tr0ub1eM4k3r Dec 7, 2023
fe5a12c
Changed deletion of engines
tr0ub1eM4k3r Dec 7, 2023
75ac2b3
Made playwright tests
tr0ub1eM4k3r Dec 7, 2023
83a225f
Made playwright tests
tr0ub1eM4k3r Dec 8, 2023
fe0cabd
lint
tr0ub1eM4k3r Dec 8, 2023
5468dcd
Changed modal css to own variable
tr0ub1eM4k3r Dec 8, 2023
d97da3d
Removed nested forms
tr0ub1eM4k3r Dec 12, 2023
f2e9aba
fixed tests
DenFlyvendeGed Dec 13, 2023
5a96d7c
Fixed multiple issues, related to comments
SolarEarth37 Dec 13, 2023
eeccc93
engineArray uses id as index
DenFlyvendeGed Dec 13, 2023
68f6910
Removed undefined elements from getEngineArray
DenFlyvendeGed Dec 13, 2023
d417a52
Fixed problem with hard coded EngineUI
SolarEarth37 Dec 13, 2023
20e88b8
lint and changes from button to SvgButton
SolarEarth37 Dec 13, 2023
c804b9d
fixed port input accepting decimals
DenFlyvendeGed Dec 13, 2023
4233339
Fixed Bundle problem, along with closeModal not working as expected
SolarEarth37 Dec 13, 2023
5ce9222
Merge branch '81-feature-frontend-for-engine-configuration-group5' of…
SolarEarth37 Dec 13, 2023
ca8dfec
should have fixed 9 -13. tests incoming
DenFlyvendeGed Dec 13, 2023
f8d54c5
fixed ip input not centering custom value
DenFlyvendeGed Dec 13, 2023
9354871
Use bundle label trigger checkbox. test are wip
DenFlyvendeGed Dec 13, 2023
c78d08d
added test
DenFlyvendeGed Dec 13, 2023
98f02d4
format
DenFlyvendeGed Dec 13, 2023
c6672ca
Fixed most lint, only one left is label control which might be irelav…
DenFlyvendeGed Dec 13, 2023
af7a512
Added engine store to global state, and removed tempengine store from…
DenFlyvendeGed Dec 14, 2023
e926bf1
fixed a11y-label-has-associated-control
KamyaPA Dec 14, 2023
5e89113
Merge branch '81-feature-frontend-for-engine-configuration-group5' of…
KamyaPA Dec 14, 2023
d676f15
cleanup
DenFlyvendeGed Dec 14, 2023
414a065
lint
DenFlyvendeGed Dec 14, 2023
fcfb0f1
Fixed being able to delete all engines
DenFlyvendeGed Dec 14, 2023
9fc1b68
Removed old functionality for not deleting last element
DenFlyvendeGed Dec 14, 2023
09fa393
fixed tests
DenFlyvendeGed Dec 14, 2023
85e0647
Added URL.canParse
KamyaPA Dec 14, 2023
4692d6d
readded ip support
DenFlyvendeGed Dec 14, 2023
d998c42
Merge branch 'main' into 81-feature-frontend-for-engine-configuration…
KamyaPA Dec 14, 2023
0530e0d
Refactored to new modal
KamyaPA Dec 14, 2023
403d6ce
Main merge fixed
DenFlyvendeGed Dec 14, 2023
0386eab
Minor deletions
KamyaPA Dec 14, 2023
939fd1f
fixed engine store not being utilized + escape press bug
DenFlyvendeGed Dec 14, 2023
b2902e1
Merge remote-tracking branch 'origin/main' into 81-feature-frontend-f…
DenFlyvendeGed Dec 14, 2023
126fd77
Fixed input placeholder color
SolarEarth37 Dec 15, 2023
4368a69
Fixed scrollbar CSS issues, and light mode being a random combination…
SolarEarth37 Dec 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 86 additions & 1 deletion src/lib/GlobalCssProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,54 @@
0.39901960784,
0.43823529411
],
"--engine-ui-underline-color": ["display-p3", 1, 1, 1],
"--engine-ui-error-underline-color": [
"display-p3",
0.82745098039,
0.18431372549,
0.18431372549
],
"--engine-ui-input-text-placeholder-color": [
"display-p3",
0.8,
0.8,
0.8
],
"--engine-ui-scrollbar-thumb-background-color": [
"display-p3",
0.5608,
0.498,
0.4353
],
"--engine-ui-scrollbar-thumb-color": [
"display-p3",
0.7137,
0.6941,
0.6706
],
"--engine-ui-text-color": ["display-p3", 1, 1, 1],
"--engine-ui-background-color": [
"display-p3",
0.2862745098,
0.34901960784,
0.38823529411
],
"--engine-ui-checkbox-color": [
"display-p3",
0.2862745098,
0.34901960784,
0.38823529411
],
"--settings-danger-button-color": ["srgb", 0.498, 0.0902, 0.0549],
"--settings-safe-button-color": ["srgb", 0.3255, 0.498, 0.2667]
"--settings-safe-button-color": ["srgb", 0.3255, 0.498, 0.2667],
"--dropdown-button-color": ["srgb", 1, 1, 1],
"--dropdown-text-color": ["srgb", 0, 0, 0],
"--modal-background-color": [
"display-p3",
0.22745098039,
0.27450980392,
0.30588235294
]
},
"fontSize": {
"--sidebar-fontsize": [1, "rem"],
Expand Down Expand Up @@ -206,6 +252,45 @@
0.13490196078,
0.14666666666,
0.17019607843
],
"--engine-ui-underline-color": ["display-p3", 1, 1, 1],
"--engine-ui-error-underline-color": [
"display-p3",
0.82745098039,
0.18431372549,
0.18431372549
],
"--engine-ui-input-text-placeholder-color": [
"display-p3",
0.7333,
0.7333,
0.7333
],
"--engine-ui-scrollbar-thumb-background-color": [
"display-p3",
0.95,
0.95,
0.95
],
"--engine-ui-scrollbar-thumb-color": ["display-p3", 0, 0, 0],
"--engine-ui-background-color": [
"display-p3",
0.08490196078,
0.09666666666,
0.12019607843
],
"--engine-ui-checkbox-color": [
"display-p3",
0.08490196078,
0.09666666666,
0.12019607843
],
"--engine-ui-text-color": ["display-p3", 1, 1, 1],
"--modal-background-color": [
"display-p3",
0.0156862745,
0.02352941176,
0.03529411764
]
}
},
Expand Down
113 changes: 113 additions & 0 deletions src/lib/classes/engine/Engine.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import {
comparePortRange,
validateEndPort,
validateIP,
validateName,
validateStartPort,
} from "./Validation";

/**
* A Reveaal, JEcdar andd API engine definition
* It stores the IP and port of an engine
* */
export class Engine {
/**
* The #name of the Engine
* */
#name: string = "";
get name(): string {
return this.#name;
}
set name(setName: string) {
if (validateName(setName)) this.#name = setName;
else throw new Error("Engine must have a name");
}
/**
* The IP #address of the engine
* */
#address: string = "";
get address(): string {
return this.#address;
}
set address(ipAdress: string) {
if (validateIP(ipAdress)) this.#address = ipAdress;
else throw new Error(ipAdress + " Is an invalid IP address");
}
/**
* The starting number of the portrange
* */
#portRangeStart: number = 0;
get portRangeStart(): number {
return this.#portRangeStart;
}
set portRangeStart(portStart: number) {
if (validateStartPort(portStart)) this.#portRangeStart = portStart;
else throw new Error("Invalid start port");
}

/**
* The last number of the portrange
* */
#portRangeEnd: number = 0;
get portRangeEnd(): number {
return this.#portRangeEnd;
}
set portRangeEnd(portEnd: number) {
if (
comparePortRange(this.#portRangeStart, portEnd) &&
validateEndPort(portEnd)
)
this.#portRangeEnd = portEnd;
else throw new Error("Invalid end port");
}

/**
* Unique identifier
* */
#id: number = 0;
get id(): number {
return this.#id;
}
set id(inputId: number) {
if (inputId >= 0) this.#id = inputId;
else throw new Error("Invalid id");
}

hasBeenChanged: boolean = false;

#useBundle: boolean = false;
get useBundle(): boolean {
return this.#useBundle;
}
set useBundle(useBundle: boolean) {
this.#useBundle = useBundle;
if (useBundle) this.address = "127.0.0.1";
}

constructor(
name: string,
address: string,
portRangeStart: number,
portRangeEnd: number,
id: number,
useBundle: boolean,
) {
this.name = name;
if (!useBundle) this.address = address;
this.portRangeStart = portRangeStart;
this.portRangeEnd = portRangeEnd;
this.id = id;
this.#useBundle = useBundle;
}

toJSON() {
return {
name: this.#name,
address: this.#address,
portRangeStart: this.#portRangeStart,
portRangeEnd: this.#portRangeEnd,
id: this.#id,
useBundle: this.#useBundle,
};
}
}
162 changes: 162 additions & 0 deletions src/lib/classes/engine/EngineStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import type IEngineStorageObject from "$lib/interfaces/IEngineStorageObject";
import { Engine } from "./Engine";
/**
* Engine storage definition.
* Stores an array of Engine instances, and can create, delete or search the array
* */
class EngineStorage {
/**
* Array of engines defined
* */
engineArray: Array<Engine | undefined> = [];

/**
* variable used to give unique id to engines
* */
#engineId: number = 0;

get engineId(): number {
return (this.engineId = ++this.#engineId); //auto inc
DenFlyvendeGed marked this conversation as resolved.
Show resolved Hide resolved
}
set engineId(id: number) {
if (id >= 0) this.#engineId = id;
else throw new Error("Invalid engineId");
}

/**
* Array of engines defined
* */
#defaultEngine: Engine | undefined;
get defaultEngine(): Engine | undefined {
return this.#defaultEngine;
}
set defaultEngine(engine: Engine | undefined) {
let index = -1;

index = this.engineArray.findIndex(
(arrayEngine: Engine | undefined) => {
return arrayEngine?.id === engine?.id;
},
);
if (engine === undefined || index > -1) this.#defaultEngine = engine;
DenFlyvendeGed marked this conversation as resolved.
Show resolved Hide resolved
else throw new Error("Failed to set default engine");
}

constructor() {
this.engineArray = new Array<Engine>();
this.engineId = 0;
this.defaultEngine = undefined;
}

/**
* Create an Engine and pushes it to engineArray
*/
createEngine(
name: string,
address: string,
portRangeStart: number,
portRangeEnd: number,
useBundle: boolean,
) {
const newEngine = new Engine(
name,
address,
portRangeStart,
portRangeEnd,
this.engineId,
useBundle,
);
this.engineArray[this.engineId - 1] = newEngine;

return newEngine;
}

/**
* Deletes the engine with the given id
*/
deleteEngine(id: number) {
//check for results
if (this.engineArray[id]) {
//Check if the default engine is being removed
if (this.defaultEngine?.id === id) this.defaultEngine = undefined;

this.engineArray[id] = undefined;
} else {
throw new Error("Engine Id does not exist");
}
}
KamyaPA marked this conversation as resolved.
Show resolved Hide resolved
/**
* Get engines based on id or name
*/
getEngine(identifier: number | string): Engine {
let returnEngine: undefined | Engine;

//Find engine based on id
if (typeof identifier === "number") {
returnEngine = this.engineArray[identifier];
}
//Find engine based on name
else {
returnEngine = this.engineArray.find(
(engine: Engine | undefined) => {
return engine?.name === identifier;
},
);
}
if (returnEngine !== undefined) return returnEngine;
else throw new Error("Could not find engine");
}

/**
* Returns all engines in the store in the form of an array
*/
getEngineArray(): Array<Engine> {
const filtered: Engine[] = this.engineArray.filter(
(element) => element !== undefined,
) as Engine[];
return filtered;
}

/**
* Coonvert the EngineStorage to a JSON string
*/
serialize(): string {
return JSON.stringify(this);
}

toJSON() {
return {
engineArray: this.engineArray,
engineId: this.#engineId,
defaultEngine: this.defaultEngine,
};
}

/**
* Reads fields and engines from JSON string, and applies them in the store
*/
deSerialize(json: string) {
const parsedJSON: IEngineStorageObject = JSON.parse(
json,
) as IEngineStorageObject;
this.engineArray = [];
this.engineId = parsedJSON.engineId;
this.defaultEngine = parsedJSON.defaultEngine;

//run Engine constructer to validate input.
parsedJSON.engineArray.forEach((engine) => {
this.engineArray.push(
new Engine(
engine.name,
engine.address,
engine.portRangeStart,
engine.portRangeEnd,
engine.id,
engine.useBundle,
),
);
});
}
}
const engineStorage = new EngineStorage();
export default engineStorage;
Loading
Loading