Make modules lazy, I think...
This commit is contained in:
Родитель
a2d6598d57
Коммит
3d7278a2d8
|
@ -0,0 +1,49 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { Routes } from "@angular/router";
|
||||
import { NativeScriptRouterModule } from 'nativescript-angular/router';
|
||||
import { AuthGuard } from './services';
|
||||
import { SettingsComponent } from './settings';
|
||||
|
||||
const routes: any = [
|
||||
{
|
||||
path: 'settings',
|
||||
canActivate: [ AuthGuard ],
|
||||
loadChildren: () => {
|
||||
console.log('++++ s called');
|
||||
return require('./settings/settings.module')['SettingsModule'];
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'events',
|
||||
loadChildren: () => {
|
||||
console.log('++++ e called');
|
||||
return require('./events/events.module')['EventsModule'];
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'groups',
|
||||
loadChildren: () => {
|
||||
console.log('++++ g called');
|
||||
return require('./groups/groups.module')['GroupsModule'];
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'user',
|
||||
loadChildren: () => {
|
||||
console.log('++++ u called');
|
||||
return require('./users/users.module')['UsersModule'];
|
||||
}
|
||||
},
|
||||
{ path: '', redirectTo: 'events', pathMatch: 'full' }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
NativeScriptRouterModule.forRoot(routes)
|
||||
],
|
||||
exports: [
|
||||
NativeScriptRouterModule
|
||||
],
|
||||
providers: [ AuthGuard ]
|
||||
})
|
||||
export class AppRoutingModule {}
|
|
@ -3,15 +3,14 @@ import { NativeScriptFormsModule } from "nativescript-angular/forms";
|
|||
import { NativeScriptRouterModule } from "nativescript-angular/router";
|
||||
import { SIDEDRAWER_DIRECTIVES } from 'nativescript-telerik-ui/sidedrawer/angular';
|
||||
import { NgModule } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
|
||||
import { AppComponent } from "./app.component";
|
||||
import { SettingsComponent } from './settings';
|
||||
import { appRoutes } from './app.routing';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
|
||||
import {
|
||||
EverliveProvider,
|
||||
UsersService,
|
||||
AuthGuard,
|
||||
PlatformService,
|
||||
AlertService,
|
||||
EventRegistrationsService,
|
||||
|
@ -30,13 +29,11 @@ import { SharedModule } from './shared';
|
|||
@NgModule({
|
||||
declarations: [
|
||||
SIDEDRAWER_DIRECTIVES,
|
||||
AppComponent,
|
||||
SettingsComponent
|
||||
AppComponent
|
||||
],
|
||||
providers: [
|
||||
EverliveProvider,
|
||||
UsersService,
|
||||
AuthGuard,
|
||||
PlatformService,
|
||||
AlertService,
|
||||
EventRegistrationsService,
|
||||
|
@ -50,13 +47,7 @@ import { SharedModule } from './shared';
|
|||
imports: [
|
||||
NativeScriptFormsModule,
|
||||
NativeScriptModule,
|
||||
NativeScriptRouterModule,
|
||||
NativeScriptRouterModule.forRoot(appRoutes),
|
||||
EventsModule,
|
||||
GroupsModule,
|
||||
UsersModule,
|
||||
SharedModule
|
||||
AppRoutingModule
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
import { Routes } from "@angular/router";
|
||||
import { AuthGuard } from './services';
|
||||
import { SettingsComponent } from './settings';
|
||||
|
||||
export const appRoutes: any = [
|
||||
{ path: '', redirectTo: 'settings', pathMatch: 'full' },
|
||||
{
|
||||
path: 'events',
|
||||
loadChildren: () => {
|
||||
let t = require('./events/events.module')['EventsModule'];
|
||||
console.log('++++ e called');
|
||||
return t;
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'groups',
|
||||
loadChildren: () => {
|
||||
let t = require('./groups/groups.module')['GroupsModule'];
|
||||
console.log('++++ g called');
|
||||
return t;
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'user',
|
||||
loadChildren: () => {
|
||||
let t = require('./users/users.module')['UsersModule'];
|
||||
console.log('++++ u called');
|
||||
return t;
|
||||
}
|
||||
},
|
||||
{ path: 'settings', canActivate: [ AuthGuard ], component: SettingsComponent },
|
||||
|
||||
// { path: 'user/login', component: LoginComponent },
|
||||
// { path: 'user/edit', canActivate: [ AuthGuardService ], component: EditUserComponent },
|
||||
// { path: 'user', canActivate: [ AuthGuardService ], component: UserDetailsComponent },
|
||||
|
||||
// { path: 'events', canActivate: [ AuthGuardService ], children: [
|
||||
// { path: '', component: EventsComponent },
|
||||
// { path: 'add', component: AddEventComponent },
|
||||
// { path: ':id', component: EventDetailsComponent },
|
||||
// { path: ':id/edit', component: EditEventComponent },
|
||||
// { path: ':id/participants', component: EventParticipantsComponent },
|
||||
// ]
|
||||
// },
|
||||
|
||||
// { path: 'groups', canActivate: [ AuthGuardService ], children: [
|
||||
// { path: '', component: GroupsComponent },
|
||||
// { path: 'add', component: AddGroupComponent },
|
||||
// { path: ':id', component: GroupDetailsComponent },
|
||||
// { path: ':id/edit', component: EditGroupComponent },
|
||||
// { path: ':id/events', component: GroupEventsComponent },
|
||||
// { path: ':id/members', component: GroupMembersComponent }
|
||||
// ]
|
||||
// }
|
||||
];
|
|
@ -58,10 +58,8 @@ export class EventDetailsComponent implements OnInit {
|
|||
this._page.actionBar.title = '';
|
||||
this._route.params.subscribe(p => {
|
||||
this._eventId = p['id'];
|
||||
console.log('ev id: ' + this._eventId);
|
||||
let event = this._eventsService.getById(this._eventId)
|
||||
.then((event) => {
|
||||
console.log('got ev: ' + JSON.stringify(this.event));
|
||||
this.event = event;
|
||||
this._page.actionBar.title = event.Name;
|
||||
this.isPastEvent = this._eventsService.isPastEvent(this.event);
|
||||
|
@ -69,10 +67,7 @@ export class EventDetailsComponent implements OnInit {
|
|||
this._updateCountsByDate();
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(`the err: ${JSON.stringify(err)}`);
|
||||
this._onError(err);
|
||||
});
|
||||
.catch(err => this._onError.bind(this));
|
||||
|
||||
let currentUser = this._usersService.currentUser()
|
||||
.then(currentUser => {
|
||||
|
@ -84,11 +79,7 @@ export class EventDetailsComponent implements OnInit {
|
|||
this.alreadyRegistered = this.registeredUsers.some(u => u.Id === this._currentUser.Id);
|
||||
this.remainingUsersCount = Math.max(0, this.registeredUsers.length - 3);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(`curr user + participants`);
|
||||
this._onError(err);
|
||||
return Promise.reject(err);
|
||||
});
|
||||
.catch(err => this._onError.bind(this));
|
||||
|
||||
let user = this._usersService.currentUser()
|
||||
.then(user => this._regsService.getUserRegistrationForEvent(this._eventId, user.Id))
|
||||
|
@ -143,10 +134,7 @@ export class EventDetailsComponent implements OnInit {
|
|||
this._alertsService.showModal(ctx, this._vcRef, AppModalComponent);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(`reg`);
|
||||
this._onError(err);
|
||||
});
|
||||
.catch(err => this._onError.bind(this));
|
||||
}
|
||||
|
||||
changeVote() {
|
||||
|
|
|
@ -14,14 +14,9 @@ import {
|
|||
} from './';
|
||||
|
||||
export const eventsRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
children: [
|
||||
{ path: '', canActivate: [AuthGuard], component: EventsComponent },
|
||||
{ path: 'add', component: AddEventComponent },
|
||||
{ path: ':id', component: EventDetailsComponent },
|
||||
{ path: ':id/edit', component: EditEventComponent },
|
||||
{ path: ':id/participants', component: EventParticipantsComponent },
|
||||
]
|
||||
}
|
||||
{ path: '', canActivate: [AuthGuard], component: EventsComponent },
|
||||
{ path: 'add', component: AddEventComponent },
|
||||
{ path: ':id', component: EventDetailsComponent },
|
||||
{ path: ':id/edit', component: EditEventComponent },
|
||||
{ path: ':id/participants', component: EventParticipantsComponent },
|
||||
];
|
||||
|
|
|
@ -12,10 +12,10 @@ import {
|
|||
} from './';
|
||||
|
||||
export const routes: Routes = [
|
||||
{ path: 'groups', component: GroupsComponent },
|
||||
{ path: 'groups/add', component: AddGroupComponent },
|
||||
{ path: 'groups/:id', component: GroupDetailsComponent },
|
||||
{ path: 'groups/:id/edit', component: EditGroupComponent },
|
||||
{ path: 'groups/:id/events', component: GroupEventsComponent },
|
||||
{ path: 'groups/:id/members', component: GroupMembersComponent }
|
||||
{ path: '', component: GroupsComponent },
|
||||
{ path: 'add', component: AddGroupComponent },
|
||||
{ path: ':id', component: GroupDetailsComponent },
|
||||
{ path: ':id/edit', component: EditGroupComponent },
|
||||
{ path: ':id/events', component: GroupEventsComponent },
|
||||
{ path: ':id/members', component: GroupMembersComponent }
|
||||
];
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
|
||||
import { NativeScriptFormsModule } from "nativescript-angular/forms";
|
||||
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
|
||||
|
||||
import { NativeScriptRouterModule } from "nativescript-angular/router";
|
||||
import { routes } from './settings.routing';
|
||||
import { SharedModule } from '../shared';
|
||||
|
||||
import {
|
||||
SettingsComponent
|
||||
} from './';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
NativeScriptModule,
|
||||
NativeScriptFormsModule,
|
||||
NativeScriptRouterModule.forChild(routes),
|
||||
SharedModule
|
||||
],
|
||||
declarations: [
|
||||
SettingsComponent
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
export class SettingsModule {}
|
|
@ -0,0 +1,6 @@
|
|||
import { Routes } from '@angular/router';
|
||||
import { SettingsComponent } from './';
|
||||
|
||||
export const routes: Routes = [
|
||||
{ path: '', component: SettingsComponent }
|
||||
];
|
|
@ -30,6 +30,7 @@ import {
|
|||
ListPickerModalComponent
|
||||
],
|
||||
exports: [
|
||||
AppModalComponent,
|
||||
PhotoPickerComponent,
|
||||
UserDisplayComponent,
|
||||
UsersListComponent
|
||||
|
|
Загрузка…
Ссылка в новой задаче