From 9ad358e2010b833fc4801fcd55f2705e5b669b39 Mon Sep 17 00:00:00 2001 From: Luis Nunez Date: Tue, 31 Jan 2017 09:27:39 -0200 Subject: [PATCH] adding transactions home page and mocking all endpoints --- src/app/app.module.ts | 3 + src/app/app.scss | 11 +- src/app/app.settings.ts | 3 +- src/pages/addTransaction/addTransaction.html | 15 ++ src/pages/addTransaction/addTransaction.scss | 3 + src/pages/addTransaction/addTransaction.ts | 45 ++++ src/pages/home/home.html | 54 +++-- src/pages/home/home.ts | 37 +++- src/pages/login/login.ts | 2 +- src/pages/members/members.html | 2 +- src/services/AuthService.ts | 8 +- src/services/ConfigService.ts | 2 + src/services/HttpBasicAuth.ts | 207 ++++++++++--------- src/services/MemberService.ts | 77 +++---- src/services/OfferService.ts | 26 ++- src/services/TransactionService.ts | 34 ++- src/services/WantService.ts | 26 ++- src/test/mock-member.ts | 11 - src/test/mock-members.ts | 82 ++++---- src/test/mock-options-transaction.ts | 31 +++ src/test/mock-transaction.ts | 15 -- src/test/mock-transactions.ts | 74 ++++--- 22 files changed, 468 insertions(+), 300 deletions(-) create mode 100644 src/pages/addTransaction/addTransaction.html create mode 100644 src/pages/addTransaction/addTransaction.scss create mode 100644 src/pages/addTransaction/addTransaction.ts delete mode 100644 src/test/mock-member.ts create mode 100644 src/test/mock-options-transaction.ts delete mode 100644 src/test/mock-transaction.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5009668..4a58ada 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -18,6 +18,7 @@ import { FormBuilderComponent } from '../components/formBuilder/formBuilder'; import { FieldBuilderComponent } from '../components/fieldBuilder/fieldBuilder'; import { LoginPage } from '../pages/login/login'; import { HomePage } from '../pages/home/home'; +import { AddTransactionPage } from '../pages/addTransaction/addTransaction'; import { OfferPage } from '../pages/offer/offer'; import { OfferDetailPage } from '../pages/offerDetail/offerDetail'; import { AddOfferPage } from '../pages/addOffer/addOffer'; @@ -37,6 +38,7 @@ import { ProfileEditPage } from '../pages/userProfileEdit/userProfileEdit'; LetsApp, LoginPage, HomePage, + AddTransactionPage, OfferPage, OfferDetailPage, AddOfferPage, @@ -63,6 +65,7 @@ import { ProfileEditPage } from '../pages/userProfileEdit/userProfileEdit'; LetsApp, LoginPage, HomePage, + AddTransactionPage, OfferPage, OfferDetailPage, AddOfferPage, diff --git a/src/app/app.scss b/src/app/app.scss index 67ad6ef..57c2734 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -38,10 +38,13 @@ ion-menu { } } -.ui.card>.content{ - .author { - text-align: right; - padding-top: 10px; +.ui.card { + width: 100%; + &>.content{ + .author { + text-align: right; + padding-top: 10px; + } } } diff --git a/src/app/app.settings.ts b/src/app/app.settings.ts index a807d4f..fee9aca 100644 --- a/src/app/app.settings.ts +++ b/src/app/app.settings.ts @@ -3,7 +3,8 @@ import { Injectable } from '@angular/core'; @Injectable() export class AppSettings { public get SERVER_URL(): any { - return 'http://hamlets.communityforge.net/commex'; + // return 'http://hamlets.communityforge.net/commex'; + return 'http://northwind.servicestack.net/customers.json'; } public get URL(): any { diff --git a/src/pages/addTransaction/addTransaction.html b/src/pages/addTransaction/addTransaction.html new file mode 100644 index 0000000..650e399 --- /dev/null +++ b/src/pages/addTransaction/addTransaction.html @@ -0,0 +1,15 @@ + + +

New Transaction

+ + + +
+
+ + + + \ No newline at end of file diff --git a/src/pages/addTransaction/addTransaction.scss b/src/pages/addTransaction/addTransaction.scss new file mode 100644 index 0000000..e263528 --- /dev/null +++ b/src/pages/addTransaction/addTransaction.scss @@ -0,0 +1,3 @@ +page-add-transaction { + +} \ No newline at end of file diff --git a/src/pages/addTransaction/addTransaction.ts b/src/pages/addTransaction/addTransaction.ts new file mode 100644 index 0000000..d613f67 --- /dev/null +++ b/src/pages/addTransaction/addTransaction.ts @@ -0,0 +1,45 @@ +import { Component, OnInit } from '@angular/core'; +import { ViewController } from 'ionic-angular'; +import { TransactionService } from '../../services/TransactionService'; +import { AlertService } from '../../services/AlertService'; +import { Transaction } from '../../domain/Transaction'; + +@Component({ + selector: 'page-add-transaction', + templateUrl: 'addTransaction.html' +}) +export class AddTransactionPage implements OnInit { + private definitionTransaction: any; + private fields: Array; + private transaction: Transaction; + + constructor(private viewCtrl: ViewController, + private transactionService: TransactionService, + private alertService: AlertService) { } + + ngOnInit(): void { + this.transactionService.describe() + .subscribe( + response => { + this.definitionTransaction = response; + this.fields = this.definitionTransaction.POST; + }, + error => this.alertService.showError('Connection problem!') + ); + } + + onCreated(transaction: Transaction) { + this.transaction = transaction; + this.transactionService.post(this.transaction) + .subscribe( + response => this.viewCtrl.dismiss({ + success: true + }), + error => this.alertService.showError(error) + ); + } + + dismiss() { + this.viewCtrl.dismiss(); + } +} diff --git a/src/pages/home/home.html b/src/pages/home/home.html index 222b89c..f193a5f 100644 --- a/src/pages/home/home.html +++ b/src/pages/home/home.html @@ -8,33 +8,29 @@

Welcome, {{ username }}

- - - - - {{ transaction.tags }} - -

- {{ transaction.payer }} paid {{ transaction.payee }} - {{ transaction.amount }} hour(s) for {{ transaction.description }} -

-
- - - - - - - - - - - -
+
+ +
Success!
+

New transaction created.

+
+
+
+
+
+

{{ transaction.description }}

+
+

{{ transaction.payer_name }} paid {{ transaction.payee_name }}
+ {{ transaction.amount }} hour(s)

+
+
+
+ +
+
+
+
+ +
diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts index 33939d2..eedc2c4 100644 --- a/src/pages/home/home.ts +++ b/src/pages/home/home.ts @@ -1,9 +1,11 @@ import { Component, OnInit } from '@angular/core'; -import { MenuController } from 'ionic-angular'; +import { MenuController, ModalController } from 'ionic-angular'; import { AuthService } from '../../services/AuthService'; import { TransactionService } from '../../services/TransactionService'; import { AlertService } from '../../services/AlertService'; import { Transaction } from '../../domain/Transaction'; +import { MemberDetailModal } from '../memberDetail/memberDetail'; +import { AddTransactionPage } from '../addTransaction/addTransaction'; @Component({ selector: 'page-home', @@ -11,9 +13,13 @@ import { Transaction } from '../../domain/Transaction'; }) export class HomePage implements OnInit { private username: string; + private canPost = false; + private success = false; + private definitionTransaction: any; private transactions: Array; constructor(private menuCtrl: MenuController, + private modalCtrl: ModalController, private authService: AuthService, private transactionService: TransactionService, private alertService: AlertService) { @@ -25,6 +31,18 @@ export class HomePage implements OnInit { } ngOnInit(): void { + this.transactionService.describe() + .subscribe( + response => { + this.definitionTransaction = response; + this.canPost = !!this.definitionTransaction.POST; + }, + error => this.alertService.showError('Connection problem!') + ); + this.loadTransactions(); + } + + loadTransactions() { this.transactionService.list() .subscribe( response => this.transactions = response, @@ -32,8 +50,19 @@ export class HomePage implements OnInit { ); } - stateIcons = { - 'done': 'checkmark-circle', - 'pending': 'ios-time' + showMember(userId) { + let modal = this.modalCtrl.create(MemberDetailModal, { + memberId: userId + }); + modal.present(); + } + + addTransaction() { + let modal = this.modalCtrl.create(AddTransactionPage); + modal.onDidDismiss((data: any = {}) => { + this.success = data.success; + this.loadTransactions(); + }); + modal.present(); } } diff --git a/src/pages/login/login.ts b/src/pages/login/login.ts index a29189a..4c82870 100644 --- a/src/pages/login/login.ts +++ b/src/pages/login/login.ts @@ -36,7 +36,7 @@ export class LoginPage implements OnInit { this.authService.login(this.username, this.password) .subscribe( response => this.navCtrl.setRoot(HomePage), - error => this.alertService.showError('Connection problem!') + error => this.alertService.showError('Error with credentials. Please try again.') ); } diff --git a/src/pages/members/members.html b/src/pages/members/members.html index 65e47fd..383754c 100644 --- a/src/pages/members/members.html +++ b/src/pages/members/members.html @@ -3,7 +3,7 @@ - Welcome to Member, {{ username }} +

Members

diff --git a/src/services/AuthService.ts b/src/services/AuthService.ts index da997d0..1ea8928 100644 --- a/src/services/AuthService.ts +++ b/src/services/AuthService.ts @@ -4,6 +4,7 @@ import { ReplaySubject } from 'rxjs/ReplaySubject'; import { AppSettings } from '../app/app.settings'; import { HttpBasicAuth } from './HttpBasicAuth'; import { Member } from '../domain/Member'; +import { MEMBERS } from '../test/mock-members'; @Injectable() export class AuthService { @@ -44,11 +45,14 @@ export class AuthService { } private requestUserInfo(username): Observable { - return this.httpBasicAuth - .getWithAuth(`${this.settings.URL.members}?fragment=${username}&depth=1`) + return this.httpBasicAuth.get(this.settings.URL.config) + // return this.httpBasicAuth + // .getWithAuth(`${this.settings.URL.members}?fragment=${username}&depth=1`) .map(response => { + response = MEMBERS; for (let id in response) { this.storeToken(response[id]); + break; } return response; }); diff --git a/src/services/ConfigService.ts b/src/services/ConfigService.ts index 8bf82eb..ab37126 100644 --- a/src/services/ConfigService.ts +++ b/src/services/ConfigService.ts @@ -9,6 +9,7 @@ import { CategoriesService } from './CategoriesService'; import { FieldTypesService } from './FieldTypesService'; import { Config } from '../domain/Config'; import { Category } from '../domain/Category'; +import { CONFIG } from '../test/mock-config'; @Injectable() export class ConfigService { @@ -27,6 +28,7 @@ export class ConfigService { requestAppConfig(): Observable { return this.httpBasicAuth.get(this.settings.URL.config) .map((response: Config) => { + response = CONFIG; this.categoriesService.setCategories( lodash.map(response.categories, (category: Category, id: string) => { category.id = id; diff --git a/src/services/HttpBasicAuth.ts b/src/services/HttpBasicAuth.ts index af1844a..82bb0cb 100644 --- a/src/services/HttpBasicAuth.ts +++ b/src/services/HttpBasicAuth.ts @@ -4,107 +4,108 @@ import { AppSettings } from '../app/app.settings'; @Injectable() export class HttpBasicAuth { - private authorizationToken: string; - private AUTH_TOKEN_KEY: string; - - constructor(private http: Http, - private settings: AppSettings) { - this.AUTH_TOKEN_KEY = 'auth_token'; - this.loadToken(); - } - - loadToken() { - var token = window.localStorage.getItem(this.AUTH_TOKEN_KEY); - if (token) { - this.setToken(JSON.parse(token)); - } - } - - private storeToken(token) { - window.localStorage.setItem(this.AUTH_TOKEN_KEY, JSON.stringify(token)); - this.setToken(token); - } - - private destroyToken() { - window.localStorage.removeItem(this.AUTH_TOKEN_KEY); - } - - private setToken(token) { - this.authorizationToken = token; - } - - setAuthorizationToken(username, password) { - this.authorizationToken = `Basic ${btoa(`${username}:${password}`)}`; - this.storeToken(this.authorizationToken); - } - - private createAuthorizationHeader(headers: Headers) { - headers.append('Authorization', this.authorizationToken); - } - - private extractData(response: Response) { - let body = response.json(); - return body || {}; - } - - private extractError(error): any { - throw JSON.stringify(error.json()); - } - - getWithAuth(url) { - let headers = new Headers(); - this.createAuthorizationHeader(headers); - return this.get(url, headers); - } - - get(url, headers?) { - return this.http.get(url, { - headers: headers - }).map(this.extractData) - .catch(this.extractError); - } - - getAutocomplete(autocompleteURL?, fragment?) { - let headers = new Headers(); - this.createAuthorizationHeader(headers); - return this.get(`${this.settings.SERVER_URL}${autocompleteURL || ''}${fragment || ''}`, headers); - } - - postWithAuth(url, data) { - let headers = new Headers(); - this.createAuthorizationHeader(headers); - return this.post(url, data, headers); - } - - post(url, data, headers?) { - return this.http.post(url, data, { - headers: headers - }).map(this.extractData) - .catch(this.extractError); - } - - patchWithAuth(url, data) { - let headers = new Headers(); - this.createAuthorizationHeader(headers); - return this.patch(url, data, headers); - } - - patch(url, data, headers?){ - return this.http.patch(url, data, { - headers: headers - }).map(this.extractData) - .catch(this.extractError); - } - - options(url) { - let headers = new Headers(); - return this.http.options(url, { - headers: headers - }).map(this.extractData) - .catch(this.extractError); - } - - logout() { - this.destroyToken(); - } + private authorizationToken: string; + private AUTH_TOKEN_KEY: string; + + constructor(private http: Http, + private settings: AppSettings) { + this.AUTH_TOKEN_KEY = 'auth_token'; + this.loadToken(); + } + + loadToken() { + var token = window.localStorage.getItem(this.AUTH_TOKEN_KEY); + if (token) { + this.setToken(JSON.parse(token)); + } + } + + private storeToken(token) { + window.localStorage.setItem(this.AUTH_TOKEN_KEY, JSON.stringify(token)); + this.setToken(token); + } + + private destroyToken() { + window.localStorage.removeItem(this.AUTH_TOKEN_KEY); + } + + private setToken(token) { + this.authorizationToken = token; + } + + setAuthorizationToken(username, password) { + this.authorizationToken = `Basic ${btoa(`${username}:${password}`)}`; + this.storeToken(this.authorizationToken); + } + + private createAuthorizationHeader(headers: Headers) { + headers.append('Authorization', this.authorizationToken); + } + + private extractData(response: Response) { + let body = response.json(); + return body || {}; + } + + private extractError(error): any { + console.log('error', error); + throw JSON.stringify(error.json()); + } + + getWithAuth(url) { + let headers = new Headers(); + this.createAuthorizationHeader(headers); + return this.get(url, headers); + } + + get(url, headers?) { + return this.http.get(url, { + headers: headers + }).map(this.extractData) + .catch(this.extractError); + } + + getAutocomplete(autocompleteURL?, fragment?) { + let headers = new Headers(); + this.createAuthorizationHeader(headers); + return this.get(`${this.settings.SERVER_URL}${autocompleteURL || ''}${fragment || ''}`, headers); + } + + postWithAuth(url, data) { + let headers = new Headers(); + this.createAuthorizationHeader(headers); + return this.post(url, data, headers); + } + + post(url, data, headers?) { + return this.http.post(url, data, { + headers: headers + }).map(this.extractData) + .catch(this.extractError); + } + + patchWithAuth(url, data) { + let headers = new Headers(); + this.createAuthorizationHeader(headers); + return this.patch(url, data, headers); + } + + patch(url, data, headers?) { + return this.http.patch(url, data, { + headers: headers + }).map(this.extractData) + .catch(this.extractError); + } + + options(url) { + let headers = new Headers(); + return this.http.options(url, { + headers: headers + }).map(this.extractData) + .catch(this.extractError); + } + + logout() { + this.destroyToken(); + } } \ No newline at end of file diff --git a/src/services/MemberService.ts b/src/services/MemberService.ts index f0d12a3..f05ce52 100644 --- a/src/services/MemberService.ts +++ b/src/services/MemberService.ts @@ -4,42 +4,47 @@ import { AppSettings } from '../app/app.settings'; import { HttpBasicAuth } from './HttpBasicAuth'; import { Member } from '../domain/Member'; import { MEMBERS } from '../test/mock-members'; +import * as lodash from 'lodash'; @Injectable() -export class MemberService{ - - private membersArray: Array - - constructor(private settings: AppSettings, - private httpBasicAuth: HttpBasicAuth){ } - - list(): Observable> { - - // return this.httpBasicAuth.getWithAuth(this.settings.URL.members) - this.membersArray = MEMBERS; - return this.httpBasicAuth.get(this.settings.URL.config) - .map(response => { - return MEMBERS; - }); - } - - getMemberWithId(id): Member { - return this.membersArray.filter(member => member.id === id)[0]; - } - - get(id): Observable { - return this.httpBasicAuth.getWithAuth(`${this.settings.URL.members}/${id}?depth=1`); - } - - post(member: Member): Observable { - return this.httpBasicAuth.postWithAuth(this.settings.URL.members, member); - } - - patch(member: Member): Observable { - return this.httpBasicAuth.patchWithAuth(`${this.settings.URL.members}/${member.id}`,member); - } - - descripe(): Observable { - return this.httpBasicAuth.options(this.settings.URL.members); - } +export class MemberService { + + constructor(private settings: AppSettings, + private httpBasicAuth: HttpBasicAuth) { } + + list(): Observable> { + return this.httpBasicAuth.get(this.settings.URL.config) + // return this.httpBasicAuth.getWithAuth(this.settings.URL.members) + .map((response: Array) => { + response = MEMBERS; + response = lodash.map(response, (member: Member, key: any) => { + if (!member.id) { + member.id = key; + } + return member; + }); + return response; + }); + } + + get(id): Observable { + return this.httpBasicAuth.get(this.settings.URL.config) + // return this.httpBasicAuth.getWithAuth(`${this.settings.URL.members}/${id}?depth=1`); + .map(response => { + response = MEMBERS[id]; + return response; + }); + } + + post(member: Member): Observable { + return this.httpBasicAuth.postWithAuth(this.settings.URL.members, member); + } + + patch(member: Member): Observable { + return this.httpBasicAuth.patchWithAuth(`${this.settings.URL.members}/${member.id}`, member); + } + + describe(): Observable { + return this.httpBasicAuth.options(this.settings.URL.members); + } } \ No newline at end of file diff --git a/src/services/OfferService.ts b/src/services/OfferService.ts index 1a0ee8b..054caf8 100644 --- a/src/services/OfferService.ts +++ b/src/services/OfferService.ts @@ -3,6 +3,8 @@ import { Observable } from 'rxjs/Observable'; import { AppSettings } from '../app/app.settings'; import { HttpBasicAuth } from './HttpBasicAuth'; import { Offer } from '../domain/Offer'; +import { OPTIONS_OFFER } from '../test/mock-options-offer'; +import { OFFERS } from '../test/mock-offers'; import * as lodash from 'lodash'; @Injectable() @@ -12,13 +14,18 @@ export class OfferService { private httpBasicAuth: HttpBasicAuth) { } list(): Observable> { - return this.httpBasicAuth.getWithAuth(`${this.settings.URL.offers}?depth=1`) - .map((response: Array) => { - response = lodash.map(response, (offer: Offer) => { - return offer; + return this.httpBasicAuth.get(this.settings.URL.config) + // return this.httpBasicAuth.getWithAuth(`${this.settings.URL.offers}?depth=1`) + .map((response: Array) => { + response = OFFERS; + response = lodash.map(response, (offer: Offer, key: any) => { + if (!offer.id) { + offer.id = key; + } + return offer; + }); + return response; }); - return response; - }); } get(id): Observable { @@ -30,6 +37,11 @@ export class OfferService { } describe(): Observable { - return this.httpBasicAuth.options(this.settings.URL.offers); + return this.httpBasicAuth.get(this.settings.URL.config) + // return this.httpBasicAuth.options(this.settings.URL.offers) + .map(response => { + response = OPTIONS_OFFER; + return response; + }); } } \ No newline at end of file diff --git a/src/services/TransactionService.ts b/src/services/TransactionService.ts index d9efc9e..ddcde59 100644 --- a/src/services/TransactionService.ts +++ b/src/services/TransactionService.ts @@ -4,6 +4,8 @@ import { AppSettings } from '../app/app.settings'; import { HttpBasicAuth } from './HttpBasicAuth'; import { Transaction } from '../domain/Transaction'; import { TRANSACTIONS } from '../test/mock-transactions'; +import { OPTIONS_TRANSACTION } from '../test/mock-options-transaction'; +import * as lodash from 'lodash'; @Injectable() export class TransactionService { @@ -12,10 +14,34 @@ export class TransactionService { private httpBasicAuth: HttpBasicAuth) { } list(): Observable> { - // return this.httpBasicAuth.getWithAuth(this.settings.URL.transactions) return this.httpBasicAuth.get(this.settings.URL.config) - .map(response => { - return TRANSACTIONS; - }); + // return this.httpBasicAuth.getWithAuth(`${this.settings.URL.transactions}?depth=1`) + .map((response: Array) => { + response = TRANSACTIONS; + response = lodash.map(response, (transaction: Transaction, key: any) => { + if (!transaction.id) { + transaction.id = key; + } + return transaction; + }); + return response; + }); + } + + get(id): Observable { + return this.httpBasicAuth.getWithAuth(`${this.settings.URL.transactions}/${id}?depth=1`); + } + + post(transaction: Transaction): Observable { + return this.httpBasicAuth.postWithAuth(this.settings.URL.transactions, transaction); + } + + describe(): Observable { + return this.httpBasicAuth.get(this.settings.URL.config) + // return this.httpBasicAuth.options(this.settings.URL.transactions) + .map(response => { + response = OPTIONS_TRANSACTION; + return response; + }); } } \ No newline at end of file diff --git a/src/services/WantService.ts b/src/services/WantService.ts index 71eec12..b596fad 100644 --- a/src/services/WantService.ts +++ b/src/services/WantService.ts @@ -3,6 +3,8 @@ import { Observable } from 'rxjs/Observable'; import { AppSettings } from '../app/app.settings'; import { HttpBasicAuth } from './HttpBasicAuth'; import { Want } from '../domain/Want'; +import { OPTIONS_OFFER } from '../test/mock-options-offer'; +import { OFFERS } from '../test/mock-offers'; import * as lodash from 'lodash'; @Injectable() @@ -12,13 +14,18 @@ export class WantService { private httpBasicAuth: HttpBasicAuth) { } list(): Observable> { - return this.httpBasicAuth.getWithAuth(`${this.settings.URL.wants}?depth=1`) - .map((response: Array) => { - response = lodash.map(response, (want: Want) => { - return want; + return this.httpBasicAuth.get(this.settings.URL.config) + // return this.httpBasicAuth.getWithAuth(`${this.settings.URL.wants}?depth=1`) + .map((response: Array) => { + response = OFFERS; + response = lodash.map(response, (want: Want, key: any) => { + if (!want.id) { + want.id = key; + } + return want; + }); + return response; }); - return response; - }); } get(id): Observable { @@ -30,6 +37,11 @@ export class WantService { } describe(): Observable { - return this.httpBasicAuth.options(this.settings.URL.wants); + return this.httpBasicAuth.get(this.settings.URL.config) + // return this.httpBasicAuth.options(this.settings.URL.wants) + .map(response => { + response = OPTIONS_OFFER; + return response; + }); } } \ No newline at end of file diff --git a/src/test/mock-member.ts b/src/test/mock-member.ts deleted file mode 100644 index c006fa9..0000000 --- a/src/test/mock-member.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Member } from '../domain/Member'; - -export const MEMBER: Member = { - 'id': '3', - 'name': 'Kerry Turner', - 'aboutme': 'Aliquip dignissim esca iusto lobortis neo paulatim refero sudo tation.', - 'balance': 'Hrs12:45m', - 'created': 1451973792, - 'locality': 'Ditchwater', - 'uri': 'member/3' -} \ No newline at end of file diff --git a/src/test/mock-members.ts b/src/test/mock-members.ts index 22cc2e1..78497e7 100644 --- a/src/test/mock-members.ts +++ b/src/test/mock-members.ts @@ -1,36 +1,46 @@ -import { Member } from '../domain/Member'; - -export const MEMBERS: Array = [ - { - 'id': '1', - 'name': 'Member 1', - 'aboutme': 'Aliquip dignissim esca iusto lobortis neo paulatim refero sudo tation.', - 'balance': 'Hrs12:45m', - 'created': 1451973792, - 'locality': 'Ditchwater', - 'uri': 'member/1' -}, { - 'id': '2', - 'name': 'Member 2', - 'aboutme': 'Aliquip dignissim esca iusto lobortis neo paulatim refero sudo tation.', - 'balance': 'Hrs12:45m', - 'created': 1451973792, - 'locality': 'Ditchwater', - 'uri': 'member/2' -}, { - 'id': '3', - 'name': 'Kerry Turner', - 'aboutme': 'Aliquip dignissim esca iusto lobortis neo paulatim refero sudo tation.', - 'balance': 'Hrs12:45m', - 'created': 1451973792, - 'locality': 'Ditchwater', - 'uri': 'member/3' -}, { - 'id': '4', - 'name': 'Member 3', - 'aboutme': 'Aliquip dignissim esca iusto lobortis neo paulatim refero sudo tation.', - 'balance': 'Hrs12:45m', - 'created': 1451973792, - 'locality': 'Ditchwater', - 'uri': 'member/3' -}] \ No newline at end of file +export const MEMBERS = { + "1": { + "name": "Hamlets Demo", + "mail": "admin@matslats.net", + "pass": "", + "phone": "", + "aboutme": "", + "street_address": "", + "locality": "", + "image": "", + "uri": "member/1" + }, + "3": { + "name": "Harry Example", + "mail": "Harry@example.com", + "pass": "", + "phone": "03455 843136", + "aboutme": "Magna nutus sagaciter turpis vicis. Accumsan causa gemino modo premo quadrum. Distineo eros exerci lenis paulatim quidne vindico. Dignissim interdico macto natu patria verto. Pecus quae sed sit volutpat. Quibus rusticus similis. Acsi conventio gravis in paulatim tamen tation. Consectetuer esse macto roto rusticus vero virtus voco vulputate. Feugiat gemino jus patria praemitto validus. Consectetuer imputo in modo nibh pagus pneum vel.\n\nDignissim eligo interdico lobortis sagaciter tum. Ex gravis lenis quidne saepius secundum tamen usitas. Ille immitto proprius quis. Jugis molior nibh odio quadrum. Brevitas erat gilvus quidem similis te. Sagaciter veniam vicis. Abico pertineo quidne. Appellatio dolus ex sagaciter. Appellatio fere sed.\n\nAliquip mos venio voco. Camur cogo genitus nimis quis secundum usitas. Aliquam esca nisl occuro vel vulputate. Brevitas dolore praemitto proprius quia refoveo. Huic illum neo vulputate.\n\nHaero humo modo mos nunc pneum si tation vulputate. Commoveo quae suscipere. Accumsan dolus facilisi lenis letalis lobortis nibh probo. Abico ad natu. Abigo aliquip scisco. Commoveo huic incassum jumentum pagus pala praesent utinam wisi. Ad causa ludus. Defui incassum jugis letalis luctus quis rusticus tincidunt utinam.\n\nAmet causa dignissim hendrerit loquor si sudo ut. Ad consequat metuo oppeto quidne sagaciter. Bene ibidem pala paratus patria pneum refoveo saluto. Jugis luctus modo nulla nunc persto. Interdico jumentum lucidus neque populus quibus roto ullamcorper. Aptent causa iusto mos similis. Humo nostrud si suscipere tincidunt venio. Abdo abigo acsi caecus erat jumentum melior similis zelus.\n\nAppellatio enim euismod iriure populus sit vulpes. Commoveo enim quia. Aliquam capto causa distineo duis ille luctus nostrud. Causa esse laoreet nulla os typicus valde. Ideo populus scisco ulciscor utrum vicis volutpat. Abico autem defui letalis macto quia sagaciter tego. Plaga validus vindico.\n\nAntehabeo blandit eligo mos olim pertineo utrum validus. Blandit commoveo in vereor wisi. Autem damnum eros feugiat gravis lucidus persto quadrum ut. Aliquip antehabeo facilisis hendrerit melior nutus sino. Facilisis illum ludus mos si ut.\n\nCapto causa enim exputo gravis probo quia singularis. Aptent defui iustum loquor quadrum suscipit verto. Aliquam esca eu exputo huic incassum iriure quadrum sagaciter vel. Camur iaceo inhibeo ludus pagus. Camur incassum luctus patria sed velit. Antehabeo dolus elit euismod ideo persto refoveo tamen tation vel.\n\nAt te ulciscor. Acsi caecus comis enim erat gravis inhibeo minim sino zelus. Haero ibidem interdico natu os validus vulpes. Acsi ea metuo paratus praesent proprius suscipere turpis ulciscor venio.\n\nDolus laoreet nimis pneum vulpes. Cui eligo et neque quidne. Camur hendrerit jumentum magna vereor. Brevitas cogo dignissim eros exputo jumentum metuo os pneum typicus.\n\nCaecus camur damnum importunus quia quidem saluto tum vero. Accumsan elit et eu importunus rusticus usitas vereor. Appellatio autem cogo dolus elit eros humo roto saluto sudo. Abico abluo consectetuer gravis.\n\nIllum quadrum sino tation vero. Erat exputo humo natu neo. Augue brevitas dolor oppeto paratus refoveo sit venio. Consectetuer dignissim dolor ille interdico nutus saluto. Conventio ea humo iusto mos quae quidne scisco valetudo vel. Abigo elit esse euismod gemino meus typicus velit. Iustum lobortis tation. Comis decet gemino jugis minim olim suscipere. Antehabeo blandit damnum hendrerit humo lobortis praemitto suscipere torqueo valde.\n\n", + "street_address": "Rochester Road", + "locality": "Cow Common", + "image": "", + "uri": "member/3" + }, + "4": { + "name": "Ursula Example", + "mail": "Ursula@example.com", + "pass": "", + "phone": "04773 636977", + "aboutme": "Adipiscing aliquip antehabeo consequat distineo et incassum olim refero vero. Imputo luptatum minim natu odio venio. Causa eros haero iaceo ibidem importunus scisco te turpis ulciscor. Antehabeo jumentum olim paratus patria. Cogo immitto modo suscipit tincidunt. Abbas facilisis humo laoreet magna nobis qui vulpes. Augue cogo eligo ex importunus in nulla paulatim populus roto. Sit turpis typicus vero.\n\nAbico brevitas exputo loquor pala. Defui iusto mauris neo obruo pagus verto volutpat. Acsi euismod nunc paratus suscipere turpis. Adipiscing brevitas commoveo cui exerci facilisi gemino gilvus iusto quadrum. Laoreet natu paratus sagaciter.\n\nAbdo abico elit eros ibidem importunus premo refoveo uxor. Appellatio eum nostrud plaga. Appellatio at comis duis huic jumentum ludus qui tation. Aptent consectetuer hos plaga qui quis tamen vel vulputate. Comis nostrud tamen. Caecus gravis ille incassum iusto nulla quia quis saluto wisi.\n\nAt exputo nobis quidem roto tincidunt torqueo ulciscor vereor. Conventio dignissim eu jus persto probo valetudo. Acsi distineo hos mauris nobis praemitto suscipere. Enim gilvus lucidus magna olim patria quis valde.\n\nAliquip autem commodo cui eu macto nutus paratus populus typicus. Aliquip exerci nulla. Comis cui mos typicus ulciscor venio. Abdo importunus neque nostrud probo refoveo singularis uxor vereor volutpat. Abluo comis ideo nostrud virtus. Cogo nutus quibus quidne roto rusticus venio. Exerci illum letalis lobortis nobis populus rusticus torqueo ulciscor valde.\n\nAcsi huic interdico nostrud sino vindico. Ad camur dignissim et ille interdico laoreet os. Amet appellatio defui jumentum nisl odio plaga probo vereor. Appellatio camur causa comis facilisis humo ille meus patria ullamcorper.\n\nLucidus singularis veniam. Eligo esca neo quidne ratis singularis. Importunus pecus validus. Autem camur dolus illum pagus quadrum verto vulputate. Acsi cogo consequat mauris similis.\n\nAutem eligo interdico iusto magna. Acsi dignissim enim feugiat iusto vereor. Accumsan augue jus melior metuo te virtus. Comis humo obruo. Eum minim premo scisco similis te usitas valetudo vulputate. Accumsan aliquip fere genitus melior refoveo ullamcorper velit. Aliquam damnum decet exerci ille neo sagaciter velit. Antehabeo erat interdico magna singularis sino sit. At augue dignissim meus secundum tum. Facilisis ludus nunc.\n\nBlandit enim in tego zelus. Autem conventio elit mos nisl premo saepius tamen. Capto dignissim lobortis mauris obruo praesent rusticus ulciscor utinam verto. Modo natu vel vicis. Aliquip duis ex imputo natu nunc refero.\n\nFeugiat inhibeo populus tego. Commoveo et pertineo vero. Abluo camur gemino importunus jus nunc pertineo utinam. Abigo enim hos ille importunus iustum jumentum lobortis vulputate. Eros immitto in sagaciter zelus. Consequat duis elit erat et euismod ideo inhibeo usitas. Conventio importunus iusto jus premo quadrum sed sudo tamen volutpat. Autem dolus haero hendrerit iustum mauris paulatim singularis venio.\n\nGilvus quidne typicus. Abico nulla pagus rusticus sino usitas validus. Comis distineo ludus minim nostrud vero. Adipiscing aptent commoveo diam in macto refero typicus uxor.\n\nAliquam brevitas eu valetudo. Eligo enim ibidem nulla paulatim refoveo scisco sit utinam vulpes. Acsi odio patria quis. At facilisi ideo iusto loquor nisl pala quidne tincidunt.\n\n", + "street_address": "Paisley Park", + "locality": "Cow Common", + "image": "", + "uri": "member/4" + }, + "5": { + "name": "Yuri Example", + "mail": "Yuri@example.com", + "pass": "", + "phone": "07180 498641", + "aboutme": "Dolus luptatum olim quidem veniam. Abbas decet erat et euismod interdico quidem vereor virtus. Ad oppeto qui zelus. Facilisi metuo meus. Abbas ea lobortis magna utinam. Aptent dolor ex humo sit volutpat. Conventio magna torqueo uxor. Ad brevitas eu uxor. Acsi distineo eros pala proprius quidem validus verto. Diam immitto imputo pecus pertineo premo roto rusticus secundum vindico.\n\nAbbas comis facilisis lobortis nutus populus tamen. Abbas feugiat sit sudo. Decet lobortis virtus. Cogo huic velit. Commoveo dignissim mauris sit suscipit. Haero iriure nunc odio pagus. Abigo ideo imputo praesent quidem. Accumsan acsi autem esca euismod gemino mos valde virtus zelus. Eligo eum feugiat iustum mauris nobis premo tego velit ymo.\n\nAbico immitto natu. Amet iriure quae quibus sino tamen tincidunt turpis vulputate. Importunus molior vicis. Ex incassum lobortis luctus si. Accumsan blandit lobortis minim paratus singularis tego. Hos iusto loquor obruo sino turpis ymo. Ex pecus populus tego uxor. Jumentum minim praemitto.\n\nAbdo iaceo mos nulla odio os pneum praemitto saepius vulputate. Exputo feugiat iaceo mos paratus utinam. Capto commoveo duis ullamcorper voco. Facilisis gilvus iaceo meus nunc pala sudo tincidunt tum ulciscor. Autem haero inhibeo lucidus modo oppeto. Abbas augue elit iaceo saepius torqueo. Capto commodo dolore esca iustum odio tamen. Abdo inhibeo nibh paratus pecus typicus vulpes.\n\nConsequat molior nisl quibus tamen tum uxor. Aptent immitto nimis probo vulpes. Populus quibus tego vulputate. Minim nisl proprius refero.\n\nAbbas accumsan appellatio dolor euismod nostrud rusticus saluto secundum venio. Hos sed tamen tation. Acsi gravis lenis modo nibh quidem rusticus tego utinam venio. Autem consectetuer ille inhibeo nisl rusticus sagaciter tamen torqueo. Blandit importunus jugis lucidus nimis os pertineo. Luptatum nobis plaga. Commodo commoveo dignissim refoveo singularis. Comis ex illum nisl persto ullamcorper.\n\nEnim humo ludus os. Abico aptent euismod letalis refero ulciscor uxor valetudo. Abigo antehabeo bene genitus gilvus jumentum proprius quidem tego valde. Commodo commoveo dolor esca pneum refero. Abbas at brevitas exerci genitus quadrum utrum uxor wisi. Defui huic obruo probo. Acsi conventio huic immitto plaga refero tamen vulputate. Elit imputo iusto nostrud quadrum turpis.\n\nLoquor pecus quis. Appellatio dolus eligo humo. Ex gravis hendrerit ideo in lenis roto validus volutpat. Defui duis feugiat inhibeo interdico loquor luctus suscipit tincidunt veniam. Ad huic ludus singularis.\n\nDecet distineo importunus molior natu paratus premo quis refero ulciscor. Accumsan gravis incassum lenis neque olim saluto velit venio. Ideo occuro tamen ulciscor. Acsi dolor feugiat gilvus ibidem minim virtus zelus. Aliquip augue distineo fere iustum quadrum saluto ut vicis. Abigo dolus genitus humo interdico lenis singularis ullamcorper usitas velit.\n\nExerci imputo nunc oppeto sed valetudo vereor. Abigo adipiscing dolore praemitto tamen ullamcorper. Causa gemino occuro os. Decet gravis jus melior secundum. Abdo camur vero. Gemino meus pala scisco. Aptent distineo gravis hos ille luctus meus refero volutpat. Aliquam cogo decet ullamcorper zelus.\n\nAliquip elit pertineo quia quidne refoveo sino veniam verto vulputate. Adipiscing ideo quidem sagaciter suscipere. Facilisis neo si. Accumsan aptent dignissim ex fere humo torqueo uxor velit.\n\nAbico aliquip bene inhibeo populus quibus quidem tamen virtus. Amet ea os. Adipiscing esca ibidem quadrum. Commoveo consectetuer humo ille lucidus neque pneum proprius tamen usitas.\n\n", + "street_address": "Harwich Highway", + "locality": "Elephantine", + "image": "", + "uri": "member/5" + } +}; \ No newline at end of file diff --git a/src/test/mock-options-transaction.ts b/src/test/mock-options-transaction.ts new file mode 100644 index 0000000..c3a715a --- /dev/null +++ b/src/test/mock-options-transaction.ts @@ -0,0 +1,31 @@ +export const OPTIONS_TRANSACTION = { + "POST": { + "description": { + "label": "Description", + "type": "text", + "required": true + }, + "payer": { + "label": "Payer", + "type": "member", + "required": false, + "_comment": "defaults to the current user" + }, + "payee": { + "label": "Payee", + "type": "member", + "required": false, + "_comment": "defaults to the current user" + }, + "amount": { + "label": "Amount", + "type": "number", + "required": true + }, + "category": { + "type": "categories", + "label": "Category", + "required": true + } + } +}; \ No newline at end of file diff --git a/src/test/mock-transaction.ts b/src/test/mock-transaction.ts deleted file mode 100644 index 398ce2f..0000000 --- a/src/test/mock-transaction.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Transaction } from '../domain/Transaction'; - -export const TRANSACTION: Transaction = { - 'id': '1002', - 'created': 1297373635, - 'payer': 'member/345', - 'payee': 'member/346', - 'amount': 1, - 'description': 'children\'s entertainment', - 'categories': [1, 2, 3], - 'tags': ['clowning', 'pantomime'], - 'type': 'default', - 'state': 'done', - 'canSign': false -} \ No newline at end of file diff --git a/src/test/mock-transactions.ts b/src/test/mock-transactions.ts index 5a612e9..871eadf 100644 --- a/src/test/mock-transactions.ts +++ b/src/test/mock-transactions.ts @@ -1,39 +1,35 @@ -import { Transaction } from '../domain/Transaction'; - -export const TRANSACTIONS: Array = [{ - 'id': '1002', - 'created': 1297373635, - 'payer': 'Kerry', - 'payee': 'Paul', - 'amount': 1, - 'description': 'children\'s entertainment', - 'categories': [1, 2, 3], - 'tags': ['clowning', 'pantomime'], - 'type': 'default', - 'state': 'pending', - 'canSign': true -}, { - 'id': '1003', - 'created': 1297373635, - 'payer': 'Kerry', - 'payee': 'Paul', - 'amount': 1, - 'description': 'children\'s entertainment', - 'categories': [1, 2, 3], - 'tags': ['clowning', 'pantomime'], - 'type': 'default', - 'state': 'done', - 'canSign': false -}, { - 'id': '1004', - 'created': 1297373635, - 'payer': 'Kerry', - 'payee': 'Paul', - 'amount': 1, - 'description': 'children\'s entertainment', - 'categories': [1, 2, 3], - 'tags': ['clowning', 'pantomime'], - 'type': 'default', - 'state': 'done', - 'canSign': false -}] \ No newline at end of file +export const TRANSACTIONS = { + "1": { + "description": "A very nice stress-tested buffet in need of repair.", + "payer": "13", + "payer_name": "Fanny Earl", + "payee": "21", + "payee_name": "Cherry Rider", + "amount": 5, + "id": "1", + "uri": "commex/v1/offer/1", + "created": "1479473161" + }, + "2": { + "description": "Jewish fried donkey ", + "payer": "21", + "payer_name": "Cherry Rider", + "payee": "9", + "payee_name": "Oliver Gardener", + "amount": 5, + "id": "2", + "uri": "commex/v1/offer/2", + "created": "1470210417" + }, + "3": { + "description": "Hand-crafted gelatinous armistice in need of repair.", + "payer": "9", + "payer_name": "Oliver Gardener", + "payee": "13", + "payee_name": "Fanny Earl", + "amount": 5, + "id": "3", + "uri": "commex/v1/offer/3", + "created": "1479282277" + } +}; \ No newline at end of file