presets
parent
56e77f1660
commit
ed97c3d18c
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -22,19 +22,34 @@
|
|||
</mat-select>
|
||||
</mat-form-field>
|
||||
<div class="scalarContainer">
|
||||
<mat-button-toggle-group style="margin-top: 5px;" (change)="changeScalar()" name="fontStyle" aria-label="Font Style" [(ngModel)]="selectedScalar">
|
||||
<mat-button-toggle-group style="margin-top: 5px;" (change)="changeScalar()" name="fontStyle" aria-label="Font Style" [(ngModel)]="selectedScalar">
|
||||
<mat-button-toggle value="bold"*ngFor="let scalar of scalars" [value]="scalar">
|
||||
{{scalar}}
|
||||
</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
||||
</div>
|
||||
<mat-form-field appearance="fill">
|
||||
|
||||
<!-- <mat-form-field appearance="fill" >
|
||||
<mat-label>Preset</mat-label>
|
||||
<mat-select>
|
||||
<mat-option *ngFor="let preset of presets" [value]="preset.id" >
|
||||
<mat-select [(value)]="selectedPreset">
|
||||
<mat-option *ngFor="let preset of presets" [value]="preset">
|
||||
{{preset.name}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field> -->
|
||||
|
||||
<mat-form-field appearance="fill" style="width: 300px;">
|
||||
<mat-label>Preset</mat-label>
|
||||
<mat-select [(value)]="selectedPreset" (selectionChange)="selectPreset($event)">
|
||||
<mat-optgroup *ngFor="let group of presetGroups" [label]="group.name"
|
||||
[disabled]="group.disabled">
|
||||
<mat-option *ngFor="let preset of group.presets" [value]="preset">
|
||||
{{preset.name}}
|
||||
<!-- <button style="align-self: right;" *ngIf="group.name == 'User'" mat-icon-button><mat-icon>delete_forever</mat-icon></button>
|
||||
<button *ngIf="group.name == 'User'" mat-icon-button><mat-icon>edit</mat-icon></button> -->
|
||||
</mat-option>
|
||||
</mat-optgroup>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
|
|
@ -42,9 +57,12 @@
|
|||
<button mat-raised-button class="filterButton" aria-label="Filtern" (click)="openFilterDialog()">
|
||||
{{languageService.lMap.get('nttGanttFilterButton')}} <mat-icon style="color: #00a79d;">filter_alt</mat-icon>
|
||||
</button>
|
||||
<button *ngIf="showSaveButton" mat-raised-button (click)="updatePreset()">Speichern</button>
|
||||
<button *ngIf="showSaveUnderButton" mat-raised-button >Speichern unter</button>
|
||||
<button [disabled]="!filterEnabled" mat-icon-button aria-label="clear Filters and Sort" class="clearFilter" (click)="clearFilter()">
|
||||
{{languageService.lMap.get('clearFilter')}} <mat-icon>close</mat-icon>
|
||||
</button>
|
||||
|
||||
<mat-slide-toggle class="showDetails" color="primary" [(ngModel)]="showDetails" [checked]="showDetails" (change)="refreshData()">{{languageService.lMap.get('detailButton')}}</mat-slide-toggle>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,19 @@ export const MY_DATE_FORMATS = {
|
|||
monthYearA11yLabel: 'MMMM YYYY'
|
||||
},
|
||||
};
|
||||
interface Preset {
|
||||
id: string;
|
||||
name: string;
|
||||
presetType: string;
|
||||
definition: any;
|
||||
}
|
||||
|
||||
interface presetGroup {
|
||||
disabled?: boolean;
|
||||
name: string;
|
||||
presets: Preset[];
|
||||
}
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'ntt-gantt',
|
||||
|
|
@ -118,7 +131,35 @@ export class NttGanttComponent implements OnInit {
|
|||
public sortSelectorName: any;
|
||||
|
||||
public presets : any[] = [];
|
||||
public selectedPreset: any;
|
||||
public selectedPreset: Preset = {id: 'test', name : 'test', presetType: 'test', definition: {}};
|
||||
public presetControl: FormControl = new FormControl('');;
|
||||
public presetGroups: presetGroup[] = [
|
||||
{
|
||||
name: 'Sysdemdefault',
|
||||
presets: [
|
||||
{id: '0', name: 'TEST', presetType: 'Sysdemdefault', definition: {}},
|
||||
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'Admin',
|
||||
presets: [
|
||||
{id: '1', name: 'TEST1', presetType: 'Admin', definition: {}},
|
||||
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'User',
|
||||
presets: [
|
||||
{id: '2', name: 'TEST2', presetType: 'User', definition: {}},
|
||||
|
||||
],
|
||||
},
|
||||
];
|
||||
public userPreferences: {language:'', showDetails: false, view: ''};
|
||||
public showSaveButton: boolean = false;
|
||||
public showSaveUnderButton: boolean = false;
|
||||
|
||||
|
||||
/**###################################################################### Initial Loading functions ######################################################################*/
|
||||
|
||||
|
|
@ -143,28 +184,29 @@ export class NttGanttComponent implements OnInit {
|
|||
this.sliceStart = 0;
|
||||
this.sliceEnd = 20;
|
||||
|
||||
this.dataService.initPresets().then((res: any)=>{
|
||||
this.presets = res.presets;
|
||||
this.selectedPreset = res.selectedPreset;
|
||||
this.filters = this.selectedPreset.definition;
|
||||
this.filterEnabled = true;
|
||||
this.showDetails = res.userPreferences.showDetails;
|
||||
this.selectedScalar = this.scalars[res.userPreferences.view];
|
||||
// this.dataService.initPresets().then((res: any)=>{
|
||||
// this.presets = res.presets;
|
||||
// this.selectedPreset = res.selectedPreset;
|
||||
// this.presetGroups = res.presetGroups;
|
||||
// this.filters = this.selectedPreset.definition;
|
||||
// this.filterEnabled = true;
|
||||
// this.showDetails = res.userPreferences.showDetails;
|
||||
// this.selectedScalar = this.scalars[res.userPreferences.view];
|
||||
|
||||
|
||||
this.dataService.fetchUserSupportGroup().then((res: any)=>{
|
||||
this.userSupportGroup = res.name;
|
||||
this.refreshData();
|
||||
this.states = this.dataService.getStates();
|
||||
this.dataService.fetchStates().then((res: any [])=>{
|
||||
this.states = res;
|
||||
this.stateList = res;
|
||||
this.spin = false;
|
||||
console.log(this.states);
|
||||
this.inputForTimeline = [this.splitterSettings, this.projectStartDate, this.projectEndDate];
|
||||
});
|
||||
});
|
||||
});
|
||||
// this.dataService.fetchUserSupportGroup().then((res: any)=>{
|
||||
// this.userSupportGroup = res.name;
|
||||
// this.refreshData();
|
||||
// this.states = this.dataService.getStates();
|
||||
// this.dataService.fetchStates().then((res: any [])=>{
|
||||
// this.states = res;
|
||||
// this.stateList = res;
|
||||
// this.spin = false;
|
||||
// console.log(this.states);
|
||||
// this.inputForTimeline = [this.splitterSettings, this.projectStartDate, this.projectEndDate];
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
this.refreshGanttwithPresets();
|
||||
|
||||
|
||||
this.taskSettings = {
|
||||
|
|
@ -222,16 +264,29 @@ export class NttGanttComponent implements OnInit {
|
|||
this.inputForTimeline = [this.splitterSettings, this.projectStartDate, this.projectEndDate];
|
||||
}
|
||||
|
||||
public selectPreset(preset: any){
|
||||
public selectPreset(event: any){
|
||||
this.showSaveButton = false;
|
||||
this.showSaveUnderButton = false;
|
||||
console.log(event);
|
||||
this.dataService.selectPreset(event.value).then((res)=>{
|
||||
this.refreshGanttwithPresets();
|
||||
});
|
||||
|
||||
}
|
||||
public savePreset(preset: any){
|
||||
this.showSaveButton = false;
|
||||
this.showSaveUnderButton = false;
|
||||
|
||||
this.dataService.savePreset(preset).then((res)=>{{
|
||||
console.log(res);
|
||||
}})
|
||||
}
|
||||
public updatePreset(preset: any){
|
||||
|
||||
public updatePreset(){
|
||||
this.showSaveButton = false;
|
||||
this.selectedPreset.definition = this.filters;
|
||||
this.dataService.updatePreset(this.selectedPreset).then((res)=>{
|
||||
console.log(res);
|
||||
});
|
||||
}
|
||||
public renamePreset(preset: any){
|
||||
|
||||
|
|
@ -240,8 +295,55 @@ export class NttGanttComponent implements OnInit {
|
|||
|
||||
}
|
||||
|
||||
public editUserPreferences(language: any, showDetails: any, view: any){
|
||||
public editUserPreferences(){
|
||||
let showDetails = 0;
|
||||
if(this.showDetails){
|
||||
showDetails = 1;
|
||||
}
|
||||
let view;
|
||||
let index = 0;
|
||||
for (const scalar of this.scalars) {
|
||||
index++;
|
||||
if(scalar == this.selectedScalar){
|
||||
view = index;
|
||||
}
|
||||
}
|
||||
if(this.userPreferences.language == this.languageService.language && this.userPreferences.showDetails == this.showDetails && this.userPreferences.view == view){
|
||||
}else{
|
||||
this.dataService.editUserPreferences({language: this.languageService.language, showDetails: showDetails, view: view}).then((res)=>{
|
||||
console.log(res);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public refreshGanttwithPresets(){
|
||||
this.showSaveButton = false;
|
||||
this.showSaveUnderButton = false;
|
||||
this.dataService.initPresets().then((res: any)=>{
|
||||
this.presets = res.presets;
|
||||
this.selectedPreset = res.selectedPreset;
|
||||
this.presetGroups = res.presetGroups;
|
||||
this.filters = this.selectedPreset.definition;
|
||||
this.filterEnabled = true;
|
||||
this.userPreferences = res.userPreferences;
|
||||
this.showDetails = res.userPreferences.showDetails;
|
||||
this.selectedScalar = this.scalars[res.userPreferences.view];
|
||||
this.changeScalar();
|
||||
|
||||
|
||||
this.dataService.fetchUserSupportGroup().then((res: any)=>{
|
||||
this.userSupportGroup = res.name;
|
||||
this.refreshData();
|
||||
this.states = this.dataService.getStates();
|
||||
this.dataService.fetchStates().then((res: any [])=>{
|
||||
this.states = res;
|
||||
this.stateList = res;
|
||||
this.spin = false;
|
||||
console.log(this.states);
|
||||
this.inputForTimeline = [this.splitterSettings, this.projectStartDate, this.projectEndDate];
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -269,6 +371,7 @@ export class NttGanttComponent implements OnInit {
|
|||
* This function is the most called Funktion in the whole project, it is triggered by a pageEvent, when a filter gets applied and much more...
|
||||
*/
|
||||
refreshData(){
|
||||
this.editUserPreferences();
|
||||
this.showNoResultsError = false;
|
||||
this.renderGantt = false;
|
||||
this.dataService.fetchChanges(this.mapRequestJSON()).then((res: any[])=>{
|
||||
|
|
@ -356,6 +459,14 @@ export class NttGanttComponent implements OnInit {
|
|||
// this.dataService.updatePreset({id: 'AGGAA5V0G2LS6ASCSUZZSBS79E40O5', definition: JSON.stringify(this.filters)}).then((res)=>{
|
||||
// console.log(res);
|
||||
// });
|
||||
if(this.filters !== this.selectedPreset.definition){
|
||||
if(this.selectedPreset.presetType == ''){
|
||||
this.showSaveButton = true;
|
||||
}else{
|
||||
this.showSaveUnderButton = true;
|
||||
}
|
||||
|
||||
}
|
||||
this.refreshData();
|
||||
}
|
||||
});
|
||||
|
|
@ -373,6 +484,7 @@ export class NttGanttComponent implements OnInit {
|
|||
this.languageService.languageChange(args.value),
|
||||
this.initLanguge();
|
||||
this.plantimeComponent.changeLanguage();
|
||||
this.editUserPreferences();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -414,6 +526,8 @@ export class NttGanttComponent implements OnInit {
|
|||
this.timelineSettings = {topTier: {unit: 'Year'}, bottomTier: {format: 'MM',unit: 'Month',count: 1}};
|
||||
this.renderplanTime = false;
|
||||
}
|
||||
this.editUserPreferences();
|
||||
|
||||
}
|
||||
|
||||
/**############################### NTT Gantt Component EVENTS /**###############################*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue