Commit 0562ac3a by Tuukka Kivilahti

commit before mergin onja's changes

1 parent 4f6f5ef2
package-lock=false
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
"zone.js": "^0.8.26" "zone.js": "^0.8.26"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "~0.7.0", "@angular-devkit/build-angular": "~0.7.2",
"@angular/cdk": "^6.4.2", "@angular/cdk": "^6.4.2",
"@angular/cli": "6.1.2", "@angular/cli": "6.1.2",
"@angular/compiler-cli": "6.1.1", "@angular/compiler-cli": "6.1.1",
......
/** /**
* Created by tuukka on 04/02/17. * Created by tuukka on 04/02/17.
*/ */
import gql from "graphql-tag";
export class VipProductDelivery { export class VipProductDelivery {
/* static fragments = gql`
public Integer id; fragment vipProductDeliveryPrimitives on VipProductDelivery {
public Integer delivererId; deliverytime
public BigDecimal quantity; id
public Date deliveryTime; notes
public String notes; quantity
*/ }
`;
id: number; id: number;
delivererId: number; delivererId: number;
......
import {VipProductDelivery} from './vip-product-delivery.model'; import {VipProductDelivery} from './vip-product-delivery.model';
import gql from "graphql-tag";
/** /**
* Created by tuukka on 04/02/17. * Created by tuukka on 04/02/17.
*/ */
...@@ -7,17 +8,14 @@ import {VipProductDelivery} from './vip-product-delivery.model'; ...@@ -7,17 +8,14 @@ import {VipProductDelivery} from './vip-product-delivery.model';
export class VipProduct { export class VipProduct {
/* static fragments = gql`
fragment vipProductPrimitives on VipProduct {
public Integer id; id
public String name; name
public Integer productId; notes
public String notes; quantity
public BigDecimal quantity; }
public BigDecimal delivered; `;
public List<VipProductDeliveryPojo> deliveries = new ArrayList<>();
*/
id: number; id: number;
name: string; name: string;
......
import {VipProduct} from './vip-product.model'; import {VipProduct} from './vip-product.model';
import {User} from '../../../shared/models/user.model'; import {User} from '../../../shared/models/user.model';
import gql from "graphql-tag";
import {VipProductDelivery} from "./vip-product-delivery.model";
/** /**
* Created by tuukka on 04/02/17. * Created by tuukka on 04/02/17.
*/ */
...@@ -8,17 +10,14 @@ import {User} from '../../../shared/models/user.model'; ...@@ -8,17 +10,14 @@ import {User} from '../../../shared/models/user.model';
export class Vip { export class Vip {
/* static fragments = gql`
fragment vipPrimitives on Vip {
public Integer id; created
public String description; description
public String shortdescr; id
public Date created; shortdescr
public Integer eventuserId; }
public Integer creatorId; `;
public Integer hostId;
public List<VipProductPojo> products = new ArrayList<>();
*/
id: number; id: number;
description: string; description: string;
...@@ -35,3 +34,9 @@ export class Vip { ...@@ -35,3 +34,9 @@ export class Vip {
} }
} }
export const VipFragmentsCombined = gql`
${Vip.fragments}
${VipProduct.fragments}
${VipProductDelivery.fragments}
`;
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Vip} from './models/vip.model'; import {Vip, VipFragmentsCombined} from './models/vip.model';
import {User} from '../../shared/models/user.model'; import {User} from '../../shared/models/user.model';
import {UserService} from '../../shared/services/user.service'; import {UserService} from '../../shared/services/user.service';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
...@@ -9,11 +9,46 @@ import 'rxjs/add/observable/forkJoin'; ...@@ -9,11 +9,46 @@ import 'rxjs/add/observable/forkJoin';
import 'rxjs/add/operator/first'; import 'rxjs/add/operator/first';
import {HttpClient} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {MOYA_REST_URL} from "../../shared/config/moya.config"; import {MOYA_REST_URL} from "../../shared/config/moya.config";
import gql from 'graphql-tag';
import {EventUser} from "../../shared/models/event-user.model";
import {Apollo} from "apollo-angular";
import "rxjs-compat/add/operator/map";
export const Q_VIPS_N_DATA = gql`
query Vips() {
vips {
...vipPrimitives
products {
...vipProductPrimitives
deliveries {
...vipProductDeliveryPrimitives
}
}
creator {
...eventUserPrimitives
user {
...userPrimitives
}
}
}
}
${VipFragmentsCombined}
${EventUser.fragments}
${User.fragments}
`;
@Injectable() @Injectable()
export class ViplistService { export class ViplistService {
constructor(private http: HttpClient, private userService: UserService) {
constructor(private apollo: Apollo, private http: HttpClient, private userService: UserService) {
} }
...@@ -22,15 +57,19 @@ export class ViplistService { ...@@ -22,15 +57,19 @@ export class ViplistService {
* get vips * get vips
* @param searchString: searchString, skip to return all vips * @param searchString: searchString, skip to return all vips
*/ */
public get(searchString?: string): Observable<Array<Vip>> { public get(): Observable<Array<Vip>> {
return this.apollo.watchQuery<Array<Vip>>({query: Q_VIPS_N_DATA}).valueChanges.map(x => x.data);
//Vip .map(x => x as Vip);
if (!searchString) { if (!searchString) {
return this.http.get(MOYA_REST_URL + 'v3/vip/all') return this.http.get(MOYA_REST_URL + 'v3/vip/all')
.switchMap(res => Observable.forkJoin(...(res as Array<any>).map(apiRow => this.hostPopulator(apiRow)))); .switchMap(res => Observable.forkJoin(...(res as Array<any>).map(apiRow => this.hostPopulator(apiRow))));
} }
return this.http.get(MOYA_REST_URL + 'v3/vip/search/' + searchString)
.switchMap(v => Observable.forkJoin(...(v as Array<any>).map(x => this.hostPopulator(x))));
} }
......
import {User} from "./user.model";
import gql from "graphql-tag";
export enum UserGender {
MALE,
FEMALE,
UNSPECIFIED
}
export class EventUser {
static fragments = gql`
fragment eventUserPrimitives on EventUser {
id
eventusercreated
}
`;
id: number;
eventusercreated: Date;
user: User;
constructor() { }
}
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
// vim magic: %s/^\s*\w\+\s\+\(\w\+\)\s\+\(\w\+\)\s*.*;$/ \2: \L\1;/ // vim magic: %s/^\s*\w\+\s\+\(\w\+\)\s\+\(\w\+\)\s*.*;$/ \2: \L\1;/
import gql from "graphql-tag";
export enum UserGender { export enum UserGender {
MALE, MALE,
FEMALE, FEMALE,
...@@ -12,10 +14,33 @@ export enum UserGender { ...@@ -12,10 +14,33 @@ export enum UserGender {
export class User { export class User {
static fragments = gql`
fragment userPrimitives on User {
address
allergiesFreetext
birthday
email
firstnames
gender
id:
lastname
login
nick
phone
town
shirtSize
town
zip
}
`;
nick: string; nick: string;
login: string; login: string;
eventuserId: number; id: number;
userId: number;
firstname: string; firstname: string;
lastname: string; lastname: string;
password: string; password: string;
...@@ -23,12 +48,12 @@ export class User { ...@@ -23,12 +48,12 @@ export class User {
birthday: Date; birthday: Date;
gender: UserGender; gender: UserGender;
phoneNumber: string; phone: string;
email: string; email: string;
streetAddress: string; streetAddress: string;
zipCode: string; zip: string;
postOffice: string; town: string;
constructor() { } constructor() { }
......
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
"node_modules/@types" "node_modules/@types"
], ],
"lib": [ "lib": [
"es2017", "es2018",
"dom" "dom",
"esnext.asynciterable"
], ],
"module": "es2015", "module": "es2015",
"baseUrl": "./" "baseUrl": "./"
} }
} }
\ No newline at end of file
...@@ -626,6 +626,13 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -626,6 +626,13 @@ public class BootstrapBean implements BootstrapBeanLocal {
"ALTER TABLE compo_voting_roles ADD CONSTRAINT FK_compo_voting_roles_scheme_id FOREIGN KEY (scheme_id) REFERENCES compo_voting_schemes (id)", "ALTER TABLE compo_voting_roles ADD CONSTRAINT FK_compo_voting_roles_scheme_id FOREIGN KEY (scheme_id) REFERENCES compo_voting_schemes (id)",
"ALTER TABLE compo_voting_roles ADD CONSTRAINT FK_compo_voting_roles_role_id FOREIGN KEY (role_id) REFERENCES roles (id)", "ALTER TABLE compo_voting_roles ADD CONSTRAINT FK_compo_voting_roles_role_id FOREIGN KEY (role_id) REFERENCES roles (id)",
}); });
dbUpdates.add(new String[]{
"ALTER TABLE users DROP COLUMN postal_town;"
});
} }
......
...@@ -96,9 +96,6 @@ public class User extends GenericEntity implements IUser { ...@@ -96,9 +96,6 @@ public class User extends GenericEntity implements IUser {
@Column(name = "zip") @Column(name = "zip")
private String zip = ""; private String zip = "";
@Column(name = "postal_town")
private String postalTown = "";
@Column(name = "town") @Column(name = "town")
private String town = ""; private String town = "";
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!