From 2e83920e2ff18580775c1a84a1635d17866d58fe Mon Sep 17 00:00:00 2001 From: Guillaume Heurtier <guillaume.heurtier@maarch.org> Date: Fri, 3 Jan 2020 18:13:36 +0100 Subject: [PATCH] FEAT #11406 TIME 1:00 added followed shortcut --- rest/index.php | 1 + .../controllers/UserFollowedResourceController.php | 7 +++++++ src/frontend/app/header/header-panel.component.html | 2 +- src/frontend/app/header/header-panel.component.ts | 4 ++-- .../followed-list/followed-document-list.component.ts | 6 +----- src/frontend/app/home/home.component.html | 2 +- src/frontend/app/menu/menu-shortcut.component.html | 7 ++++--- src/frontend/app/menu/menu-shortcut.component.ts | 9 +++++++-- src/frontend/service/privileges.service.ts | 10 +++++----- 9 files changed, 29 insertions(+), 19 deletions(-) diff --git a/rest/index.php b/rest/index.php index 707ea8d28db..81b5f39915c 100755 --- a/rest/index.php +++ b/rest/index.php @@ -363,6 +363,7 @@ $app->delete('/resources/unfollow', \Resource\controllers\UserFollowedResourceCo $app->get('/followedResources', \Resource\controllers\UserFollowedResourceController::class . ':getFollowedResources'); $app->get('/followedResources/{resId}/baskets', \Resource\controllers\UserFollowedResourceController::class . ':getBasketsFromFolder'); $app->get('/followedResources/filters', \Resource\controllers\UserFollowedResourceController::class . ':getFilters'); +$app->get('/followedResources/count', \Resource\controllers\UserFollowedResourceController::class . ':getNumberOfFollowedResources'); //ResourcesList $app->get('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}', \Resource\controllers\ResourceListController::class . ':get'); diff --git a/src/app/resource/controllers/UserFollowedResourceController.php b/src/app/resource/controllers/UserFollowedResourceController.php index 08fa70606dc..8bd1b454bdf 100644 --- a/src/app/resource/controllers/UserFollowedResourceController.php +++ b/src/app/resource/controllers/UserFollowedResourceController.php @@ -218,4 +218,11 @@ class UserFollowedResourceController return $response->withJson($filters); } + + public static function getNumberOfFollowedResources(Request $request, Response $response) + { + $followedResources = UserFollowedResourceModel::get(['select' => ['res_id'], 'where' => ['user_id = ?'], 'data' => [$GLOBALS['id']]]); + + return $response->withJson(['nbResourcesFollowed' => count($followedResources)]); + } } diff --git a/src/frontend/app/header/header-panel.component.html b/src/frontend/app/header/header-panel.component.html index 073106ce27e..30598b019d8 100644 --- a/src/frontend/app/header/header-panel.component.html +++ b/src/frontend/app/header/header-panel.component.html @@ -16,4 +16,4 @@ </button> </div> </div> -<mat-divider></mat-divider> \ No newline at end of file +<mat-divider></mat-divider> diff --git a/src/frontend/app/header/header-panel.component.ts b/src/frontend/app/header/header-panel.component.ts index 6b9658d6a55..992b5e4966e 100644 --- a/src/frontend/app/header/header-panel.component.ts +++ b/src/frontend/app/header/header-panel.component.ts @@ -19,7 +19,7 @@ export class HeaderPanelComponent implements OnInit { config : any = {}; - @Input('navButton') navButton: any = null; + @Input('navButton') navButton: any = {icon: 'fa fa-home', route : '/home'}; @Input('snavLeft') snavLeft: MatSidenav; constructor( @@ -33,4 +33,4 @@ export class HeaderPanelComponent implements OnInit { gotTo() { this.router.navigate([this.navButton.route]); } -} \ No newline at end of file +} diff --git a/src/frontend/app/home/followed-list/followed-document-list.component.ts b/src/frontend/app/home/followed-list/followed-document-list.component.ts index 3d9cc1ce5e0..519c3103ffa 100644 --- a/src/frontend/app/home/followed-list/followed-document-list.component.ts +++ b/src/frontend/app/home/followed-list/followed-document-list.component.ts @@ -131,15 +131,11 @@ export class FollowedDocumentListComponent implements OnInit { this.http.get('../../rest/followedResources') .subscribe((data: any) => { this.headerService.setHeader(this.lang.followedMail, '', 'fas fa-star'); - setTimeout(() => { - this.basketHome.togglePanel(false); - }, 200); - }); this.basketUrl = '../../rest/followedResources'; this.filtersListService.filterMode = false; this.selectedRes = []; - this.sidenavRight.close(); + window['MainHeaderComponent'].setSnav(this.sidenavLeft); window['MainHeaderComponent'].setSnavRight(null); diff --git a/src/frontend/app/home/home.component.html b/src/frontend/app/home/home.component.html index bab1fdcf826..3f8c1e2893f 100644 --- a/src/frontend/app/home/home.component.html +++ b/src/frontend/app/home/home.component.html @@ -133,4 +133,4 @@ </pdf-viewer> <!-- <div *ngIf="innerHtml" [innerHTML]="innerHtml" style="height: 100%;overflow: hidden;"></div> --> </mat-sidenav> -</mat-sidenav-container> \ No newline at end of file +</mat-sidenav-container> diff --git a/src/frontend/app/menu/menu-shortcut.component.html b/src/frontend/app/menu/menu-shortcut.component.html index cd28add8014..fbea56d2b81 100755 --- a/src/frontend/app/menu/menu-shortcut.component.html +++ b/src/frontend/app/menu/menu-shortcut.component.html @@ -1,13 +1,14 @@ <mat-nav-list style="position:relative;"> </mat-nav-list> <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 shortcuts"> <span style="flex:1;text-align: left;padding: 5px;" *ngIf="(shortcut.id == 'indexing' && shortcut.groups.length<=1) || (shortcut.id != 'indexing')"> <button style="z-index: 9999;" color="default" mat-fab (click)="gotToMenu(shortcut);" matTooltip="{{shortcut.label}}" matTooltipPosition="above"> - <mat-icon class="fa {{shortcut.style}}" style="height:auto;font-size:22px;"></mat-icon> + <mat-icon class="fa {{shortcut.style}}" style="height:auto;font-size:22px;" + matBadge="{{this.nbResourcesFollowed}}" matBadgeHidden="{{shortcut.id != 'followed'}}" + ></mat-icon> </button> </span> <span style="flex:1;text-align: left;padding: 5px;position: relative;" *ngIf="shortcut.id=='indexing' && shortcut.groups.length>1"> @@ -30,4 +31,4 @@ </ng-container> </div> </mat-nav-list> -<mat-divider></mat-divider> \ No newline at end of file +<mat-divider></mat-divider> diff --git a/src/frontend/app/menu/menu-shortcut.component.ts b/src/frontend/app/menu/menu-shortcut.component.ts index 17ed0d6a4c0..36c5a301f45 100755 --- a/src/frontend/app/menu/menu-shortcut.component.ts +++ b/src/frontend/app/menu/menu-shortcut.component.ts @@ -22,7 +22,7 @@ export class MenuShortcutComponent implements OnInit { speedDialFabButtons: any = []; speedDialFabColumnDirection = 'column'; shortcuts: any; - + nbResourcesFollowed: any; constructor( public http: HttpClient, @@ -41,6 +41,11 @@ export class MenuShortcutComponent implements OnInit { loadShortcuts() { this.shortcuts = this.privilegeService.getCurrentUserShortcuts(); + + this.http.get("../../rest/followedResources/count") + .subscribe((data: any) => { + this.nbResourcesFollowed = data.nbResourcesFollowed; + }); } onSpeedDialFabClicked(group: any, shortcut: any) { @@ -76,4 +81,4 @@ export class IndexingGroupModalComponent { this.router.navigate(['/indexing/' + group.id]); this.dialogRef.close(); } -} \ No newline at end of file +} diff --git a/src/frontend/service/privileges.service.ts b/src/frontend/service/privileges.service.ts index 941a177b3cd..68b7ca039f5 100644 --- a/src/frontend/service/privileges.service.ts +++ b/src/frontend/service/privileges.service.ts @@ -588,11 +588,11 @@ export class PrivilegeService { getCurrentUserShortcuts(): Array<menu> { let shortcuts: any[] = [ { - "id": "home", - "label": this.lang.home, - "comment": this.lang.home, - "route": "/home", - "style": "fa fa-home", + "id": "followed", + "label": this.lang.followedMail, + "comment": this.lang.followedMail, + "route": "/followed", + "style": "fas fa-star", "unit": "application", "angular": true, "shortcut" : true -- GitLab