diff --git a/FrontEnd/src/app/groups/group-details/group-details.component.html b/FrontEnd/src/app/groups/group-details/group-details.component.html
index 7c9ba16..1b05cea 100644
--- a/FrontEnd/src/app/groups/group-details/group-details.component.html
+++ b/FrontEnd/src/app/groups/group-details/group-details.component.html
@@ -57,12 +57,12 @@
[contentStyle]="{'min-height':'600px', 'min-width': '800px'}">
Ta funkcjonalność pozwala tylko na edycję dostępności testów.
diff --git a/FrontEnd/src/app/groups/group-details/group-details.component.ts b/FrontEnd/src/app/groups/group-details/group-details.component.ts
index 696f52e..d60485d 100644
--- a/FrontEnd/src/app/groups/group-details/group-details.component.ts
+++ b/FrontEnd/src/app/groups/group-details/group-details.component.ts
@@ -31,14 +31,17 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
displayAvailability = false;
- dateFrom: Date;
+ dateFrom: Date = new Date();
howLong = 10;
testId = 1;
+ minDate: Date = new Date();
+
columnDefs = [
{ headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
{ headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
{ headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.', hide: false },
+ { headerName: 'Start', field: 'startDate', headerTooltip: 'Start' },
{
headerName: '',
suppressMenu: true,
@@ -46,6 +49,9 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
cellRenderer: this.customCellRendererFunc
}
];
+ timetest: number;
+
+ timeout: any;
constructor(private route: ActivatedRoute, private groupService: GroupsService, private router: Router,
public snackBar: MatSnackBar) { }
@@ -87,7 +93,8 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
success => {
this.snackBar.open('Prawidłowo edytowano przedział czasowy.', null,
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-success'] });
- this.displayAvailability = false;
+ this.displayAvailability = false;
+ this.isDisplayed('testów');
},
error => {
this.snackBar.open('Wystąpił błąd serwera. Spróbuj ponownie później.', null,
@@ -119,8 +126,16 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
public onRowClicked(e) {
if (e.event.target !== undefined) {
const data = e.data;
+ const now1 = new Date();
+ const now = now1.getTime();
const actionType = e.event.target.getAttribute('data-action-type');
-
+ const temp = new Date(data['dateFrom']);
+ const timetest = temp.getTime();
+ const tempstop = new Date(data['dateTo']);
+ const timeteststop = tempstop.getTime();
+ const currentUsername = JSON.parse(localStorage.getItem('currentUser')).username;
+ const groupOwnerUsername = localStorage.getItem('groupOwnerUsername');
+ if ((groupOwnerUsername === currentUsername) || (timetest < now && now < timeteststop)) {
switch (actionType) {
case 'remove':
return this.onActionRemoveClick(e);
@@ -129,7 +144,23 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
default:
this.goTo(e);
}
+ } else {
+ switch (actionType) {
+ case 'remove':
+ return this.onActionRemoveClick(e);
+ case 'edit':
+ return this.showAvailabilityDialog(e.data);
+ default:
+ this.noTime();
+ }
}
+
+ }
+ }
+
+ noTime() {
+ this.snackBar.open('Test jest nieaktywny.', null,
+ { duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-error'] });
}
goTo(event: RowDoubleClickedEvent) {
@@ -201,30 +232,52 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
}
onGridSizeChanged(params) {
+ const currentUsername = JSON.parse(localStorage.getItem('currentUser')).username;
+ const groupOwnerUsername = localStorage.getItem('groupOwnerUsername');
if (params.clientWidth < 800) {
- this.columnDefs = [
- { headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
- { headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
- { headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.', hide: true },
- {
- headerName: '',
- suppressMenu: true,
- suppressSorting: true,
- cellRenderer: this.customCellRendererFunc
- }
- ];
+ if (groupOwnerUsername === currentUsername) {
+ this.columnDefs = [
+ { headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
+ { headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
+ { headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.', hide: true },
+ { headerName: 'Start', field: 'startDate', headerTooltip: 'Start'},
+ {
+ headerName: '',
+ suppressMenu: true,
+ suppressSorting: true,
+ cellRenderer: this.customCellRendererFunc
+ }
+ ];
+ } else {
+ this.columnDefs = [
+ { headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
+ { headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
+ { headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.', hide: true },
+ { headerName: 'Start', field: 'startDate', headerTooltip: 'Start'},
+ ];
+ }
} else {
- this.columnDefs = [
- { headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
- { headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
- { headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.' },
- {
- headerName: '',
- suppressMenu: true,
- suppressSorting: true,
- cellRenderer: this.customCellRendererFunc
- }
- ];
+ if (groupOwnerUsername === currentUsername) {
+ this.columnDefs = [
+ { headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
+ { headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
+ { headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.' },
+ { headerName: 'Start', field: 'startDate', headerTooltip: 'Start'},
+ {
+ headerName: '',
+ suppressMenu: true,
+ suppressSorting: true,
+ cellRenderer: this.customCellRendererFunc
+ }
+ ];
+ } else {
+ this.columnDefs = [
+ { headerName: 'Nazwa', field: 'title', headerTooltip: 'Nazwa' },
+ { headerName: 'Ocena', field: 'grade', headerTooltip: 'Ocena' },
+ { headerName: 'Max.', field: 'maxScore', headerTooltip: 'Max.' },
+ { headerName: 'Start', field: 'startDate', headerTooltip: 'Start'}
+ ];
+ }
}
params.api.sizeColumnsToFit();
@@ -275,8 +328,30 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
}
if (resource === 'testów') {
this.localeText.noRowsToShow = 'Brak testów do wyświetlenia';
- setTimeout(() => {
- this.testsSubscription = this.groupService.getResource(this.id, 'tests').subscribe(data => this.data = data);
+ if (this.timeout) {
+ clearTimeout(this.timeout);
+ }
+ this.timeout = setTimeout(() => {
+ this.testsSubscription = this.groupService.getResource(this.id, 'tests').subscribe(data => {
+ this.data = data;
+ data.forEach(x => {
+ const temp = new Date(x['dateFrom']);
+ const tempstop = new Date(x['dateTo']);
+ x['startDate'] = '';
+ const hours = temp.getHours();
+ const minutes = temp.getMinutes();
+ // const months = ['STY', 'LUT', 'MAR', 'KWI', 'MAJ', 'CZE', 'LIP', 'SIE', 'WRZ', 'PAŹ', 'LIS', 'GRU'];
+ const year = temp.getFullYear().toString().substring(2);
+ const monthTemp = (temp.getMonth() + 1);
+ let month = monthTemp.toString();
+ if (monthTemp < 10) {
+ month = `0${monthTemp}`;
+ }
+ const date = temp.getDate();
+ const time = date + '.' + month + '.' + year + ' ' + hours + ':' + minutes;
+ x['startDate'] += time;
+ });
+ });
this.dataToDisplay = resource;
}, 200);
diff --git a/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.html b/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.html
index 46162e9..e6240a5 100644
--- a/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.html
+++ b/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.html
@@ -28,13 +28,13 @@
0">
Od kiedy test ma być dostępny:
-
+
Ile minut ma być dostępny ten test:
-
+