Showing
16 changed files
with
98 additions
and
114 deletions
| 1 | -import { Http } from '@angular/http'; | ||
| 2 | import { Rest } from './services/rest'; | 1 | import { Rest } from './services/rest'; |
| 3 | import { Repository } from './services/repository'; | 2 | import { Repository } from './services/repository'; |
| 4 | export { Rest } from './services/rest'; | 3 | export { Rest } from './services/rest'; |
| 5 | export { Repository } from './services/repository'; | 4 | export { Repository } from './services/repository'; |
| 6 | export { Device } from './services/device'; | 5 | export { Device } from './services/device'; |
| 7 | -export declare function provideRest(http: Http): Rest; | 6 | +export declare function provideRest(): Rest; |
| 8 | export declare function provideRepository(rest: Rest): Repository; | 7 | export declare function provideRepository(rest: Rest): Repository; | ... | ... |
| ... | @@ -9,8 +9,8 @@ var repository_2 = require("./services/repository"); | ... | @@ -9,8 +9,8 @@ var repository_2 = require("./services/repository"); |
| 9 | exports.Repository = repository_2.Repository; | 9 | exports.Repository = repository_2.Repository; |
| 10 | var device_2 = require("./services/device"); | 10 | var device_2 = require("./services/device"); |
| 11 | exports.Device = device_2.Device; | 11 | exports.Device = device_2.Device; |
| 12 | -function provideRest(http) { | 12 | +function provideRest() { |
| 13 | - return new rest_1.Rest(http); | 13 | + return new rest_1.Rest(); |
| 14 | } | 14 | } |
| 15 | exports.provideRest = provideRest; | 15 | exports.provideRest = provideRest; |
| 16 | function provideRepository(rest) { | 16 | function provideRepository(rest) { | ... | ... |
| 1 | -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AACA,wCAAuC;AACvC,oDAAmD;AACnD,4CAA2C;AAE3C,wCAAuC;AAA9B,sBAAA,IAAI,CAAA;AACb,oDAAmD;AAA1C,kCAAA,UAAU,CAAA;AACnB,4CAA2C;AAAlC,0BAAA,MAAM,CAAA;AAEf,qBAA4B,IAAS;IACjC,MAAM,CAAC,IAAI,WAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAFD,kCAEC;AAED,2BAAkC,IAAS;IACvC,MAAM,CAAC,IAAI,uBAAU,CAAC,IAAI,EAAE,IAAI,eAAM,CAAC,CAAC;AAC5C,CAAC;AAFD,8CAEC"} | ||
| ... | \ 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,wCAAuC;AACvC,oDAAmD;AACnD,4CAA2C;AAC3C,wCAAuC;AAA9B,sBAAA,IAAI,CAAA;AACb,oDAAmD;AAA1C,kCAAA,UAAU,CAAA;AACnB,4CAA2C;AAAlC,0BAAA,MAAM,CAAA;AAEf;IACI,OAAO,IAAI,WAAI,EAAE,CAAC;AACtB,CAAC;AAFD,kCAEC;AAED,2BAAkC,IAAS;IACvC,OAAO,IAAI,uBAAU,CAAC,IAAI,EAAE,IAAI,eAAM,CAAC,CAAC;AAC5C,CAAC;AAFD,8CAEC"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | "use strict"; | 1 | "use strict"; |
| 2 | Object.defineProperty(exports, "__esModule", { value: true }); | 2 | Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 | -var Device = (function () { | 3 | +var Device = /** @class */ (function () { |
| 4 | function Device() { | 4 | function Device() { |
| 5 | } | 5 | } |
| 6 | Device.prototype.reload = function () { | 6 | Device.prototype.reload = function () { | ... | ... |
| 1 | -{"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/services/device.ts"],"names":[],"mappings":";;AAAA;IAAA;IA6BA,CAAC;IA3BG,uBAAM,GAAN;QACI,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC5B,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC7B,CAAC;IACL,CAAC;IAED,qBAAI,GAAJ;QACI,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;YAC7C,EAAE,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;gBACnC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACtC,CAAC;QACL,CAAC;QACD,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC9C,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,CAAC;IACL,CAAC;IAED,2BAAU,GAAV,UAAW,UAAU;QACjB,EAAE,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAI,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;YAC7C,EAAE,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;gBACnC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;YACxD,CAAC;QACL,CAAC;IACL,CAAC;IAEL,aAAC;AAAD,CAAC,AA7BD,IA6BC;AA7BY,wBAAM"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +{"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/services/device.ts"],"names":[],"mappings":";;AAAA;IAAA;IA6BA,CAAC;IA3BG,uBAAM,GAAN;QACI,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE;YAC3B,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;SAC5B;IACL,CAAC;IAED,qBAAI,GAAJ;QACI,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE;YAC7B,IAAI,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;YAC7C,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE;gBAClC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACrC;SACJ;QACD,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAC7C,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;SACxC;IACL,CAAC;IAED,2BAAU,GAAV,UAAW,UAAU;QACjB,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE;YAC7B,IAAI,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,CAAC;YAC7C,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE;gBAClC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;aACvD;SACJ;IACL,CAAC;IAEL,aAAC;AAAD,CAAC,AA7BD,IA6BC;AA7BY,wBAAM"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | "use strict"; | 1 | "use strict"; |
| 2 | Object.defineProperty(exports, "__esModule", { value: true }); | 2 | Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 | -var Repository = (function () { | 3 | +var Repository = /** @class */ (function () { |
| 4 | function Repository(rest, device) { | 4 | function Repository(rest, device) { |
| 5 | this.rest = rest; | 5 | this.rest = rest; |
| 6 | this.device = device; | 6 | this.device = device; | ... | ... |
This diff is collapsed. Click to expand it.
| 1 | -import { Http } from '@angular/http'; | ||
| 2 | import { DeviceInfo } from './../api/device-info'; | 1 | import { DeviceInfo } from './../api/device-info'; |
| 3 | import { Node } from './../api/node'; | 2 | import { Node } from './../api/node'; |
| 4 | -import 'rxjs/add/operator/timeout'; | ||
| 5 | export declare const ERROR_CODE_UNAUTHORIZED: string; | 3 | export declare const ERROR_CODE_UNAUTHORIZED: string; |
| 6 | export declare const ERROR_CODE_NOT_FOUND: string; | 4 | export declare const ERROR_CODE_NOT_FOUND: string; |
| 7 | export declare const ERROR_CODE_SERVER_ERROR: string; | 5 | export declare const ERROR_CODE_SERVER_ERROR: string; |
| 8 | export declare class Rest { | 6 | export declare class Rest { |
| 9 | - private http; | ||
| 10 | static localWebPort: number; | 7 | static localWebPort: number; |
| 11 | static serviceUrl: string; | 8 | static serviceUrl: string; |
| 12 | - constructor(http: Http); | ||
| 13 | prepareDeviceInfo(deviceInfo: DeviceInfo, prefixed?: boolean): string; | 9 | prepareDeviceInfo(deviceInfo: DeviceInfo, prefixed?: boolean): string; |
| 14 | register(registerCode: string, deviceInfo: DeviceInfo): Promise<any>; | 10 | register(registerCode: string, deviceInfo: DeviceInfo): Promise<any>; |
| 15 | heartbeat(deviceInfo: DeviceInfo): Promise<any>; | 11 | heartbeat(deviceInfo: DeviceInfo): Promise<any>; | ... | ... |
| 1 | "use strict"; | 1 | "use strict"; |
| 2 | Object.defineProperty(exports, "__esModule", { value: true }); | 2 | Object.defineProperty(exports, "__esModule", { value: true }); |
| 3 | -var http_1 = require("@angular/http"); | ||
| 4 | -require("rxjs/add/operator/timeout"); | ||
| 5 | exports.ERROR_CODE_UNAUTHORIZED = "unauthorized"; | 3 | exports.ERROR_CODE_UNAUTHORIZED = "unauthorized"; |
| 6 | exports.ERROR_CODE_NOT_FOUND = "not-found"; | 4 | exports.ERROR_CODE_NOT_FOUND = "not-found"; |
| 7 | exports.ERROR_CODE_SERVER_ERROR = "server-error"; | 5 | exports.ERROR_CODE_SERVER_ERROR = "server-error"; |
| 8 | -var Rest = (function () { | 6 | +var Rest = /** @class */ (function () { |
| 9 | - function Rest(http) { | 7 | + function Rest() { |
| 10 | - this.http = http; | ||
| 11 | } | 8 | } |
| 12 | Rest.prototype.prepareDeviceInfo = function (deviceInfo, prefixed) { | 9 | Rest.prototype.prepareDeviceInfo = function (deviceInfo, prefixed) { |
| 13 | if (prefixed === void 0) { prefixed = true; } | 10 | if (prefixed === void 0) { prefixed = true; } |
| ... | @@ -42,75 +39,82 @@ var Rest = (function () { | ... | @@ -42,75 +39,82 @@ var Rest = (function () { |
| 42 | Rest.prototype.register = function (registerCode, deviceInfo) { | 39 | Rest.prototype.register = function (registerCode, deviceInfo) { |
| 43 | var _this = this; | 40 | var _this = this; |
| 44 | return new Promise(function (resolve, reject) { | 41 | return new Promise(function (resolve, reject) { |
| 45 | - var headers = new http_1.Headers(); | 42 | + var headers = new Headers(); |
| 46 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); | 43 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); |
| 47 | deviceInfo.code = registerCode; | 44 | deviceInfo.code = registerCode; |
| 48 | - _this.http.post(Rest.serviceUrl + "/config/register", _this.prepareDeviceInfo(deviceInfo), { headers: headers }).subscribe(function (response) { | 45 | + fetch(Rest.serviceUrl + "/config/register", { |
| 46 | + method: 'POST', | ||
| 47 | + headers: headers, | ||
| 48 | + body: _this.prepareDeviceInfo(deviceInfo) | ||
| 49 | + }).then(function (response) { | ||
| 50 | + if (response.ok) { | ||
| 49 | resolve(); | 51 | resolve(); |
| 50 | - }, function (error) { | 52 | + } |
| 51 | - if (error.status == 401) { | 53 | + else if (response.status == 401) { |
| 52 | reject(exports.ERROR_CODE_UNAUTHORIZED); | 54 | reject(exports.ERROR_CODE_UNAUTHORIZED); |
| 53 | } | 55 | } |
| 54 | else { | 56 | else { |
| 55 | reject(exports.ERROR_CODE_SERVER_ERROR); | 57 | reject(exports.ERROR_CODE_SERVER_ERROR); |
| 56 | } | 58 | } |
| 59 | + }).catch(function () { | ||
| 60 | + reject(exports.ERROR_CODE_SERVER_ERROR); | ||
| 57 | }); | 61 | }); |
| 58 | }); | 62 | }); |
| 59 | }; | 63 | }; |
| 60 | Rest.prototype.heartbeat = function (deviceInfo) { | 64 | Rest.prototype.heartbeat = function (deviceInfo) { |
| 61 | var _this = this; | 65 | var _this = this; |
| 62 | return new Promise(function (resolve, reject) { | 66 | return new Promise(function (resolve, reject) { |
| 63 | - var headers = new http_1.Headers(); | 67 | + var headers = new Headers(); |
| 64 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); | 68 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); |
| 65 | - _this.http.post(Rest.serviceUrl + "/config/heartbeat", _this.prepareDeviceInfo(deviceInfo, false), { headers: headers }) | 69 | + fetch(Rest.serviceUrl + "/config/heartbeat", { |
| 66 | - .subscribe(function (response) { | 70 | + method: 'POST', |
| 67 | - resolve(response.json()); | 71 | + headers: headers, |
| 68 | - }, function (error) { | 72 | + body: _this.prepareDeviceInfo(deviceInfo, false) |
| 69 | - switch (error.status) { | 73 | + }).then(function (response) { |
| 70 | - case 401: | 74 | + if (response.ok) { |
| 75 | + resolve(); | ||
| 76 | + } | ||
| 77 | + else if (response.status == 401) { | ||
| 71 | reject(exports.ERROR_CODE_UNAUTHORIZED); | 78 | reject(exports.ERROR_CODE_UNAUTHORIZED); |
| 72 | - break; | 79 | + } |
| 73 | - case 404: | 80 | + else if (response.status == 404) { |
| 74 | reject(exports.ERROR_CODE_NOT_FOUND); | 81 | reject(exports.ERROR_CODE_NOT_FOUND); |
| 75 | - break; | 82 | + } |
| 76 | - default: | 83 | + else { |
| 77 | reject(exports.ERROR_CODE_SERVER_ERROR); | 84 | reject(exports.ERROR_CODE_SERVER_ERROR); |
| 78 | - break; | ||
| 79 | } | 85 | } |
| 86 | + }).catch(function () { | ||
| 87 | + reject(exports.ERROR_CODE_SERVER_ERROR); | ||
| 80 | }); | 88 | }); |
| 81 | }); | 89 | }); |
| 82 | }; | 90 | }; |
| 83 | Rest.prototype.scanNode = function (node) { | 91 | Rest.prototype.scanNode = function (node) { |
| 84 | - var _this = this; | ||
| 85 | return new Promise(function (resolve, reject) { | 92 | return new Promise(function (resolve, reject) { |
| 86 | if (node && node.IP) { | 93 | if (node && node.IP) { |
| 87 | - _this.http.get("http://" + node.IP + ":" + Rest.localWebPort + "/device") | 94 | + fetch("http://" + node.IP + ":" + Rest.localWebPort + "/device") |
| 88 | - .timeout(2000) | 95 | + .then(function (response) { |
| 89 | - .subscribe(function (response) { | 96 | + if (response.ok) { |
| 90 | - try { | 97 | + return response.json(); |
| 91 | - var body = response.json(); | ||
| 92 | - if (body.device_id == node.UUID) { | ||
| 93 | - resolve({ | ||
| 94 | - ip: node.IP, | ||
| 95 | - uuid: body.device_id, | ||
| 96 | - couchPort: body.couch_port, | ||
| 97 | - webPort: body.web_port | ||
| 98 | - }); | ||
| 99 | } | 98 | } |
| 100 | else { | 99 | else { |
| 101 | reject(); | 100 | reject(); |
| 102 | } | 101 | } |
| 102 | + }).then(function (data) { | ||
| 103 | + if (data.device_id == node.UUID) { | ||
| 104 | + resolve({ | ||
| 105 | + ip: node.IP, | ||
| 106 | + uuid: data.device_id, | ||
| 107 | + couchPort: data.couch_port, | ||
| 108 | + webPort: data.web_port | ||
| 109 | + }); | ||
| 103 | } | 110 | } |
| 104 | - catch (e) { | 111 | + else { |
| 105 | reject(); | 112 | reject(); |
| 106 | } | 113 | } |
| 107 | - }, function () { | 114 | + }).catch(function () { |
| 108 | reject(); | 115 | reject(); |
| 109 | }); | 116 | }); |
| 110 | } | 117 | } |
| 111 | - else { | ||
| 112 | - reject(); | ||
| 113 | - } | ||
| 114 | }); | 118 | }); |
| 115 | }; | 119 | }; |
| 116 | Rest.prototype.scanEnvironment = function (nodes) { | 120 | Rest.prototype.scanEnvironment = function (nodes) { |
| ... | @@ -131,9 +135,9 @@ var Rest = (function () { | ... | @@ -131,9 +135,9 @@ var Rest = (function () { |
| 131 | }); | 135 | }); |
| 132 | }); | 136 | }); |
| 133 | }; | 137 | }; |
| 138 | + Rest.localWebPort = 8320; | ||
| 139 | + Rest.serviceUrl = "http://someurl.com"; | ||
| 134 | return Rest; | 140 | return Rest; |
| 135 | }()); | 141 | }()); |
| 136 | -Rest.localWebPort = 8320; | ||
| 137 | -Rest.serviceUrl = "http://someurl.com"; | ||
| 138 | exports.Rest = Rest; | 142 | exports.Rest = Rest; |
| 139 | //# sourceMappingURL=rest.js.map | 143 | //# 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,sCAAsD;AAGtD,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,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,CAAC,CAAC,CAAC;YACtB,MAAM,IAAI,mBAAmB,GAAC,UAAU,CAAC,QAAQ,CAAC;QACtD,CAAC;QACD,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;YACtB,MAAM,IAAI,mBAAmB,GAAC,UAAU,CAAC,QAAQ,CAAC;QACtD,CAAC;QACD,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;YAClB,MAAM,IAAI,eAAe,GAAC,UAAU,CAAC,IAAI,CAAC;QAC9C,CAAC;QACD,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;YACrB,MAAM,IAAI,kBAAkB,GAAC,UAAU,CAAC,OAAO,CAAC;QACpD,CAAC;QACD,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;YAClB,MAAM,IAAI,eAAe,GAAC,UAAU,CAAC,IAAI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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 | +{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/services/rest.ts"],"names":[],"mappings":";;AAGa,QAAA,uBAAuB,GAAU,cAAc,CAAC;AAChD,QAAA,oBAAoB,GAAU,WAAW,CAAC;AAC1C,QAAA,uBAAuB,GAAU,cAAc,CAAC;AAE7D;IAAA;IAuIA,CAAC;IAlIG,gCAAiB,GAAjB,UAAkB,UAAqB,EAAE,QAAuB;QAAvB,yBAAA,EAAA,eAAuB;QAC5D,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,IAAI,UAAU,CAAC,EAAE,EAAE;YACf,MAAM,IAAI,aAAa,GAAC,UAAU,CAAC,EAAE,CAAC;SACzC;QACD,IAAI,UAAU,CAAC,QAAQ,EAAE;YACrB,MAAM,IAAI,mBAAmB,GAAC,UAAU,CAAC,QAAQ,CAAC;SACrD;QACD,IAAI,UAAU,CAAC,QAAQ,EAAE;YACrB,MAAM,IAAI,mBAAmB,GAAC,UAAU,CAAC,QAAQ,CAAC;SACrD;QACD,IAAI,UAAU,CAAC,IAAI,EAAE;YACjB,MAAM,IAAI,eAAe,GAAC,UAAU,CAAC,IAAI,CAAC;SAC7C;QACD,IAAI,UAAU,CAAC,OAAO,EAAE;YACpB,MAAM,IAAI,kBAAkB,GAAC,UAAU,CAAC,OAAO,CAAC;SACnD;QACD,IAAI,UAAU,CAAC,IAAI,EAAE;YACjB,MAAM,IAAI,eAAe,GAAC,UAAU,CAAC,IAAI,CAAC;SAC7C;QACD,IAAI,UAAU,CAAC,IAAI,EAAE;YACjB,MAAM,IAAI,iBAAiB,GAAC,UAAU,CAAC,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AAG,IAAI,CAAC,SAAS;4BACrB,SAAS,EAAG,IAAI,CAAC,UAAU;4BAC3B,OAAO,EAAG,IAAI,CAAC,QAAQ;yBAC1B,CAAC,CAAC;qBACN;yBAAM;wBACH,MAAM,EAAE,CAAC;qBACZ;gBACL,CAAC,CAAC,CAAC,KAAK,CAAC;oBACL,MAAM,EAAE,CAAC;gBACb,CAAC,CAAC,CAAC;aACV;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,8BAAe,GAAf,UAAgB,KAAW;QAA3B,iBAeC;QAdG,OAAO,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,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBAClB,OAAO,CAAC,KAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;iBACxC;qBAAM;oBACH,MAAM,EAAE,CAAC;iBACZ;YACL,CAAC,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC;IAnIa,iBAAY,GAAU,IAAI,CAAC;IAC3B,eAAU,GAAW,oBAAoB,CAAC;IAoI5D,WAAC;CAAA,AAvID,IAuIC;AAvIY,oBAAI"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
package-lock.json
0 → 100644
This diff is collapsed. Click to expand it.
| ... | @@ -15,23 +15,13 @@ | ... | @@ -15,23 +15,13 @@ |
| 15 | "author": "", | 15 | "author": "", |
| 16 | "license": "ISC", | 16 | "license": "ISC", |
| 17 | "devDependencies": { | 17 | "devDependencies": { |
| 18 | - "@angular/core": "4.1.0", | 18 | + "@types/jasmine": "^2.8.8", |
| 19 | - "@angular/http": "4.1.0", | 19 | + "jasmine": "^3.1.0", |
| 20 | - "@angular/common": "4.1.0", | 20 | + "pouchdb": "^6.4.3", |
| 21 | - "@angular/platform-browser": "4.1.0", | 21 | + "pouchdb-upsert": "^2.2.0", |
| 22 | - "@types/jasmine": "^2.5.43", | 22 | + "typescript": "^2.9.1" |
| 23 | - "jasmine": "^2.5.3", | ||
| 24 | - "pouchdb": "^6.1.2", | ||
| 25 | - "pouchdb-upsert": "^2.0.2", | ||
| 26 | - "reflect-metadata": "^0.1.9", | ||
| 27 | - "rxjs": "5.1.1", | ||
| 28 | - "sw-toolbox": "3.4.0", | ||
| 29 | - "typescript": "^2.3.2", | ||
| 30 | - "zone.js": "^0.8.4" | ||
| 31 | }, | 23 | }, |
| 32 | "peerDependencies": { | 24 | "peerDependencies": { |
| 33 | - "@angular/http": "*", | ||
| 34 | - "rxjs": "*", | ||
| 35 | "pouchdb": "*", | 25 | "pouchdb": "*", |
| 36 | "pouchdb-upsert": "*" | 26 | "pouchdb-upsert": "*" |
| 37 | } | 27 | } | ... | ... |
| ... | @@ -3,7 +3,7 @@ import {Rest} from '../src/services/rest'; | ... | @@ -3,7 +3,7 @@ import {Rest} from '../src/services/rest'; |
| 3 | describe('Rest API', () => { | 3 | describe('Rest API', () => { |
| 4 | 4 | ||
| 5 | Rest.serviceUrl = "http://digsig.local/config/register"; | 5 | Rest.serviceUrl = "http://digsig.local/config/register"; |
| 6 | - let restService : Rest = new Rest(null); | 6 | + let restService : Rest = new Rest(); |
| 7 | 7 | ||
| 8 | it('Prepare Device Info', () => { | 8 | it('Prepare Device Info', () => { |
| 9 | 9 | ... | ... |
| 1 | -import { Http } from '@angular/http'; | ||
| 2 | import { Rest } from './services/rest'; | 1 | import { Rest } from './services/rest'; |
| 3 | import { Repository } from './services/repository'; | 2 | import { Repository } from './services/repository'; |
| 4 | import { Device } from './services/device'; | 3 | import { Device } from './services/device'; |
| 5 | - | ||
| 6 | export { Rest } from './services/rest'; | 4 | export { Rest } from './services/rest'; |
| 7 | export { Repository } from './services/repository'; | 5 | export { Repository } from './services/repository'; |
| 8 | export { Device } from './services/device'; | 6 | export { Device } from './services/device'; |
| 9 | 7 | ||
| 10 | -export function provideRest(http:Http) : Rest { | 8 | +export function provideRest() : Rest { |
| 11 | - return new Rest(http); | 9 | + return new Rest(); |
| 12 | } | 10 | } |
| 13 | 11 | ||
| 14 | export function provideRepository(rest:Rest) : Repository { | 12 | export function provideRepository(rest:Rest) : Repository { | ... | ... |
| 1 | -import { Http,Response,Headers } from '@angular/http'; | ||
| 2 | import { DeviceInfo } from './../api/device-info'; | 1 | import { DeviceInfo } from './../api/device-info'; |
| 3 | import { Node } from './../api/node'; | 2 | import { Node } from './../api/node'; |
| 4 | -import 'rxjs/add/operator/timeout' | ||
| 5 | 3 | ||
| 6 | export const ERROR_CODE_UNAUTHORIZED:string = "unauthorized"; | 4 | export const ERROR_CODE_UNAUTHORIZED:string = "unauthorized"; |
| 7 | export const ERROR_CODE_NOT_FOUND:string = "not-found"; | 5 | export const ERROR_CODE_NOT_FOUND:string = "not-found"; |
| ... | @@ -12,8 +10,6 @@ export class Rest { | ... | @@ -12,8 +10,6 @@ export class Rest { |
| 12 | public static localWebPort:number = 8320; | 10 | public static localWebPort:number = 8320; |
| 13 | public static serviceUrl: string = "http://someurl.com"; | 11 | public static serviceUrl: string = "http://someurl.com"; |
| 14 | 12 | ||
| 15 | - constructor(private http:Http) {} | ||
| 16 | - | ||
| 17 | prepareDeviceInfo(deviceInfo:DeviceInfo, prefixed:boolean = true) : string { | 13 | prepareDeviceInfo(deviceInfo:DeviceInfo, prefixed:boolean = true) : string { |
| 18 | let output = ""; | 14 | let output = ""; |
| 19 | 15 | ||
| ... | @@ -47,23 +43,27 @@ export class Rest { | ... | @@ -47,23 +43,27 @@ export class Rest { |
| 47 | return output; | 43 | return output; |
| 48 | } | 44 | } |
| 49 | 45 | ||
| 50 | - register(registerCode: string, deviceInfo:DeviceInfo) : Promise<any> { | 46 | + register(registerCode:string, deviceInfo:DeviceInfo) : Promise<any> { |
| 51 | return new Promise<any>((resolve, reject) => { | 47 | return new Promise<any>((resolve, reject) => { |
| 52 | 48 | ||
| 53 | - var headers = new Headers(); | 49 | + let headers = new Headers(); |
| 54 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); | 50 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); |
| 55 | deviceInfo.code = registerCode; | 51 | deviceInfo.code = registerCode; |
| 56 | 52 | ||
| 57 | - this.http.post(Rest.serviceUrl+"/config/register", | 53 | + fetch(Rest.serviceUrl+"/config/register", { |
| 58 | - this.prepareDeviceInfo(deviceInfo), | 54 | + method: 'POST' , |
| 59 | - { headers: headers }).subscribe((response:Response) => { | 55 | + headers : headers , |
| 56 | + body : this.prepareDeviceInfo(deviceInfo) | ||
| 57 | + }).then(response => { | ||
| 58 | + if (response.ok) { | ||
| 60 | resolve(); | 59 | resolve(); |
| 61 | - }, (error:Response) => { | 60 | + } else if (response.status == 401) { |
| 62 | - if (error.status == 401) { | ||
| 63 | reject(ERROR_CODE_UNAUTHORIZED); | 61 | reject(ERROR_CODE_UNAUTHORIZED); |
| 64 | } else { | 62 | } else { |
| 65 | reject(ERROR_CODE_SERVER_ERROR); | 63 | reject(ERROR_CODE_SERVER_ERROR); |
| 66 | } | 64 | } |
| 65 | + }).catch(() => { | ||
| 66 | + reject(ERROR_CODE_SERVER_ERROR); | ||
| 67 | }); | 67 | }); |
| 68 | }); | 68 | }); |
| 69 | } | 69 | } |
| ... | @@ -74,53 +74,51 @@ export class Rest { | ... | @@ -74,53 +74,51 @@ export class Rest { |
| 74 | var headers = new Headers(); | 74 | var headers = new Headers(); |
| 75 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); | 75 | headers.append('Content-Type', 'application/x-www-form-urlencoded'); |
| 76 | 76 | ||
| 77 | - this.http.post(Rest.serviceUrl+"/config/heartbeat", | 77 | + fetch(Rest.serviceUrl+"/config/heartbeat", { |
| 78 | - this.prepareDeviceInfo(deviceInfo, false), | 78 | + method: 'POST' , |
| 79 | - { headers: headers }) | 79 | + headers: headers , |
| 80 | - .subscribe((response:Response) => { | 80 | + body: this.prepareDeviceInfo(deviceInfo, false) |
| 81 | - resolve(response.json()); | 81 | + }).then(response => { |
| 82 | - },(error:Response) => { | 82 | + if (response.ok) { |
| 83 | - switch (error.status) { | 83 | + resolve(); |
| 84 | - case 401: | 84 | + } else if (response.status == 401) { |
| 85 | reject(ERROR_CODE_UNAUTHORIZED); | 85 | reject(ERROR_CODE_UNAUTHORIZED); |
| 86 | - break; | 86 | + } else if (response.status == 404) { |
| 87 | - case 404: | ||
| 88 | reject(ERROR_CODE_NOT_FOUND); | 87 | reject(ERROR_CODE_NOT_FOUND); |
| 89 | - break; | 88 | + } else { |
| 90 | - default: | ||
| 91 | reject(ERROR_CODE_SERVER_ERROR); | 89 | reject(ERROR_CODE_SERVER_ERROR); |
| 92 | - break; | ||
| 93 | } | 90 | } |
| 91 | + }).catch(() => { | ||
| 92 | + reject(ERROR_CODE_SERVER_ERROR); | ||
| 94 | }); | 93 | }); |
| 94 | + | ||
| 95 | }); | 95 | }); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | scanNode(node:any) : Promise<Node> { | 98 | scanNode(node:any) : Promise<Node> { |
| 99 | return new Promise<Node> ((resolve, reject) => { | 99 | return new Promise<Node> ((resolve, reject) => { |
| 100 | if (node && node.IP) { | 100 | if (node && node.IP) { |
| 101 | - this.http.get("http://" + node.IP + ":" + Rest.localWebPort + "/device") | 101 | + fetch("http://" + node.IP + ":" + Rest.localWebPort + "/device") |
| 102 | - .timeout(2000) | 102 | + .then((response) => { |
| 103 | - .subscribe(response => { | 103 | + if (response.ok) { |
| 104 | - try { | 104 | + return response.json() |
| 105 | - let body = response.json(); | 105 | + } else { |
| 106 | - if (body.device_id == node.UUID) { | 106 | + reject(); |
| 107 | + } | ||
| 108 | + }).then((data) => { | ||
| 109 | + if (data.device_id == node.UUID) { | ||
| 107 | resolve({ | 110 | resolve({ |
| 108 | ip : node.IP , | 111 | ip : node.IP , |
| 109 | - uuid : body.device_id , | 112 | + uuid : data.device_id , |
| 110 | - couchPort : body.couch_port , | 113 | + couchPort : data.couch_port , |
| 111 | - webPort : body.web_port | 114 | + webPort : data.web_port |
| 112 | }); | 115 | }); |
| 113 | } else { | 116 | } else { |
| 114 | reject(); | 117 | reject(); |
| 115 | } | 118 | } |
| 116 | - } catch(e) { | 119 | + }).catch(() => { |
| 117 | - reject(); | ||
| 118 | - } | ||
| 119 | - }, () => { | ||
| 120 | reject(); | 120 | reject(); |
| 121 | }); | 121 | }); |
| 122 | - } else { | ||
| 123 | - reject(); | ||
| 124 | } | 122 | } |
| 125 | }); | 123 | }); |
| 126 | } | 124 | } | ... | ... |
-
Please register or login to post a comment