Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Commit ef415a2

Browse files
committed
feat(fire): update layout to new configuration
1 parent 95e8aad commit ef415a2

File tree

18 files changed

+182
-183
lines changed

18 files changed

+182
-183
lines changed

apps/demo/src/app/app.service.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,26 @@ import { environment } from '../environments/environment'
44

55
const sourceCode = {
66
label: 'Source Code',
7+
labelClass: 'd-none d-lg-inline',
78
link: environment.urls.repo,
8-
class: 'btn btn-sm btn-outline-primary ml-2',
9-
icon: 'fe fe-github',
9+
linkClass: 'btn btn-sm btn-outline-primary ml-2',
10+
icon: 'fa fa-fw fa-github',
1011
external: true,
1112
}
1213
const documentation = {
1314
label: 'Documentation',
15+
labelClass: 'd-none d-lg-inline',
1416
link: environment.urls.docs,
15-
class: 'btn btn-sm btn-outline-success ml-2',
16-
icon: 'fe fe-info',
17+
linkClass: 'btn btn-sm btn-outline-success ml-2',
18+
icon: 'fa fa-fw fa-info',
1719
external: true,
1820
}
1921
const fire = {
20-
label: 'Fire',
22+
label: 'Firebase Demo',
23+
labelClass: 'd-none d-lg-inline',
2124
link: environment.urls.fire,
22-
class: 'btn btn-sm btn-outline-warning ml-2',
23-
icon: 'fa fa-fire',
25+
linkClass: 'btn btn-sm btn-outline-warning ml-2',
26+
icon: 'fa fa-fw fa-fire',
2427
external: true,
2528
}
2629

apps/fire/src/app/app-routing.module.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
import { ExtraOptions, RouterModule, Routes } from '@angular/router'
22
import { ModuleWithProviders } from '@angular/core'
3+
import { LayoutComponent } from '@tabler/angular-ui'
34
import { AuthModuleRoutes } from './auth/auth.module'
45
import { LoggedInGuard } from './auth/guards/logged-in.guard'
56

67
const routes: Routes = [
7-
{ path: '', redirectTo: 'fire', pathMatch: 'full' },
8-
{ path: 'auth', children: [...AuthModuleRoutes] },
8+
{ path: '', redirectTo: 'guestbook', pathMatch: 'full' },
99
{
10-
path: 'crud',
11-
loadChildren: './crud/crud.module#CrudModule',
12-
canActivate: [LoggedInGuard],
10+
path: '',
11+
component: LayoutComponent,
12+
children: [
13+
{ path: 'auth', children: [...AuthModuleRoutes] },
14+
{ path: 'guestbook', loadChildren: './fire/fire.module#FireModule' },
15+
{
16+
path: 'crud',
17+
loadChildren: './crud/crud.module#CrudModule',
18+
canActivate: [LoggedInGuard],
19+
},
20+
],
1321
},
14-
{ path: 'fire', loadChildren: './fire/fire.module#FireModule' },
1522
{ path: '**', redirectTo: '/404' },
1623
]
1724

apps/fire/src/app/app.component.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import { Component } from '@angular/core'
2-
import { AppService } from './app.service'
32

43
@Component({
54
selector: 'app-root',
65
template: `
7-
<ui-layout [config]="app.config$ | async"></ui-layout>
6+
<router-outlet></router-outlet>
87
`,
98
})
10-
export class AppComponent {
11-
constructor(public app: AppService) {}
12-
}
9+
export class AppComponent {}

apps/fire/src/app/app.service.ts

Lines changed: 74 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,83 @@ const defaultUser = {
77
email: 'Guest account',
88
avatarText: '?',
99
}
10+
const headerBaseLinks = [
11+
{
12+
label: 'Guestbook',
13+
icon: 'fe fe-book',
14+
link: '/guestbook',
15+
},
16+
]
17+
const headerLoggedIn = [
18+
...headerBaseLinks,
19+
{
20+
label: 'Beers',
21+
icon: 'fa fa-beer',
22+
link: '/crud/beers',
23+
},
24+
{
25+
label: 'Notes',
26+
icon: 'fa fa-pencil-square-o',
27+
link: '/crud/notes',
28+
},
29+
]
30+
const headerLoggedOut = [
31+
...headerBaseLinks,
32+
{
33+
label: 'Firebase CRUD',
34+
icon: 'fa fa-database',
35+
link: '/crud/beers',
36+
},
37+
]
38+
const profileLoggedIn = [
39+
{
40+
link: '/auth/profile',
41+
linkClass: 'dropdown-item',
42+
label: 'Profile',
43+
icon: 'fe fe-user dropdown-icon',
44+
},
45+
{
46+
link: '/auth/logout',
47+
linkClass: 'dropdown-item',
48+
label: 'Log out',
49+
icon: 'fe fe-log-out dropdown-icon',
50+
},
51+
]
52+
const profileLoggedOut = [
53+
{
54+
link: '/auth/login',
55+
linkClass: 'dropdown-item',
56+
label: 'Log in',
57+
icon: 'fe fe-log-in dropdown-icon',
58+
},
59+
]
1060

1161
@Injectable()
1262
export class AppService {
1363
public config$
1464
constructor(private auth: AuthService, private ui: UiService) {
1565
this.config$ = ui.config$
16-
this.auth.user$.map(user => (user ? user : defaultUser)).subscribe(user => (this.ui.profile = user))
66+
this.auth.user$.map(user => (user ? user : defaultUser)).subscribe(user => this.updateUser(user))
1767
this.init()
1868
}
69+
70+
public updateUser(user) {
71+
this.ui.profile = user || defaultUser
72+
this.ui.updateLayout({
73+
headerNav: user.id ? headerLoggedIn : headerLoggedOut,
74+
profileNav: user.id ? profileLoggedIn : profileLoggedOut,
75+
})
76+
}
77+
1978
public init() {
2079
this.ui.appName = 'Firebase Demo'
21-
this.ui.headerNav = [
22-
{
23-
label: 'Guestbook',
24-
icon: 'fe fe-book',
25-
link: '/fire/guestbook',
26-
},
27-
{
28-
label: 'Beers',
29-
icon: 'fa fa-beer',
30-
link: '/crud/beers',
31-
},
80+
this.ui.headerSubNav = [
3281
{
33-
label: 'Notes',
34-
icon: 'fa fa-pencil-square-o',
35-
link: '/crud/notes',
82+
label: 'Source Code',
83+
labelClass: 'd-none d-lg-inline',
84+
link: 'https://github.com/tabler/tabler-angular/tree/develop/apps/fire/src/app',
85+
linkClass: 'btn btn-sm btn-outline-primary ml-2',
86+
icon: 'fe fe-github mr-1',
3687
},
3788
]
3889
this.ui.footerText = `
@@ -41,21 +92,13 @@ export class AppService {
4192
Angular by <a href="https://github.com/beeman" target="_blank">@beeman</a>.
4293
MIT Licensed
4394
`
44-
this.ui.links.set('logoutLink', {
45-
link: '/auth/logout',
46-
label: 'Log out',
47-
icon: 'fe fe-log-out',
48-
})
49-
this.ui.links.set('loginLink', {
50-
link: '/auth/login',
51-
label: 'Log in',
52-
icon: 'fe fe-log-in',
53-
})
54-
this.ui.links.set('sourceLink', {
55-
label: 'Source Code',
56-
link: 'https://github.com/tabler/tabler-angular/tree/develop/apps/fire/src/app',
57-
class: 'btn btn-sm btn-outline-primary ml-2',
58-
icon: 'fe fe-github',
59-
})
95+
this.ui.footerNav = [
96+
{
97+
label: 'Source Code',
98+
link: 'https://github.com/tabler/tabler-angular/tree/develop/apps/fire/src/app',
99+
linkClass: 'btn btn-sm btn-outline-primary ml-2',
100+
icon: 'fe fe-github mr-2',
101+
},
102+
]
60103
}
61104
}

apps/fire/src/app/crud/containers/items-index/items-index.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ export const getProperties = o =>
1818
<ui-page>
1919
<div class="py-5">
2020
<div class="row">
21-
<div class="col-8">
21+
<div class="col-md-12 col-lg-8">
2222
<app-item-list [items]="items$ | async"
2323
[user]="user"
2424
[collection]="collection"
2525
(action)="handleAction($event)">
2626
</app-item-list>
2727
</div>
28-
<div class="col-4">
28+
<div class="col-md-12 col-lg-4">
2929
<div class="card">
3030
<div class="card-body">
3131
<h3 class="card-title">Crud Models</h3>

apps/fire/src/app/fire/fire.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ const routes: Routes = [
1515
path: '',
1616
component: FireIndexComponent,
1717
children: [
18-
{ path: '', redirectTo: 'guestbook', pathMatch: 'full' },
19-
{ path: 'guestbook', component: GuestbookComponent },
18+
{ path: '', component: GuestbookComponent },
2019
],
2120
},
2221
]
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { NgModule } from '@angular/core'
22
import { CommonModule } from '@angular/common'
3+
import { RouterModule } from '@angular/router'
34
import { FormsModule } from '@tabler/angular-forms'
45
import { UiModule } from '@tabler/angular-ui'
56
import { ModalModule } from 'ngx-bootstrap'
67

78
@NgModule({
8-
imports: [CommonModule, UiModule, FormsModule, ModalModule],
9-
exports: [CommonModule, UiModule, FormsModule, ModalModule],
9+
imports: [CommonModule, RouterModule, UiModule, FormsModule, ModalModule],
10+
exports: [CommonModule, RouterModule, UiModule, FormsModule, ModalModule],
1011
})
1112
export class SharedModule {}

libs/angular-ui/src/modules/header/components/header-links/header-links.component.spec.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

libs/angular-ui/src/modules/header/components/header-links/header-links.component.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

libs/angular-ui/src/modules/header/components/header-profile-link/header-profile-link.component.spec.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)