Skip to content

Commit 8d2e693

Browse files
Merge pull request #203 from OS2iot/bugfix/administration-navbar
Changed name and check for who should be able to see administration
2 parents ca8fdd0 + d2f6210 commit 8d2e693

File tree

5 files changed

+34
-16
lines changed

5 files changed

+34
-16
lines changed

src/app/navbar/global-admin/global-admin.component.html renamed to src/app/navbar/administration/administration.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
@if(isGlobalAdmin){
1+
@if(isGlobalAdmin || isUserAdmin){
2+
3+
<div class="nav-bar-title">{{ "NAV.TITLES.ADMINISTRATION" | translate }}</div>
24

35
<ul class="navbar-nav flex-column">
46
<li class="nav-item">
@@ -11,7 +13,7 @@
1113
{{ "NAV.PERMISSIONS" | translate }}
1214
</a>
1315
</li>
14-
<li class="nav-item">
16+
<li class="nav-item" *ngIf="isGlobalAdmin">
1517
<a routerLink="/admin/organisations" routerLinkActive="active">
1618
{{ "NAV.ORGANISATIONS" | translate }}
1719
</a>

src/app/navbar/global-admin/global-admin.component.scss renamed to src/app/navbar/administration/administration.component.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
@import "../../../assets/scss/setup/variables";
22

3+
.nav-bar-title {
4+
color: $default-color;
5+
font-size: 14px;
6+
font-weight: 400;
7+
font-family: "Inter", sans-serif;
8+
margin-top: 40px;
9+
margin-left: 5px;
10+
margin-bottom: 10px;
11+
}
12+
313
mat-expansion-panel {
414
box-shadow: none !important;
515
}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
import { Component, OnInit } from "@angular/core";
1+
import { Component, Input, OnInit } from "@angular/core";
22
import { UserResponse } from "@app/admin/users/user.model";
3+
import { OrganizationAccessScope } from "@shared/enums/access-scopes";
34
import { MeService } from "@shared/services/me.service";
45
import { SharedVariableService } from "@shared/shared-variable/shared-variable.service";
56

67
@Component({
7-
selector: "app-global-admin",
8-
templateUrl: "./global-admin.component.html",
9-
styleUrls: ["./global-admin.component.scss"],
8+
selector: "app-administration",
9+
templateUrl: "./administration.component.html",
10+
styleUrls: ["./administration.component.scss"],
1011
})
11-
export class GlobalAdminComponent implements OnInit {
12+
export class AdministrationComponent implements OnInit {
1213
public user: UserResponse;
1314
public isGlobalAdmin = false;
1415

16+
public isUserAdmin = false;
17+
@Input() orgId: number;
18+
1519
constructor(private sharedVariableService: SharedVariableService, private meService: MeService) {}
1620

1721
ngOnInit(): void {
1822
this.user = this.sharedVariableService.getUserInfo().user;
1923
this.isGlobalAdmin = this.meService.hasGlobalAdmin();
24+
this.isUserAdmin = this.meService.hasAccessToTargetOrganization(
25+
OrganizationAccessScope.UserAdministrationWrite,
26+
this.orgId
27+
);
2028
}
2129
}

src/app/navbar/navbar.component.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
aria-expanded="false"
44
class="navbar-container navbar navbar-expand-md navbar-light d-md-flex align-items-md-start flex-md-column p-3 no-shadow"
55
>
6-
<img [src]="imagePath" alt="OS2IoT-logo" class="img-logo"/>
6+
<img [src]="imagePath" alt="OS2IoT-logo" class="img-logo" />
77

88
<div *ngIf="!isLoggedIn(); else loggedInBlock" class="collapse navbar-collapse flex-grow-0" id="navbar-login">
99
<ul class="navbar-nav flex-column">
@@ -43,7 +43,7 @@
4343
<mat-select-trigger>
4444
<div class="nav-bar-selector-trigger">
4545
<div class="nav-bar-selector-building-icon">
46-
<img height="20" src="assets/images/building.svg" width="20"/>
46+
<img height="20" src="assets/images/building.svg" width="20" />
4747
</div>
4848
{{ getOrgName(selected) }}
4949
</div>
@@ -54,8 +54,8 @@
5454
</mat-select>
5555

5656
<div class="custom-dropdown-icon" matSuffix>
57-
<img class="dropdown-up" height="7" src="assets/images/angle-up.svg" width="11"/>
58-
<img class="dropdown-down" height="7" src="assets/images/angle-down.svg" width="11"/>
57+
<img class="dropdown-up" height="7" src="assets/images/angle-up.svg" width="11" />
58+
<img class="dropdown-down" height="7" src="assets/images/angle-down.svg" width="11" />
5959
</div>
6060
</mat-form-field>
6161

@@ -118,10 +118,8 @@
118118
</ul>
119119
</li>
120120

121-
<div class="nav-bar-title">{{ "NAV.TITLES.ADMINISTRATION" | translate }}</div>
122-
123121
<li class="nav-item">
124-
<app-global-admin></app-global-admin>
122+
<app-administration [orgId]="selected"></app-administration>
125123
</li>
126124
</div>
127125
</ul>

src/app/navbar/navbar.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import { TranslateModule } from "@ngx-translate/core";
1515
import { NGMaterialModule } from "@shared/Modules/materiale.module";
1616
import { InlineSVGModule } from "ng-inline-svg-2";
1717
import { RestService } from "../shared/services/rest.service";
18-
import { GlobalAdminComponent } from "./global-admin/global-admin.component";
18+
import { AdministrationComponent } from "./administration/administration.component";
1919

2020
@NgModule({
21-
declarations: [NavbarComponent, GlobalAdminComponent],
21+
declarations: [NavbarComponent, AdministrationComponent],
2222
imports: [
2323
CommonModule,
2424
SharedModule,

0 commit comments

Comments
 (0)