Commit 091de5de by Tuukka Kivilahti

Merge branch 'feature/routing' into 'master'

Feature/routing

See merge request !397
2 parents 1cbc86e7 9e0c1706
Showing with 291 additions and 95 deletions
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"test": "test.ts", "test": "test.ts",
"tsconfig": "tsconfig.app.json", "tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json", "testTsconfig": "tsconfig.spec.json",
"prefix": "app", "prefix": "moya",
"styles": [ "styles": [
"styles.scss" "styles.scss"
], ],
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
# IDEs and editors # IDEs and editors
/.idea /.idea
/.vscode
.project .project
.classpath .classpath
.c9/ .c9/
......
...@@ -6,6 +6,6 @@ export class MoyaAngularPage { ...@@ -6,6 +6,6 @@ export class MoyaAngularPage {
} }
getParagraphText() { getParagraphText() {
return element(by.css('app-root h1')).getText(); return element(by.css('moya-root h1')).getText();
} }
} }
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
}, },
"devDependencies": { "devDependencies": {
"@angular/cdk": "^5.2.4", "@angular/cdk": "^5.2.4",
"@angular/cli": "^1.7.3", "@angular/cli": "^1.6.5",
"@angular/compiler-cli": "^5.2.9", "@angular/compiler-cli": "^5.2.9",
"@angular/language-service": "^5.2.9", "@angular/language-service": "^5.2.9",
"@types/jasmine": "~2.8.3", "@types/jasmine": "~2.8.3",
......
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './pages/login/login.component';
import { InfoComponent } from './pages/info/info.component';
const APP_ROUTES: Routes = [
{ path: 'info', loadChildren: 'app/pages/info/info.module#InfoModule' },
{ path: 'admin', loadChildren: 'app/pages/admin/admin.module#AdminModule' },
{ path: 'user', loadChildren: 'app/pages/user/user.module#UserModule' },
{ path: 'login', component: LoginComponent },
{ path: '', pathMatch: 'full', redirectTo: 'login' },
{ path: '**', component: LoginComponent }
];
@NgModule({
imports: [
RouterModule.forRoot(
APP_ROUTES
)
],
exports: [
RouterModule
]
})
export class AppRoutingModule { }
<div id="top-container"> <div id="top-container">
<div id="left-menu"> <div id="left-menu">
<router-outlet name="left-menu"></router-outlet> <router-outlet name="left-menu"></router-outlet>
...@@ -15,4 +13,4 @@ ...@@ -15,4 +13,4 @@
<router-outlet></router-outlet> <router-outlet></router-outlet>
</div> </div>
</div> </div>
</div>
\ No newline at end of file
...@@ -3,10 +3,8 @@ import {Router} from '@angular/router'; ...@@ -3,10 +3,8 @@ import {Router} from '@angular/router';
declare var window: any; declare var window: any;
@Component({ @Component({
selector: 'app-root', selector: 'moya-root',
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'] styleUrls: ['./app.component.scss']
}) })
......
import {BrowserModule} from '@angular/platform-browser'; import { UserService } from './shared/services/user.service';
import {NgModule} from '@angular/core'; import { ErrorInterceptor } from './shared/interceptors/error.interceptor';
import {FormsModule} from '@angular/forms'; import { MoyaLocaleService } from './components/moya-locale/moya-locale.service';
import { CacheService } from './shared/services/cache.service';
import {AppComponent} from './app.component'; import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import {ViplistComponent} from './pages/info/viplist/viplist.component'; import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import {AlertModule} from 'ngx-bootstrap'; import { AlertModule } from 'ngx-bootstrap';
import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
import { FormsModule } from '@angular/forms';
import {RouterModule, Routes} from '@angular/router'; import { AppRoutingModule } from './app-routing.module';
import {OldMoyaComponent} from './pages/old-moya/old-moya.component'; import { BrowserModule } from '@angular/platform-browser';
import {TestComponent} from './test/test.component';
import {AdminMenuComponent} from './menu/admin-menu/admin-menu.component';
import {TopMenuComponent} from './menu/top-menu/top-menu.component';
import {LeftMenuComponent} from './menu/left-menu/left-menu.component';
import {InfoMenuComponent} from './menu/info-menu/info-menu.component';
import {UserMenuComponent} from './menu/user-menu/user-menu.component';
import {UserComponent} from './pages/user/user.component';
import {InfoComponent} from './pages/info/info.component';
import {AdminComponent} from './pages/admin/admin.component';
import {HTTP_INTERCEPTORS, HttpClient, HttpClientModule} from '@angular/common/http';
import {CommonModule} from '@angular/common';
import {CacheService} from './shared/services/cache.service';
import {SafePipe} from './shared/pipes/safe.pipe';
import {TranslateLoader, TranslateModule} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {MoyaLocaleService} from './components/moya-locale/moya-locale.service';
import { MoyaLocaleComponent } from './components/moya-locale/moya-locale.component'; import { MoyaLocaleComponent } from './components/moya-locale/moya-locale.component';
import {ErrorInterceptor} from './shared/interceptors/error.interceptor'; import { TopMenuComponent } from './menu/top-menu/top-menu.component';
import {ViplistService} from './pages/info/viplist/viplist.service'; import { AppComponent } from './app.component';
import {UserService} from './shared/services/user.service'; import { LoginComponent } from './pages/login/login.component';
import { NgModule } from '@angular/core';
const appRoutes: Routes = [
{
path: 'user',
children: [
{path: '', component: UserMenuComponent, outlet: 'left-menu'},
{path: '', pathMatch: 'full', component: UserComponent},
{path: 'old', component: OldMoyaComponent},
]
},
{
path: 'info',
children: [
{path: '', component: InfoMenuComponent, outlet: 'left-menu'},
{path: '', pathMatch: 'full', component: OldMoyaComponent},
{path: 'old', component: OldMoyaComponent},
{path: 'viplist', component: ViplistComponent},
]
},
{
path: 'admin',
children: [
{path: '', component: AdminMenuComponent, outlet: 'left-menu'},
{path: '', pathMatch: 'full', component: AdminComponent},
{path: 'old', component: OldMoyaComponent},
]
},
{path: 'old', pathMatch: 'prefix', component: OldMoyaComponent},
];
@NgModule({ @NgModule({
declarations: [ declarations: [
LoginComponent,
AppComponent, AppComponent,
ViplistComponent,
OldMoyaComponent,
TestComponent,
TopMenuComponent, TopMenuComponent,
LeftMenuComponent,
AdminMenuComponent,
InfoMenuComponent,
UserMenuComponent,
UserComponent,
InfoComponent,
AdminComponent,
SafePipe,
MoyaLocaleComponent MoyaLocaleComponent
], ],
imports: [ imports: [
CommonModule,
BrowserModule, BrowserModule,
AppRoutingModule,
FormsModule, FormsModule,
HttpClientModule, HttpClientModule,
AlertModule.forRoot(), AlertModule.forRoot(),
RouterModule.forRoot(appRoutes),
TranslateModule.forRoot({ TranslateModule.forRoot({
loader: { loader: {
provide: TranslateLoader, provide: TranslateLoader,
...@@ -103,5 +45,4 @@ const appRoutes: Routes = [ ...@@ -103,5 +45,4 @@ const appRoutes: Routes = [
UserService], UserService],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { export class AppModule { }
}
...@@ -3,7 +3,7 @@ import {MenuGroup} from '../models/menu-group.model'; ...@@ -3,7 +3,7 @@ import {MenuGroup} from '../models/menu-group.model';
import {MENU} from '../defines/menu'; import {MENU} from '../defines/menu';
@Component({ @Component({
selector: 'app-admin-menu', selector: 'moya-admin-menu',
templateUrl: './admin-menu.component.html', templateUrl: './admin-menu.component.html',
styleUrls: ['./admin-menu.component.scss'] styleUrls: ['./admin-menu.component.scss']
}) })
......
...@@ -3,7 +3,7 @@ import {MenuGroup} from '../models/menu-group.model'; ...@@ -3,7 +3,7 @@ import {MenuGroup} from '../models/menu-group.model';
import {MENU} from '../defines/menu'; import {MENU} from '../defines/menu';
@Component({ @Component({
selector: 'app-info-menu', selector: 'moya-info-menu',
templateUrl: './info-menu.component.html', templateUrl: './info-menu.component.html',
styleUrls: ['./info-menu.component.scss'] styleUrls: ['./info-menu.component.scss']
}) })
......
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { LeftMenuComponent } from './left-menu.component';
import { RouterModule } from '@angular/router';
@NgModule({
imports: [
CommonModule,
RouterModule
],
declarations: [LeftMenuComponent],
exports : [
LeftMenuComponent
]
})
export class LeftMenuModule { }
...@@ -3,7 +3,7 @@ import {MenuGroup} from '../models/menu-group.model'; ...@@ -3,7 +3,7 @@ import {MenuGroup} from '../models/menu-group.model';
import {MENU} from '../defines/menu'; import {MENU} from '../defines/menu';
@Component({ @Component({
selector: 'app-user-menu', selector: 'moya-user-menu',
templateUrl: './user-menu.component.html', templateUrl: './user-menu.component.html',
styleUrls: ['./user-menu.component.scss'] styleUrls: ['./user-menu.component.scss']
}) })
......
import { OldMoyaComponent } from './../old-moya/old-moya.component';
import { AdminMenuComponent } from './../../menu/admin-menu/admin-menu.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AdminComponent } from './admin.component';
const routes: Routes = [
{ path: '', component: AdminMenuComponent, outlet: 'left-menu' },
{ path: '', pathMatch: 'full', component: AdminComponent },
{ path: 'old', component: OldMoyaComponent }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AdminRoutingModule { }
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
@Component({ @Component({
selector: 'app-admin', selector: 'moya-admin',
templateUrl: './admin.component.html', templateUrl: './admin.component.html',
styleUrls: ['./admin.component.scss'] styleUrls: ['./admin.component.scss']
}) })
......
import { OldMoyaModule } from './../old-moya/old-moya.module';
import { AdminMenuComponent } from './../../menu/admin-menu/admin-menu.component';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AdminRoutingModule } from './admin-routing.module';
import { AdminComponent } from './admin.component';
import { LeftMenuModule } from '../../menu/left-menu/left-menu.module';
@NgModule({
imports: [
CommonModule,
AdminRoutingModule,
LeftMenuModule,
OldMoyaModule
],
declarations: [AdminComponent, AdminMenuComponent]
})
export class AdminModule { }
import { ViplistComponent } from './viplist/viplist.component';
import { OldMoyaComponent } from './../old-moya/old-moya.component';
import { InfoMenuComponent } from './../../menu/info-menu/info-menu.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { InfoComponent } from './info.component';
const routes: Routes = [
{ path: '', component: InfoMenuComponent, outlet: 'left-menu' },
{ path: '', pathMatch: 'full', component: OldMoyaComponent },
{ path: 'old', component: OldMoyaComponent },
{ path: 'viplist', component: ViplistComponent }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class InfoRoutingModule { }
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
@Component({ @Component({
selector: 'app-info', selector: 'moya-info',
templateUrl: './info.component.html', templateUrl: './info.component.html',
styleUrls: ['./info.component.scss'] styleUrls: ['./info.component.scss']
}) })
......
import { ViplistComponent } from './viplist/viplist.component';
import { OldMoyaModule } from './../old-moya/old-moya.module';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { InfoRoutingModule } from './info-routing.module';
import { InfoComponent } from './info.component';
import { InfoMenuComponent } from '../../menu/info-menu/info-menu.component';
import { LeftMenuModule } from '../../menu/left-menu/left-menu.module';
@NgModule({
imports: [
CommonModule,
InfoRoutingModule,
LeftMenuModule,
OldMoyaModule
],
declarations: [InfoComponent, InfoMenuComponent, ViplistComponent]
})
export class InfoModule { }
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login.component';
const routes: Routes = [
{ path: '', component: LoginComponent }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class LoginRoutingModule { }
<div>Login works!</div>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'moya-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
import { LoginRoutingModule } from './login-routing.module';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { LoginComponent } from './login.component';
import { TopMenuComponent } from '../../menu/top-menu/top-menu.component';
@NgModule({
imports: [
CommonModule,
LoginRoutingModule
],
declarations: [ LoginComponent, TopMenuComponent ]
})
export class LoginModule { }
import { PipesModule } from './../../shared/pipes/pipes.module';
import { OldMoyaComponent } from './old-moya.component';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule,
PipesModule.forRoot()
],
declarations: [OldMoyaComponent],
exports: [OldMoyaComponent]
})
export class OldMoyaModule { }
import { OldMoyaComponent } from './../old-moya/old-moya.component';
import { UserMenuComponent } from './../../menu/user-menu/user-menu.component';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { UserComponent } from './user.component';
const routes: Routes = [
{ path: '', pathMatch: 'full', component: UserComponent },
{ path: '', component: UserMenuComponent, outlet: 'left-menu' },
{ path: 'old', component: OldMoyaComponent }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class UserRoutingModule { }
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
@Component({ @Component({
selector: 'app-user', selector: 'moya-user',
templateUrl: './user.component.html', templateUrl: './user.component.html',
styleUrls: ['./user.component.scss'] styleUrls: ['./user.component.scss']
}) })
......
import { PipesModule } from './../../shared/pipes/pipes.module';
import { OldMoyaModule } from './../old-moya/old-moya.module';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { UserRoutingModule } from './user-routing.module';
import { UserComponent } from './user.component';
import { UserMenuComponent } from '../../menu/user-menu/user-menu.component';
import { LeftMenuModule } from '../../menu/left-menu/left-menu.module';
import { TranslateModule } from '@ngx-translate/core';
@NgModule({
imports: [
CommonModule,
UserRoutingModule,
LeftMenuModule,
OldMoyaModule,
TranslateModule.forRoot()
],
declarations: [UserComponent, UserMenuComponent]
})
export class UserModule { }
import { SafePipe } from './safe.pipe';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
imports: [
CommonModule
],
declarations: [SafePipe],
exports: [SafePipe]
})
export class PipesModule {
static forRoot() {
return {
ngModule: PipesModule,
providers: [],
};
}
}
import {Component, OnInit, Input} from '@angular/core'; import {Component, OnInit, Input} from '@angular/core';
@Component({ @Component({
selector: 'app-test', selector: 'moya-test',
templateUrl: './test.component.html', templateUrl: './test.component.html',
styleUrls: ['./test.component.scss'] styleUrls: ['./test.component.scss']
}) })
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
<base href="/MoyaNG/"> <base href="/MoyaNG/">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body> <body>
<app-root>Welcome to new MOYA</app-root> <moya-root>Welcome to new MOYA</moya-root>
</body> </body>
</html> </html>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!