Merge branch 'master' into sivanov/styles

This commit is contained in:
stoyanvi 2017-02-07 11:13:25 +02:00
Родитель 05ca5c32f6 9fc9038b49
Коммит 8fdf2f58b8
11 изменённых файлов: 53 добавлений и 65 удалений

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

@ -104,3 +104,7 @@
background-size: cover;
background-position: -5 0;
}
.going-label {
margin-left: 5;
}

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

@ -62,7 +62,9 @@ export class EventDetailsComponent implements OnInit {
this.event = event;
this._page.actionBar.title = event.Name;
this.isPastEvent = this._eventsService.isPastEvent(this.event);
return this._updateCountsByDate();
if (!this.isPastEvent) {
this._updateCountsByDate();
}
})
.catch(this._onError.bind(this));

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

@ -70,14 +70,14 @@
<StackLayout class="info-wrapper">
<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 class="info-wrapper no-separator">
<Label class="info-label" text="Registered Participants"></Label>
<StackLayout *ngIf="registeredUsers.length > 0" (tap)="onParticipantsTap()" class="registered-users-wrapper" orientation="horizontal">
<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>
<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 _usersService: UsersService
) {}
@Input() events: Event[];
@Output() onEventTap: EventEmitter<any> = new EventEmitter<any>();
ngOnInit() {
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) {
this.onEventTap.emit(event);

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

@ -19,6 +19,7 @@ export class GroupDetailsComponent implements OnInit {
isAndroid: boolean = false;
iosPopupOpen: boolean = false;
private _currentUser: User;
private _disableJoinBtn: boolean = false;
constructor(
private _usersService: UsersService,
@ -46,7 +47,7 @@ export class GroupDetailsComponent implements OnInit {
this.group = group;
this._page.actionBar.title = this.group.Name;
});
// TODO: refactor :(
Promise.all<any>([userPrm, groupPrm])
.then(() => this._groupsService.getGroupMembers(this.group.Id))
.then(members => {
@ -57,12 +58,14 @@ export class GroupDetailsComponent implements OnInit {
let promise = Promise.resolve(false);
if (!this.hasJoined && p['joinRedirect']) { // join if its a join redirect
this._disableJoinBtn = true;
promise = this._groupsService.joinGroup(this.group.Id, this._currentUser.Id);
}
return promise;
})
.then((result) => {
this._disableJoinBtn = false;
if (result === false) { // was not a join redirect or was already a member
return;
}
@ -74,6 +77,7 @@ export class GroupDetailsComponent implements OnInit {
this._addCurrentUserAsRegistered();
})
.catch(err => {
this._disableJoinBtn = false;
this._alertsService.showError(err && err.message);
});;
});
@ -129,6 +133,11 @@ export class GroupDetailsComponent implements OnInit {
}
onJoin() {
if (this._disableJoinBtn) {
return;
}
this._disableJoinBtn = true;
this._groupsService.joinGroup(this.group.Id, this._currentUser.Id)
.then((resp) => {
if (this.group.RequiresApproval) {
@ -136,8 +145,10 @@ export class GroupDetailsComponent implements OnInit {
} else {
this._addCurrentUserAsRegistered();
}
this._disableJoinBtn = false;
})
.catch((err) => {
this._disableJoinBtn = false;
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>
<GridLayout *ngIf="hasJoined === true" class="action-bar" [ngClass]="{ 'admin': !canEdit() }" [attr.columns]="canEdit() ? '*, *, *' : '*, *'">
<StackLayout *ngIf="canEdit()" class="btn" (tap)="onViewRequests()" col="0">
<GridLayout *ngIf="hasJoined === true" class="action-bar" [ngClass]="{ 'admin': !canEdit() }" [attr.columns]="(canEdit() && group.RequiresApproval) ? '*, *, *' : '*, *'">
<StackLayout *ngIf="group.RequiresApproval && canEdit()" class="btn" (tap)="onViewRequests()" col="0">
<Label class="btn-icon if" text="&#x6d;"></Label>
<Label class="btn-text" text="See requests"></Label>
</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="&#x6b;"></Label>
<Label class="btn-text" text="See Events"></Label>
</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="&#x76;"></Label>
<Label class="btn-text" text="Leave Group"></Label>
</StackLayout>

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

@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { Data } from '../../node_modules/everlive-sdk/dist/declarations/everlive/types/Data';
import { EverliveProvider } from './everlive-provider.service';
import { EventRegistration } from '../shared/models';
import { EventRegistration, User } from '../shared/models';
@Injectable()
export class EventRegistrationsService {
@ -38,7 +38,11 @@ export class EventRegistrationsService {
query.where().eq('EventId', eventId);
query.expand(this._expandUserExpression);
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) {

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

@ -109,7 +109,11 @@ export class GroupsService {
let query = this._elProvider.getNewQuery();
query.where({ GroupId: groupId });
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>
@ -174,6 +178,7 @@ export class GroupsService {
} else {
if (r.result > 1) {
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' });
}

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

@ -3,6 +3,7 @@ import { RouterExtensions } from 'nativescript-angular/router';
import { EverliveProvider } from './everlive-provider.service';
import { PlatformService } from './platform.service';
import { AlertService } from './alert.service';
import { utilities, constants } from '../shared';
@Injectable()
@ -10,7 +11,8 @@ export class PushNotificationsService {
constructor(
private _everlive: EverliveProvider,
private _router: RouterExtensions,
private _platform: PlatformService
private _platform: PlatformService,
private _alertsService: AlertService
) {}
private get data() {
@ -18,59 +20,18 @@ export class PushNotificationsService {
}
private pushCb(...args) {
// let eventId = args[0].eventId;
console.log('args: ' + JSON.stringify(args));
// this._alertsService.showSuccess('got push' + JSON.stringify(args));
}
subscribe(userId: string) {
let pushRegSettings = {
iOS: { badge: true, sound: true, alert: true, notificationCallbackIOS: this.pushCb.bind(this) },
android: { senderID: constants.androidProjNumber }
iOS: { badge: true, sound: true, alert: true },
android: { senderID: constants.androidProjNumber },
notificationCallbackIOS: this.pushCb.bind(this),
notificationCallbackAndroid: this.pushCb.bind(this)
};
let useSettings: any;
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);
return this._everlive.get.push.register(pushRegSettings);
}
}

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

@ -1,7 +1,8 @@
<WrapLayout class="list-wrapper">
<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]="'&#x6c;'"></photo-picker>
<Label *ngIf="showNames" class="user-name" [text]="user.DisplayName || user.Username"></Label>
<photo-picker *ngIf="user && showImage(ind)" class="user-image" [url]="user.ImageUrl" [type]="'user'" [small]="true" [noImageIcon]="'&#x6c;'"></photo-picker>
<Label *ngIf="user && showNames" class="user-name" [text]="user.DisplayName || user.Username"></Label>
<Label *ngIf="!user" text="Unknown User"></Label>
</StackLayout>
<Label class="remaining-users" *ngIf="hasRemainingLabel()" [text]="getRemainingText()"></Label>
</WrapLayout>

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

@ -25,7 +25,7 @@
"nativescript-angular": "1.1.0",
"nativescript-imagepicker": "^2.4.1",
"nativescript-permissions": "^1.2.0",
"nativescript-push-notifications": "0.1.0",
"nativescript-push-notifications": "0.1.1",
"nativescript-telerik-ui": "^1.4.1",
"nativescript-theme-core": "^0.1.3",
"reflect-metadata": "~0.1.8",