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

Refactor navigation sidebar #247

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { MatSortModule } from '@angular/material/sort';
import { MatTableModule } from '@angular/material/table';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatTabsModule } from '@angular/material/tabs';
import { MatExpansionModule } from '@angular/material/expansion';
import { environment } from '../environments/environment';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
Expand Down Expand Up @@ -158,6 +159,7 @@ import { LibraryTableComponent } from './components/libraries/library-table/libr
MatTableModule,
MatCheckboxModule,
MatTabsModule,
MatExpansionModule,
],
bootstrap: [AppComponent],
providers: [
Expand Down
129 changes: 61 additions & 68 deletions src/app/components/navigation/navigation.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,92 +7,85 @@
<img (click)="goToHome()" src="../assets/logo.png" class="logo-img">
<span (click)="goToHome()">QC Atlas</span>
</mat-toolbar>
<mat-nav-list>
<a mat-list-item
(click)="executionEnvironmentCollapseContent.hide(); minorComponentsCollapse.hide(); literatureComponentsCollapse.hide()"
[routerLink]="'./algorithms'" routerLinkActive="routerLinkActive">
<nav>
<a class="nav-link" [routerLink]="'./algorithms'" routerLinkActive="active">
Algorithms
</a>
<a mat-list-item
(click)="executionEnvironmentCollapseContent.hide(); minorComponentsCollapse.hide(); literatureComponentsCollapse.hide()"
[routerLink]="'./qai-apps'" routerLinkActive="routerLinkActive">
<a class="nav-link" [routerLink]="'./qai-apps'" routerLinkActive="active">
qAI Apps
</a>
<a mat-list-item
(click)="executionEnvironmentCollapseContent.hide(); minorComponentsCollapse.hide(); literatureComponentsCollapse.hide()"
[routerLink]="'./publications'" routerLinkActive="routerLinkActive">
<a class="nav-link" [routerLink]="'./publications'" routerLinkActive="active">
Publications
</a>
<a mat-list-item
(click)="executionEnvironmentCollapseContent.hide(); minorComponentsCollapse.hide(); literatureComponentsCollapse.show()"
[routerLink]="'./libraries'" routerLinkActive="routerLinkActive">
Libraries
<mat-icon
class="collapse-arrow-icon">{{ literatureComponentsCollapse.isCollapsed ? 'keyboard_arrow_down' : 'keyboard_arrow_up' }}</mat-icon>
</a>
<div mat-list-item mdbCollapse #literatureComponentsCollapse="bs-collapse">
<a class="sub-tab" mat-list-item [routerLink]="'./slr'"
routerLinkActive="routerLinkActive">
<span class="pl-3">Systematic Literature Review</span>
<mat-expansion-panel class="flat-panel" [expanded]="activeGroup === 'libraries'">
<mat-expansion-panel-header>
<mat-panel-title class="nav-panel-header">
Libraries
</mat-panel-title>
</mat-expansion-panel-header>
<a class="nav-link" [routerLink]="'./libraries'" routerLinkActive="active">
Libraries
</a>
</div>
<a (click)="executionEnvironmentCollapseContent.show(); minorComponentsCollapse.hide(); literatureComponentsCollapse.hide()"
mat-list-item
[routerLink]="'./execution-environments/search'"
routerLinkActive="routerLinkActive">
Execution Environments
<mat-icon
class="collapse-arrow-icon">{{ executionEnvironmentCollapseContent.isCollapsed ? 'keyboard_arrow_down' : 'keyboard_arrow_up' }}</mat-icon>
</a>
<div mat-list-item mdbCollapse #executionEnvironmentCollapseContent="bs-collapse">
<a class="sub-tab" mat-list-item [routerLink]="'./execution-environments/software-platforms'"
routerLinkActive="routerLinkActive">
<span class="pl-3">Software Platforms</span>
<a class="nav-link" [routerLink]="'./slr'" routerLinkActive="active">
Systematic Literature Review
</a>
<a class="sub-tab" mat-list-item [routerLink]="'./execution-environments/cloud-services'"
routerLinkActive="routerLinkActive">
<span class="pl-3">Cloud Services</span>
</mat-expansion-panel>
<mat-expansion-panel class="flat-panel" [expanded]="activeGroup === 'execution'">
<mat-expansion-panel-header>
<mat-panel-title class="nav-panel-header">
Execution Environments
</mat-panel-title>
</mat-expansion-panel-header>
<a class="nav-link" [routerLink]="'./execution-environments/search'" routerLinkActive="active">
Search
</a>
<a class="sub-tab" mat-list-item [routerLink]="'./execution-environments/compute-resources'"
routerLinkActive="routerLinkActive">
<span class="pl-3">Compute Resources</span>
<a class="nav-link" [routerLink]="'./execution-environments/software-platforms'"
routerLinkActive="active">
Software Platforms
</a>
</div>
<a mat-list-item
(click)="minorComponentsCollapse.show(); executionEnvironmentCollapseContent.hide(); literatureComponentsCollapse.hide()">
Manage Components
<mat-icon
class="collapse-arrow-icon">{{ minorComponentsCollapse.isCollapsed ? 'keyboard_arrow_down' : 'keyboard_arrow_up' }}</mat-icon>
</a>
<div mat-list-item mdbCollapse #minorComponentsCollapse="bs-collapse">
<a class="sub-tab" mat-list-item [routerLink]="'./problem-types'"
routerLinkActive="routerLinkActive">
<span class="pl-3">Problem Types</span>
<a class="nav-link" [routerLink]="'./execution-environments/cloud-services'"
routerLinkActive="active">
Cloud Services
</a>
<a class="nav-link" [routerLink]="'./execution-environments/compute-resources'"
routerLinkActive="active">
Compute Resources
</a>
</mat-expansion-panel>
<mat-expansion-panel class="flat-panel" [expanded]="activeGroup === 'components'">
<mat-expansion-panel-header>
<mat-panel-title class="nav-panel-header">
Manage Components
</mat-panel-title>
</mat-expansion-panel-header>
<a class="nav-link" [routerLink]="'./problem-types'" routerLinkActive="active">
Problem Types
</a>
<a class="sub-tab" mat-list-item [routerLink]="'./application-areas'"
routerLinkActive="routerLinkActive">
<span class="pl-3">Application Areas</span>
<a class="nav-link" [routerLink]="'./application-areas'" routerLinkActive="active">
Application Areas
</a>
<a class="sub-tab" mat-list-item [routerLink]="'./algorithm-relation-types'"
routerLinkActive="routerLinkActive">
<span class="pl-3">Algorithm Relation Types</span>
<a class="nav-link" [routerLink]="'./algorithm-relation-types'"
routerLinkActive="active">
Algorithm Relation Types
</a>
<a *ngIf="configData.configuration.features.patternAtlas" class="sub-tab" mat-list-item [routerLink]="'./pattern-relation-types'"
routerLinkActive="routerLinkActive">
<span class="pl-3" *ngIf="configData.configuration.features.patternAtlas">Pattern Relation Types</span>
<a *ngIf="configData.configuration.features.patternAtlas"
class="nav-link" [routerLink]="'./pattern-relation-types'"
routerLinkActive="active">
Pattern Relation Types
</a>
<a class="sub-tab" mat-list-item [routerLink]="'./compute-resource-property-types'"
routerLinkActive="routerLinkActive">
<span class="pl-3">Compute Resource Property Types</span>
<a class="nav-link" [routerLink]="'./compute-resource-property-types'"
routerLinkActive="active">
Compute Resource Property Types
</a>
</div>
</mat-expansion-panel>

<!-- TODO add external links in navigation -->

<a *ngIf="configData.configuration.features.showSettings"
mat-list-item
(click)="executionEnvironmentCollapseContent.hide(); minorComponentsCollapse.hide(); literatureComponentsCollapse.hide()"
[routerLink]="'./feature-toggling'" routerLinkActive="routerLinkActive">
class="nav-link" [routerLink]="'./feature-toggling'" routerLinkActive="active">
Settings
</a>
</mat-nav-list>
</nav>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar color="primary">
Expand Down
48 changes: 36 additions & 12 deletions src/app/components/navigation/navigation.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,53 @@
top: 0;
z-index: 1000;
}
.mat-nav-list a.routerLinkActive {
background: rgba(mat-color($qc-atlas-ui-primary), 0.20);

nav {
padding-block: 0.5rem;
overflow-y: auto;
max-height: calc(100% - 64px);
}
.mat-nav-list:hover a.routerLinkActive {
background: rgba(mat-color($qc-atlas-ui-primary), 0.20);

.nav-link {
min-height: 2rem;
color: initial;
font-size: 16px;
font-weight: 300;
}
.mat-nav-list a.routerLinkActive:focus {

.nav-link:focus, .nav-link:active, .nav-link.active {
background: rgba(mat-color($qc-atlas-ui-primary), 0.20);
}
.mat-nav-list:hover a:hover {

.nav-link:hover {
background: rgba(mat-color($qc-atlas-ui-primary), 0.10);
}

.mat-drawer-side {
border: none;
.mat-expansion-panel.flat-panel {
box-shadow: none;
border-radius: 0px;
}

.sub-tab {
font-size: 14px;
// TODO: check styles after angular upgrade!
::ng-deep .mat-expansion-panel .mat-expansion-panel-header {
padding-inline-start: 16px;
}

.collapse-arrow-icon {
color: mat-color($qc-atlas-ui-primary);
::ng-deep .mat-expansion-panel .mat-expansion-panel-body {
padding-inline: 0px;
}

.nav-panel-header {
font-weight: 300;
}

mat-expansion-panel .nav-link {
padding-inline-start: 24px;
}


.mat-drawer-side {
border: none;
}

.menu-button {
Expand Down
50 changes: 49 additions & 1 deletion src/app/components/navigation/navigation.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import {
Breakpoints,
BreakpointState,
} from '@angular/cdk/layout';
import { Router } from '@angular/router';
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import { ApiConfiguration } from 'api-atlas/api-configuration';
import { Observable, from } from 'rxjs';
import { filter } from 'rxjs/operators';
import {
QcAtlasUiRepositoryConfigurationService,
UiFeatures,
Expand All @@ -26,16 +27,33 @@ export class NavigationComponent implements OnInit {
hideNav = false;
bearerTokenSet = false;

activeGroup: 'libraries' | 'execution' | 'components' | null = null;

constructor(
private breakpointObserver: BreakpointObserver,
private router: Router,
private activeRoute: ActivatedRoute,
public configData: QcAtlasUiRepositoryConfigurationService,
private config: ApiConfiguration,
private utilService: UtilService,
private planqkPlatformLoginService: PlanqkPlatformLoginService
) {}

ngOnInit(): void {
if (this.activeRoute.firstChild) {
const path = this.activeRoute.firstChild.snapshot.url?.[0]?.path;
this.onUrlChanged(path);
}

this.router.events
.pipe(filter<NavigationEnd>((event) => event instanceof NavigationEnd))
.subscribe((event) => {
if (event.url.length < 2) {
this.onUrlChanged('');
return;
}
this.onUrlChanged(event.url.substring(1));
});
this.breakpointObserver
.observe([Breakpoints.Small, Breakpoints.XSmall])
.subscribe((state: BreakpointState) => {
Expand Down Expand Up @@ -86,4 +104,34 @@ export class NavigationComponent implements OnInit {
.then(() => this.router.navigate(['/algorithms']))
);
}

private onUrlChanged(newPath: string): void {
if (newPath === '') {
this.activeGroup = null;
return;
}
console.log(newPath);
if (newPath === 'libraries' || newPath === 'slr') {
this.activeGroup = 'libraries';
return;
}

if (newPath.startsWith('execution-environments')) {
this.activeGroup = 'execution';
return;
}

if (
newPath.startsWith('problem-types') ||
newPath.startsWith('application-areas') ||
newPath.startsWith('algorithm-relation-types') ||
newPath.startsWith('pattern-relation-types') ||
newPath.startsWith('compute-resource-property-types')
) {
this.activeGroup = 'components';
return;
}

this.activeGroup = null;
}
}
Loading