Merge branch 'master' into sivanov/styles
This commit is contained in:
Коммит
8fdf2f58b8
|
@ -104,3 +104,7 @@
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-position: -5 0;
|
background-position: -5 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.going-label {
|
||||||
|
margin-left: 5;
|
||||||
|
}
|
||||||
|
|
|
@ -62,7 +62,9 @@ export class EventDetailsComponent implements OnInit {
|
||||||
this.event = event;
|
this.event = event;
|
||||||
this._page.actionBar.title = event.Name;
|
this._page.actionBar.title = event.Name;
|
||||||
this.isPastEvent = this._eventsService.isPastEvent(this.event);
|
this.isPastEvent = this._eventsService.isPastEvent(this.event);
|
||||||
return this._updateCountsByDate();
|
if (!this.isPastEvent) {
|
||||||
|
this._updateCountsByDate();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(this._onError.bind(this));
|
.catch(this._onError.bind(this));
|
||||||
|
|
||||||
|
|
|
@ -70,14 +70,14 @@
|
||||||
|
|
||||||
<StackLayout class="info-wrapper">
|
<StackLayout class="info-wrapper">
|
||||||
<Label class="info-label" text="Organizer"></Label>
|
<Label class="info-label" text="Organizer"></Label>
|
||||||
<Label class="info-value" [text]="event.Organizer.DisplayName || event.Organizer.Username"></Label>
|
<user-display [users]="event.Organizer" [showNames]="true"></user-display>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
|
||||||
<StackLayout class="info-wrapper no-separator">
|
<StackLayout class="info-wrapper no-separator">
|
||||||
<Label class="info-label" text="Registered Participants"></Label>
|
<Label class="info-label" text="Registered Participants"></Label>
|
||||||
<StackLayout *ngIf="registeredUsers.length > 0" (tap)="onParticipantsTap()" class="registered-users-wrapper" orientation="horizontal">
|
<StackLayout *ngIf="registeredUsers.length > 0" (tap)="onParticipantsTap()" class="registered-users-wrapper" orientation="horizontal">
|
||||||
<user-display [users]="registeredUsers" [withImages]="3"></user-display>
|
<user-display [users]="registeredUsers" [withImages]="3"></user-display>
|
||||||
<Label class="info-value" [text]="(registeredUsers.length === 1 ? 'is' : 'are') + ' going'"></Label>
|
<Label class="info-value going-label" [text]="(registeredUsers.length === 1 ? 'is' : 'are') + ' going'"></Label>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
|
||||||
<Label class="info-value" *ngIf="registeredUsers.length === 0" [text]="'No one has registered for this event.'"></Label>
|
<Label class="info-value" *ngIf="registeredUsers.length === 0" [text]="'No one has registered for this event.'"></Label>
|
||||||
|
|
|
@ -17,6 +17,9 @@ export class EventListComponent implements OnInit {
|
||||||
private _regsService: EventRegistrationsService,
|
private _regsService: EventRegistrationsService,
|
||||||
private _usersService: UsersService
|
private _usersService: UsersService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@Input() events: Event[];
|
||||||
|
@Output() onEventTap: EventEmitter<any> = new EventEmitter<any>();
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this._usersService.currentUser()
|
this._usersService.currentUser()
|
||||||
|
@ -27,9 +30,6 @@ export class EventListComponent implements OnInit {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Input() events: Event[];
|
|
||||||
@Output() onEventTap: EventEmitter<any> = new EventEmitter<any>();
|
|
||||||
|
|
||||||
eventTap(event: Event) {
|
eventTap(event: Event) {
|
||||||
this.onEventTap.emit(event);
|
this.onEventTap.emit(event);
|
||||||
|
|
|
@ -19,6 +19,7 @@ export class GroupDetailsComponent implements OnInit {
|
||||||
isAndroid: boolean = false;
|
isAndroid: boolean = false;
|
||||||
iosPopupOpen: boolean = false;
|
iosPopupOpen: boolean = false;
|
||||||
private _currentUser: User;
|
private _currentUser: User;
|
||||||
|
private _disableJoinBtn: boolean = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _usersService: UsersService,
|
private _usersService: UsersService,
|
||||||
|
@ -46,7 +47,7 @@ export class GroupDetailsComponent implements OnInit {
|
||||||
this.group = group;
|
this.group = group;
|
||||||
this._page.actionBar.title = this.group.Name;
|
this._page.actionBar.title = this.group.Name;
|
||||||
});
|
});
|
||||||
|
// TODO: refactor :(
|
||||||
Promise.all<any>([userPrm, groupPrm])
|
Promise.all<any>([userPrm, groupPrm])
|
||||||
.then(() => this._groupsService.getGroupMembers(this.group.Id))
|
.then(() => this._groupsService.getGroupMembers(this.group.Id))
|
||||||
.then(members => {
|
.then(members => {
|
||||||
|
@ -57,12 +58,14 @@ export class GroupDetailsComponent implements OnInit {
|
||||||
let promise = Promise.resolve(false);
|
let promise = Promise.resolve(false);
|
||||||
|
|
||||||
if (!this.hasJoined && p['joinRedirect']) { // join if its a join redirect
|
if (!this.hasJoined && p['joinRedirect']) { // join if its a join redirect
|
||||||
|
this._disableJoinBtn = true;
|
||||||
promise = this._groupsService.joinGroup(this.group.Id, this._currentUser.Id);
|
promise = this._groupsService.joinGroup(this.group.Id, this._currentUser.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
this._disableJoinBtn = false;
|
||||||
if (result === false) { // was not a join redirect or was already a member
|
if (result === false) { // was not a join redirect or was already a member
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +77,7 @@ export class GroupDetailsComponent implements OnInit {
|
||||||
this._addCurrentUserAsRegistered();
|
this._addCurrentUserAsRegistered();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
this._disableJoinBtn = false;
|
||||||
this._alertsService.showError(err && err.message);
|
this._alertsService.showError(err && err.message);
|
||||||
});;
|
});;
|
||||||
});
|
});
|
||||||
|
@ -129,6 +133,11 @@ export class GroupDetailsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
onJoin() {
|
onJoin() {
|
||||||
|
if (this._disableJoinBtn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._disableJoinBtn = true;
|
||||||
this._groupsService.joinGroup(this.group.Id, this._currentUser.Id)
|
this._groupsService.joinGroup(this.group.Id, this._currentUser.Id)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (this.group.RequiresApproval) {
|
if (this.group.RequiresApproval) {
|
||||||
|
@ -136,8 +145,10 @@ export class GroupDetailsComponent implements OnInit {
|
||||||
} else {
|
} else {
|
||||||
this._addCurrentUserAsRegistered();
|
this._addCurrentUserAsRegistered();
|
||||||
}
|
}
|
||||||
|
this._disableJoinBtn = false;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
this._disableJoinBtn = false;
|
||||||
this._alertsService.showError(err && err.message);
|
this._alertsService.showError(err && err.message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,16 +23,16 @@
|
||||||
|
|
||||||
<Label class="btn btn-primary join-group" *ngIf="hasJoined === false" [text]="getJoinBtnText()" (tap)="onJoin()"></Label>
|
<Label class="btn btn-primary join-group" *ngIf="hasJoined === false" [text]="getJoinBtnText()" (tap)="onJoin()"></Label>
|
||||||
|
|
||||||
<GridLayout *ngIf="hasJoined === true" class="action-bar" [ngClass]="{ 'admin': !canEdit() }" [attr.columns]="canEdit() ? '*, *, *' : '*, *'">
|
<GridLayout *ngIf="hasJoined === true" class="action-bar" [ngClass]="{ 'admin': !canEdit() }" [attr.columns]="(canEdit() && group.RequiresApproval) ? '*, *, *' : '*, *'">
|
||||||
<StackLayout *ngIf="canEdit()" class="btn" (tap)="onViewRequests()" col="0">
|
<StackLayout *ngIf="group.RequiresApproval && canEdit()" class="btn" (tap)="onViewRequests()" col="0">
|
||||||
<Label class="btn-icon if" text="m"></Label>
|
<Label class="btn-icon if" text="m"></Label>
|
||||||
<Label class="btn-text" text="See requests"></Label>
|
<Label class="btn-text" text="See requests"></Label>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<StackLayout class="btn" (tap)="onViewEvents()" [attr.col]="canEdit() ? 1 : 0">
|
<StackLayout class="btn" (tap)="onViewEvents()" [attr.col]="(canEdit() && group.RequiresApproval) ? 1 : 0">
|
||||||
<Label class="btn-icon if" text="k"></Label>
|
<Label class="btn-icon if" text="k"></Label>
|
||||||
<Label class="btn-text" text="See Events"></Label>
|
<Label class="btn-text" text="See Events"></Label>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<StackLayout class="btn" (tap)="onLeave()" [attr.col]="canEdit() ? 2 : 1">
|
<StackLayout class="btn" (tap)="onLeave()" [attr.col]="(canEdit() && group.RequiresApproval) ? 2 : 1">
|
||||||
<Label class="btn-icon if" text="v"></Label>
|
<Label class="btn-icon if" text="v"></Label>
|
||||||
<Label class="btn-text" text="Leave Group"></Label>
|
<Label class="btn-text" text="Leave Group"></Label>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { Data } from '../../node_modules/everlive-sdk/dist/declarations/everlive/types/Data';
|
import { Data } from '../../node_modules/everlive-sdk/dist/declarations/everlive/types/Data';
|
||||||
|
|
||||||
import { EverliveProvider } from './everlive-provider.service';
|
import { EverliveProvider } from './everlive-provider.service';
|
||||||
import { EventRegistration } from '../shared/models';
|
import { EventRegistration, User } from '../shared/models';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class EventRegistrationsService {
|
export class EventRegistrationsService {
|
||||||
|
@ -38,7 +38,11 @@ export class EventRegistrationsService {
|
||||||
query.where().eq('EventId', eventId);
|
query.where().eq('EventId', eventId);
|
||||||
query.expand(this._expandUserExpression);
|
query.expand(this._expandUserExpression);
|
||||||
query.select('User');
|
query.select('User');
|
||||||
return this._data.get(query).then(r => r.result.map(r => r.User));
|
return this._data.get(query).then(resp => {
|
||||||
|
let result: User[] = [];
|
||||||
|
resp.result.forEach(r => r.User && result.push(r.User));
|
||||||
|
return result;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getEventDateChoiceCounts(eventId: string) {
|
getEventDateChoiceCounts(eventId: string) {
|
||||||
|
|
|
@ -109,7 +109,11 @@ export class GroupsService {
|
||||||
let query = this._elProvider.getNewQuery();
|
let query = this._elProvider.getNewQuery();
|
||||||
query.where({ GroupId: groupId });
|
query.where({ GroupId: groupId });
|
||||||
query.expand(this._expandUserInMembership);
|
query.expand(this._expandUserInMembership);
|
||||||
return this._membershipsData.get(query).then(r => r.result.map(gm => gm.User));
|
return this._membershipsData.get(query).then(resp => {
|
||||||
|
let result: User[] = [];
|
||||||
|
resp.result.forEach(gm => gm.User && result.push(gm.User));
|
||||||
|
return result;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isUserAMember(userId: string, groupId: string): Promise<boolean>
|
isUserAMember(userId: string, groupId: string): Promise<boolean>
|
||||||
|
@ -174,6 +178,7 @@ export class GroupsService {
|
||||||
} else {
|
} else {
|
||||||
if (r.result > 1) {
|
if (r.result > 1) {
|
||||||
console.log('Deleted more than one registration - cant be good');
|
console.log('Deleted more than one registration - cant be good');
|
||||||
|
console.log('resp: ' + JSON.stringify(r));
|
||||||
}
|
}
|
||||||
return Promise.reject({ message: 'You are not part of this group' });
|
return Promise.reject({ message: 'You are not part of this group' });
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { RouterExtensions } from 'nativescript-angular/router';
|
||||||
|
|
||||||
import { EverliveProvider } from './everlive-provider.service';
|
import { EverliveProvider } from './everlive-provider.service';
|
||||||
import { PlatformService } from './platform.service';
|
import { PlatformService } from './platform.service';
|
||||||
|
import { AlertService } from './alert.service';
|
||||||
import { utilities, constants } from '../shared';
|
import { utilities, constants } from '../shared';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -10,7 +11,8 @@ export class PushNotificationsService {
|
||||||
constructor(
|
constructor(
|
||||||
private _everlive: EverliveProvider,
|
private _everlive: EverliveProvider,
|
||||||
private _router: RouterExtensions,
|
private _router: RouterExtensions,
|
||||||
private _platform: PlatformService
|
private _platform: PlatformService,
|
||||||
|
private _alertsService: AlertService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
private get data() {
|
private get data() {
|
||||||
|
@ -18,59 +20,18 @@ export class PushNotificationsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private pushCb(...args) {
|
private pushCb(...args) {
|
||||||
// let eventId = args[0].eventId;
|
|
||||||
console.log('args: ' + JSON.stringify(args));
|
console.log('args: ' + JSON.stringify(args));
|
||||||
|
// this._alertsService.showSuccess('got push' + JSON.stringify(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribe(userId: string) {
|
subscribe(userId: string) {
|
||||||
let pushRegSettings = {
|
let pushRegSettings = {
|
||||||
iOS: { badge: true, sound: true, alert: true, notificationCallbackIOS: this.pushCb.bind(this) },
|
iOS: { badge: true, sound: true, alert: true },
|
||||||
android: { senderID: constants.androidProjNumber }
|
android: { senderID: constants.androidProjNumber },
|
||||||
|
notificationCallbackIOS: this.pushCb.bind(this),
|
||||||
|
notificationCallbackAndroid: this.pushCb.bind(this)
|
||||||
};
|
};
|
||||||
|
|
||||||
let useSettings: any;
|
return this._everlive.get.push.register(pushRegSettings);
|
||||||
var pushPlugin = require('nativescript-push-notifications');
|
|
||||||
|
|
||||||
if (this._platform.isAndroid) {
|
|
||||||
useSettings = pushRegSettings.android;
|
|
||||||
pushPlugin.onMessageReceived(this.pushCb.bind(this));
|
|
||||||
} else {
|
|
||||||
useSettings = pushRegSettings.iOS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise<any>((resolve, reject) => {
|
|
||||||
pushPlugin.register(useSettings, (token) => {
|
|
||||||
this._createDeviceReg(token, userId)
|
|
||||||
.then(res => resolve(res))
|
|
||||||
.catch((err) => {
|
|
||||||
if (err.code !== 601) {
|
|
||||||
return reject(err);
|
|
||||||
}
|
|
||||||
let regOpts: any = {
|
|
||||||
// authHeaders: true,
|
|
||||||
method: 'PUT',
|
|
||||||
data: { UserId: userId },
|
|
||||||
endpoint: `Push/Devices/HardwareId/${this._platform.deviceId}`
|
|
||||||
};
|
|
||||||
|
|
||||||
return this._everlive.makeRequest(regOpts);
|
|
||||||
})
|
|
||||||
.then(resolve)
|
|
||||||
.catch(reject);
|
|
||||||
}, reject);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private _createDeviceReg(token: string, userId: string) {
|
|
||||||
let data = {
|
|
||||||
HardwareId: this._platform.deviceId,
|
|
||||||
HardwareModel: this._platform.deviceModel,
|
|
||||||
PushToken: token,
|
|
||||||
Locale: 'en_US',
|
|
||||||
TimeZone: 'Europe/Sofia',
|
|
||||||
PlatformType: this._platform.isAndroid ? 3 : 4,
|
|
||||||
PlatformVersion: this._platform.osVersion
|
|
||||||
};
|
|
||||||
return this.data.devices.create(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<WrapLayout class="list-wrapper">
|
<WrapLayout class="list-wrapper">
|
||||||
<StackLayout orientation="horizontal" *ngFor="let user of users; let ind = index">
|
<StackLayout orientation="horizontal" *ngFor="let user of users; let ind = index">
|
||||||
<photo-picker *ngIf="showImage(ind)" class="user-image" [url]="user.ImageUrl" [type]="'user'" [small]="true" [noImageIcon]="'l'"></photo-picker>
|
<photo-picker *ngIf="user && showImage(ind)" class="user-image" [url]="user.ImageUrl" [type]="'user'" [small]="true" [noImageIcon]="'l'"></photo-picker>
|
||||||
<Label *ngIf="showNames" class="user-name" [text]="user.DisplayName || user.Username"></Label>
|
<Label *ngIf="user && showNames" class="user-name" [text]="user.DisplayName || user.Username"></Label>
|
||||||
|
<Label *ngIf="!user" text="Unknown User"></Label>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<Label class="remaining-users" *ngIf="hasRemainingLabel()" [text]="getRemainingText()"></Label>
|
<Label class="remaining-users" *ngIf="hasRemainingLabel()" [text]="getRemainingText()"></Label>
|
||||||
</WrapLayout>
|
</WrapLayout>
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
"nativescript-angular": "1.1.0",
|
"nativescript-angular": "1.1.0",
|
||||||
"nativescript-imagepicker": "^2.4.1",
|
"nativescript-imagepicker": "^2.4.1",
|
||||||
"nativescript-permissions": "^1.2.0",
|
"nativescript-permissions": "^1.2.0",
|
||||||
"nativescript-push-notifications": "0.1.0",
|
"nativescript-push-notifications": "0.1.1",
|
||||||
"nativescript-telerik-ui": "^1.4.1",
|
"nativescript-telerik-ui": "^1.4.1",
|
||||||
"nativescript-theme-core": "^0.1.3",
|
"nativescript-theme-core": "^0.1.3",
|
||||||
"reflect-metadata": "~0.1.8",
|
"reflect-metadata": "~0.1.8",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче