2016-05-11 17:38:01 +03:00
|
|
|
import {Component, ViewEncapsulation} from '@angular/core';
|
|
|
|
|
import {RouteConfig, Router} from '@angular/router-deprecated';
|
2016-04-29 11:49:49 +03:00
|
|
|
import {Subscription} from 'rxjs/Subscription';
|
|
|
|
|
|
2016-04-21 20:34:07 +03:00
|
|
|
import {Pages} from './pages';
|
2016-05-04 11:49:36 +03:00
|
|
|
import {ThemeGlobal} from "./theme";
|
2016-04-20 16:32:12 +03:00
|
|
|
|
2016-04-28 13:08:33 +03:00
|
|
|
// TODO: is it really the best place to globally require that dependency?
|
|
|
|
|
require("!style!css!sass!./theme/sass/_ionicons.scss");
|
|
|
|
|
|
2016-04-29 17:27:19 +03:00
|
|
|
/*
|
|
|
|
|
* App Component
|
|
|
|
|
* Top Level Component
|
|
|
|
|
*/
|
2016-04-20 16:32:12 +03:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app',
|
2016-04-29 17:27:19 +03:00
|
|
|
pipes: [],
|
2016-05-02 14:40:12 +03:00
|
|
|
providers: [],
|
2016-04-20 16:32:12 +03:00
|
|
|
encapsulation: ViewEncapsulation.None,
|
2016-04-29 17:27:19 +03:00
|
|
|
styles: [require('normalize.css'), require('./app.scss')],
|
2016-04-20 16:32:12 +03:00
|
|
|
template: `
|
2016-04-29 11:49:49 +03:00
|
|
|
<main [ngClass]="{'menu-collapsed': isMenuCollapsed}">
|
2016-04-20 16:32:12 +03:00
|
|
|
<router-outlet></router-outlet>
|
|
|
|
|
</main>
|
|
|
|
|
`
|
|
|
|
|
})
|
|
|
|
|
@RouteConfig([
|
2016-04-21 20:34:07 +03:00
|
|
|
{
|
2016-04-28 15:08:48 +03:00
|
|
|
path: '/pages/...',
|
2016-04-21 20:34:07 +03:00
|
|
|
name: 'Pages',
|
|
|
|
|
component: Pages,
|
|
|
|
|
useAsDefault: true
|
|
|
|
|
},
|
2016-04-20 16:32:12 +03:00
|
|
|
])
|
|
|
|
|
export class App {
|
2016-04-29 17:23:33 +03:00
|
|
|
|
2016-04-29 17:27:19 +03:00
|
|
|
isMenuCollapsed:boolean = false;
|
2016-04-29 11:49:49 +03:00
|
|
|
|
2016-05-02 14:40:12 +03:00
|
|
|
private _themeGlobalSubscription:Subscription;
|
2016-04-20 16:32:12 +03:00
|
|
|
|
2016-05-02 14:40:12 +03:00
|
|
|
constructor(private _themeGlobal:ThemeGlobal) {
|
|
|
|
|
this._themeGlobalSubscription = this._themeGlobal.getDataStream().subscribe((data) => {
|
|
|
|
|
this.isMenuCollapsed = data['menu.isCollapsed'] != null ? data['menu.isCollapsed'] : this.isMenuCollapsed;
|
|
|
|
|
});
|
2016-04-29 11:49:49 +03:00
|
|
|
}
|
2016-04-20 16:32:12 +03:00
|
|
|
|
2016-04-29 17:27:19 +03:00
|
|
|
ngOnDestroy() {
|
2016-04-29 11:49:49 +03:00
|
|
|
// prevent memory leak when component destroyed
|
2016-05-02 14:40:12 +03:00
|
|
|
this._themeGlobalSubscription.unsubscribe();
|
2016-04-29 11:49:49 +03:00
|
|
|
}
|
2016-04-20 16:32:12 +03:00
|
|
|
}
|