From a9a79b7c7faa621cd42cb737361b06dbfa456a2f Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Mon, 6 Apr 2020 09:50:12 +0200 Subject: [PATCH] FEAT #13670 TIME 0:10 my message --- src/frontend/app/app-common.module.ts | 6 -- .../app/menu/main-header.component.html | 56 ------------- .../app/menu/main-header.component.ts | 83 ------------------- src/frontend/app/menu/menu.component.html | 15 ---- src/frontend/app/menu/menu.component.ts | 16 ---- .../app/password-modification.component.ts | 4 +- src/frontend/app/profile.component.ts | 5 +- 7 files changed, 7 insertions(+), 178 deletions(-) delete mode 100755 src/frontend/app/menu/main-header.component.html delete mode 100755 src/frontend/app/menu/main-header.component.ts delete mode 100755 src/frontend/app/menu/menu.component.html delete mode 100755 src/frontend/app/menu/menu.component.ts diff --git a/src/frontend/app/app-common.module.ts b/src/frontend/app/app-common.module.ts index a2c30614726..47a4678477a 100755 --- a/src/frontend/app/app-common.module.ts +++ b/src/frontend/app/app-common.module.ts @@ -38,8 +38,6 @@ import { SmdFabSpeedDialComponent, SmdFabSpeedDialTrigger, SmdFabSpeedDialAction import { HeaderRightComponent } from './header/header-right.component'; import { HeaderLeftComponent } from './header/header-left.component'; import { HeaderPanelComponent } from './header/header-panel.component'; -import { MainHeaderComponent } from './menu/main-header.component'; -import { MenuComponent } from './menu/menu.component'; import { MenuNavComponent } from './menu/menu-nav.component'; import { MenuShortcutComponent, IndexingGroupModalComponent } from './menu/menu-shortcut.component'; @@ -99,8 +97,6 @@ export class MyHammerConfig extends HammerGestureConfig { DragDropModule ], declarations: [ - MainHeaderComponent, - MenuComponent, MenuNavComponent, MenuShortcutComponent, HeaderRightComponent, @@ -140,8 +136,6 @@ export class MyHammerConfig extends HammerGestureConfig { ], exports: [ CommonModule, - MainHeaderComponent, - MenuComponent, MenuNavComponent, MenuShortcutComponent, HeaderRightComponent, diff --git a/src/frontend/app/menu/main-header.component.html b/src/frontend/app/menu/main-header.component.html deleted file mode 100755 index 65565499057..00000000000 --- a/src/frontend/app/menu/main-header.component.html +++ /dev/null @@ -1,56 +0,0 @@ -<mat-toolbar color="primary" class="admin-toolbar"> - <button mat-button (click)="this.snav.toggle();" style="min-width: 50px;padding: 5px;opacity: 0.8;color: #F99830"> - <mat-icon class="fa fa-bars fa-2x"></mat-icon> - </button> - <a href="#" title="{{lang.home}}" *ngIf="!appService.getViewMode()" style="margin-right: 30px;"><mat-icon class="maarchLogo" svgIcon="maarchLogo"></mat-icon></a> - <h1 class="admin-toolbar-title">{{headerService.headerMessage}}</h1><span class="admin-toolbar-title-small">{{headerService.subHeaderMessage}}</span> - <span style="flex: 1 1 auto;"></span> - <search-home></search-home> - <button mat-button [matMenuTriggerFor]="applications" (click)="getMenus()" *ngIf="!appService.getViewMode()" style="min-width:0px;width:65px;height: 40px;margin-left: 10px" matTooltip="{{lang.menu}}"> - <mat-icon mat-list-icon class="fa fa-th" style="font-size:20px;color:white;height:auto;"></mat-icon> - </button> - <mat-menu #applications="matMenu" class="headerMaarchShortcut"> - <ng-container *ngFor="let shortcut of menus | sortBy: 'label'"> - <button (click)="gotToMenu(shortcut);" style="white-space:inherit;height: 100px;line-height:20px;" class="col-md-4 col-xs-6" mat-button color="primary" matTooltip="{{shortcut.comment}}"> - <i class="{{shortcut.style}} fa-2x"></i> - <br/>{{shortcut.label}} - </button> - </ng-container> - </mat-menu> - <button mat-button [matMenuTriggerFor]="menu" *ngIf="!appService.getViewMode()"> - <mat-icon mat-list-icon class="fa fa-user fa-2x" style="color:white; margin:0px 12px 8px 0px;"></mat-icon><span>{{headerService.user.firstname | titlecase }}</span> <b>{{headerService.user.lastname | uppercase}}</b></button> - <mat-menu #menu="matMenu" class="headerMaarch"> - <canvas class="header-bg" width="250" height="70" style="margin-top:-8px;background-image: url('static.php?filename=login-banner.jpg');background-size:cover;border-bottom: solid 1px white;"></canvas> - <i title="{{lang.myProfileAccess}}" routerLink="/profile" style="cursor:pointer;z-index:1;color:white;position: absolute;left: 85px;top: 17px;background-image: url('static.php?filename=logo_only.svg');width: 70px;height: 70px;background-size: cover;background-position: top center;border-radius: 50%;border: solid white;background-color:white;"></i> - <div class="content" style="padding-top:20px;color:white;max-height:250px;overflow-y:auto;overflow-x:hidden;"> - <p routerLink="/profile" class="text-center" style="cursor:pointer;">{{headerService.user.firstname}} {{headerService.user.lastname | uppercase}}</p> - <mat-list> - <h3 mat-subheader style="color:white;">{{lang.groups}}</h3> - <mat-divider></mat-divider> - <mat-list-item *ngFor="let group of headerService.user.groups"> - <p mat-line style="color:white;opacity:0.5;"> {{group.group_desc}} </p> - </mat-list-item> - <h3 mat-subheader style="color:white;">{{lang.entities}}</h3> - <mat-divider></mat-divider> - <mat-list-item *ngFor="let entity of headerService.user.entities"> - <p mat-line style="color:white;opacity:0.5;"> {{entity.entity_label}} </p> - </mat-list-item> - </mat-list> - </div> - <div style="display:flex;padding: 5px;"> - <div style="text-align:left;flex:1"> - <a routerLink="/profile" style="color: white;padding-left: 10px;"> - <span class="badge" style="background:white;" color="primary">{{lang.myProfile}}</span> - </a> - </div> - <div style="text-align:right;flex:2;"> - <a href="index.php?display=true&page=logout&logout=true" style="color: white;padding-right: 10px;"> - <span class="badge" style="background:white;" color="primary">{{lang.logout}}</span> - </a> - </div> - </div> - </mat-menu> - <button id="snav2Button" mat-icon-button (click)="this.snav2.toggle()"> - <mat-icon class="fa fa-2x" [ngClass]="[this.snav2 && this.snav2.opened ? 'fa-chevron-right' : 'fa-chevron-left']"></mat-icon> - </button> -</mat-toolbar> diff --git a/src/frontend/app/menu/main-header.component.ts b/src/frontend/app/menu/main-header.component.ts deleted file mode 100755 index bbb49272f7f..00000000000 --- a/src/frontend/app/menu/main-header.component.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { Component, OnInit, NgZone } from '@angular/core'; -import { LANG } from '../translate.component'; -import { MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { MatSidenav } from '@angular/material/sidenav'; -import { HttpClient } from '@angular/common/http'; -import { Router } from '@angular/router'; -import { IndexingGroupModalComponent } from './menu-shortcut.component'; -import { HeaderService } from '../../service/header.service'; -import { AppService } from '../../service/app.service'; -import { PrivilegeService } from '../../service/privileges.service'; - -declare var $: any; - -@Component({ - selector: 'main-header', - templateUrl: 'main-header.component.html', - providers: [AppService], -}) -export class MainHeaderComponent implements OnInit { - - lang: any = LANG; - user: any = { firstname: '', lastname: '' }; - dialogRef: MatDialogRef<any>; - config: any = {}; - titleHeader: string; - router: any; - menus: any = []; - - snav: MatSidenav; - snav2: MatSidenav; - - - constructor( - public http: HttpClient, - private zone: NgZone, - private _router: Router, - public headerService: HeaderService, - public dialog: MatDialog, - public appService: AppService, - private privilegeService: PrivilegeService - ) { - this.router = _router; - window['MainHeaderComponent'] = { - refreshTitle: (value: string) => this.setTitle(value), - setSnav: (value: MatSidenav) => this.getSnav(value), - setSnavRight: (value: MatSidenav) => this.getSnavRight(value), - }; - } - - ngOnInit(): void { } - - getMenus() { - this.menus = this.privilegeService.getCurrentUserMenus(); - } - - setTitle(title: string) { - this.zone.run(() => this.titleHeader = title); - } - - getSnav(snav: MatSidenav) { - this.zone.run(() => this.snav = snav); - } - - getSnavRight(snav2: MatSidenav) { - if (snav2 == null) { - $('#snav2Button').hide(); - } else { - $('#snav2Button').show(); - this.zone.run(() => this.snav2 = snav2); - } - } - - gotToMenu(shortcut: any) { - if (shortcut.id === 'indexing' && shortcut.groups.length > 1) { - this.config = { panelClass: 'maarch-modal', data: { indexingGroups: shortcut.groups, link: shortcut.route } }; - this.dialogRef = this.dialog.open(IndexingGroupModalComponent, this.config); - } else if (shortcut.angular === true) { - this.router.navigate([shortcut.route]); - } else { - location.href = shortcut.route; - } - } -} diff --git a/src/frontend/app/menu/menu.component.html b/src/frontend/app/menu/menu.component.html deleted file mode 100755 index f076ce1bf08..00000000000 --- a/src/frontend/app/menu/menu.component.html +++ /dev/null @@ -1,15 +0,0 @@ -<mat-nav-list> - <h3 mat-subheader>{{lang.myMenu}}</h3> - <a mat-list-item routerLink="/profile"> - <mat-icon color="primary" mat-list-icon class="fa fa-user-circle"></mat-icon> - <p mat-line> - {{lang.myProfile}} - </p> - </a> - <a mat-list-item href="index.php?display=true&page=logout&logout=true"> - <mat-icon color="warn" mat-list-icon class="fa fa-sign-out-alt"></mat-icon> - <p mat-line> - {{lang.logout}} - </p> - </a> -</mat-nav-list> \ No newline at end of file diff --git a/src/frontend/app/menu/menu.component.ts b/src/frontend/app/menu/menu.component.ts deleted file mode 100755 index 69eca6072a5..00000000000 --- a/src/frontend/app/menu/menu.component.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { LANG } from '../translate.component'; - -@Component({ - selector: 'menu-app', - templateUrl: 'menu.component.html', -}) -export class MenuComponent implements OnInit { - - lang: any = LANG; - - constructor() { - } - - ngOnInit(): void { } -} diff --git a/src/frontend/app/password-modification.component.ts b/src/frontend/app/password-modification.component.ts index 4616dd1ae48..c0c9ea6bce6 100755 --- a/src/frontend/app/password-modification.component.ts +++ b/src/frontend/app/password-modification.component.ts @@ -7,6 +7,7 @@ import { MAT_DIALOG_DATA, MatDialogRef, MatDialog } from '@angular/material/dial import { AppService } from '../service/app.service'; import { Router } from '@angular/router'; import { HeaderService } from '../service/header.service'; +import { AuthService } from '../service/auth.service'; @Component({ templateUrl: 'password-modification.component.html', @@ -49,6 +50,7 @@ export class PasswordModificationComponent implements OnInit { constructor( public http: HttpClient, + private authService: AuthService, private headerService: HeaderService, private notify: NotificationService, private _formBuilder: FormBuilder, @@ -195,7 +197,7 @@ export class PasswordModificationComponent implements OnInit { } logout() { - location.href = 'index.php?display=true&page=logout&logout=true'; + this.authService.logout(); } } diff --git a/src/frontend/app/profile.component.ts b/src/frontend/app/profile.component.ts index 9ab84a6b6e0..9c5bfd611b4 100755 --- a/src/frontend/app/profile.component.ts +++ b/src/frontend/app/profile.component.ts @@ -14,6 +14,8 @@ import { SelectionModel } from '@angular/cdk/collections'; import { FormControl, FormGroup, Validators, AbstractControl, ValidationErrors, ValidatorFn, FormBuilder } from '@angular/forms'; import { AppService } from '../service/app.service'; import { FunctionsService } from '../service/functions.service'; +import { AuthService } from '../service/auth.service'; +import { Router } from '@angular/router'; declare var $: any; declare var tinymce: any; @@ -165,6 +167,7 @@ export class ProfileComponent implements OnInit { private notify: NotificationService, public dialog: MatDialog, private _formBuilder: FormBuilder, + private authService: AuthService, private headerService: HeaderService, public appService: AppService, private viewContainerRef: ViewContainerRef, @@ -608,7 +611,7 @@ export class ProfileComponent implements OnInit { if (r) { this.http.put('../../rest/users/' + this.user.id + '/status', { 'status': 'ABS' }) .subscribe(() => { - location.search = '?display=true&page=logout&logout=true'; + this.authService.logout(); }, (err) => { this.notify.error(err.error.errors); }); -- GitLab