Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { HttpClientModule, HttpClient } from '@angular/common/http';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
import { i18nData } from './assets/i18n-en';
import { AppConfigModule } from '../shared/app-config/app-config.module';
import { TranslationModule } from '../shared/translation/translation.module';
import { MomentModule } from 'angular2-moment';
import { WindowRef } from '../shared/window';
Expand Down Expand Up @@ -63,7 +64,7 @@ import { EventsListPage } from '../pages/events/list/list.page';
import { EventsPreviewPage } from '../pages/events/download/events-preview.page';
import { EventsViewPage } from '../pages/events/view/events-view.page';
import { ForgetPasswordPage } from '../pages/forget-password/forget-password';
import { GalleryPage } from '../pages/gallery/gallery';
import { GalleryPage } from '../pages/gallery/gallery.page';
import { ItemsPopupPage } from '../pages/assessments/popup/items-popup.page';
import { LeaderboardSettingsPage } from '../pages/settings/leaderboard/leaderboard-settings.page';
import { LevelsListPage } from '../pages/levels/list/list';
Expand All @@ -77,7 +78,7 @@ import { ResetPasswordPage } from '../pages/reset-password/reset-password';
import { SettingsPage } from '../pages/settings/settings.page';
import { SidenavPage } from '../pages/sidenav/sidenav';
import { TabsPage } from '../pages/tabs/tabs.page';
import { TeamPage } from '../pages/team/team';
import { TeamPage } from '../pages/team/team.page';
import { TermsConditionsPage } from '../pages/registration/terms-conditions/terms-conditions.page';
import { TestPage } from '../pages/tabs/test.page';
import { TutorialPage } from '../pages/settings/tutorial/tutorial.page';
Expand Down Expand Up @@ -147,6 +148,7 @@ export function createTranslateLoader(http: HttpClient) {
EscapeHtmlPipe,
],
imports: [
AppConfigModule,
BrowserModule,
CacheModule,
FormsModule,
Expand Down
4 changes: 0 additions & 4 deletions src/pages/events/list/list.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ export class EventsListPage {

return result;
}
// Check event allow to check-in
allowCheckIn(event) {
return (moment(event.start).isAfter() && moment(event.end).isBefore());
}

view(event) {
this.navCtrl.push(EventsViewPage, {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/events/view/events-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{{ 'EVENTS.BOOK' | translate }}
</button>

<button ion-button *ngIf="event.isBooked && allowCheckIn(event)" class="checkin-btn" (click)="checkin(event)">
<button ion-button *ngIf="event.isBooked && hasReference(event) && allowCheckIn(event)" class="checkin-btn" (click)="checkin(event)">
<span *ngIf="completedSubmissions">
{{ 'EVENTS.VIEWCHECKIN' | translate }}
</span>
Expand All @@ -52,7 +52,7 @@
</span>
</button>

<button ion-button *ngIf="!completedSubmissions && !event.isAttended && event.isBooked && allowCheckIn(event)" class="cancel-btn" outline (click)="cancelBooking(event)">
<button ion-button *ngIf="!completedSubmissions && !event.isAttended && event.isBooked && hasReference(event) && allowCheckIn(event)" class="cancel-btn" outline (click)="cancelBooking(event)">
{{ 'EVENTS.CANCELBOOKING' | translate }}
</button>
</ion-buttons>
Expand Down
12 changes: 10 additions & 2 deletions src/pages/events/view/events-view.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,24 @@ export class EventsViewPage {
/**
* @note existence of References array determines if an event is
* a checkin type
* @description examine event to allow check in
* @description examine event contain reference, because we need context ID
* @param {Object} event
*/
allowCheckIn(event) {
hasReference(event) {
if (event.References && event.References.length > 0) {
return true;
}
return false;
}

/**
* @description examine event to allow check in
* @param {Object} event
*/
allowCheckIn(event) {
return moment().isAfter(moment(event.start));
}

/**
* Event checkin action
* @param {Object} event single event object return from get_event API
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions src/pages/spinwheel/celebration.html

This file was deleted.

8 changes: 0 additions & 8 deletions src/pages/spinwheel/celebration.page.ts

This file was deleted.

7 changes: 1 addition & 6 deletions src/pages/tabs/tabs.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<ion-tabs>
<ion-tab tabsHideOnSubPages="true" [root]="dashboard" tabTitle=" {{ 'TABS.DASHBOARD' | translate }}" tabIcon="md-list-box"></ion-tab>
<ion-tab tabsHideOnSubPages="true" [root]="events" tabTitle=" {{ 'TABS.EVENTS' | translate }}" tabIcon="md-calendar"></ion-tab>
<ion-tab tabsHideOnSubPages="true" [root]="ranking" tabTitle=" {{ 'TABS.RANKING' | translate }}" tabIcon="md-medal"></ion-tab>
<ion-tab tabsHideOnSubPages="true" [root]="settings" tabTitle=" {{ 'TABS.ACCOUNT' | translate }}" tabIcon="md-person"></ion-tab>
<ion-tab *ngFor="let tab of tabs" tabsHideOnSubPages="true" [root]="tab.root" tabTitle=" {{ tab.title | translate }}" tabIcon="{{tab.icon}}"></ion-tab>
</ion-tabs>



20 changes: 12 additions & 8 deletions src/pages/tabs/tabs.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { Component } from '@angular/core';

// Pages
import { ActivitiesListPage } from '../activities/list/list.page';
import { RankingsPage } from '../rankings/list/rankings.page';
import { SettingsPage } from '../settings/settings.page';
import { TestPage } from './test.page';
import { EventsListPage } from '../events/list/list.page';
// Others
import { AppConfigService } from '../../shared/app-config/app-config.service';
import { TranslationService } from '../../shared/translation/translation.service';

@Component({
Expand All @@ -16,13 +13,20 @@ import { TranslationService } from '../../shared/translation/translation.service
export class TabsPage {
// this tells the tabs component which Pages
// should be each tab's root Page
ranking: any = RankingsPage;
// ranking: any = TestPage;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @imkven, do we need to remove this commented code?


// We need hardcode at least one tab menu,
// otherwise any misconfigure will break
dashboard: any = ActivitiesListPage;
settings: any = SettingsPage;
events: any = EventsListPage;
tabs: any = [];

constructor(
public appConfig: AppConfigService,
public translationService: TranslationService
) {}

ionViewWillEnter() {
this.appConfig.getTabs().then(modules => {
this.tabs = modules;
});
}
}
File renamed without changes.
51 changes: 40 additions & 11 deletions src/services/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,46 @@ import * as moment from 'moment';
@Injectable()
export class EventService {
bookEventUrl = 'api/book_events.json';
targetUrl = 'api/events.json';

constructor(
public cache: CacheService,
public request: RequestService
) {}

getEvents(options: object = {}) {
return this.request.get('api/events.json', {
search: _.merge({ type: 'session' }, options)
})
.map(this._normalise)
.toPromise();
}

/**
* @description Normalise event
* @param {[events]} events data from API
*/
_normalise(events) {
_.forEach(events, (event, idx) => {
events[idx].isAttended = (event.isBooked === true && moment().isAfter(moment(event.end)));
// We assume server datetime response is UTC...
events[idx].startDisplay = moment.utc(event.start).local().format("dddd, MMM D [at] h:mm A");
events[idx].startDisplayDate = moment.utc(event.start).local().format("dddd, MMM D");
events[idx].startDisplayTime = moment.utc(event.start).local().format("h:mm A");
events[idx].endDisplay = moment.utc(event.end).local().format("dddd, MMM D [at] h:mm A");
events[idx].endDisplayDate = moment.utc(event.end).local().format("dddd, MMM D");
events[idx].endDisplayTime = moment.utc(event.end).local().format("h:mm A");
});

return events;
}

/**
* download attachment by single event object
* @description Get events data
* @param {object} options
*/
getEvents(options: object = {}) {
return this.request.get(this.targetUrl, {
search: _.merge({ type: 'session' }, options)
})
.map(this._normalise)
.toPromise();
}

/**
* @description download attachment by single event object
* @param {[type]} event [description]
*/

Expand All @@ -47,14 +61,29 @@ export class EventService {
}

/**
* get event using observable
* @description get event using observable
* @param {integer} eventId single event id
*/

bookEvent(eventId) {
return this.request.post(this.bookEventUrl, { event_id: eventId});
}

cancelEventBooking(eventId){
/**
* @description cancel booked event
* @param {integer} eventId single event id
*/

cancelEventBooking(eventId) {
return this.request.delete(this.bookEventUrl + '?event_id=' + eventId);
}

/**
* @description Get session events
* @param {[integer]} activityIDs
*/

getUserEvents(activityIDs) {
return this.request.get(this.targetUrl+`?type=session&activity_id=[${activityIDs}]`);
}
}
6 changes: 6 additions & 0 deletions src/shared/app-config/app-config.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { NgModule } from '@angular/core';
import { AppConfigService } from './app-config.service';
@NgModule({
providers: [ AppConfigService ]
})
export class AppConfigModule {}
75 changes: 75 additions & 0 deletions src/shared/app-config/app-config.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Injectable } from '@angular/core';

// Pages
import { EventsListPage } from '../../pages/events/list/list.page';
import { GalleryPage } from '../../pages/gallery/gallery.page';
import { LevelsPage } from '../../pages/levels/list/list.page';
import { RankingsPage } from '../../pages/rankings/list/rankings.page';
import { SettingsPage } from '../../pages/settings/settings.page';
import { TeamPage } from '../../pages/team/team.page';

// Others
import * as _ from 'lodash';

@Injectable()
export class AppConfigService {
// Mapping page to name,
// use for changing page in tab menu
pagesMap: any = {
events: EventsListPage,
rankings: RankingsPage,
settings: SettingsPage,
gallery: GalleryPage,
team: TeamPage
}

// JSON format sent back from server
appConfigContent: any = {
app: {
name: 'ISDK'
},
tabs: {
events: {
name: 'events',
title: 'Events',
icon: 'md-calendar',
order: 1
},
rankings: {
name: 'rankings',
title: 'Rankings',
icon: 'md-medal',
order: 2
},
settings: {
name: 'settings',
title: 'Settings',
icon: 'md-person',
order: 3
}
}
};

/**
* @description Get raw configure data from server
*/
get(): Promise<any> {
return new Promise((resolve, reject) => {
resolve(this.appConfigContent);
});
}

/**
* @description Get only configure for tabs
*/
getTabs(): Promise<any> {
return this.get().then((data: any) => {
return _.sortBy(data.tabs, [(o) => o.order]);
}).then((data: any) => {
return _.map(data, (o) => {
o.root = this.pagesMap[o.name];
return o;
});
});
}
}
6 changes: 3 additions & 3 deletions src/shared/request/request.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ export class RequestService {
let apiKey = this.cacheService.getCached('apikey') ||
this.cacheService.getLocal('apikey');
if (!_.isEmpty(apiKey)) {
result = result.set('apikey', apiKey.toString());
result = result.set('apikey', _.toString(apiKey));
}
// Inject timelineID from cached
let timelineId = this.cacheService.getCached('timelineID') ||
this.cacheService.getLocal('timelineID');
if (timelineId) {
result = result.set('timelineID', timelineId.toString());
result = result.set('timelineID', _.toString(timelineId));
}
return result;
}
Expand All @@ -100,7 +100,7 @@ export class RequestService {
let params = (options && options.params) ? options.params : new HttpParams();
if (options && options.search) {
_.each(options.search, (value, key) => {
params = params.set(key, value.toString());
params = params.set(key, _.toString(value));
});
}
let timelineId = this.cacheService.getLocal('timelineID');
Expand Down
9 changes: 2 additions & 7 deletions src/shared/testModules/pages/test/test-start.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ import { AssessmentsGroupPage } from '../../../../pages/assessments/group/assess
import { ActivitiesListPage } from '../../../../pages/activities/list/list.page';
import { EventsListPage } from '../../../../pages/events/list/list.page';
import { EventsDownloadPage } from '../../../../pages/events/download/events-download.page';
import { GalleryPage } from '../../../../pages/gallery/gallery';
import { GalleryPage } from '../../../../pages/gallery/gallery.page';
import { LevelsListPage } from '../../../../pages/levels/list/list';
import { LoginPage } from '../../../../pages/login/login';
import { RegisterPage } from '../../../../pages/registration/register.page';
import { SettingsPage } from '../../../../pages/settings/settings.page';
import { EventCheckinPage } from '../../../../pages/events/checkin/event-checkin.page';
import { TeamPage } from '../../../../pages/team/team';
import { CelebrationPage } from '../../../../pages/spinwheel/celebration.page';
import { TeamPage } from '../../../../pages/team/team.page';

const PAGES = [
{
name: 'celebration',
page: CelebrationPage
},
{
name: 'Check-in',
page: EventCheckinPage,
Expand Down