Skip to content

Commit

Permalink
cosas xD
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusveca committed Nov 26, 2016
2 parents fc5cc66 + 2ce889f commit 19e7bcf
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
h1 Detail Product Lot Component Gretel
h1 Detail Lot

<div>
<table border="1">
<tr>
<td>Cod</td>
<td>Producto</td>
</tr>
<tr>
<td>01</td>
<td>Coca-cola</td>
</tr>
<tr>
<td>02</td>
<td>Fanta</td>
</tr>

</table>
</div>
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
import {Component} from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {Provider} from '../../../../../../../../core/db-models/Provider.ts';
import {Resources} from '../../services/Resources.ts';

@Component({
styles: [require('./style.styl').toString()],
template: require('./template.jade')(),
})
export class RegisterProviderComponent {
export class RegisterProviderComponent implements OnInit {

// Attributes
provider: Provider;
resources: Resources;

// Methods
constructor () {

constructor (resources: Resources) {
this.resources = resources;
this.provider = {
name: ''
}
}
ngOnInit () {}
submitRegister () {
this.resources.registerProvider({
urlParams: {},
data: {
name: this.provider.name
}
}).subscribe((resp) => {
console.log(resp);
})
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
h1 RegisterProvider Component
div
form
p
span Provider name
input([(ngModel)]="provider.name", type="text", name="providerName")
p
button((click)="submitRegister()") Submit
72 changes: 55 additions & 17 deletions src/server/statics/webapps/dashboard/src/app/services/Resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import {Injectable} from '@angular/core';
import config from '../../../../../../../settings/index.ts';
import * as q from 'q';
import {Response, Http} from '@angular/http';
import {Observable} from 'rxjs/Rx';
import {RequestParams as GetLotRequestParams, ResponseBody as GetLotResponseBody} from '../../../../../../../server/routers/handlers/lot/getLot/interface.ts';
import {RequestParams as GetProviderRequestParams, ResponseBody as GetProviderResponseBody} from '../../../../../../../server/routers/handlers/provider/getProvider/interface.ts';
import {RequestParams as GetProviderProductsRequestParams, ResponseBody as GetProviderProductsResponseBody} from '../../../../../../../server/routers/handlers/provider/getProviderProducts/interface.ts';
import {RequestParams as RegisterProviderRequestParams, ResponseBody as RegisterProviderResponseBody} from '../../../../../../../server/routers/handlers/provider/registerProvider/interface.ts';

@Injectable()
export class Resources {
Expand All @@ -26,42 +31,75 @@ export class Resources {
url = url.replace(':'+param, '');
return;
}
// url = url.replace(':'+param+'/', params[param]);
url = url.replace(':'+param, params[param]);
});
return url;
}

private request (serviceName: string, data: any, urlParams: any) {
let deferred = q.defer();
private request<T> (serviceName: string, urlParams: any, data: any): Observable<T> {
urlParams = (urlParams || {});
var service = config.apiServices[serviceName];
return deferred.promise;
var response = null;
var url = this.domain+this.processUrl(service.url, urlParams);
if (data) {
response = this.$http[service.method.toLowerCase()](url, data);
}
else {
response = this.$http[service.method.toLowerCase()](url);
}
return response.map((data:Response) => data.json());
}

public registerPerson () {}
public registerPerson (params: { urlParams: any; data: any }): Observable<any> {
return this.request('registerPerson', params.urlParams, params.data);
}

public createSession () {}
public createSession (params: { urlParams: any; data: any }): Observable<any> {
return this.request('createSession', params.urlParams, params.data);
}

public deleteSession () {}
public deleteSession (params: { urlParams: any; data: any }): Observable<any> {
return this.request('deleteSession', params.urlParams, params.data);
}

public registerUser () {}
public registerUser (params: { urlParams: any; data: any }): Observable<any> {
return this.request('registerUser', params.urlParams, params.data);
}

public registerProvider () {}
public registerProvider (params: { urlParams: any; data: RegisterProviderRequestParams }): Observable<any> {
return this.request('registerProvider', params.urlParams, params.data);
}

public registerProviderProduct () {}
public registerProviderProduct (params: { urlParams: any; data: any }): Observable<any> {
return this.request('registerProviderProduct', params.urlParams, params.data);
}

public registerProductLot () {}
public registerProductLot (params: { urlParams: any; data: any }): Observable<any> {
return this.request('registerProductLot', params.urlParams, params.data);
}

public getProviders () {}
public getProviders (params: { urlParams: any; data: any }): Observable<any> {
return this.request('getProviders', params.urlParams, params.data);
}

public getProvider () {}
public getProvider (params: { urlParams: { providerId: string }; data: GetProviderRequestParams }): Observable<GetProviderResponseBody> {
return this.request('getProvider', params.urlParams, params.data);
}

public getProviderProducts () {}
public getProviderProducts (params: { urlParams: { providerId: string }; data: GetProviderProductsRequestParams }): Observable<GetProviderProductsResponseBody> {
return this.request('getProviderProducts', params.urlParams, params.data);
}

public getProduct () {}
public getProduct (params: { urlParams: any; data: any }): Observable<any> {
return this.request('getProduct', params.urlParams, params.data);
}

public getProductLots () {}
public getProductLots (params: { urlParams: any; data: any }): Observable<any> {
return this.request('getProductLots', params.urlParams, params.data);
}

public getLot () {}
public getLot (params: { urlParams: { lotId: string }; data: GetLotRequestParams }): Observable<GetLotResponseBody> {
return this.request('getLot', params.urlParams, params.data);
}

}

0 comments on commit 19e7bcf

Please sign in to comment.