initial Load with Presets implemented

main
manueltauber 2023-10-20 01:44:09 +02:00
parent 39182ef484
commit 3673460903
4 changed files with 105 additions and 19 deletions

View File

@ -118,6 +118,62 @@ export class DataService {
return this.contracts.find((contract)=> {return contract.id == contractId;}).name;
}
/**
* The function initPresets fetches an array of all presets
* @returns promise for the fetched presets array
*/
public async initPresets(){
const promise = new Promise(resolve=>{
let res = {presets: [], selectedPreset: '', userPreferences: {}};
this.http.get('http://localhost:8080/api/initPresets')
.subscribe((response: any)=>{
res.selectedPreset = response.selectedPreset;
let userPreferences = {language: 'DE', showDetails: true, view: 2};
if(response.userPreferences.language == "EN"){
userPreferences.language = "EN";
}
if(response.userPreferences.showDetails == 0){
userPreferences.showDetails = false;
}
if(response.userPreferences.view == 1){
userPreferences.view = 1;
}
if(response.userPreferences.view == 2){
userPreferences.view = 2;
}
if(response.userPreferences.view == 3){
userPreferences.view = 3;
}
res.userPreferences = userPreferences;
response.presets.forEach(preset => {
res.presets.push(preset);
});
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 savePreset(preset: any){
const promise = new Promise(resolve=>{
let serializableResource = {name: preset.name, definition: preset.definition};
let strigifiedResource = JSON.stringify(serializableResource);
let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource;
console.log(resJson);
this.http.post('http://localhost:8080/api/savePreset', resJson).subscribe((response:any)=>{
resolve(response);
console.log(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
@ -154,6 +210,8 @@ export class DataService {
return promise;
}
/**
* The function fetchContracts fetches an array of all contracts
* @returns promise for the fetched contracts array

View File

@ -87,7 +87,7 @@ export class FilterDialogComponent implements OnInit {
* The function ngOnInit initialized the component by fetching all relevant data via the dataService
*/
ngOnInit(): void {
console.log(this.prevFilters);
//console.log(this.prevFilters);
if(this.prevFilters.length > 0){
for (const filter of this.prevFilters) {
//console.log(filter);
@ -120,13 +120,21 @@ export class FilterDialogComponent implements OnInit {
//console.log("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
//console.log(this.dataService.getPaketTypes());
for (const crit of filter.criteria) {
console.log(crit);
//console.log(crit);
this.prevFiltersPaketType.push(this.dataService.getPaketTypeNameByID(crit));
}
console.log(this.prevFiltersPaketType);
//console.log(this.prevFiltersPaketType);
//this.prevFiltersPaketType = filter.criteria;
}
if(filter.column == "D2"){
this.filterStartDate = filter.criteria[0];
this.filterEndDate = filter.criteria[1];
}
if(filter.column == "ResourceName"){
this.criteria = filter.criteria[0];
}
}
}
@ -284,7 +292,7 @@ export class FilterDialogComponent implements OnInit {
}
let filter = {filterElement: filterElement};
console.log(filter);
//console.log(filter);
this.dialogRef.close(filter);
}
}

View File

@ -65,21 +65,21 @@ export class MultiselectAutocompleteComponent implements OnInit {
],
},
});
console.log(this.appliedFilters);
console.log(this.rawData);
//console.log(this.appliedFilters);
//console.log(this.rawData);
if(this.appliedFilters.length > 0){
for (const filter of this.appliedFilters) {
for (const item of this.rawData) {
if(item.item == filter){
console.log("MATCH"+item.item);
//console.log("MATCH"+item.item);
item.selected = true;
this.toggleSelection({'item': filter, selected: false});
}
}
}
}
console.log(this.selectData);
//console.log(this.selectData);
this.evaluateIndeterminate();
}
@ -115,7 +115,7 @@ export class MultiselectAutocompleteComponent implements OnInit {
* it builds the base for many filter select option
*/
toggleSelection = (data: ItemData): void => {
//console.log(data);
////console.log(data);
//console.log(this.selectData);
data.selected = !data.selected;
if (data.selected === true) {

View File

@ -139,6 +139,21 @@ export class NttGanttComponent implements OnInit {
this.firstLoad = true;
this.sliceStart = 0;
this.sliceEnd = 20;
this.dataService.initPresets().then((res: any)=>{
let currentPreset;
console.log(res);
for (const preset of res.presets) {
if(preset.id == 'AGGAA5V0G2LS6ASCSVD9SBS7MO40RV'){
currentPreset = preset;
}
}
console.log(currentPreset);
this.filters = JSON.parse(currentPreset.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;
@ -152,6 +167,8 @@ export class NttGanttComponent implements OnInit {
this.inputForTimeline = [this.splitterSettings, this.projectStartDate, this.projectEndDate];
});
});
});
this.taskSettings = {
id: 'TaskID',
@ -313,6 +330,9 @@ export class NttGanttComponent implements OnInit {
if(res){
this.filters = res;
this.filterEnabled = true;
// this.dataService.savePreset({name: "FRONTEND TEST PRESET", definition: JSON.stringify(this.filters)}).then((res)=>{
// console.log(res);
// });
this.refreshData();
}
});