From 5a9bf2a09ff0a6ca1bbc9603dde713343193f6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szrnka?= Date: Wed, 6 Dec 2023 08:25:08 +0100 Subject: [PATCH 1/2] GMS-65 Frontend bugfixes --- .../src/app/components/home/home.component.html | 14 +++++++------- .../src/app/components/home/home.component.scss | 2 +- .../src/app/components/home/home.component.spec.ts | 2 +- .../src/app/components/home/home.component.ts | 9 +++++---- .../app/components/home/model/home-data.model.ts | 4 ++-- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/code/gms-frontend/src/app/components/home/home.component.html b/code/gms-frontend/src/app/components/home/home.component.html index 79e99741..c928635d 100644 --- a/code/gms-frontend/src/app/components/home/home.component.html +++ b/code/gms-frontend/src/app/components/home/home.component.html @@ -1,10 +1,10 @@ -
-
+
+
-
+
Please add an API key!
-
+
Please add a keystore!
@@ -47,17 +47,17 @@
-
+
User management Manage your users -
+
Warning: No user registered yet!
-

+

Number of users: {{data.userCount}}

diff --git a/code/gms-frontend/src/app/components/home/home.component.scss b/code/gms-frontend/src/app/components/home/home.component.scss index 68fad0df..d096d1db 100644 --- a/code/gms-frontend/src/app/components/home/home.component.scss +++ b/code/gms-frontend/src/app/components/home/home.component.scss @@ -69,7 +69,7 @@ tr th { @media screen and (min-width: 1200px) { .gms-sub-box { - display: inline-table; + display: inline-block; width: 50%; } diff --git a/code/gms-frontend/src/app/components/home/home.component.spec.ts b/code/gms-frontend/src/app/components/home/home.component.spec.ts index a8bbf48d..d6872c42 100644 --- a/code/gms-frontend/src/app/components/home/home.component.spec.ts +++ b/code/gms-frontend/src/app/components/home/home.component.spec.ts @@ -70,7 +70,7 @@ describe('HomeComponent', () => { totalElements: 0 }, userCount: 1, - admin: true, + role: 'ROLE_ADMIN', apiKeyCount: 0, keystoreCount: 0, announcementCount: 0, diff --git a/code/gms-frontend/src/app/components/home/home.component.ts b/code/gms-frontend/src/app/components/home/home.component.ts index 92cddc8e..099b3813 100644 --- a/code/gms-frontend/src/app/components/home/home.component.ts +++ b/code/gms-frontend/src/app/components/home/home.component.ts @@ -2,7 +2,6 @@ import { ArrayDataSource } from "@angular/cdk/collections"; import { Component, OnInit } from "@angular/core"; import { Router } from "@angular/router"; import { SharedDataService } from "../../common/service/shared-data-service"; -import { isSpecificUser } from "../../common/utils/permission-utils"; import { Event } from "../event/model/event.model"; import { User } from "../user/model/user.model"; import { EMPTY_HOME_DATA, HomeData } from "./model/home-data.model"; @@ -22,7 +21,7 @@ export class HomeComponent implements OnInit { eventColumns: string[] = ['id', 'userId', 'eventDate', 'operation', 'target']; eventDataSource: ArrayDataSource; data: HomeData; - loading = true; + loading: string = ''; constructor( public router: Router, @@ -31,6 +30,7 @@ export class HomeComponent implements OnInit { ) {} ngOnInit(): void { + this.loading = 'LOADING'; this.sharedData.userSubject$ .pipe(mergeMap((user: User | undefined): Observable => this.processUser(user))) .subscribe((homeData: HomeData) => { @@ -39,7 +39,7 @@ export class HomeComponent implements OnInit { ...homeData }; this.eventDataSource = new ArrayDataSource(this.data.events.resultList); - this.loading = false; + this.loading = 'LOADED'; }); } @@ -50,7 +50,8 @@ export class HomeComponent implements OnInit { return this.homeService.getData().pipe(map((response): HomeData => { const data: HomeData = response; - data.admin = isSpecificUser(user.roles, 'ROLE_ADMIN'); + // TODO Refactor the app to allow only 1 type of role + data.role = user.roles?.[0]; return data; })); } diff --git a/code/gms-frontend/src/app/components/home/model/home-data.model.ts b/code/gms-frontend/src/app/components/home/model/home-data.model.ts index e1beee14..790fb52a 100644 --- a/code/gms-frontend/src/app/components/home/model/home-data.model.ts +++ b/code/gms-frontend/src/app/components/home/model/home-data.model.ts @@ -12,7 +12,7 @@ export interface HomeData { userCount : number, announcements : AnnouncementList, events : EventList, - admin? : boolean + role? : string } export const EMPTY_HOME_DATA: HomeData = { @@ -25,7 +25,7 @@ export const EMPTY_HOME_DATA: HomeData = { totalElements: 0 }, userCount: 0, - admin: false, + role: undefined, apiKeyCount: 0, keystoreCount: 0, announcementCount: 0, From c90191f1b0108f3350da21fd9557c760474134f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szrnka?= Date: Wed, 6 Dec 2023 08:38:03 +0100 Subject: [PATCH 2/2] GMS-65 Fix of component --- code/gms-frontend/src/app/components/home/home.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/gms-frontend/src/app/components/home/home.component.ts b/code/gms-frontend/src/app/components/home/home.component.ts index 099b3813..aed20f3a 100644 --- a/code/gms-frontend/src/app/components/home/home.component.ts +++ b/code/gms-frontend/src/app/components/home/home.component.ts @@ -51,7 +51,7 @@ export class HomeComponent implements OnInit { return this.homeService.getData().pipe(map((response): HomeData => { const data: HomeData = response; // TODO Refactor the app to allow only 1 type of role - data.role = user.roles?.[0]; + data.role = user.roles[0]; return data; })); }