diff --git a/src/frontend/app/menu/menu-shortcut.component.html b/src/frontend/app/menu/menu-shortcut.component.html index 61da3d789345d30fc3aa7c89ff4f53a9d732f153..11b453d7b1f22b23388fe4395c2e05dd9603525f 100755 --- a/src/frontend/app/menu/menu-shortcut.component.html +++ b/src/frontend/app/menu/menu-shortcut.component.html @@ -30,14 +30,14 @@ <mat-nav-list> <h3 mat-subheader>{{lang.shortcut}}</h3> <div class="button-row" style="padding-left: 10px;padding-right: 10px;display: flex;width: 300px;margin-top: -10px;margin-bottom: 10px;"> - <ng-container *ngFor="let shortcut of headerService.menu"> - <span style="flex:1;text-align: left;padding: 5px;" *ngIf="(shortcut.id == 'index_mlb' && speedDialFabButtons.length<=1) || (shortcut.id != 'index_mlb' && shortcut.shortcut == 'true')"> + <ng-container *ngFor="let shortcut of headerService.shortcut"> + <span style="flex:1;text-align: left;padding: 5px;" *ngIf="(shortcut.id == 'indexing' && speedDialFabButtons.length<=1) || (shortcut.id != 'indexing')"> <button style="z-index: 9999;" color="default" mat-fab (click)="gotToMenu(shortcut);" matTooltip="{{shortcut.name}}" matTooltipPosition="above"> <mat-icon class="fa {{shortcut.style}}" style="height:auto;font-size:22px;"></mat-icon> </button> </span> - <span style="flex:1;text-align: left;padding: 5px;position: relative;" *ngIf="shortcut.id=='index_mlb' && shortcut.shortcut == 'true' && speedDialFabButtons.length>1"> + <span style="flex:1;text-align: left;padding: 5px;position: relative;" *ngIf="shortcut.id=='indexing' && speedDialFabButtons.length>1"> <smd-fab-speed-dial #myFab direction="down" animationMode="fling" fixed="false" (mouseenter)="myFab.open = true" (mouseleave)="myFab.open = false"> <smd-fab-trigger spin="true"> diff --git a/src/frontend/app/menu/menu-shortcut.component.ts b/src/frontend/app/menu/menu-shortcut.component.ts index 95e9aa1428fb5ee87cb8a677255e70eb7a75541f..b57be28f20db5592e11d35114d2f91430dfc4a08 100755 --- a/src/frontend/app/menu/menu-shortcut.component.ts +++ b/src/frontend/app/menu/menu-shortcut.component.ts @@ -36,13 +36,14 @@ export class MenuShortcutComponent implements OnInit { ngOnInit(): void { setTimeout(() => { - if(this.headerService.user.indexingGroups.length > 0) { - this.headerService.user.indexingGroups.forEach((group: any) => { + const index = this.headerService.shortcut.map(index => index.id).indexOf('indexing'); + if(index > -1) { + this.headerService.shortcut[index].groups.forEach((group: any) => { this.speedDialFabButtons.push({ icon: 'fa fa-plus', tooltip: this.lang.indexingWithProfile+' '+ group.label, label: group.label, - id: group.groupId + id: group.id }); }); } diff --git a/src/frontend/service/header.service.ts b/src/frontend/service/header.service.ts index 1a6015f15a8a05e415d4c740a5b0a0aab5ec61ae..c03551758f93d6a54da2d3d3049ec0a9e7d8fe50 100755 --- a/src/frontend/service/header.service.ts +++ b/src/frontend/service/header.service.ts @@ -1,6 +1,8 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { LANG } from '../app/translate.component'; +import { tap, catchError } from 'rxjs/operators'; +import { of } from 'rxjs'; @Injectable() export class HeaderService { @@ -8,29 +10,79 @@ export class HeaderService { subHeaderMessage: string = ""; user: any = { firstname: "", lastname: "" }; menu: any[] = []; + shortcut: any[] = []; + shortcutIcon: any = { + home: 'fa fa-home', + administration: 'fa fa-cogs', + search: 'fa fa-search', + indexing: 'fa fa-file-medical', + } lang: any = LANG; constructor(public http: HttpClient) { } loadHeader() { - this.http.get('../../rest/header') - .subscribe((data: any) => { - this.user = data.user; - this.user.menu = data.menu; - - data.menu.unshift({ - "name": this.lang.home, - "comment": this.lang.home, - "servicepage": "/home", - "shortcut": "true", - "style": "fa fa-home", - "angular": "true" - }); - this.menu = data.menu; - - }, (err) => { + this.http.get('../../rest/header').pipe( + tap((data: any) => this.setUser(data.user)), + tap((data: any) => this.setMenu(data.menu)), + tap((data: any) => this.setShortcut(data.shortcuts)), + catchError((err: any) => { console.log(err.error.errors); - }); + return of(false); + }) + ).subscribe(); + } + + setUser(user: any) { + this.user = user; + } + + setMenu(menu: any) { + + menu.unshift({ + "name": this.lang.home, + "comment": this.lang.home, + "servicepage": "/home", + "shortcut": "true", + "style": "fa fa-home", + "angular": "true" + }); + + this.menu = menu; + + } + + setShortcut(shortcuts: any) { + shortcuts.forEach((element: any) => { + if (['indexing', 'search'].indexOf(element.id) > -1) { + // TO DO : DELETE AFTER FULL V2 + this.setShortcutV1(element); + } else { + this.shortcut.push( + { + id: element.id, + name: this.lang[element.id], + servicepage: '/' + element.id, + style: this.shortcutIcon[element.id], + angular: element.id !== 'search' ? "true" : "false", + groups : element.groups !== undefined ? element.groups : '' + }, + ); + } + }); + } + + setShortcutV1(shortcut: any) { + this.shortcut.push( + { + id: shortcut.id, + name: this.lang[shortcut.id], + servicepage: shortcut.id !== 'search' ? "index.php?page=view_baskets&module=basket&baskets=IndexingBasket" : "index.php?page=search_adv&dir=indexing_searching", + style: this.shortcutIcon[shortcut.id], + angular: "false", + groups : shortcut.groups !== undefined ? shortcut.groups : '' + }, + ); } setHeader(maintTitle: string, subTitle: any = '') {