mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-02-23 08:24:07 +01:00
feat(rc5): update to angular rc.5
- NgaModule - module wrapper for all ng2-admin custom features - Ng Module per page - async components load - menu moved (again) to a separate file (as now each module has its own route file) - no need to import Ba* directives into the pages which have NgaModule in the import statement
This commit is contained in:
parent
983f6f1675
commit
5b7c132eac
86 changed files with 854 additions and 384 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import {Component} from '@angular/core';
|
||||
|
||||
import {AppState} from "../../../app.state";
|
||||
import {GlobalState} from '../../../global.state';
|
||||
|
||||
@Component({
|
||||
selector: 'ba-content-top',
|
||||
|
|
@ -11,7 +11,7 @@ export class BaContentTop {
|
|||
|
||||
public activePageTitle:string = '';
|
||||
|
||||
constructor(private _state:AppState) {
|
||||
constructor(private _state:GlobalState) {
|
||||
this._state.subscribe('menu.activeLink', (activeLink) => {
|
||||
if (activeLink) {
|
||||
this.activePageTitle = activeLink.title;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import {Component, ViewEncapsulation, Input, Output, EventEmitter} from '@angular/core';
|
||||
import {Router, RouterConfig, NavigationEnd} from '@angular/router';
|
||||
import {Router, Routes, NavigationEnd} from '@angular/router';
|
||||
import {Subscription} from 'rxjs/Rx';
|
||||
|
||||
import {BaSlimScroll} from '../../../theme/directives';
|
||||
import {BaMenuService} from './baMenu.service';
|
||||
import {BaMenuItem} from './components/baMenuItem';
|
||||
import {AppState} from '../../../app.state';
|
||||
import {GlobalState} from '../../../global.state';
|
||||
|
||||
@Component({
|
||||
selector: 'ba-menu',
|
||||
|
|
@ -17,7 +17,7 @@ import {AppState} from '../../../app.state';
|
|||
})
|
||||
export class BaMenu {
|
||||
|
||||
@Input() menuRoutes:RouterConfig = [];
|
||||
@Input() menuRoutes:Routes = [];
|
||||
@Input() sidebarCollapsed:boolean = false;
|
||||
@Input() menuHeight:number;
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ export class BaMenu {
|
|||
protected _onRouteChange:Subscription;
|
||||
public outOfArea:number = -200;
|
||||
|
||||
constructor(private _router:Router, private _service:BaMenuService, private _state:AppState) {
|
||||
constructor(private _router:Router, private _service:BaMenuService, private _state:GlobalState) {
|
||||
this._onRouteChange = this._router.events.subscribe((event) => {
|
||||
|
||||
if (event instanceof NavigationEnd) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {Router, UrlTree, RouterConfig} from '@angular/router';
|
||||
import {Router, Routes} from '@angular/router';
|
||||
|
||||
@Injectable()
|
||||
export class BaMenuService {
|
||||
|
|
@ -9,7 +9,7 @@ export class BaMenuService {
|
|||
constructor(private _router:Router) {
|
||||
}
|
||||
|
||||
public convertRoutesToMenus(routes:RouterConfig):any[] {
|
||||
public convertRoutesToMenus(routes:Routes):any[] {
|
||||
let items = this._convertArrayToItems(routes);
|
||||
return this._skipEmpty(items);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import {Component, ViewEncapsulation} from '@angular/core';
|
||||
|
||||
import {AppState} from '../../../app.state';
|
||||
import {GlobalState} from '../../../global.state';
|
||||
import {BaProfilePicturePipe} from '../../pipes';
|
||||
import {BaMsgCenter} from '../../components/baMsgCenter';
|
||||
import {BaScrollPosition} from '../../directives';
|
||||
|
|
@ -18,7 +18,7 @@ export class BaPageTop {
|
|||
public isScrolled:boolean = false;
|
||||
public isMenuCollapsed:boolean = false;
|
||||
|
||||
constructor(private _state:AppState) {
|
||||
constructor(private _state:GlobalState) {
|
||||
this._state.subscribe('menu.isCollapsed', (isCollapsed) => {
|
||||
this.isMenuCollapsed = isCollapsed;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import {Component, ElementRef, HostListener, ViewEncapsulation} from '@angular/core';
|
||||
import {AppState} from '../../../app.state';
|
||||
import {GlobalState} from '../../../global.state';
|
||||
import {layoutSizes} from '../../../theme';
|
||||
import {BaMenu} from '../baMenu';
|
||||
import {routes} from '../../../../app/app.routes';
|
||||
import {MENU} from '../../../../app/app.menu';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
@Component({
|
||||
|
|
@ -16,14 +16,14 @@ import * as _ from 'lodash';
|
|||
export class BaSidebar {
|
||||
|
||||
// here we declare which routes we want to use as a menu in our sidebar
|
||||
public routes = _.cloneDeep(routes); // we're creating a deep copy since we are going to change that object
|
||||
public routes = _.cloneDeep(MENU); // we're creating a deep copy since we are going to change that object
|
||||
|
||||
public menuHeight:number;
|
||||
public isMenuCollapsed:boolean = false;
|
||||
public isMenuShouldCollapsed:boolean = false;
|
||||
|
||||
|
||||
constructor(private _elementRef:ElementRef, private _state:AppState) {
|
||||
constructor(private _elementRef:ElementRef, private _state:GlobalState) {
|
||||
|
||||
this._state.subscribe('menu.isCollapsed', (isCollapsed) => {
|
||||
this.isMenuCollapsed = isCollapsed;
|
||||
|
|
|
|||
117
src/app/theme/nga.module.ts
Normal file
117
src/app/theme/nga.module.ts
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
||||
import { HttpModule } from '@angular/http';
|
||||
|
||||
import {
|
||||
BaThemeConfig
|
||||
} from './theme.config';
|
||||
|
||||
import {
|
||||
BaThemeConfigProvider
|
||||
} from './theme.configProvider';
|
||||
|
||||
import {
|
||||
BaAmChart,
|
||||
BaBackTop,
|
||||
BaCard,
|
||||
BaChartistChart,
|
||||
BaCheckbox,
|
||||
BaContentTop,
|
||||
BaFullCalendar,
|
||||
BaMenu,
|
||||
BaMsgCenter,
|
||||
BaMultiCheckbox,
|
||||
BaPageTop,
|
||||
BaPictureUploader,
|
||||
BaSidebar
|
||||
} from './components';
|
||||
|
||||
import {
|
||||
BaScrollPosition,
|
||||
BaSlimScroll,
|
||||
BaThemeRun
|
||||
} from './directives';
|
||||
|
||||
import {
|
||||
BaAppPicturePipe,
|
||||
BaKameleonPicturePipe,
|
||||
BaProfilePicturePipe
|
||||
} from './pipes';
|
||||
|
||||
import {
|
||||
BaImageLoaderService,
|
||||
BaThemePreloader,
|
||||
BaThemeSpinner
|
||||
} from './services';
|
||||
|
||||
import {
|
||||
EmailValidator,
|
||||
EqualPasswordsValidator
|
||||
} from './validators';
|
||||
|
||||
const NGA_COMPONENTS = [
|
||||
BaAmChart,
|
||||
BaBackTop,
|
||||
BaCard,
|
||||
BaChartistChart,
|
||||
BaCheckbox,
|
||||
BaContentTop,
|
||||
BaFullCalendar,
|
||||
BaMenu,
|
||||
BaMsgCenter,
|
||||
BaMultiCheckbox,
|
||||
BaPageTop,
|
||||
BaPictureUploader,
|
||||
BaSidebar
|
||||
];
|
||||
|
||||
const NGA_DIRECTIVES = [
|
||||
BaScrollPosition,
|
||||
BaSlimScroll,
|
||||
BaThemeRun
|
||||
];
|
||||
|
||||
const NGA_PIPES = [
|
||||
BaAppPicturePipe,
|
||||
BaKameleonPicturePipe,
|
||||
BaProfilePicturePipe
|
||||
];
|
||||
|
||||
const NGA_SERVICES = [
|
||||
BaImageLoaderService,
|
||||
BaThemePreloader,
|
||||
BaThemeSpinner
|
||||
];
|
||||
|
||||
const NGA_VALIDATORS = [
|
||||
EmailValidator,
|
||||
EqualPasswordsValidator
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
...NGA_PIPES,
|
||||
...NGA_DIRECTIVES,
|
||||
...NGA_COMPONENTS
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
HttpModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
providers: [
|
||||
BaThemeConfigProvider,
|
||||
BaThemeConfig,
|
||||
...NGA_VALIDATORS,
|
||||
...NGA_SERVICES
|
||||
],
|
||||
exports: [
|
||||
...NGA_PIPES,
|
||||
...NGA_DIRECTIVES,
|
||||
...NGA_COMPONENTS
|
||||
]
|
||||
})
|
||||
export class NgaModule {
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue