diff --git a/frontend/src/app/data.service.ts b/frontend/src/app/data.service.ts
index fd2769b..808ff23 100644
--- a/frontend/src/app/data.service.ts
+++ b/frontend/src/app/data.service.ts
@@ -4,10 +4,24 @@ import { Injectable } from '@angular/core';
import { ResourceFields } from '@syncfusion/ej2-angular-gantt';
import { LanguageService } from './language.service';
+interface Preset {
+ id: string;
+ name: string;
+ presetType: string;
+ definition: any;
+}
+
+interface presetGroup {
+ disabled?: boolean;
+ name: string;
+ presets: Preset[];
+}
+
@Injectable({
providedIn: 'root'
})
+
/**
* The DataService manages the communication between Frontend and Backend, fetches Data from the Backend and maps it to the Frontend Data Structure. Additionally it updates data on the Backend.
*
@@ -124,9 +138,10 @@ export class DataService {
*/
public async initPresets(){
const promise = new Promise(resolve=>{
- let res = {presets: [], selectedPreset: '', userPreferences: {}};
+ let res = {presets: [], selectedPreset: '', userPreferences: {}, presetGroups: []};
this.http.get('http://localhost:8080/api/initPresets')
.subscribe((response: any)=>{
+ console.log(response);
res.selectedPreset = response.selectedPreset;
let userPreferences = {language: 'DE', showDetails: true, view: 2};
if(response.userPreferences.language == "EN"){
@@ -136,13 +151,13 @@ export class DataService {
userPreferences.showDetails = false;
}
if(response.userPreferences.view == 1){
- userPreferences.view = 1;
+ userPreferences.view = 0;
}
if(response.userPreferences.view == 2){
- userPreferences.view = 2;
+ userPreferences.view = 1;
}
if(response.userPreferences.view == 3){
- userPreferences.view = 3;
+ userPreferences.view = 2;
}
res.userPreferences = userPreferences;
response.presets.forEach(preset => {
@@ -154,18 +169,66 @@ export class DataService {
definition: JSON.parse(preset.definition)
});
for (const preset of res.presets) {
- if(preset.id == 'AGGAA5V0G2LS6ASCSVD9SBS7MO40RV'){
+ if(preset.id == response.selectedPreset){
res.selectedPreset = preset;
}
}
});
- resolve(res);
- })
- })
+ let presetGroups : presetGroup[] = [];
+ let system = [];
+ let user = [];
+ let admin = [];
+ for (const preset of res.presets) {
+ if(preset.presetType == "Sysdemdefault"){
+ system.push(preset);
+ }else{
+ user.push(preset);
+ }
+ }
+ presetGroups = [
+ {
+ name: 'Sysdemdefault',
+ presets: system,
+ },
+ {
+ name: 'Admin',
+ presets: admin
+ },
+ {
+ name: 'User',
+ presets: user,
+ },
+
+ ];
+ res.presetGroups = presetGroups;
+ console.log(res.presetGroups);
+ resolve(res);
+ })
+ })
return promise;
}
- /**
+ /**
+ * The function updateDatePerChange sends the new date to the backend if the date was moved
+ * @param change the Change (the Resource) from which the date should be changed
+ */
+ public async selectPreset(preset: any){
+ const promise = new Promise(resolve=>{
+ let serializableResource = {guid: preset.id};
+ let strigifiedResource = JSON.stringify(serializableResource);
+ let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource;
+ console.log(resJson);
+ this.http.post('http://localhost:8080/api/selectPreset', resJson).subscribe((response:any)=>{
+ resolve(response);
+ console.log(response);
+ },(error:any)=>{
+ resolve(error);
+ });
+ });
+ return promise;
+ }
+
+ /**
* The function updateDatePerChange sends the new date to the backend if the date was moved
* @param change the Change (the Resource) from which the date should be changed
*/
@@ -191,7 +254,7 @@ export class DataService {
*/
public async updatePreset(preset: any){
const promise = new Promise(resolve=>{
- let serializableResource = {id: preset.id, definition: preset.definition};
+ let serializableResource = {id: preset.id, definition: JSON.stringify(preset.definition)};
let strigifiedResource = JSON.stringify(serializableResource);
let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource;
this.http.post('http://localhost:8080/api/updatePreset', resJson).subscribe((response:any)=>{
@@ -203,6 +266,25 @@ export class DataService {
return promise;
}
+ /**
+ * The function updateDatePerChange sends the new date to the backend if the date was moved
+ * @param change the Change (the Resource) from which the date should be changed
+ */
+ public async editUserPreferences(userPreferences: any){
+ const promise = new Promise(resolve=>{
+ let serializableResource = {details: userPreferences.showDetails, view: userPreferences.view, language: userPreferences.language };
+ let strigifiedResource = JSON.stringify(serializableResource);
+ let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource;
+ console.log(resJson);
+ this.http.post('http://localhost:8080/api/editUserPreferences', resJson).subscribe((response:any)=>{
+ resolve(response);
+ },(error:any)=>{
+ resolve(error);
+ });
+ });
+ return promise;
+ }
+
/**
* The function fetchStates fetches an array from the possible statuses per state
* @returns promise for the fetched Status Array
diff --git a/frontend/src/app/ntt-gantt/ntt-gantt.component.html b/frontend/src/app/ntt-gantt/ntt-gantt.component.html
index b8c1322..0f31191 100644
--- a/frontend/src/app/ntt-gantt/ntt-gantt.component.html
+++ b/frontend/src/app/ntt-gantt/ntt-gantt.component.html
@@ -22,19 +22,34 @@