plantime/improvement

main
manueltauber 2023-06-15 13:27:10 +02:00
parent b200174bc0
commit ba00b625e4
5 changed files with 69 additions and 17 deletions

View File

@ -149,16 +149,31 @@ export class DataService {
* 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 updateDatePerChange(change: any){
//console.log(change);
let serializableResource = { resourceId: change.resourceId, d2: change.tasks[1].StartDate, changeNr: change.changeNr, state: change.state};
let strigifiedResource = JSON.stringify(serializableResource);
let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource;
// console.log(resJson);
this.http.post('http://localhost:8080/api/updateChange', resJson).toPromise().then((value)=>{
console.log(value);
public async updateDatePerChange(change: any){
// //console.log(change);
// let serializableResource = { resourceId: change.resourceId, d2: change.tasks[1].StartDate, changeNr: change.changeNr, state: change.state};
// let strigifiedResource = JSON.stringify(serializableResource);
// let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource;
// // console.log(resJson);
// this.http.post('http://localhost:8080/api/updateChange', resJson).toPromise().then((value)=>{
// console.log(value);
// });
const promise = new Promise(resolve=>{
let serializableResource = { resourceId: change.resourceId, d2: change.tasks[1].StartDate, changeNr: change.changeNr, state: change.state};
let strigifiedResource = JSON.stringify(serializableResource);
let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource;
// console.log(dataJson);
this.http.post('http://localhost:8080/api/updateChange', resJson).subscribe((response:any)=>{
resolve(response);
},(error:any)=>{
resolve(error);
});
});
return promise;
}
/**

View File

@ -38,6 +38,9 @@
<tr>
<td style="padding:3px"> Planzeit: {{data.taskData.planzeit}}</td>
</tr>
<tr>
<td style="padding:3px"> StartDate: {{data.taskData.StartDate| date:'dd.MM.yyyy'}}</td>
</tr>
</ng-container>
</table>
</div>

View File

@ -25,7 +25,7 @@ export class PlanTimeBarComponent implements OnInit {
@Input() splitterSettings: object;
@Input() parentResources: Array<any> = [];
@ViewChild('ganttObjectSum')
public ganttDefault!: GanttComponent;
public ganttObjectSum!: GanttComponent;
public data: any[] = [];
public resources: any[] = [];
public userSupportGroup: string;
@ -60,10 +60,11 @@ export class PlanTimeBarComponent implements OnInit {
calendarWeeks.forEach((week, index) => {
let weekNr = this.getWeekNumber(new Date(calendarWeeks[index].start.toISOString()));
let planzeit = this.getPlantimeFromResources(this.parentResources, weekNr);
//console.log(`Kalenderwoche ${index + 1}: ${week.start} - ${week.end}`);
// console.log(`Kalenderwoche ${index + 1}: ${week.start} - ${week.end}`);
// console.log(week);
this.data.push(
{
TaskID: '' + weekNr, index , TaskName: "Woche " + weekNr, StartDate: calendarWeeks[index].start.toISOString(),EndDate: calendarWeeks[index].end.toISOString() , planzeit: planzeit,
TaskID: '' + weekNr, index , TaskName: "Woche " + weekNr, StartDate: calendarWeeks[index].start.toISOString(), EndDate: calendarWeeks[index].end.toISOString() , planzeit: planzeit.toFixed(0),
resources: [{resourceId: this.resources[0].resourceId},], Progress: 0, work: 0, isRes: false
});
});
@ -97,6 +98,8 @@ export class PlanTimeBarComponent implements OnInit {
this.columns = [
{ field: 'TaskName', headerText: 'Planzeit pro Woche', width: 250 },
{ field: 'StartDate', headerText: 'Beginn', width: 250 },
{ field: 'EndDate', headerText: 'Ende', width: 250 },
]
}
@ -147,9 +150,30 @@ getCalendarWeeks(startDate: Date, endDate: Date): { start: Date, end: Date }[] {
public queryTaskbarInfo(args: any) {
// console.log(args);
args.taskbarBgColor = "white";
args.taskbarBorderColor = "white";
args.taskbarBgColor = "transparent";
args.taskbarBorderColor = "transparent";
args.taskLabelColor = "black";
}
public movePlanTime(oldDate: Date, newDate: Date, planTime: any){
if(planTime && planTime != 0){
let oldWeek = this.getWeekNumber(oldDate);
let newWeek = this.getWeekNumber(newDate);
for (let week of this.data) {
if(week.TaskID == oldWeek){
console.log(week);
week.planzeit - planTime;
}
}
for (let week of this.data) {
if(week.TaskID == newWeek){
console.log(week);
week.planzeit + planTime;
}
}
}
console.log(this.data);
}
}

View File

@ -139,7 +139,7 @@
</ng-template>
</ejs-gantt>
<app-plan-time-bar *ngIf="renderplanTime"
<app-plan-time-bar #plantimeComponent *ngIf="renderplanTime"
[inputData]="inputForTimeline"
[splitterSettings]="splitterSettings"
[parentResources]="allResources"

View File

@ -12,6 +12,7 @@ import * as $ from 'jquery';
import { StateDialogComponent } from 'src/app/state-dialog/state-dialog.component';
import { MatSnackBar, MatSnackBarHorizontalPosition, MatSnackBarVerticalPosition } from '@angular/material/snack-bar';
import { MAT_DATE_FORMATS } from '@angular/material/core';
import { PlanTimeBarComponent } from 'src/app/plan-time-bar/plan-time-bar.component';
export const MY_DATE_FORMATS = {
parse: {
@ -38,6 +39,7 @@ export class NttGanttComponent implements OnInit {
public ganttDefault!: GanttComponent;
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild('plantimeComponent')plantimeComponent!:PlanTimeBarComponent;
public range = new FormGroup({
start: new FormControl<Date | null>(new Date('12/01/2022')),
@ -460,9 +462,17 @@ public logg(args){
const found = this.allResources.find((resource) => {
return resource.resourceId == args.data.taskData.resources[0].resourceId;
});
this.dataService.updateDatePerChange(found);
this.renderplanTime = false;
this.refreshData();
this.dataService.updateDatePerChange(found).then((res:any)=>{
//console.log(args);
console.log(args.data.taskData.resources[0].plantime);
console.log(args.previousData.startDate);
console.log(args.editingFields.startDate);
this.plantimeComponent.movePlanTime(args.previousData.startDate, args.editingFields.startDate, args.data.taskData.resources[0].plantime)
});
//this.renderplanTime = false;
//this.refreshData();
}
}