Stefan Huber

repository changed

......@@ -6,8 +6,10 @@ export declare class Repository {
protected device: Device;
protected _db: any;
protected _params: any;
protected _localWebPort: number;
db: any;
params: any;
readonly localWebPort: number;
constructor(rest: Rest, device: Device);
findById(id: string): Promise<any>;
findByIds(ids: Array<string>): Promise<Array<any>>;
......
......@@ -15,6 +15,7 @@ var Repository = (function () {
function Repository(rest, device) {
this.rest = rest;
this.device = device;
this._localWebPort = 8320;
}
Object.defineProperty(Repository.prototype, "db", {
get: function () {
......@@ -36,6 +37,13 @@ var Repository = (function () {
enumerable: true,
configurable: true
});
Object.defineProperty(Repository.prototype, "localWebPort", {
get: function () {
return this._localWebPort;
},
enumerable: true,
configurable: true
});
Repository.prototype.findById = function (id) {
return this.db.get(id);
};
......@@ -104,7 +112,7 @@ var Repository = (function () {
_this.rest.scanEnvironment(response.local_ips)
.then(function (node) {
var res = _this.parseUrl(response.db_url);
resolve(_this.prepare(res.protocol + '://' + res.user + ':' + res.pass + '@' + res.domain + '/' + res.orig_db_name));
resolve(_this.prepare(res.protocol + '://' + res.user + ':' + res.pass + '@' + node.IP + ':' + _this.localWebPort + '/' + res.orig_db_name));
}).catch(function () {
resolve(_this.prepare(response.db_url));
});
......
......@@ -10,6 +10,7 @@ export class Repository {
protected _db:any;
protected _params:any;
protected _localWebPort:number = 8320;
get db() {
return this._db;
......@@ -27,6 +28,10 @@ export class Repository {
this._params = params;
}
get localWebPort() : number {
return this._localWebPort;
}
constructor(
protected rest:Rest ,
protected device:Device
......@@ -99,7 +104,7 @@ export class Repository {
this.rest.scanEnvironment(response.local_ips)
.then(node => {
let res = this.parseUrl(response.db_url);
resolve(this.prepare(res.protocol + '://' + res.user + ':' + res.pass + '@' + res.domain + '/' + res.orig_db_name));
resolve(this.prepare(res.protocol + '://' + res.user + ':' + res.pass + '@' + node.IP + ':' + this.localWebPort + '/' + res.orig_db_name));
}).catch(() => {
resolve(this.prepare(response.db_url));
});
......