chore: base layout

This commit is contained in:
tibing 2017-04-13 14:24:23 +03:00
parent 1fb884a633
commit d82d691681
19 changed files with 195 additions and 44 deletions

View file

@ -0,0 +1,16 @@
import { NgModule, Optional, SkipSelf } from '@angular/core';
import { CommonModule } from '@angular/common';
import { throwIfAlreadyLoaded } from './module-import-guard';
@NgModule({
imports: [
CommonModule
],
declarations: []
})
export class CoreModule {
constructor(@Optional() @SkipSelf() parentModule: CoreModule) {
throwIfAlreadyLoaded(parentModule, 'CoreModule');
}
}

View file

@ -0,0 +1,5 @@
export function throwIfAlreadyLoaded(parentModule: any, moduleName: string) {
if (parentModule) {
throw new Error(`${moduleName} has already been loaded. Import Core modules in the AppModule only.`);
}
}

View file

@ -0,0 +1 @@
export * from './one-coll-layout/one-coll.layout';

View file

@ -0,0 +1,18 @@
import { Component } from '@angular/core';
@Component({
selector: 'one-coll-layout',
template: `
<nga-layout>
<nga-layout-header fixed></nga-layout-header>
<nga-sidebar fixed></nga-sidebar>
<nga-layout-column>
<ng-content></ng-content>
</nga-layout-column>
<nga-layout-footer fixed></nga-layout-footer>
</nga-layout>
`,
})
export class RootLayoutComponent {
constructor() { }
}

View file

@ -0,0 +1,3 @@
@import '~@nga/theme/styles/themes/nga.theme.default';
@include nga-theme();

View file

@ -0,0 +1 @@
@import "default.theme";

View file

@ -0,0 +1,50 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import {
NgaCardModule,
NgaLayoutModule,
NgaTabsetModule,
NgaRouteTabsetModule,
NgaSidebarModule,
NgaMenuModule
} from '@nga/theme';
import { RootLayoutComponent } from './layouts';
const BASE_MODULES = [
CommonModule,
FormsModule,
ReactiveFormsModule
];
const NGA_MODULES = [
NgaCardModule,
NgaLayoutModule,
NgaTabsetModule,
NgaRouteTabsetModule,
NgaSidebarModule,
NgaMenuModule
];
const LAYOUT_COMPONENTS = [
RootLayoutComponent
];
@NgModule({
imports: [
...BASE_MODULES,
...NGA_MODULES,
],
exports: [
...BASE_MODULES,
...NGA_MODULES,
...LAYOUT_COMPONENTS
],
declarations: [
...LAYOUT_COMPONENTS
]
})
export class ThemeModule {
}

View file

@ -0,0 +1,20 @@
import { ExtraOptions, RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';
const routes: Routes = [
// {path: 'admin'}
{path: 'pages', loadChildren: 'app/pages/pages.module#PagesModule'},
{path: '', redirectTo: 'pages', pathMatch: 'full'},
{path: '**', redirectTo: 'pages'}
];
const config: ExtraOptions = {
useHash: true
};
@NgModule({
imports: [RouterModule.forRoot(routes, config)],
exports: [RouterModule]
})
export class AppRoutingModule {
}

View file

@ -1,11 +0,0 @@
<nga-card status="danger">
<nga-card-header>
<span>Header</span>
</nga-card-header>
<nga-card-body>
<span>Body</span>
</nga-card-body>
<nga-card-footer>
<span>Footer</span>
</nga-card-footer>
</nga-card>

View file

@ -1,9 +1 @@
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
@import '~@nga/theme/styles/themes/nga.theme.default';
@include nga-theme();
@import "@theme/styles/styles";

View file

@ -6,10 +6,9 @@
import { Component } from '@angular/core';
@Component({
selector: 'nga-app-root',
templateUrl: './app.component.html',
selector: 'app',
template: '<router-outlet></router-outlet>',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
title = 'app works!';
}

View file

@ -5,37 +5,31 @@
*/
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import {
NgaThemeModule,
NgaCardModule,
NgaLayoutModule,
NgaMenuModule,
NgaRouteTabsetModule,
NgaSidebarModule,
NgaTabsetModule,
NgaThemeModule
} from '@nga/theme';
import { AppComponent } from './app.component';
import { CoreModule } from './@core/core.module';
import { PagesModule } from './pages/pages.module';
import { AppRoutingModule } from './app-routing.module';
@NgModule({
declarations: [
AppComponent,
],
declarations: [AppComponent],
imports: [
BrowserModule,
FormsModule,
HttpModule,
NgaThemeModule,
NgaCardModule,
NgaLayoutModule,
NgaMenuModule,
NgaRouteTabsetModule,
NgaSidebarModule,
NgaTabsetModule,
NgaThemeModule.forRoot(),
NgaSidebarModule.forRoot(),
AppRoutingModule,
CoreModule,
PagesModule
],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule { }
export class AppModule {
}

View file

@ -0,0 +1,9 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss']
})
export class DashboardComponent {
}

View file

@ -0,0 +1,23 @@
import { RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';
import { PagesComponent } from './pages.component';
import { DashboardComponent } from './dashboard/dashboard.component';
const routes: Routes = [
{
path: '',
component: PagesComponent,
children: [
{path: '', redirectTo: 'dashboard', pathMatch: 'full'},
{path: 'dashboard', component: DashboardComponent}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class PagesRoutingModule {
}

View file

@ -0,0 +1,12 @@
import { Component } from '@angular/core';
@Component({
selector: 'pages',
template: `
<one-coll-layout>
<router-outlet></router-outlet>
</one-coll-layout>
`
})
export class PagesComponent {
}

View file

@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { PagesComponent } from './pages.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { PagesRoutingModule } from './pages-routing.module';
import { ThemeModule } from '../@theme/theme.module';
@NgModule({
imports: [
PagesRoutingModule,
ThemeModule
],
declarations: [
PagesComponent,
DashboardComponent
]
})
export class PagesModule {
}

View file

@ -2,13 +2,13 @@
<html>
<head>
<meta charset="utf-8">
<title>@nga/framework</title>
<title>NgX Admin Demo</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<nga-app-root>Loading...</nga-app-root>
<app>Loading...</app>
</body>
</html>