From 1d6b848fccfa4fa4efae865c331cf210e09f0236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Szczepa=C5=84ski?= Date: Sat, 21 Dec 2019 19:06:42 +0100 Subject: [PATCH] =?UTF-8?q?PUNKT-49=20Dost=C4=99pno=C5=9B=C4=87=20testu=20?= =?UTF-8?q?przy=20dodawaniu=20do=20grupy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FrontEnd/.angular-cli.json | 1 + FrontEnd/src/app/groups/groups.module.ts | 4 ++- FrontEnd/src/app/groups/groups.service.ts | 36 +++++++++++++++++-- .../sharing-resources-in-groups.component.css | 5 +++ ...sharing-resources-in-groups.component.html | 8 +++++ .../sharing-resources-in-groups.component.ts | 10 +++++- FrontEnd/src/styles.css | 31 +++++++++++++++- 7 files changed, 90 insertions(+), 5 deletions(-) diff --git a/FrontEnd/.angular-cli.json b/FrontEnd/.angular-cli.json index 7aacfe0..d127adf 100644 --- a/FrontEnd/.angular-cli.json +++ b/FrontEnd/.angular-cli.json @@ -24,6 +24,7 @@ "../node_modules/primeng/resources/primeng.min.css", "../node_modules/primeng/resources/themes/luna-amber/theme.css", "../node_modules/primeng/resources/components/dialog/dialog.css", + "../node_modules/primeng/resources/components/calendar/calendar.css", "styles.css" ], "scripts": [ diff --git a/FrontEnd/src/app/groups/groups.module.ts b/FrontEnd/src/app/groups/groups.module.ts index 9657517..084f928 100644 --- a/FrontEnd/src/app/groups/groups.module.ts +++ b/FrontEnd/src/app/groups/groups.module.ts @@ -14,6 +14,7 @@ import { MatDatepickerModule } from '@angular/material/datepicker'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { MatNativeDateModule } from '@angular/material'; +import { CalendarModule } from 'primeng/calendar'; import { GroupsService } from './groups.service'; @@ -50,7 +51,8 @@ import { TestsInGroupResultsComponent } from './tests-in-group-results/tests-in- MatInputModule, MatDatepickerModule, ReactiveFormsModule, - MatNativeDateModule + MatNativeDateModule, + CalendarModule ], declarations: [ MyGroupsComponent, diff --git a/FrontEnd/src/app/groups/groups.service.ts b/FrontEnd/src/app/groups/groups.service.ts index 97a9b78..0d43858 100644 --- a/FrontEnd/src/app/groups/groups.service.ts +++ b/FrontEnd/src/app/groups/groups.service.ts @@ -177,9 +177,17 @@ export class GroupsService { }); } - addTestsToGroup(group: number, tests: Array): Observable { + addTestsToGroup(group: number, tests: Array, dateFrom: number = null, dateTo = null): Observable { const testToSend = tests.map(item => { - return { testId: item }; + if (dateFrom === null) { + return { testId: item }; + } else { + return { + testId: item, + dateFrom: dateFrom, + dateTo: dateTo + } + } }); this.setHeaders(); return this.httpClient.post(`groups/${group}/tests`, @@ -193,6 +201,30 @@ export class GroupsService { }); } + putTestsToGroup(group: number, tests: Array, dateFrom: number = null, dateTo = null): Observable { + const testToSend = tests.map(item => { + if (dateFrom === null) { + return { testId: item }; + } else { + return { + testId: item, + dateFrom: dateFrom, + dateTo: dateTo + } + } + }); + this.setHeaders(); + return this.httpClient.put(`groups/${group}/tests`, + testToSend, + { + headers: this.headers, + observe: 'response', + responseType: 'text' + }).catch((error: any) => { + return Observable.throw(error); + }); + } + addMaterialsToGroup(group: number, materials: Array): Observable { const testToSend = materials.map(item => { return { materialId: item }; diff --git a/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.css b/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.css index d811e3a..7fa25a8 100644 --- a/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.css +++ b/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.css @@ -30,3 +30,8 @@ display: flex; justify-content: center; } + +input { + margin-left: 1rem; + padding-left: 5px; +} 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 faa3a83..46162e9 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 @@ -25,6 +25,14 @@

Testy

+
+

+ Od kiedy test ma być dostępny: + +


+ Ile minut ma być dostępny ten test: + +


diff --git a/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.ts b/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.ts index fa4a8bb..e83688b 100644 --- a/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.ts +++ b/FrontEnd/src/app/groups/sharing-resources-in-groups/sharing-resources-in-groups.component.ts @@ -15,6 +15,8 @@ import { Subscription } from 'rxjs/Subscription'; export class SharingResourcesInGroupsComponent implements OnInit, OnDestroy { public id = 0; + public dateFrom: Date; + public howLong = 10; public materialsToAdd: Resource[] = []; public testsToAdd: Resource[] = []; @@ -159,7 +161,13 @@ export class SharingResourcesInGroupsComponent implements OnInit, OnDestroy { addResources() { this.id = this.route.snapshot.params.id; if (this.selectedTypeOfResource === ResourceType.test) { - this.addTestsToGroupSub = this.groupService.addTestsToGroup(this.id, this.selected).subscribe( + let dateFrom = null; + let dateTo = null; + if (this.dateFrom) { + dateFrom = this.dateFrom.getTime(); + dateTo = dateFrom + this.howLong * 60 * 1000; + } + this.addTestsToGroupSub = this.groupService.addTestsToGroup(this.id, this.selected, dateFrom, dateTo).subscribe( success => { this.snackBar.open('Twoje testy zostały dodane do grupy.', null, { duration: 3000, verticalPosition: 'top', panelClass: ['snackbar-success'] }); diff --git a/FrontEnd/src/styles.css b/FrontEnd/src/styles.css index 5611f1c..dffd8f2 100644 --- a/FrontEnd/src/styles.css +++ b/FrontEnd/src/styles.css @@ -202,11 +202,21 @@ button:hover, a:hover { border: 1px solid #625283 !important; } -.wrapper .wrapper-add .container .wrapper .wrapper-add .container { +.wrapper .wrapper-add .container .wrapper .wrapper-add .container, body .ui-listbox .ui-listbox-list { background-color: #19032f !important; border: 1px solid #45395e !important; } +body .ui-listbox .ui-listbox-header { + background-color: #0c0118 !important; + border: 1px solid #45395e !important; +} + +body .ui-chkbox .ui-chkbox-box { + background-color: #45395e !important; + border: 1px solid #625283 !important; +} + .ui-dialog * { font-family: 'Roboto Slab', 'Cambria', serif !important; } @@ -333,3 +343,22 @@ button:hover, a:hover { } } + +p-calendar { + margin-left: 1rem !important; +} + +body .ui-inputtext { + background-color: #FFF !important; + border: 1px solid #FFF !important; + color: #000 !important; +} + +body .ui-datepicker { + background-color: #19032f !important; + border: 1px solid #45395e !important; +} + +body .ui-datepicker .ui-datepicker-header { + background-color: #0c0118 !important; +}