diff --git a/src/server/statics/webapps/dashboard/src/app/components/DetailLot/template.jade b/src/server/statics/webapps/dashboard/src/app/components/DetailLot/template.jade
index 5602237..5cf7c8f 100644
--- a/src/server/statics/webapps/dashboard/src/app/components/DetailLot/template.jade
+++ b/src/server/statics/webapps/dashboard/src/app/components/DetailLot/template.jade
@@ -1 +1,19 @@
-h1 Detail Product Lot Component Gretel
\ No newline at end of file
+h1 Detail Lot
+
+
+
+
+Cod |
+Producto |
+
+
+01 |
+Coca-cola |
+
+
+02 |
+Fanta |
+
+
+
+
\ No newline at end of file
diff --git a/src/server/statics/webapps/dashboard/src/app/components/RegisterProvider/index.ts b/src/server/statics/webapps/dashboard/src/app/components/RegisterProvider/index.ts
index a687cf7..4fdd9eb 100644
--- a/src/server/statics/webapps/dashboard/src/app/components/RegisterProvider/index.ts
+++ b/src/server/statics/webapps/dashboard/src/app/components/RegisterProvider/index.ts
@@ -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);
+ })
}
}
diff --git a/src/server/statics/webapps/dashboard/src/app/components/RegisterProvider/template.jade b/src/server/statics/webapps/dashboard/src/app/components/RegisterProvider/template.jade
index f8c7722..29f11dd 100644
--- a/src/server/statics/webapps/dashboard/src/app/components/RegisterProvider/template.jade
+++ b/src/server/statics/webapps/dashboard/src/app/components/RegisterProvider/template.jade
@@ -1 +1,7 @@
-h1 RegisterProvider Component
\ No newline at end of file
+div
+ form
+ p
+ span Provider name
+ input([(ngModel)]="provider.name", type="text", name="providerName")
+ p
+ button((click)="submitRegister()") Submit
\ No newline at end of file
diff --git a/src/server/statics/webapps/dashboard/src/app/services/Resources.ts b/src/server/statics/webapps/dashboard/src/app/services/Resources.ts
index ee90d1e..3418594 100644
--- a/src/server/statics/webapps/dashboard/src/app/services/Resources.ts
+++ b/src/server/statics/webapps/dashboard/src/app/services/Resources.ts
@@ -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 {
@@ -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 (serviceName: string, urlParams: any, data: any): Observable {
+ 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 {
+ return this.request('registerPerson', params.urlParams, params.data);
+ }
- public createSession () {}
+ public createSession (params: { urlParams: any; data: any }): Observable {
+ return this.request('createSession', params.urlParams, params.data);
+ }
- public deleteSession () {}
+ public deleteSession (params: { urlParams: any; data: any }): Observable {
+ return this.request('deleteSession', params.urlParams, params.data);
+ }
- public registerUser () {}
+ public registerUser (params: { urlParams: any; data: any }): Observable {
+ return this.request('registerUser', params.urlParams, params.data);
+ }
- public registerProvider () {}
+ public registerProvider (params: { urlParams: any; data: RegisterProviderRequestParams }): Observable {
+ return this.request('registerProvider', params.urlParams, params.data);
+ }
- public registerProviderProduct () {}
+ public registerProviderProduct (params: { urlParams: any; data: any }): Observable {
+ return this.request('registerProviderProduct', params.urlParams, params.data);
+ }
- public registerProductLot () {}
+ public registerProductLot (params: { urlParams: any; data: any }): Observable {
+ return this.request('registerProductLot', params.urlParams, params.data);
+ }
- public getProviders () {}
+ public getProviders (params: { urlParams: any; data: any }): Observable {
+ return this.request('getProviders', params.urlParams, params.data);
+ }
- public getProvider () {}
+ public getProvider (params: { urlParams: { providerId: string }; data: GetProviderRequestParams }): Observable {
+ return this.request('getProvider', params.urlParams, params.data);
+ }
- public getProviderProducts () {}
+ public getProviderProducts (params: { urlParams: { providerId: string }; data: GetProviderProductsRequestParams }): Observable {
+ return this.request('getProviderProducts', params.urlParams, params.data);
+ }
- public getProduct () {}
+ public getProduct (params: { urlParams: any; data: any }): Observable {
+ return this.request('getProduct', params.urlParams, params.data);
+ }
- public getProductLots () {}
+ public getProductLots (params: { urlParams: any; data: any }): Observable {
+ return this.request('getProductLots', params.urlParams, params.data);
+ }
- public getLot () {}
+ public getLot (params: { urlParams: { lotId: string }; data: GetLotRequestParams }): Observable {
+ return this.request('getLot', params.urlParams, params.data);
+ }
}
\ No newline at end of file