-
Notifications
You must be signed in to change notification settings - Fork 44
/
pages.component.ts
93 lines (86 loc) · 2.4 KB
/
pages.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { Component, OnInit } from '@angular/core';
import { NbMenuItem, NbSidebarService } from '@nebular/theme';
import { ResponsiveSizeInfoRx } from 'ngx-responsive';
import { CurrentUserService } from './current-user.service';
import { MENU_ITEMS } from './pages-menu';
@Component({
selector: 'app-rng-pages',
template: `
<nb-layout [withScroll]="false" [responsive-window]="'pages'">
<nb-layout-header fixed>
<nb-actions>
<nb-action
style="padding: 0 0.5rem;"
icon="menu-outline"
(click)="toggleNav()"
*hideItBootstrap="['lg', 'xl']"
></nb-action>
<nb-action style="padding: 0 0.5rem;">
<img src="./assets/favicon.svg" style="height: 3rem;" />
</nb-action>
<nb-action style="padding: 0 0.5rem;"> <h3>RcloneNg</h3> </nb-action>
</nb-actions>
</nb-layout-header>
<nb-sidebar class="main-sidebar" tag="nav" [fixed]="mainSideBarFixed">
<nb-menu [items]="menu"> </nb-menu>
</nb-sidebar>
<nb-layout-column class="colored-column-basic basic-contant" style="padding: 0;">
<router-outlet></router-outlet>
</nb-layout-column>
</nb-layout>
`,
styles: [
`
.main-sidebar {
z-index: 1039;
}
`,
],
})
export class PagesComponent implements OnInit {
constructor(
private sidebarService: NbSidebarService,
private currUserService: CurrentUserService,
private resp: ResponsiveSizeInfoRx
) {
resp.connect();
}
menu = MENU_ITEMS;
respSize = 'lg';
mainSideBarFixed = false;
toggleNav() {
this.sidebarService.toggle(false, 'nav');
}
ngOnInit(): void {
this.resp.getResponsiveSize.subscribe(data => {
this.respSize = data;
this.mainSideBarFixed = data === 'xs' || data === 'sm' || data === 'md';
if (!this.mainSideBarFixed) this.sidebarService.expand('nav');
else this.sidebarService.collapse('nav');
});
this.currUserService.currentUserFlow$.getSupersetOutput().subscribe(node => {
if (node[1].length !== 0) return;
const userGroup = this.menu[0];
userGroup.title = node[0].name;
userGroup.children = node[0].users
.filter(x => x.name !== node[0].name) // disable show current user in child item
.map(
(x): NbMenuItem => {
return {
title: x.name,
icon: 'person',
link: 'user/login',
queryParams: {
name: x.name,
},
};
}
);
userGroup.children.push({
title: 'Manage',
icon: 'grid-outline',
link: 'user',
});
});
}
}