This commit is contained in:
Georgi Prodanov 2017-02-17 13:16:25 +02:00
Родитель ec624be19d
Коммит a2d6598d57
11 изменённых файлов: 77 добавлений и 35 удалений

Просмотреть файл

@ -39,6 +39,8 @@ export class AppComponent implements OnInit {
ngOnInit() {
this._routerExtensions.router.events.subscribe((ev) => {
if (ev instanceof NavigationEnd) {
console.log('navved to ' + ev.url);
this.disableDrawer = utilities.shouldDisableDrawer(ev.url);
this.drawer.sideDrawer.gesturesEnabled = !this.disableDrawer;
}

Просмотреть файл

@ -11,7 +11,7 @@ import { appRoutes } from './app.routing';
import {
EverliveProvider,
UsersService,
AuthGuardService,
AuthGuard,
PlatformService,
AlertService,
EventRegistrationsService,
@ -36,7 +36,7 @@ import { SharedModule } from './shared';
providers: [
EverliveProvider,
UsersService,
AuthGuardService,
AuthGuard,
PlatformService,
AlertService,
EventRegistrationsService,
@ -59,3 +59,4 @@ import { SharedModule } from './shared';
]
})
export class AppModule {}

Просмотреть файл

@ -1,10 +1,34 @@
import { Routes } from "@angular/router";
import { EverliveProvider, UsersService, AuthGuardService } from './services';
import { AuthGuard } from './services';
import { SettingsComponent } from './settings';
export const appRoutes: Routes = [
{ path: '', redirectTo: 'events', pathMatch: 'full' },
{ path: 'settings', canActivate: [ AuthGuardService ], component: SettingsComponent },
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 },

Просмотреть файл

@ -58,8 +58,10 @@ 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);
@ -67,7 +69,10 @@ export class EventDetailsComponent implements OnInit {
this._updateCountsByDate();
}
})
.catch(this._onError.bind(this));
.catch(err => {
console.log(`the err: ${JSON.stringify(err)}`);
this._onError(err);
});
let currentUser = this._usersService.currentUser()
.then(currentUser => {
@ -79,7 +84,11 @@ 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(this._onError.bind(this));
.catch(err => {
console.log(`curr user + participants`);
this._onError(err);
return Promise.reject(err);
});
let user = this._usersService.currentUser()
.then(user => this._regsService.getUserRegistrationForEvent(this._eventId, user.Id))
@ -134,7 +143,10 @@ export class EventDetailsComponent implements OnInit {
this._alertsService.showModal(ctx, this._vcRef, AppModalComponent);
}
})
.catch(this._onError.bind(this));
.catch(err => {
console.log(`reg`);
this._onError(err);
});
}
changeVote() {

Просмотреть файл

@ -2,7 +2,7 @@ import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptFormsModule } from "nativescript-angular/forms";
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { RouterModule } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { eventsRoutes } from './events.routing';
import { SharedModule } from '../shared';
@ -22,8 +22,8 @@ import {
imports: [
NativeScriptModule,
NativeScriptFormsModule,
SharedModule,
RouterModule.forChild(eventsRoutes)
NativeScriptRouterModule.forChild(eventsRoutes),
SharedModule
],
declarations: [
EventsComponent,

Просмотреть файл

@ -1,5 +1,5 @@
import { Routes } from "@angular/router";
import { AuthGuardService } from '../services';
import { AuthGuard } from '../services';
import {
EventsComponent,
@ -14,8 +14,10 @@ import {
} from './';
export const eventsRoutes: Routes = [
{ path: 'events', canActivate: [ AuthGuardService ], children: [
{ path: '', component: EventsComponent },
{
path: '',
children: [
{ path: '', canActivate: [AuthGuard], component: EventsComponent },
{ path: 'add', component: AddEventComponent },
{ path: ':id', component: EventDetailsComponent },
{ path: ':id/edit', component: EditEventComponent },

Просмотреть файл

@ -2,7 +2,8 @@ import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptFormsModule } from "nativescript-angular/forms";
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { RouterModule } from "@angular/router";
// import { RouterModule } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { routes } from './groups.routing';
import { SharedModule } from '../shared';
@ -22,7 +23,7 @@ import {
imports: [
NativeScriptModule,
NativeScriptFormsModule,
RouterModule.forChild(routes),
NativeScriptRouterModule.forChild(routes),
SharedModule
],
declarations: [
@ -41,4 +42,8 @@ import {
],
schemas: [NO_ERRORS_SCHEMA]
})
export class GroupsModule {}
export class GroupsModule {
constructor() {
console.log('groups module instantiated');
}
}

Просмотреть файл

@ -1,5 +1,4 @@
import { Routes } from "@angular/router";
import { EverliveProvider, UsersService, AuthGuardService } from '../services';
import {
GroupsComponent,
GroupListComponent,
@ -13,13 +12,10 @@ import {
} from './';
export const routes: Routes = [
{ 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 }
]
}
{ 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 }
];

Просмотреть файл

@ -5,7 +5,7 @@ import { RouterExtensions } from 'nativescript-angular/router';
import { UsersService } from './users.service';
@Injectable()
export class AuthGuardService implements CanActivate {
export class AuthGuard implements CanActivate {
constructor(
private _usersService: UsersService,
@ -23,6 +23,7 @@ export class AuthGuardService implements CanActivate {
return this._usersService.currentUser()
.then(u => {
let isLoggedIn = !!u;
// console.log('isLoggedIn ' + isLoggedIn);
if (!isLoggedIn) {
this._router.navigateByUrl('user/login');
}

Просмотреть файл

@ -2,7 +2,7 @@ import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptFormsModule } from "nativescript-angular/forms";
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { RouterModule } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { routes } from './users.routing';
import { SharedModule } from '../shared';
@ -17,7 +17,7 @@ import {
imports: [
NativeScriptModule,
NativeScriptFormsModule,
RouterModule.forChild(routes),
NativeScriptRouterModule.forChild(routes),
SharedModule
],
declarations: [

Просмотреть файл

@ -1,5 +1,4 @@
import { Routes } from "@angular/router";
import { EverliveProvider, UsersService, AuthGuardService } from '../services';
import {
UserDetailsComponent,
@ -9,7 +8,7 @@ import {
} from './';
export const routes: Routes = [
{ path: 'user/login', component: LoginComponent },
{ path: 'user/edit', canActivate: [ AuthGuardService ], component: EditUserComponent },
{ path: 'user', canActivate: [ AuthGuardService ], component: UserDetailsComponent },
{ path: 'login', component: LoginComponent },
{ path: 'edit', component: EditUserComponent },
{ path: '', component: UserDetailsComponent }
];