This commit is contained in:
s416122 2020-01-16 17:18:03 +01:00
commit ece82d64cc
5 changed files with 76 additions and 42 deletions

View File

@ -57,12 +57,12 @@
[contentStyle]="{'min-height':'600px', 'min-width': '800px'}">
<div *ngIf="dataToDisplay === 'testów'">
Od kiedy test ma być dostępny:
<p-calendar [(ngModel)]="dateFrom" [showTime]="true"></p-calendar >
<p-calendar [minDate]="minDate" [(ngModel)]="dateFrom" [showTime]="true"></p-calendar>
<br /><br /><br />
Ile minut ma być dostępny ten test:
<input type="number" step="1" min="1" name="howLong" [(ngModel)]="howLong" />
<br /><br /><br />
<button class="button" (click)="editTestAvailability()">Edytuj</button>
<button [disabled]="howLong < 1" class="button" (click)="editTestAvailability()">Edytuj</button>
</div>
<div *ngIf="dataToDisplay !== 'testów'">
Ta funkcjonalność pozwala tylko na edycję dostępności testów.

View File

@ -31,15 +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: 'Rozpoczęcie testu', field: 'startDate', headerTooltip: 'Rozpoczęcie testu' },
{ headerName: 'Start', field: 'startDate', headerTooltip: 'Start' },
{
headerName: '',
suppressMenu: true,
@ -49,6 +51,8 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
];
timetest: number;
timeout: any;
constructor(private route: ActivatedRoute, private groupService: GroupsService, private router: Router,
public snackBar: MatSnackBar) { }
@ -89,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,
@ -128,7 +133,9 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
const timetest = temp.getTime();
const tempstop = new Date(data['dateTo']);
const timeteststop = tempstop.getTime();
if (timetest < now && now < timeteststop ) {
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);
@ -152,7 +159,7 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
}
noTime() {
this.snackBar.open('Test jest jeszcze nieaktywny.', null,
this.snackBar.open('Test jest nieaktywny.', null,
{ duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-error'] });
}
@ -225,32 +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: 'Rozpoczęcie testu', field: 'startDate', headerTooltip: 'Rozpoczęcie testu'},
{
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: 'Rozpoczęcie testu', field: 'startDate', headerTooltip: 'Rozpoczęcie testu'},
{
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();
@ -301,7 +328,10 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
}
if (resource === 'testów') {
this.localeText.noRowsToShow = 'Brak testów do wyświetlenia';
setTimeout(() => {
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 => {
@ -310,11 +340,15 @@ export class GroupDetailsComponent implements OnInit, OnDestroy {
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();
const month = months[temp.getMonth()];
// 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;
const time = date + '.' + month + '.' + year + ' ' + hours + ':' + minutes;
x['startDate'] += time;
});
});

View File

@ -28,13 +28,13 @@
<div *ngIf="testsToAdd.length > 0">
<br /><br />
Od kiedy test ma być dostępny:
<p-calendar [(ngModel)]="dateFrom" [showTime]="true"></p-calendar>
<p-calendar [(ngModel)]="dateFrom" [minDate]="minDate" [showTime]="true"></p-calendar>
<br /><br /><br />
Ile minut ma być dostępny ten test:
<input type="number" step="1" min="1" name="howLong" [(ngModel)]="howLong" />
</div>
<br /><br />
<button [disabled]="selected.length === 0" class="button mr-1" (click)="addResources()"><i class="fas fa-check-circle"></i> Dodaj</button>
<button [disabled]="(selected.length === 0) && (howLong < 1)" class="button mr-1" (click)="addResources()"><i class="fas fa-check-circle"></i> Dodaj</button>
</div>
<div *ngIf="!(materialsToAdd.length > 0 || flashcardsToAdd.length > 0 || testsToAdd.length > 0)">
Brak elementów do dodania

View File

@ -15,9 +15,9 @@ import { Subscription } from 'rxjs/Subscription';
export class SharingResourcesInGroupsComponent implements OnInit, OnDestroy {
public id = 0;
public dateFrom: Date;
public dateFrom: Date = new Date();
public howLong = 10;
public maxDate = new Date();
public minDate = new Date();
public materialsToAdd: Resource[] = [];
public testsToAdd: Resource[] = [];

View File

@ -1,5 +1,5 @@
#container-small {
background-color: #181616;
background-color: #28102f;
padding: 30px;
width: 25%;
height: 400px;
@ -10,7 +10,7 @@
text-align: center;
}
#container-login {
background-color: #181616;
background-color: #28102f;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);