Stefan Huber

repository changed

...@@ -6,8 +6,10 @@ export declare class Repository { ...@@ -6,8 +6,10 @@ export declare class Repository {
6 protected device: Device; 6 protected device: Device;
7 protected _db: any; 7 protected _db: any;
8 protected _params: any; 8 protected _params: any;
9 + protected _localWebPort: number;
9 db: any; 10 db: any;
10 params: any; 11 params: any;
12 + readonly localWebPort: number;
11 constructor(rest: Rest, device: Device); 13 constructor(rest: Rest, device: Device);
12 findById(id: string): Promise<any>; 14 findById(id: string): Promise<any>;
13 findByIds(ids: Array<string>): Promise<Array<any>>; 15 findByIds(ids: Array<string>): Promise<Array<any>>;
......
...@@ -15,6 +15,7 @@ var Repository = (function () { ...@@ -15,6 +15,7 @@ var Repository = (function () {
15 function Repository(rest, device) { 15 function Repository(rest, device) {
16 this.rest = rest; 16 this.rest = rest;
17 this.device = device; 17 this.device = device;
18 + this._localWebPort = 8320;
18 } 19 }
19 Object.defineProperty(Repository.prototype, "db", { 20 Object.defineProperty(Repository.prototype, "db", {
20 get: function () { 21 get: function () {
...@@ -36,6 +37,13 @@ var Repository = (function () { ...@@ -36,6 +37,13 @@ var Repository = (function () {
36 enumerable: true, 37 enumerable: true,
37 configurable: true 38 configurable: true
38 }); 39 });
40 + Object.defineProperty(Repository.prototype, "localWebPort", {
41 + get: function () {
42 + return this._localWebPort;
43 + },
44 + enumerable: true,
45 + configurable: true
46 + });
39 Repository.prototype.findById = function (id) { 47 Repository.prototype.findById = function (id) {
40 return this.db.get(id); 48 return this.db.get(id);
41 }; 49 };
...@@ -104,7 +112,7 @@ var Repository = (function () { ...@@ -104,7 +112,7 @@ var Repository = (function () {
104 _this.rest.scanEnvironment(response.local_ips) 112 _this.rest.scanEnvironment(response.local_ips)
105 .then(function (node) { 113 .then(function (node) {
106 var res = _this.parseUrl(response.db_url); 114 var res = _this.parseUrl(response.db_url);
107 - resolve(_this.prepare(res.protocol + '://' + res.user + ':' + res.pass + '@' + res.domain + '/' + res.orig_db_name)); 115 + resolve(_this.prepare(res.protocol + '://' + res.user + ':' + res.pass + '@' + node.IP + ':' + _this.localWebPort + '/' + res.orig_db_name));
108 }).catch(function () { 116 }).catch(function () {
109 resolve(_this.prepare(response.db_url)); 117 resolve(_this.prepare(response.db_url));
110 }); 118 });
......
...@@ -10,6 +10,7 @@ export class Repository { ...@@ -10,6 +10,7 @@ export class Repository {
10 10
11 protected _db:any; 11 protected _db:any;
12 protected _params:any; 12 protected _params:any;
13 + protected _localWebPort:number = 8320;
13 14
14 get db() { 15 get db() {
15 return this._db; 16 return this._db;
...@@ -27,6 +28,10 @@ export class Repository { ...@@ -27,6 +28,10 @@ export class Repository {
27 this._params = params; 28 this._params = params;
28 } 29 }
29 30
31 + get localWebPort() : number {
32 + return this._localWebPort;
33 + }
34 +
30 constructor( 35 constructor(
31 protected rest:Rest , 36 protected rest:Rest ,
32 protected device:Device 37 protected device:Device
...@@ -99,7 +104,7 @@ export class Repository { ...@@ -99,7 +104,7 @@ export class Repository {
99 this.rest.scanEnvironment(response.local_ips) 104 this.rest.scanEnvironment(response.local_ips)
100 .then(node => { 105 .then(node => {
101 let res = this.parseUrl(response.db_url); 106 let res = this.parseUrl(response.db_url);
102 - resolve(this.prepare(res.protocol + '://' + res.user + ':' + res.pass + '@' + res.domain + '/' + res.orig_db_name)); 107 + resolve(this.prepare(res.protocol + '://' + res.user + ':' + res.pass + '@' + node.IP + ':' + this.localWebPort + '/' + res.orig_db_name));
103 }).catch(() => { 108 }).catch(() => {
104 resolve(this.prepare(response.db_url)); 109 resolve(this.prepare(response.db_url));
105 }); 110 });
......