Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 160 project navigation #83

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 7 additions & 29 deletions corn-frontend/src/app/pages/boards/boards.component.html
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
<mat-toolbar color="primary">
<div class="flex space-x-4 items-center">
<button mat-icon-button (click)="toggleSidebar()">
<mat-icon>{{sidebarShown ? 'menu_open' : 'menu'}}</mat-icon>
</button>

<button mat-button [matMenuTriggerFor]="menu" #t="matMenuTrigger">
Your Projects
<mat-icon iconPositionEnd>{{t.menuOpen ? 'expand_less' : 'expand_more'}}</mat-icon>
</button>

<mat-menu #menu="matMenu">
<button mat-menu-item>Some Project</button>
<button mat-menu-item>Another Project</button>
</mat-menu>
</div>

<span class="flex-auto"></span>

@if (isLoggedIn && userProfile) {
<userinfo [username]="userProfile!.username || ''" [fullName]="userProfile!.firstName + ' ' + userProfile!.lastName"
(logout)="logout()">
</userinfo>
}
</mat-toolbar>

<mat-drawer-container style="min-height: calc(100vh - 64px);">
<app-toolbar (sidebarEvent)="sidebarShown = $event">
</app-toolbar>

<mat-drawer-container>
<mat-drawer [opened]="sidebarShown" mode="side">
<div class="p-[6px] w-[224px] flex flex-col gap-[4px]">

Expand All @@ -39,7 +16,7 @@
[label]="'Backlog'" [selected]="selected == 'backlog'"></sidebar-button>

<sidebar-button (click)="navigateToBoard()" [selected]="selected == 'board'"
[iconName]="'akarClipboard'" [label]="'Board'"></sidebar-button>
[iconName]="'akarClipboard'" [label]="'Board'"></sidebar-button>

<sidebar-button (click)="{}" [iconName]="'octGraph'" [label]="'Reports'"
[selected]="selected == 'reports'"></sidebar-button>
Expand All @@ -52,8 +29,9 @@

</div>
</mat-drawer>

<mat-drawer-content>
<div class="pl-[24px] pt-[24px]">
<div class="overflow-hidden min-h-screen">
<router-outlet></router-outlet>
</div>
</mat-drawer-content>
Expand Down
26 changes: 4 additions & 22 deletions corn-frontend/src/app/pages/boards/boards.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { KeycloakProfile } from 'keycloak-js';
import { MatMenuModule, MatMenuTrigger } from '@angular/material/menu';
import { RouterPaths } from '@core/enum/RouterPaths';
import { BoardsPaths } from '@core/enum/BoardsPaths';
import { ToolbarComponent } from "@shared/toolbar/toolbar.component";

@Component({
selector: 'app-boards',
Expand All @@ -37,6 +38,7 @@ import { BoardsPaths } from '@core/enum/BoardsPaths';
MatMenuTrigger,
MatMenuModule,
CommonModule,
ToolbarComponent,
],
templateUrl: './boards.component.html',
})
Expand All @@ -47,30 +49,20 @@ export class BoardsComponent implements OnInit {

selected: string = '';

isLoggedIn: boolean = false;
userProfile?: KeycloakProfile;

constructor(
protected readonly router: Router,
protected readonly location: Location,
protected readonly keycloak: KeycloakService,
protected readonly location: Location
) {
}

async ngOnInit() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typ

this.selected = this.location.path().split('/').pop() || '';

this.router.events.subscribe((val) => {
if (val instanceof NavigationEnd) {
this.selected = val.url.split('/').pop() || '';
}
});
this.isLoggedIn = this.keycloak.isLoggedIn();

if (this.isLoggedIn) {
this.userProfile = await this.keycloak.loadUserProfile();
} else {
this.router.navigate([RouterPaths.HOME_DIRECT_PATH]);
}
}

navigateToBacklog(): void {
Expand All @@ -84,14 +76,4 @@ export class BoardsComponent implements OnInit {
navigateToBoard(): void {
this.router.navigate([`/${RouterPaths.BOARDS_PATH}/${BoardsPaths.BOARD}`]);
}

toggleSidebar(): void {
this.sidebarShown = !this.sidebarShown;
}

logout(): void {
this.keycloak
.logout();
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<app-toolbar [isOnProjectRoute]="true"></app-toolbar>

<div class="project-list">
<mat-grid-list [cols]="cols">
<mat-grid-tile><app-project [title]="'DevCooperation'"
Expand All @@ -15,4 +17,4 @@
<mat-grid-tile><app-project></app-project></mat-grid-tile>
<mat-grid-tile><app-project></app-project></mat-grid-tile>
</mat-grid-list>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import { Component, HostListener } from '@angular/core';
import { ProjectComponent } from "@pages/project-list/project/project.component";
import { MatGridList, MatGridTile } from "@angular/material/grid-list";
import { User } from "@core/interfaces/boards/user";
import { ToolbarComponent } from "@shared/toolbar/toolbar.component";

@Component({
selector: 'app-project-list',
standalone: true,
imports: [
ProjectComponent,
MatGridList,
MatGridTile
MatGridTile,
ToolbarComponent
],
templateUrl: './project-list.component.html',
styleUrl: './project-list.component.scss'
Expand Down
28 changes: 28 additions & 0 deletions corn-frontend/src/app/shared/toolbar/toolbar.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<mat-toolbar color="primary">
@if (!isOnProjectRoute) {
<div class="flex space-x-4 items-center">
<button mat-icon-button (click)="toggleSidebar()">
<mat-icon>{{ sidebarShown ? 'menu_open' : 'menu' }}</mat-icon>
</button>

<button mat-button [matMenuTriggerFor]="menu" #t="matMenuTrigger">
Your Projects
<mat-icon iconPositionEnd>{{ t.menuOpen ? 'expand_less' : 'expand_more' }}</mat-icon>
</button>

<mat-menu #menu="matMenu">
<button mat-menu-item>Some Project</button>
<button mat-menu-item>Another Project</button>
</mat-menu>
</div>
}

<span class="flex-auto"></span>

@if (isLoggedIn && userProfile) {
<userinfo [username]="userProfile!.username || ''"
[fullName]="userProfile!.firstName + ' ' + userProfile!.lastName"
(logout)="logout()">
</userinfo>
}
</mat-toolbar>
Empty file.
23 changes: 23 additions & 0 deletions corn-frontend/src/app/shared/toolbar/toolbar.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ToolbarComponent } from './toolbar.component';

describe('ToolbarComponent', () => {
let component: ToolbarComponent;
let fixture: ComponentFixture<ToolbarComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ToolbarComponent]
})
.compileComponents();

fixture = TestBed.createComponent(ToolbarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
59 changes: 59 additions & 0 deletions corn-frontend/src/app/shared/toolbar/toolbar.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { MatButton, MatIconButton } from "@angular/material/button";
import { MatIcon } from "@angular/material/icon";
import { MatMenu, MatMenuItem, MatMenuTrigger } from "@angular/material/menu";
import { MatToolbar } from "@angular/material/toolbar";
import { KeycloakProfile } from "keycloak-js";
import { UserinfoComponent } from "@pages/boards/userinfo/userinfo.component";
import { KeycloakService } from "keycloak-angular";
import { Router } from "@angular/router";
import { RouterPaths } from "@core/enum/RouterPaths";

@Component({
selector: 'app-toolbar',
standalone: true,
imports: [
MatButton,
MatIcon,
MatIconButton,
MatMenu,
MatMenuItem,
MatToolbar,
UserinfoComponent,
MatMenuTrigger
],
templateUrl: './toolbar.component.html',
styleUrl: './toolbar.component.scss'
})
export class ToolbarComponent implements OnInit {
@Input() isOnProjectRoute: boolean = false;
userProfile ?: KeycloakProfile;
isLoggedIn: boolean = false;
@Output() sidebarEvent: EventEmitter<boolean> = new EventEmitter<boolean>();
sidebarShown: boolean = true;

constructor(private keycloak: KeycloakService,
private router: Router) {
}

async ngOnInit(): Promise<void> {
this.isLoggedIn = this.keycloak.isLoggedIn();

if (this.isLoggedIn) {
this.userProfile = await this.keycloak.loadUserProfile();
console.log(this.userProfile);
} else {
this.router.navigate([RouterPaths.HOME_DIRECT_PATH]);
}
}

toggleSidebar(): void {
this.sidebarShown = !this.sidebarShown;

this.sidebarEvent.emit(this.sidebarShown);
}

logout(): void {
this.keycloak.logout();
}
}
Loading