From 2d66d182d86941fd7fced3aa00d9e0f9a02d05f8 Mon Sep 17 00:00:00 2001 From: MiharyR Date: Sun, 21 Nov 2021 22:16:48 +0100 Subject: [PATCH] amelioration de la partie admin --- .../page-ad-list-admin.component.html | 76 ++++++++++++- .../page-ad-list-admin.component.scss | 39 +++++++ .../page-ad-list-admin.component.ts | 71 +++++++++++- .../page-user-list.component.html | 106 +++++++++++++----- .../page-user-list.component.scss | 72 ++++++++---- .../page-user-list.component.ts | 105 ++++++++++++----- .../popup-create-user.component.html | 62 +++++----- src/app/app.module.ts | 2 + .../fictitious-adverts.service.ts | 4 +- .../fictitious-users.service.ts | 3 + 10 files changed, 432 insertions(+), 108 deletions(-) diff --git a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.html b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.html index 0a462ca..41e464d 100644 --- a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.html +++ b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.html @@ -1,18 +1,80 @@
- +

- -
- + + +
+ + +
+ Filtre +
+ + + + +
+ +
+ + +
+ + +
+ visible
+ non visible +
+ + +
+ + Tags + + + {{formControlTags.value ? formControlTags.value[0] : ''}} + + (+{{formControlTags.value.length - 1}} {{formControlTags.value?.length === 2 ? 'autre' : 'autres'}}) + + + {{topping}} + + + +
+ + +
+ Période de création:   + + Date de début + + +   -   + + Date de fin + + +
+ +
-
- + + @@ -82,9 +144,11 @@ + diff --git a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.scss b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.scss index a832a58..e79c543 100644 --- a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.scss +++ b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.scss @@ -5,6 +5,25 @@ font-size: small; } +// ---------------------------------------------------------- + + +.filtersContainer { + width: 70%; + background-color: white; + padding: 10px 10px 10px 10px; + margin: 20px 3% 20px 3% +} + +.myRow { + margin-left: 1%; +} + +.textFilter { + width: 50%; + font-size: medium; + border-radius: 5px; +} // ---------------------------------------------------------- @@ -29,3 +48,23 @@ input { font-size: large; border-radius: 5px; } + + +// ------------------------------------------------------------------------- + + +// aura +::ng-deep .mat-checkbox-ripple .mat-ripple-element { + background-color: grey !important; +} + +// contenu coche +::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background { + background-color: black !important; +} + +// indeterminate +::ng-deep .mat-checkbox .mat-checkbox-frame { + border: solid 1px black !important; + background-color: white !important; +} diff --git a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.ts b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.ts index e5c29b6..c692fbe 100644 --- a/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.ts +++ b/src/app/admin/adList/page-ad-list-admin/page-ad-list-admin.component.ts @@ -10,6 +10,8 @@ import {PopupVisualizeAdAdminComponent} from "../popup-visualize-ad-admin/popup- import {PopupDeleteAdAdminComponent} from "../popup-delete-ad-admin/popup-delete-ad-admin.component"; import {PopupVisualizeImagesAdminComponent} from "../popup-visualize-images-admin/popup-visualize-images-admin.component"; import {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service"; +import {FormControl} from "@angular/forms"; +import {FictitiousUtilsService} from "../../../utils/services/fictitiousDatas/fictitiousUtils/fictitious-utils.service"; @@ -20,14 +22,23 @@ import {FictitiousAdvertsService} from "../../../utils/services/fictitiousDatas/ }) export class PageAdListAdminComponent implements AfterViewInit { + tabAdvert: Advert[]; displayedColumns: string[] = [ 'title', 'advertiser', 'tags', 'createdAt', 'updatedAt', 'views', 'isVisible', 'actions' ]; dataSource ; @ViewChild(MatSort) sort: MatSort; @ViewChild(MatPaginator) paginator: MatPaginator; + visible: boolean = true; + noVisible: boolean = true; + startDate: Date = null; + endDate: Date = null; + formControlTags = new FormControl(); + allTags: string[] = []; + constructor( public themeService: ThemeService, private fictitiousAdvertsService: FictitiousAdvertsService, + private fictitiousUtilsService: FictitiousUtilsService, public dialog: MatDialog, private snackBar: MatSnackBar ) { } @@ -35,11 +46,12 @@ export class PageAdListAdminComponent implements AfterViewInit ngAfterViewInit(): void { // --- FAUX CODE --- - const tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8); - this.dataSource = new MatTableDataSource(tabAdvert); + this.tabAdvert = this.fictitiousAdvertsService.getTabAdvert(8); + this.dataSource = new MatTableDataSource(this.tabAdvert); this.dataSource.sort = this.sort; this.dataSource.paginator = this.paginator; this.dataSource = this.dataSource; + this.allTags = this.fictitiousUtilsService.getTags(); } @@ -107,4 +119,59 @@ export class PageAdListAdminComponent implements AfterViewInit }); } + + onFilter(): void + { + console.log("b:" + this.formControlTags.value); + this.dataSource.data = []; + for(let advert of this.tabAdvert) + { + let valide: boolean = true; + + if(advert.isVisible && this.visible) valide = true; + else if((!advert.isVisible) && this.noVisible) valide = true; + else valide = false; + + if(valide) + { + if ((advert.createdAt === null) && (this.startDate !== null)) valide = false; + else if ((advert.createdAt === null) && (this.endDate !== null)) valide = false; + else if (this.startDate !== null) + { + if(this.startDate.getTime() > advert.createdAt.getTime()) valide = false; + else if (this.endDate !== null) + { + if(this.endDate.getTime() < advert.createdAt.getTime()) valide = false; + } + } + } + + if(valide) { + if(this.formControlTags.value !== null) { + for (let tag of this.formControlTags.value) { + if (advert.tags.indexOf(tag) === -1) { + valide = false; + break; + } + } + } + } + + if(valide) this.dataSource.data.push(advert); + } + + this.dataSource = new MatTableDataSource(this.dataSource.data); + this.dataSource.sort = this.sort; + this.dataSource.paginator = this.paginator; + } + + + onNewStartDate(event): void { + this.startDate = new Date(event); + } + + onNewEndDate(event): void { + this.endDate = new Date(event); + } + } diff --git a/src/app/admin/userList/page-user-list/page-user-list.component.html b/src/app/admin/userList/page-user-list/page-user-list.component.html index cfebbba..a2260b6 100644 --- a/src/app/admin/userList/page-user-list/page-user-list.component.html +++ b/src/app/admin/userList/page-user-list/page-user-list.component.html @@ -6,40 +6,97 @@

- -
- -
+ +
-
+ +
+
- -
- - - Utilisateur -
- - Annonceur -
- - Admin - -
+ +
+ Filtre +
+ + + + +
+ +
+ + +
+ + +
+ + + Utilisateur +
+ + Annonceur +
+ + Admin + +
+
+ + +
+ actif
+ non actif +
+ + +
+ Période de dernière connexion:   + + Date de début + + +   -   + + Date de fin + + +
+ +
+ +
-
-
+ +
+ + + + + + @@ -76,8 +133,8 @@ @@ -110,10 +167,9 @@ - + diff --git a/src/app/admin/userList/page-user-list/page-user-list.component.scss b/src/app/admin/userList/page-user-list/page-user-list.component.scss index 70d995d..7dc2ab9 100644 --- a/src/app/admin/userList/page-user-list/page-user-list.component.scss +++ b/src/app/admin/userList/page-user-list/page-user-list.component.scss @@ -1,25 +1,24 @@ .myContainer { - max-width: 100vw; - height: 100vh; - overflow-x: hidden; + min-height: 100vh; font-size: small; } // ---------------------------------------------------------- -.matRadioGroupContainer { - float:left; +.filtersContainer { + width: 85%; background-color: white; - width: 15%; - margin-left: 3%; padding: 10px 10px 10px 10px; - border-bottom: 1px solid #dcdcdc; } -.btnAjouterContainer { - float:left; - margin-left: 65%; - padding-top: 20px; +.myRow { + margin-left: 1%; +} + +.textFilter { + width: 50%; + font-size: medium; + border-radius: 5px; } .btnAjouter { @@ -29,14 +28,6 @@ // ---------------------------------------------------------- -input { - width: 30%; - font-size: large; - border-radius: 5px; -} - -// ---------------------------------------------------------- - table { margin: 0 auto; width: 94%; @@ -64,4 +55,45 @@ td { border: solid 1px gray !important; } +// ------------------------------------------------------------------------- + +// aura +::ng-deep .mat-checkbox-ripple .mat-ripple-element { + background-color: grey !important; +} + +// contenu coche +::ng-deep .mat-checkbox-checked.mat-accent .mat-checkbox-background { + background-color: black !important; +} + +// indeterminate +::ng-deep .mat-checkbox .mat-checkbox-frame { + border: solid 1px black !important; + background-color: white !important; +} + + +// -------------------------------------------------------------------- + + +// rong gauche +::ng-deep .mat-slide-toggle-thumb { + background-color: white !important; +} + +// trait droite +::ng-deep .mat-slide-toggle-bar { + background-color: gray !important; +} + +// rond droite +::ng-deep .mat-slide-toggle.mat-checked:not(.mat-disabled) .mat-slide-toggle-thumb { + background-color: white !important; +} + +// trait gauche +::ng-deep .mat-slide-toggle.mat-checked:not(.mat-disabled) .mat-slide-toggle-bar { + background-color: cornflowerblue !important; +} diff --git a/src/app/admin/userList/page-user-list/page-user-list.component.ts b/src/app/admin/userList/page-user-list/page-user-list.component.ts index df708dc..02c7285 100644 --- a/src/app/admin/userList/page-user-list/page-user-list.component.ts +++ b/src/app/admin/userList/page-user-list/page-user-list.component.ts @@ -21,9 +21,9 @@ import {FictitiousUsersService} from "../../../utils/services/fictitiousDatas/fi export class PageUserListComponent implements AfterViewInit { displayedColumns: string[]; - displayedColumnsUser: string[] = [ 'login', 'email', 'dateOfBirth', 'age', 'sexe', 'interests', 'createdAt', 'lastConnexion', 'actions' ]; - displayedColumnsAdvertiser: string[] = [ 'login', 'email', 'createdAt', 'lastConnexion', 'isAccepted', 'actions' ]; - displayedColumnsAdmin: string[] = [ 'login', 'email', 'createdAt', 'lastConnexion', 'actions' ]; + displayedColumnsUser: string[] = [ 'isActive', 'login', 'email', 'dateOfBirth', 'age', 'sexe', 'interests', 'createdAt', 'lastConnexion' ]; + displayedColumnsAdvertiser: string[] = [ 'isActive', 'login', 'email', 'createdAt', 'lastConnexion', 'isAccepted' ]; + displayedColumnsAdmin: string[] = [ 'isActive', 'login', 'email', 'createdAt', 'lastConnexion' ]; tabUser: any[] = []; tabAdvertiser: User[] = []; @@ -34,6 +34,11 @@ export class PageUserListComponent implements AfterViewInit @ViewChild(MatSort) sort: MatSort; @ViewChild(MatPaginator) paginator: MatPaginator; + active: boolean = true; + noActive: boolean = false; + startDate: Date = null; + endDate: Date = null; + constructor( public themeService: ThemeService, private fictitiousUsersService: FictitiousUsersService, @@ -50,30 +55,7 @@ export class PageUserListComponent implements AfterViewInit for(const user of this.tabUser) user.age = this.getAge(user.dateOfBirth); - this.displayedColumns = this.displayedColumnsUser; - - this.dataSource = new MatTableDataSource(this.tabUser); - this.dataSource.sort = this.sort; - this.dataSource.paginator = this.paginator; - this.dataSource = this.dataSource; - } - - - onChangeRoleSelected(roleName: string): void - { - if(roleName === "user") { - this.displayedColumns = this.displayedColumnsUser; - this.dataSource.data = this.tabUser; - } - else if(roleName === "advertiser") { - this.displayedColumns = this.displayedColumnsAdvertiser; - this.dataSource.data = this.tabAdvertiser; - } - else if(roleName === "admin") { - this.displayedColumns = this.displayedColumnsAdmin; - this.dataSource.data = this.tabAdmin; - } - this.dataSource = this.dataSource; + this.onFilter(); } @@ -143,10 +125,79 @@ export class PageUserListComponent implements AfterViewInit } + onSliderIsActive(user: User): void + { + // il faut envoyer la négation de user.isActive + } + + + onSlideIsAccepted(user: User): void + { + // il faut envoyer la négation de user.isActive + } + + getAge(date: Date): number { const diff = Date.now() - date.getTime(); const age = new Date(diff); return Math.abs(age.getUTCFullYear() - 1970); } + + + onFilter(): void + { + let tab1 = []; + if(this.roleName === "user") { + this.displayedColumns = this.displayedColumnsUser; + tab1 = this.tabUser; + } + else if(this.roleName === "advertiser") { + this.displayedColumns = this.displayedColumnsAdvertiser; + tab1 = this.tabAdvertiser; + } + else if(this.roleName === "admin") { + this.displayedColumns = this.displayedColumnsAdmin; + tab1 = this.tabAdmin; + } + + let tab2 = []; + for(let user of tab1) + { + let valide: boolean = true; + + if(user.isActive && this.active) valide = true; + else if((!user.isActive) && this.noActive) valide = true; + else valide = false; + if(valide) + { + if ((user.lastConnexion === null) && (this.startDate !== null)) valide = false; + else if ((user.lastConnexion === null) && (this.endDate !== null)) valide = false; + else if (this.startDate !== null) + { + if(this.startDate.getTime() > user.lastConnexion.getTime()) valide = false; + else if (this.endDate !== null) + { + if(this.endDate.getTime() < user.lastConnexion.getTime()) valide = false; + } + } + } + + if(valide) tab2.push(user); + } + + this.dataSource = new MatTableDataSource(tab2); + this.dataSource.sort = this.sort; + this.dataSource.paginator = this.paginator; + } + + + onNewStartDate(event): void { + this.startDate = new Date(event); + } + + onNewEndDate(event): void { + this.endDate = new Date(event); + } + } diff --git a/src/app/admin/userList/popup-create-user/popup-create-user.component.html b/src/app/admin/userList/popup-create-user/popup-create-user.component.html index c3d2332..c281ffc 100644 --- a/src/app/admin/userList/popup-create-user/popup-create-user.component.html +++ b/src/app/admin/userList/popup-create-user/popup-create-user.component.html @@ -109,37 +109,47 @@ + + +
+
+ +

- -
-
- -

- - - Email - -
+ +
- - - Login - -
+ +
+ + + Email + +
+ + + Login + +
+
- - - Mot de passe - -
- - - - Confirmation nouveau mot de passe - - + +
+ + + Mot de passe + +
+ + + Confirmation nouveau mot de passe + + +
+ +
diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 832ab45..1a5fb3f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -69,6 +69,7 @@ import { PopupDeleteUserComponent } from './admin/userList/popup-delete-user/pop import { PopupCreateUserComponent } from './admin/userList/popup-create-user/popup-create-user.component'; import { InputInterestsAdminComponent } from './admin/userList/input-interests-admin/input-interests-admin.component'; import { PageWatchingVideoComponent } from './user/watching/page-watching-video/page-watching-video.component'; +import {MatDatepickerModule} from "@angular/material/datepicker"; @NgModule({ @@ -146,6 +147,7 @@ import { PageWatchingVideoComponent } from './user/watching/page-watching-video/ MatRadioModule, MatStepperModule, MatPaginatorModule, + MatDatepickerModule, ], providers: [], bootstrap: [AppComponent] diff --git a/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts b/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts index 3d709b9..1506cf0 100644 --- a/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts +++ b/src/app/utils/services/fictitiousDatas/fictitiousAdverts/fictitious-adverts.service.ts @@ -15,7 +15,7 @@ const TAB_ADVERT: Advert[] = [ { url: "nutella_v_2.png", description: "image nutella 2" }, { url: "nutella_v_3.jpg", description: "image nutella 3" } ], - tags: [ "bon", "petit-déjeuner", "chocolat" ], + tags: [ "rock", "basket" ], comment: "pub pour vacances de noêl", views: 5, isVisible: true, @@ -32,7 +32,7 @@ const TAB_ADVERT: Advert[] = [ { url: "rolex_v_1.jpg", description: "rolex 1" }, { url: "rolex_v_2.png", description: "rolex 2" }, ], - tags: [ "montre", "luxe", "suisse" ], + tags: [ "rock", "rap" ], comment: "pub pour cette année", views: 2, isVisible: true, diff --git a/src/app/utils/services/fictitiousDatas/fictitiousUsers/fictitious-users.service.ts b/src/app/utils/services/fictitiousDatas/fictitiousUsers/fictitious-users.service.ts index c331fa7..2b37759 100644 --- a/src/app/utils/services/fictitiousDatas/fictitiousUsers/fictitious-users.service.ts +++ b/src/app/utils/services/fictitiousDatas/fictitiousUsers/fictitious-users.service.ts @@ -81,6 +81,9 @@ export class FictitiousUsersService res.login += (Math.floor(Math.random() * 1000)).toString(); res.email = res.login + "@gmail.com" ; res.isAccepted = (Math.random() < 0.5); + res.isActive = (Math.random() < 0.5); + res.dateOfBirth = this.fictitiousUtilsService.randomDate(new Date(1900, 0, 1), new Date()); + res.lastConnexion = this.fictitiousUtilsService.randomDate(new Date(2000, 0, 1), new Date()); return res; }
+ power_settings_new + + + Login Sexe - Homme - Femme + H + F Activé Accepté - check - +