From a62c97e16972da5753c8500a21470bd961dd7241 Mon Sep 17 00:00:00 2001 From: Nestor <npegane@hotmail.com> Date: Wed, 25 Jul 2018 15:28:14 +0200 Subject: [PATCH] FEAT #8188 Activate user front --- .../Views/activate-user.component.html | 32 ++++++++++ apps/maarch_entreprise/index.php | 21 ++++--- .../js/angular/app/activate-user.component.ts | 61 +++++++++++++++++++ .../js/angular/app/app-routing.module.ts | 3 +- .../js/angular/app/app.module.ts | 4 +- .../js/angular/lang/lang-fr.ts | 4 ++ 6 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 apps/maarch_entreprise/Views/activate-user.component.html create mode 100644 apps/maarch_entreprise/js/angular/app/activate-user.component.ts diff --git a/apps/maarch_entreprise/Views/activate-user.component.html b/apps/maarch_entreprise/Views/activate-user.component.html new file mode 100644 index 00000000000..6f7450c2b23 --- /dev/null +++ b/apps/maarch_entreprise/Views/activate-user.component.html @@ -0,0 +1,32 @@ +<div class="admin-container" [class.admin-is-mobile]="mobileQuery.matches"> + <mat-toolbar color="primary" class="admin-toolbar"> + <button mat-button (click)="snav.toggle()"> + <mat-icon class="maarchLogo" [svgIcon]="mobileQuery.matches ? 'maarchLogoOnly' : 'maarchLogo'"></mat-icon> + </button> + <h1 class="admin-toolbar-title text-center" style="color:white">{{lang.missingAdvertTitle}} + </h1> + <span style="flex: 1 1 auto;"></span> + <menu-top></menu-top> + </mat-toolbar> + <mat-sidenav-container class="admin-sidenav-container" [style.marginTop.px]="mobileMode ? 56 : 0"> + <mat-sidenav #snav [mode]="mobileMode ? 'over' : 'side'" [fixedInViewport]="mobileMode" fixedTopGap="56" [opened]="mobileMode ? false : true" + autoFocus="false"> + <menu-nav></menu-nav> + <mat-divider></mat-divider> + <menu-shortcut></menu-shortcut> + </mat-sidenav> + <mat-sidenav-content> + <div *ngIf="loading" style="display:flex;height:100%;"> + <mat-spinner style="margin:auto;"></mat-spinner> + </div> + <div *ngIf="!loading" class="text-center" style="position:relative; top:50px;"> + {{lang.missingAdvert}}<br> + {{lang.missingAdvert2}}<br> + {{lang.missingChoose}}<br> + <br> + <button mat-raised-button color="primary" type="button" (click)="deleteAbsence()">{{lang.validate}}</button> + <button mat-raised-button color="primary" type="button" (click)="logout()">{{lang.cancel}}</button> + </div> + </mat-sidenav-content> + </mat-sidenav-container> + </div> \ No newline at end of file diff --git a/apps/maarch_entreprise/index.php b/apps/maarch_entreprise/index.php index 87c0d24d432..920a75ae2f4 100755 --- a/apps/maarch_entreprise/index.php +++ b/apps/maarch_entreprise/index.php @@ -182,10 +182,11 @@ if (empty($_REQUEST['triggerAngular'])) { if ($_REQUEST['page'] != 'login' && $_REQUEST['page'] != 'log' && $_REQUEST['page'] != 'logout' && !empty($_SESSION['user']['UserId'])) { $user = \User\models\UserModel::getByUserId(['userId' => $_SESSION['user']['UserId'], 'select' => ['password_modification_date', 'change_password', 'status']]); $loggingMethod = \SrcCore\models\CoreConfigModel::getLoggingMethod(); - -// if ($user['status'] == 'ABS') { -// -// } + + if ($user['status'] == 'ABS') { + header('location: '.$_SESSION['config']['businessappurl'].'index.php?triggerAngular=activateUser'); + exit(); + } if (!in_array($loggingMethod['id'], ['sso', 'cas', 'ldap', 'ozwillo'])) { $passwordRules = \SrcCore\models\PasswordModel::getEnabledRules(); if ($user['change_password'] == 'Y') { @@ -206,7 +207,7 @@ if (empty($_REQUEST['triggerAngular'])) { } if (isset($_GET['show'])) { - $show = $_GET['show']; + $show = $_GET['show']; } else { $show = 'true'; } @@ -359,8 +360,9 @@ if (file_exists($path)) { if ($core->is_module_loaded('basket') && isset($_SESSION['abs_user_status']) - && $_SESSION['abs_user_status'] == true) { - include 'modules/basket/advert_missing.php'; + && $_SESSION['abs_user_status'] == true && !empty($_REQUEST['triggerAngular'])) { + /*include + 'modules/basket/advert_missing.php';*/ } elseif (empty($_REQUEST['triggerAngular'])) { $core->insert_page(); } @@ -387,7 +389,10 @@ if (file_exists($path)) { <?php if (!empty($_REQUEST['triggerAngular']) && $_REQUEST['triggerAngular'] == 'changePass') { ?><script>triggerAngular('#/password-modification')</script><?php - } elseif ($_SESSION['user']['UserId'] == 'superadmin' && !empty($_REQUEST['administration'])) { + } elseif (!empty($_REQUEST['triggerAngular']) && $_REQUEST['triggerAngular'] == 'activateUser') { + ?><script>triggerAngular('#/activateUser')</script><?php + } + elseif ($_SESSION['user']['UserId'] == 'superadmin' && !empty($_REQUEST['administration'])) { ?> <script>triggerAngular('#/administration')</script> <?php diff --git a/apps/maarch_entreprise/js/angular/app/activate-user.component.ts b/apps/maarch_entreprise/js/angular/app/activate-user.component.ts new file mode 100644 index 00000000000..38fdba14a5d --- /dev/null +++ b/apps/maarch_entreprise/js/angular/app/activate-user.component.ts @@ -0,0 +1,61 @@ +import { Component, OnInit, ChangeDetectorRef, ViewChild} from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { MediaMatcher } from '@angular/cdk/layout'; +import { NotificationService } from './notification.service'; +import { LANG } from './translate.component'; +import { MatDialog, MatDialogRef, MatSidenav, MatExpansionPanel } from '@angular/material'; + +declare var angularGlobals: any; +declare function $j(selector: any): any; + +@Component({ + templateUrl: "../../../Views/activate-user.component.html", + providers: [NotificationService], +}) + +export class ActivateUserComponent implements OnInit { + private _mobileQueryListener: () => void; + coreUrl : string; + mobileQuery : MediaQueryList; + lang : any = LANG; + loading : boolean = false; + user : any = { + + } + + constructor( media: MediaMatcher, changeDetectorRef: ChangeDetectorRef, public http: HttpClient, private notify: NotificationService){ + this.mobileQuery = media.matchMedia('(max-width: 768px)'); + this._mobileQueryListener = () => changeDetectorRef.detectChanges(); + this.mobileQuery.addListener(this._mobileQueryListener); + } + + + ngOnInit() : void { + this.coreUrl = angularGlobals.coreUrl; + this.loading = true; + this.http.get('../../rest/currentUser/profile') + .subscribe((data: any) => { + this.user = data; + this.loading = false; + }); + } + + deleteAbsence() : void { + this.http.put('../../rest/users/'+this.user.id+'/status', {'id' : this.user.id, 'status' : 'OK'}) + .subscribe(() => { + this.notify.success(this.lang.statusUpdated); + location.href = "index.php"; + }, + (err : any) => { + this.notify.error(err.error.errors); + }); + } + + redirect() { + location.href = "index.php"; + } + + logout() { + location.href = "index.php?display=true&page=logout&logout=true"; + } +} \ No newline at end of file diff --git a/apps/maarch_entreprise/js/angular/app/app-routing.module.ts b/apps/maarch_entreprise/js/angular/app/app-routing.module.ts index 86208a79546..bad406d4034 100755 --- a/apps/maarch_entreprise/js/angular/app/app-routing.module.ts +++ b/apps/maarch_entreprise/js/angular/app/app-routing.module.ts @@ -6,7 +6,7 @@ import { AboutUsComponent } from './about-us.component'; import { PasswordModificationComponent } from './password-modification.component'; import { SignatureBookComponent } from './signature-book.component'; import { SaveNumericPackageComponent } from './save-numeric-package.component'; - +import { ActivateUserComponent } from './activate-user.component'; @NgModule({ imports: [ @@ -15,6 +15,7 @@ import { SaveNumericPackageComponent } from './save-numeric-package.compone { path: 'about-us', component: AboutUsComponent }, { path: 'password-modification', component: PasswordModificationComponent }, { path: 'saveNumericPackage', component: SaveNumericPackageComponent }, + { path: 'activateUser', component: ActivateUserComponent}, { path: 'groups/:groupId/baskets/:basketId/signatureBook/:resId', component: SignatureBookComponent }, { path: '**', redirectTo: '', pathMatch: 'full' }, ], { useHash: true }), diff --git a/apps/maarch_entreprise/js/angular/app/app.module.ts b/apps/maarch_entreprise/js/angular/app/app.module.ts index 60d9b39209a..e29c88361e0 100755 --- a/apps/maarch_entreprise/js/angular/app/app.module.ts +++ b/apps/maarch_entreprise/js/angular/app/app.module.ts @@ -14,6 +14,7 @@ import { AboutUsComponent } from './about-us.component'; import { PasswordModificationComponent, InfoChangePasswordModalComponent, } from './password-modification.component'; import { SignatureBookComponent, SafeUrlPipe } from './signature-book.component'; import { SaveNumericPackageComponent } from './save-numeric-package.component'; +import { ActivateUserComponent } from './activate-user.component'; @NgModule({ imports: [ @@ -31,7 +32,8 @@ import { SaveNumericPackageComponent } from './save-numeric-package.com SaveNumericPackageComponent, CustomSnackbarComponent, ConfirmModalComponent, - InfoChangePasswordModalComponent + InfoChangePasswordModalComponent, + ActivateUserComponent ], entryComponents: [ CustomSnackbarComponent, diff --git a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts index 50401840546..22fe0cfb520 100755 --- a/apps/maarch_entreprise/js/angular/lang/lang-fr.ts +++ b/apps/maarch_entreprise/js/angular/lang/lang-fr.ts @@ -286,6 +286,10 @@ export const LANG_FR = { "memberUsersCopy" : "Utilisateur(s) en copie membre(s)", "menus" : "Menus", "minute" : "Minute", + "missingAdvert" : "Ce compte est actuellement défini en mode 'absent' et les courriers sont redirigés vers un autre utilisateur.", + "missingAdvert2" : "Si vous desirez vous connecter avec ce compte, le mode 'absent' sera alors supprimé.<br/> La redirection des courriers arrivera à son terme et l'application sera réactivée", + "missingAdvertTitle" : "Gestion des absences", + "missingChoose" : "Souhaitez-vous continuer?", "modificationSaved" : "Modification enregistrée", "module" : "Module", "modules" : "Modules", -- GitLab