diff options
| author | benal01 <bja4245@rit.edu> | 2025-03-17 18:42:40 -0400 | 
|---|---|---|
| committer | benal01 <bja4245@rit.edu> | 2025-03-17 18:42:40 -0400 | 
| commit | 0287d0ebd22b88c2d41f2bdb67db812c35d9024c (patch) | |
| tree | 715d6a2da27311defed76c8bd2ed4639c584dbf3 | |
| parent | 7057f8ad5e0aaf6527477a68c229db659cd674ff (diff) | |
| download | JellySolutions-0287d0ebd22b88c2d41f2bdb67db812c35d9024c.tar.gz JellySolutions-0287d0ebd22b88c2d41f2bdb67db812c35d9024c.tar.bz2 JellySolutions-0287d0ebd22b88c2d41f2bdb67db812c35d9024c.zip | |
hide admin only management elements if user is not an admin
4 files changed, 19 insertions, 7 deletions
| diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index 23aaec7..65545e8 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -1,5 +1,6 @@  <h1> Cupboard </h1> -<div id="menu"> +<h2 *ngIf="isManager()" > Admin View </h2> +<div id="menu" *ngIf="isManager()">      <button (click)="opencreate()">Create new Need</button>      <button (click)="openupdate()">Update existing Need</button>  </div> diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts index b5726cf..5a8773d 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts @@ -1,7 +1,8 @@  import { Component, OnInit, ViewChild } from '@angular/core';  import { CupboardService } from '../../services/cupboard.service'; +import { UsersService } from '../../services/users.service';  import { Need, GoalType } from '../../models/Need'; -import { Form } from '@angular/forms'; +import { userType } from '../../models/User';   @Component({    selector: 'app-cupboard', @@ -12,7 +13,7 @@ import { Form } from '@angular/forms';  export class CupboardComponent implements OnInit {  needs: any; -    constructor(private cupboardService: CupboardService) { } +    constructor(private cupboardService: CupboardService, private usersService: UsersService) { }      ngOnInit(): void {        this.cupboardService.getNeeds().subscribe(n => this.needs = n); @@ -73,6 +74,10 @@ needs: any;        this.selectedNeed = { ...need };      } +    isManager() { +      return this.usersService.getCurrentUser()?.type == userType.MANAGER; +    } +      update(form: any) {        console.log(form);        const need: Need = { diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index 6dd6511..07f6735 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -13,7 +13,7 @@              <a routerLink="/need/{{need.id}}">                  {{need.name}}              </a> -            <button (click)="delete(need.id)">Delete</button> +            <button (click)="delete(need.id)" *ngIf="isManager()">Delete</button>          </div>      </div>  </div> @@ -22,5 +22,5 @@      <a routerLink="/need/{{need.id}}">          {{need.name}}      </a> -    <button (click)="delete(need.id)">Delete</button> +    <button (click)="delete(need.id)" *ngIf="isManager()">Delete</button>  </li> diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 8451d5b..6ad9397 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -1,7 +1,8 @@  import { Component } from '@angular/core';  import {Need} from '../../models/Need';  import {CupboardService} from '../../services/cupboard.service'; - +import { UsersService } from '../../services/users.service'; +import { userType } from '../../models/User';   @Component({    selector: 'app-need-list',    standalone: false, @@ -13,7 +14,8 @@ export class NeedListComponent {    searchResults: Need[] = [];    constructor( -    private cupboardService: CupboardService +    private cupboardService: CupboardService, +    private usersService: UsersService    ) {}    ngOnInit(): void { @@ -85,6 +87,10 @@ export class NeedListComponent {      })    } +  isManager() { +    return this.usersService.getCurrentUser()?.type == userType.MANAGER; +  } +    back() {      this.searchResults = [];    } | 
