Commit f2cec643 authored by Arko Dey Bhowmick's avatar Arko Dey Bhowmick

feat: handle auth based ellement show hide

parent ead309b5
......@@ -49,8 +49,12 @@ export class AuthService {
const localStorageItem = JSON.parse(localStorage.getItem('userProfile')!);
return localStorageItem[key];
return localStorageItem[key] || '';
}
public getUserRole(): string {
return this.localStorageGetItemByKey('role');
}
}
......@@ -16,7 +16,7 @@
</button>
</ng-container>
<ng-container *ngIf="item =='edit'">
<ng-container *ngIf="item =='edit' && authService.getUserRole() !== 'student'">
<button class="view_button d_inline_block width_auto " (click)="edit(element)">
<span class="material-symbols-outlined">edit</span>
</button>
......
import { CommonModule } from '@angular/common';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, EventEmitter, inject, Input, Output } from '@angular/core';
import { MatTableModule } from '@angular/material/table';
import { MatPaginator } from '@angular/material/paginator';
import { AuthService } from '../../auth/service/auth.service';
@Component({
selector: 'app-custom-table',
......@@ -28,6 +29,8 @@ export class CustomTableComponent {
@Output() emitEdit: EventEmitter<string> = new EventEmitter<string>();
public authService = inject(AuthService);
// totalRecords: number = 3400;
// pageSize: number = 50;
......
......@@ -7,7 +7,7 @@
/>
</div>
<div class="add_btn">
<div class="add_btn" *ngIf="authService.getUserRole() !== 'student'">
<app-square-button
[buttonIcon]="'add'"
(emitSquareButtonClick)="addAssignment()"
......
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { CustomTableComponent } from '../../../component-library/custom-table/custom-table.component';
import { MatDialog } from '@angular/material/dialog';
import { ManageComponent } from '../manage/manage.component';
......@@ -10,23 +10,27 @@ import { UrlConfigService } from '../../service/url-config.service';
import { Assignment } from '../interface/assignment';
import { PrepareAssignmentTableDataService } from '../service/prepare-assignment-table-data.service';
import { DataSourceService } from '../../service/data-source.service';
import { AuthService } from '../../../auth/service/auth.service';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-assignment',
imports: [
CustomTableComponent,
CommonModule,
SquareButtonComponent
],
templateUrl: './assignment.component.html',
styleUrl: './assignment.component.scss'
})
export class AssignmentComponent {
export class AssignmentComponent implements OnInit {
constructor(
private _dialog: MatDialog,
private _assignmentTransmission: AssignmentTransmissionService,
private _urlConfig: UrlConfigService,
private _prepareAssignmentTableData: PrepareAssignmentTableDataService
private _prepareAssignmentTableData: PrepareAssignmentTableDataService,
public authService: AuthService
) { }
public columns = [
......@@ -38,7 +42,7 @@ export class AssignmentComponent {
public data: any[] = [];
ngOnInit(): void {
public ngOnInit(): void {
this.columns = this._prepareAssignmentTableData.prepareMatTableColumn();
this._getAssignments();
......@@ -74,7 +78,7 @@ export class AssignmentComponent {
)
}
public emitViewFromTable(clickedData: string) {
public emitViewFromTable(clickedData: string): void {
alert("Have to view the doc in another page");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment