From b7462e22c8504bdf45191ffaa098f752def9e4e0 Mon Sep 17 00:00:00 2001 From: Georgi Prodanov Date: Tue, 3 Jan 2017 16:19:32 +0200 Subject: [PATCH] Refactoring. --- README.md | 87 +++++++++++++++++++ app/app.component.ts | 1 - .../event-details/event-details.component.css | 4 +- .../event-details/event-details.component.ts | 12 ++- .../event-details/event-details.template.html | 2 +- .../upcoming-events.component.ts | 6 +- .../upcoming-events.template.html | 2 +- app/login/login.component.ts | 5 +- app/services/event-registrations.service.ts | 3 +- app/services/events.service.ts | 13 +-- app/services/everlive-provider.service.ts | 6 +- app/services/users.service.ts | 2 +- app/shared/constants.ts | 2 +- app/shared/index.ts | 7 +- app/shared/models/event.model.ts | 4 +- app/shared/utilities.ts | 3 + package.json | 5 +- 17 files changed, 136 insertions(+), 28 deletions(-) create mode 100644 app/shared/utilities.ts diff --git a/README.md b/README.md index c5440b9..e222ba9 100644 --- a/README.md +++ b/README.md @@ -1 +1,88 @@ # Team Spirit + +## TODO: + +Login/register with BS + +Upcoming events + - list of events + - event name + - group + - date + - days left + +Single event + - image + - name + - description + - location + - date and time (TBD) or November 1st, 2016 18:00 + - organizer + - group + - links to photos + * registered participants + * link to register + * rating for the event + +Past events + - list of events in the past + +User profile + - + +------------------ + +Create group + - name Backend Services Team + - description Only members of the Backend Services team can join this group. + - image + - approval + - period for events + * public + +Join group + - search group by name + - when you click a group youcan see its name and description and number of users + - you can then join or ask to join + + +My groups + - list of all groups you are member of + +Single group + - name + - description + - image + - members + - approval + - period of events + - invite users to this group + - last event + +- Server logic + - + + + + +----------------------- + +Event/activity ideas + - list of event ideas + +Single event idea + - + + + + +Plan +Lyubo + - create data model in server + - server logic +Georgi 1 i 2 + - NativeScript app + - repo +Kateto + - Wireframes + - diff --git a/app/app.component.ts b/app/app.component.ts index 31c9b9c..28344f3 100644 --- a/app/app.component.ts +++ b/app/app.component.ts @@ -1,7 +1,6 @@ import { Component, OnInit, ViewChild } from "@angular/core"; import { EverliveProvider, UsersService, EventsService, EventRegistrationsService } from './services'; import { RouterExtensions } from 'nativescript-angular/router' -import { Observable } from 'rxjs/Observable'; import { RadSideDrawerComponent } from 'nativescript-telerik-ui/sidedrawer/angular' @Component({ diff --git a/app/events/event-details/event-details.component.css b/app/events/event-details/event-details.component.css index b777673..4f7392f 100644 --- a/app/events/event-details/event-details.component.css +++ b/app/events/event-details/event-details.component.css @@ -1,3 +1,3 @@ Label { - background-color: white; -} \ No newline at end of file + color: white; +} diff --git a/app/events/event-details/event-details.component.ts b/app/events/event-details/event-details.component.ts index 2788017..b798e88 100644 --- a/app/events/event-details/event-details.component.ts +++ b/app/events/event-details/event-details.component.ts @@ -4,10 +4,12 @@ import * as utils from 'utils/utils'; import { EventsService, UsersService } from '../../services'; import { Event, User } from '../../shared/models'; +import { utilities } from '../../shared'; @Component({ selector: 'event-details', - templateUrl: 'events/event-details/event-details.template.html' + templateUrl: 'events/event-details/event-details.template.html', + styleUrls: [ 'events/event-details/event-details.component.css' ] }) export class EventDetailsComponent implements OnInit { event: Event; @@ -35,11 +37,18 @@ export class EventDetailsComponent implements OnInit { }) .then(currentUser => { this.alreadyRegistered = this.registeredUsers.filter(u => u.Id === currentUser.Id).length > 0; + }) + .catch(e => { + alert('An error occured: ' + JSON.stringify(e)); }); }); } + getResizedImageUrl(rawUrl: string): string { + return utilities.getAsResizeUrl(rawUrl); + } + getRegisterBtnText() { if (this.alreadyRegistered) { return 'Already Registered'; @@ -49,6 +58,7 @@ export class EventDetailsComponent implements OnInit { } getRating() { + // TODO return `Rating: 4.98 out of 5`; } diff --git a/app/events/event-details/event-details.template.html b/app/events/event-details/event-details.template.html index b51dda5..5041ddd 100644 --- a/app/events/event-details/event-details.template.html +++ b/app/events/event-details/event-details.template.html @@ -1,6 +1,6 @@ - + diff --git a/app/events/upcoming-events/upcoming-events.component.ts b/app/events/upcoming-events/upcoming-events.component.ts index 3ca3203..57d621c 100644 --- a/app/events/upcoming-events/upcoming-events.component.ts +++ b/app/events/upcoming-events/upcoming-events.component.ts @@ -4,6 +4,7 @@ import { Page } from 'ui/page'; import { EventsService } from '../../services'; import { Event } from '../../shared/models'; +import { utilities } from '../../shared'; @Component({ selector: 'upcoming-events', @@ -26,7 +27,6 @@ export class UpcomingEventsComponent implements OnInit { this._eventsService.getUpcoming() .then(events => { this.events = events; - // this.handleError(events); }, this.handleError); } @@ -40,6 +40,10 @@ export class UpcomingEventsComponent implements OnInit { return date; } + getResizedImageUrl(rawUrl: string): string { + return utilities.getAsResizeUrl(rawUrl); + } + getRemainingTime(event: Event) { let oneDay = 24 * 60 * 60 * 1000; let eventDate = this.getEventDate(event); diff --git a/app/events/upcoming-events/upcoming-events.template.html b/app/events/upcoming-events/upcoming-events.template.html index 7169c91..07f305d 100644 --- a/app/events/upcoming-events/upcoming-events.template.html +++ b/app/events/upcoming-events/upcoming-events.template.html @@ -8,7 +8,7 @@ - + diff --git a/app/login/login.component.ts b/app/login/login.component.ts index e37b312..36450af 100644 --- a/app/login/login.component.ts +++ b/app/login/login.component.ts @@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core' import { RouterExtensions } from 'nativescript-angular/router' import { Page } from 'ui/page' import { UsersService } from '../services' -import { User } from '../shared' @Component({ selector: 'login', @@ -35,11 +34,11 @@ export class LoginComponent implements OnInit { login() { this._usersService.login(this.user.username, this.user.password) .then(() => { - console.log('LOGGED IN') + console.log('LOGGED IN'); this._routerExtensions.navigate(['events/upcoming']); }) .catch((e: Error) => { - console.error(e.message) + console.error(e.message); }); } diff --git a/app/services/event-registrations.service.ts b/app/services/event-registrations.service.ts index 3422711..dc1560e 100644 --- a/app/services/event-registrations.service.ts +++ b/app/services/event-registrations.service.ts @@ -1,6 +1,5 @@ import { Injectable } from '@angular/core'; import { Data } from '../../node_modules/everlive-sdk/dist/declarations/everlive/types/Data'; -import { Query } from '../../node_modules/everlive-sdk/dist/declarations/everlive/query/Query'; import { EverliveProvider } from './everlive-provider.service'; import { EventRegistration } from '../shared/models'; @@ -22,7 +21,7 @@ export class EventRegistrationsService { }; constructor(private _elProvider: EverliveProvider) { - this._data = this._elProvider.get.data('EventRegistrations'); + this._data = this._elProvider.get.data('EventRegistrations'); } getParticipants(eventId: string): any { diff --git a/app/services/events.service.ts b/app/services/events.service.ts index f0908e5..c49ba25 100644 --- a/app/services/events.service.ts +++ b/app/services/events.service.ts @@ -21,16 +21,17 @@ export class EventsService { ReturnAs: 'Organizer' }, Image: { - 'ReturnAs': 'ImageUrl', - 'SingleField': 'Uri' + ReturnAs: 'ImageUrl', + SingleField: 'Uri' } }; constructor( private _elProvider: EverliveProvider, private _registrationsService: EventRegistrationsService, - private _usersService: UsersService) { - this._data = this._elProvider.get.data('Events'); + private _usersService: UsersService + ) { + this._data = this._elProvider.get.data('Events'); } getAll() { @@ -38,7 +39,9 @@ export class EventsService { } getById(eventId: string) { - return this._data.expand(this._eventExpandExpression).getById(eventId).then(r => r.result); + return this._data.expand(this._eventExpandExpression) + .getById(eventId) + .then(r => r.result); } getUpcoming() { diff --git a/app/services/everlive-provider.service.ts b/app/services/everlive-provider.service.ts index f1ba221..d040397 100644 --- a/app/services/everlive-provider.service.ts +++ b/app/services/everlive-provider.service.ts @@ -1,6 +1,6 @@ -import Everlive from 'everlive-sdk' -import { Injectable } from '@angular/core' -import { constants } from '../shared' +import Everlive from 'everlive-sdk'; +import { Injectable } from '@angular/core'; +import { constants } from '../shared'; @Injectable() export class EverliveProvider { diff --git a/app/services/users.service.ts b/app/services/users.service.ts index 6d22137..cc90695 100644 --- a/app/services/users.service.ts +++ b/app/services/users.service.ts @@ -51,4 +51,4 @@ export class UsersService { logout() { return this._users.logout().then(r => r, e => e); } -} \ No newline at end of file +} diff --git a/app/shared/constants.ts b/app/shared/constants.ts index 0cd6013..8b4db72 100644 --- a/app/shared/constants.ts +++ b/app/shared/constants.ts @@ -1,4 +1,4 @@ export const constants = { appId: '35ylfmbdmpzbqn0c', emptyImage: 'https://x1.xingassets.com/assets/frontend_minified/img/users/nobody_m.original.jpg' -} \ No newline at end of file +}; diff --git a/app/shared/index.ts b/app/shared/index.ts index 14d4605..027685e 100644 --- a/app/shared/index.ts +++ b/app/shared/index.ts @@ -1,2 +1,5 @@ -export * from './constants' -export * from './models' \ No newline at end of file +export * from './constants'; +export * from './models'; + +import * as utils from './utilities'; +export const utilities = utils; diff --git a/app/shared/models/event.model.ts b/app/shared/models/event.model.ts index 442668d..9da1742 100644 --- a/app/shared/models/event.model.ts +++ b/app/shared/models/event.model.ts @@ -2,7 +2,7 @@ import { ItemModel } from './item.model'; export class Event extends ItemModel { Name: string; - EventDate?: Date; - EventDateChoices?: Date[]; + EventDate?: string; + EventDateChoices?: string[]; LocationURL: string; } diff --git a/app/shared/utilities.ts b/app/shared/utilities.ts new file mode 100644 index 0000000..7f00f9b --- /dev/null +++ b/app/shared/utilities.ts @@ -0,0 +1,3 @@ +export function getAsResizeUrl (rawUrl: string, opts = { width: 300, height: 200 }) { + return `https://bs1.cdn.telerik.com/image/v1/35ylfmbdmpzbqn0c/resize=w:${opts.width},h:${opts.height},fill:cover/${rawUrl}`; +} diff --git a/package.json b/package.json index cdb5e93..6ba6bf7 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "nativescript": { "id": "org.nativescript.teamspirit", "tns-android": { - "version": "2.3.0" + "version": "2.4.1" } }, "dependencies": { @@ -21,7 +21,8 @@ "nativescript-angular": "1.1.0", "nativescript-telerik-ui": "^1.4.1", "reflect-metadata": "~0.1.8", - "tns-core-modules": "2.3.0" + "tns-core-modules": "2.4.4", + "rxjs": "5.0.2" }, "devDependencies": { "babel-traverse": "6.18.0",