Showing
9 changed files
with
25 additions
and
49 deletions
| ... | @@ -16,6 +16,12 @@ var repository_2 = require("./services/repository"); | ... | @@ -16,6 +16,12 @@ var repository_2 = require("./services/repository"); |
| 16 | exports.Repository = repository_2.Repository; | 16 | exports.Repository = repository_2.Repository; |
| 17 | var device_2 = require("./services/device"); | 17 | var device_2 = require("./services/device"); |
| 18 | exports.Device = device_2.Device; | 18 | exports.Device = device_2.Device; |
| 19 | +function provideRest(http) { | ||
| 20 | + return new rest_1.Rest(http); | ||
| 21 | +} | ||
| 22 | +function provideRepository(rest) { | ||
| 23 | + return new repository_1.Repository(rest, new device_1.Device); | ||
| 24 | +} | ||
| 19 | var DigsigServicesModule = DigsigServicesModule_1 = (function () { | 25 | var DigsigServicesModule = DigsigServicesModule_1 = (function () { |
| 20 | function DigsigServicesModule() { | 26 | function DigsigServicesModule() { |
| 21 | } | 27 | } |
| ... | @@ -23,9 +29,8 @@ var DigsigServicesModule = DigsigServicesModule_1 = (function () { | ... | @@ -23,9 +29,8 @@ var DigsigServicesModule = DigsigServicesModule_1 = (function () { |
| 23 | return { | 29 | return { |
| 24 | ngModule: DigsigServicesModule_1, | 30 | ngModule: DigsigServicesModule_1, |
| 25 | providers: [ | 31 | providers: [ |
| 26 | - rest_1.Rest, | 32 | + { provide: rest_1.Rest, useFactory: provideRest, deps: [http_1.Http] }, |
| 27 | - repository_1.Repository, | 33 | + { provide: repository_1.Repository, useFactory: provideRepository, deps: [rest_1.Rest] } |
| 28 | - device_1.Device | ||
| 29 | ] | 34 | ] |
| 30 | }; | 35 | }; |
| 31 | }; | 36 | }; | ... | ... |
| 1 | -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAAA,sCAA2C;AAC3C,sCAA8D;AAC9D,wCAAuC;AACvC,oDAAmD;AACnD,4CAA2C;AAE3C,wCAAuC;AAA9B,sBAAA,IAAI,CAAA;AACb,oDAAmD;AAA1C,kCAAA,UAAU,CAAA;AACnB,4CAA2C;AAAlC,0BAAA,MAAM,CAAA;AAOf,IAAa,oBAAoB;IAAjC;IAWA,CAAC;IAVQ,4BAAO,GAAd;QACE,MAAM,CAAC;YACL,QAAQ,EAAE,sBAAoB;YAC9B,SAAS,EAAE;gBACT,WAAI;gBACJ,uBAAU;gBACV,eAAM;aACP;SACF,CAAA;IACH,CAAC;IACH,2BAAC;AAAD,CAAC,AAXD,IAWC;AAXY,oBAAoB;IALhC,eAAQ,CAAC;QACN,OAAO,EAAG;YACN,iBAAU;SACb;KACJ,CAAC;GACW,oBAAoB,CAWhC;AAXY,oDAAoB"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAAA,sCAAiD;AACjD,sCAA8D;AAC9D,wCAAuC;AACvC,oDAAmD;AACnD,4CAA2C;AAE3C,wCAAuC;AAA9B,sBAAA,IAAI,CAAA;AACb,oDAAmD;AAA1C,kCAAA,UAAU,CAAA;AACnB,4CAA2C;AAAlC,0BAAA,MAAM,CAAA;AAEf,qBAAqB,IAAS;IAC1B,MAAM,CAAC,IAAI,WAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,2BAA2B,IAAS;IAChC,MAAM,CAAC,IAAI,uBAAU,CAAC,IAAI,EAAE,IAAI,eAAM,CAAC,CAAC;AAC5C,CAAC;AAOD,IAAa,oBAAoB;IAAjC;IAUA,CAAC;IATQ,4BAAO,GAAd;QACE,MAAM,CAAC;YACL,QAAQ,EAAE,sBAAoB;YAC9B,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,WAAI,EAAE,UAAU,EAAC,WAAW,EAAE,IAAI,EAAC,CAAC,WAAI,CAAC,EAAE;gBACtD,EAAE,OAAO,EAAE,uBAAU,EAAE,UAAU,EAAC,iBAAiB,EAAE,IAAI,EAAC,CAAC,WAAI,CAAC,EAAE;aACnE;SACF,CAAA;IACH,CAAC;IACH,2BAAC;AAAD,CAAC,AAVD,IAUC;AAVY,oBAAoB;IALhC,eAAQ,CAAC;QACN,OAAO,EAAG;YACN,iBAAU;SACb;KACJ,CAAC;GACW,oBAAoB,CAUhC;AAVY,oDAAoB"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | "use strict"; | 1 | "use strict"; |
| 2 | -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
| 3 | - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
| 4 | - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
| 5 | - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
| 6 | - return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
| 7 | -}; | ||
| 8 | -var __metadata = (this && this.__metadata) || function (k, v) { | ||
| 9 | - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
| 10 | -}; | ||
| 11 | -var core_1 = require("@angular/core"); | ||
| 12 | -var rest_1 = require("./rest"); | ||
| 13 | -var device_1 = require("./device"); | ||
| 14 | var Repository = (function () { | 2 | var Repository = (function () { |
| 15 | function Repository(rest, device) { | 3 | function Repository(rest, device) { |
| 16 | this.rest = rest; | 4 | this.rest = rest; |
| ... | @@ -202,10 +190,5 @@ var Repository = (function () { | ... | @@ -202,10 +190,5 @@ var Repository = (function () { |
| 202 | }; | 190 | }; |
| 203 | return Repository; | 191 | return Repository; |
| 204 | }()); | 192 | }()); |
| 205 | -Repository = __decorate([ | ||
| 206 | - core_1.Injectable(), | ||
| 207 | - __metadata("design:paramtypes", [rest_1.Rest, | ||
| 208 | - device_1.Device]) | ||
| 209 | -], Repository); | ||
| 210 | exports.Repository = Repository; | 193 | exports.Repository = Repository; |
| 211 | //# sourceMappingURL=repository.js.map | 194 | //# sourceMappingURL=repository.js.map |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed. Click to expand it.
| 1 | "use strict"; | 1 | "use strict"; |
| 2 | -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
| 3 | - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
| 4 | - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
| 5 | - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
| 6 | - return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
| 7 | -}; | ||
| 8 | -var __metadata = (this && this.__metadata) || function (k, v) { | ||
| 9 | - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
| 10 | -}; | ||
| 11 | -var core_1 = require("@angular/core"); | ||
| 12 | var http_1 = require("@angular/http"); | 2 | var http_1 = require("@angular/http"); |
| 13 | require("rxjs/add/operator/timeout"); | 3 | require("rxjs/add/operator/timeout"); |
| 14 | exports.ERROR_CODE_UNAUTHORIZED = "unauthorized"; | 4 | exports.ERROR_CODE_UNAUTHORIZED = "unauthorized"; |
| 15 | exports.ERROR_CODE_NOT_FOUND = "not-found"; | 5 | exports.ERROR_CODE_NOT_FOUND = "not-found"; |
| 16 | exports.ERROR_CODE_SERVER_ERROR = "server-error"; | 6 | exports.ERROR_CODE_SERVER_ERROR = "server-error"; |
| 17 | -var Rest = Rest_1 = (function () { | 7 | +var Rest = (function () { |
| 18 | function Rest(http) { | 8 | function Rest(http) { |
| 19 | this.http = http; | 9 | this.http = http; |
| 20 | } | 10 | } |
| ... | @@ -54,7 +44,7 @@ var Rest = Rest_1 = (function () { | ... | @@ -54,7 +44,7 @@ var Rest = Rest_1 = (function () { |
| 54 | var headers = new http_1.Headers(); | 44 | var headers = new http_1.Headers(); |
| 55 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); | 45 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); |
| 56 | deviceInfo.code = registerCode; | 46 | deviceInfo.code = registerCode; |
| 57 | - _this.http.post(Rest_1.serviceUrl + "/config/register", _this.prepareDeviceInfo(deviceInfo), { headers: headers }).subscribe(function (response) { | 47 | + _this.http.post(Rest.serviceUrl + "/config/register", _this.prepareDeviceInfo(deviceInfo), { headers: headers }).subscribe(function (response) { |
| 58 | resolve(); | 48 | resolve(); |
| 59 | }, function (error) { | 49 | }, function (error) { |
| 60 | if (error.status == 401) { | 50 | if (error.status == 401) { |
| ... | @@ -71,7 +61,7 @@ var Rest = Rest_1 = (function () { | ... | @@ -71,7 +61,7 @@ var Rest = Rest_1 = (function () { |
| 71 | return new Promise(function (resolve, reject) { | 61 | return new Promise(function (resolve, reject) { |
| 72 | var headers = new http_1.Headers(); | 62 | var headers = new http_1.Headers(); |
| 73 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); | 63 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); |
| 74 | - _this.http.post(Rest_1.serviceUrl + "/config/heartbeat", _this.prepareDeviceInfo(deviceInfo, false), { headers: headers }) | 64 | + _this.http.post(Rest.serviceUrl + "/config/heartbeat", _this.prepareDeviceInfo(deviceInfo, false), { headers: headers }) |
| 75 | .subscribe(function (response) { | 65 | .subscribe(function (response) { |
| 76 | resolve(response.json()); | 66 | resolve(response.json()); |
| 77 | }, function (error) { | 67 | }, function (error) { |
| ... | @@ -93,7 +83,7 @@ var Rest = Rest_1 = (function () { | ... | @@ -93,7 +83,7 @@ var Rest = Rest_1 = (function () { |
| 93 | var _this = this; | 83 | var _this = this; |
| 94 | return new Promise(function (resolve, reject) { | 84 | return new Promise(function (resolve, reject) { |
| 95 | if (node && node.IP) { | 85 | if (node && node.IP) { |
| 96 | - _this.http.get("http://" + node.IP + ":" + Rest_1.localWebPort + "/device") | 86 | + _this.http.get("http://" + node.IP + ":" + Rest.localWebPort + "/device") |
| 97 | .timeout(2000) | 87 | .timeout(2000) |
| 98 | .subscribe(function (response) { | 88 | .subscribe(function (response) { |
| 99 | try { | 89 | try { |
| ... | @@ -144,10 +134,5 @@ var Rest = Rest_1 = (function () { | ... | @@ -144,10 +134,5 @@ var Rest = Rest_1 = (function () { |
| 144 | }()); | 134 | }()); |
| 145 | Rest.localWebPort = 8320; | 135 | Rest.localWebPort = 8320; |
| 146 | Rest.serviceUrl = "http://someurl.com"; | 136 | Rest.serviceUrl = "http://someurl.com"; |
| 147 | -Rest = Rest_1 = __decorate([ | ||
| 148 | - core_1.Injectable(), | ||
| 149 | - __metadata("design:paramtypes", [http_1.Http]) | ||
| 150 | -], Rest); | ||
| 151 | exports.Rest = Rest; | 137 | exports.Rest = Rest; |
| 152 | -var Rest_1; | ||
| 153 | //# sourceMappingURL=rest.js.map | 138 | //# sourceMappingURL=rest.js.map |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/services/rest.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,sCAAyC;AACzC,sCAAoD;AAGpD,qCAAkC;AAErB,QAAA,uBAAuB,GAAU,cAAc,CAAC;AAChD,QAAA,oBAAoB,GAAU,WAAW,CAAC;AAC1C,QAAA,uBAAuB,GAAU,cAAc,CAAC;AAG7D,IAAa,IAAI;IAKb,cAAoB,IAAS;QAAT,SAAI,GAAJ,IAAI,CAAK;IAAG,CAAC;IAEjC,gCAAiB,GAAjB,UAAkB,UAAqB,EAAE,QAAuB;QAAvB,yBAAA,EAAA,eAAuB;QAC5D,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;YAChB,MAAM,IAAI,aAAa,GAAC,UAAU,CAAC,EAAE,CAAC;QAC1C,CAAC;QACD,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAA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I,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;YACrC,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACrC,KAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;iBACd,IAAI,CAAC,UAAA,IAAI;gBACN,OAAO,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC,KAAK,CAAC;gBACL,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;oBACnB,OAAO,CAAC,KAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;gBACzC,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACJ,MAAM,EAAE,CAAC;gBACb,CAAC;YACL,CAAC,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC;IAEL,WAAC;AAAD,CAAC,AAvID,IAuIC;AArIiB,iBAAY,GAAU,IAAI,CAAC;AAC3B,eAAU,GAAW,oBAAoB,CAAC;AAH/C,IAAI;IADhB,iBAAU,EAAE;qCAMgB,WAAI;GALpB,IAAI,CAuIhB;AAvIY,oBAAI"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/services/rest.ts"],"names":[],"mappings":";AAAA,sCAAoD;AAGpD,qCAAkC;AAErB,QAAA,uBAAuB,GAAU,cAAc,CAAC;AAChD,QAAA,oBAAoB,GAAU,WAAW,CAAC;AAC1C,QAAA,uBAAuB,GAAU,cAAc,CAAC;AAE7D;IAKI,cAAoB,IAAS;QAAT,SAAI,GAAJ,IAAI,CAAK;IAAG,CAAC;IAEjC,gCAAiB,GAAjB,UAAkB,UAAqB,EAAE,QAAuB;QAAvB,yB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AC,EAAE;oBACC,MAAM,EAAE,CAAC;gBACb,CAAC,CAAC,CAAC;YACX,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,MAAM,EAAE,CAAC;YACb,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,8BAAe,GAAf,UAAgB,KAAW;QAA3B,iBAeC;QAdG,MAAM,CAAC,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;YACrC,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACrC,KAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;iBACd,IAAI,CAAC,UAAA,IAAI;gBACN,OAAO,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC,KAAK,CAAC;gBACL,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;oBACnB,OAAO,CAAC,KAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;gBACzC,CAAC;gBAAC,IAAI,CAAC,CAAC;oBACJ,MAAM,EAAE,CAAC;gBACb,CAAC;YACL,CAAC,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC;IAEL,WAAC;AAAD,CAAC,AAvID;AAEkB,iBAAY,GAAU,IAAI,CAAC;AAC3B,eAAU,GAAW,oBAAoB,CAAC;AAH/C,oBAAI"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | -import { HttpModule } from '@angular/http'; | 1 | +import { HttpModule, Http } from '@angular/http'; |
| 2 | import { NgModule, ModuleWithProviders } from '@angular/core'; | 2 | import { NgModule, ModuleWithProviders } from '@angular/core'; |
| 3 | import { Rest } from './services/rest'; | 3 | import { Rest } from './services/rest'; |
| 4 | import { Repository } from './services/repository'; | 4 | import { Repository } from './services/repository'; |
| ... | @@ -8,6 +8,14 @@ export { Rest } from './services/rest'; | ... | @@ -8,6 +8,14 @@ export { Rest } from './services/rest'; |
| 8 | export { Repository } from './services/repository'; | 8 | export { Repository } from './services/repository'; |
| 9 | export { Device } from './services/device'; | 9 | export { Device } from './services/device'; |
| 10 | 10 | ||
| 11 | +function provideRest(http:Http) : Rest { | ||
| 12 | + return new Rest(http); | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +function provideRepository(rest:Rest) : Repository { | ||
| 16 | + return new Repository(rest, new Device); | ||
| 17 | +} | ||
| 18 | + | ||
| 11 | @NgModule({ | 19 | @NgModule({ |
| 12 | imports : [ | 20 | imports : [ |
| 13 | HttpModule | 21 | HttpModule |
| ... | @@ -18,9 +26,8 @@ export class DigsigServicesModule { | ... | @@ -18,9 +26,8 @@ export class DigsigServicesModule { |
| 18 | return { | 26 | return { |
| 19 | ngModule: DigsigServicesModule, | 27 | ngModule: DigsigServicesModule, |
| 20 | providers: [ | 28 | providers: [ |
| 21 | - Rest, | 29 | + { provide: Rest, useFactory:provideRest, deps:[Http] } , |
| 22 | - Repository, | 30 | + { provide: Repository, useFactory:provideRepository, deps:[Rest] } |
| 23 | - Device | ||
| 24 | ] | 31 | ] |
| 25 | } | 32 | } |
| 26 | } | 33 | } | ... | ... |
| 1 | -import {Injectable} from '@angular/core'; | ||
| 2 | import {Rest} from './rest'; | 1 | import {Rest} from './rest'; |
| 3 | import {Device} from './device'; | 2 | import {Device} from './device'; |
| 4 | import {DeviceInfo} from '../api/device-info'; | 3 | import {DeviceInfo} from '../api/device-info'; |
| ... | @@ -6,7 +5,6 @@ import {Node} from '../api/node'; | ... | @@ -6,7 +5,6 @@ import {Node} from '../api/node'; |
| 6 | 5 | ||
| 7 | declare var emit:any; | 6 | declare var emit:any; |
| 8 | 7 | ||
| 9 | -@Injectable() | ||
| 10 | export class Repository { | 8 | export class Repository { |
| 11 | 9 | ||
| 12 | protected _db:any; | 10 | protected _db:any; | ... | ... |
| 1 | -import {Injectable} from '@angular/core'; | ||
| 2 | import {Http,Response,Headers} from '@angular/http'; | 1 | import {Http,Response,Headers} from '@angular/http'; |
| 3 | import { DeviceInfo } from './../api/device-info'; | 2 | import { DeviceInfo } from './../api/device-info'; |
| 4 | import { Node } from './../api/node'; | 3 | import { Node } from './../api/node'; |
| ... | @@ -8,7 +7,6 @@ export const ERROR_CODE_UNAUTHORIZED:string = "unauthorized"; | ... | @@ -8,7 +7,6 @@ export const ERROR_CODE_UNAUTHORIZED:string = "unauthorized"; |
| 8 | export const ERROR_CODE_NOT_FOUND:string = "not-found"; | 7 | export const ERROR_CODE_NOT_FOUND:string = "not-found"; |
| 9 | export const ERROR_CODE_SERVER_ERROR:string = "server-error"; | 8 | export const ERROR_CODE_SERVER_ERROR:string = "server-error"; |
| 10 | 9 | ||
| 11 | -@Injectable() | ||
| 12 | export class Rest { | 10 | export class Rest { |
| 13 | 11 | ||
| 14 | public static localWebPort:number = 8320; | 12 | public static localWebPort:number = 8320; | ... | ... |
-
Please register or login to post a comment