Stefan Huber

dist

import { Rest } from './rest';
import { Device } from './device';
import { DeviceInfo } from '../api/device-info';
import { Node } from '../api/node';
export declare class Repository {
protected rest: Rest;
protected device: Device;
protected _db: any;
protected _params: any;
protected _node: Node;
db: any;
params: any;
readonly localNode: Node;
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._node = null;
}
Object.defineProperty(Repository.prototype, "db", {
get: function () {
......@@ -36,6 +37,13 @@ var Repository = (function () {
enumerable: true,
configurable: true
});
Object.defineProperty(Repository.prototype, "localNode", {
get: function () {
return this._node;
},
enumerable: true,
configurable: true
});
Repository.prototype.findById = function (id) {
return this.db.get(id);
};
......@@ -105,6 +113,7 @@ var Repository = (function () {
.then(function (node) {
var res = _this.parseUrl(response.db_url);
var localCouchUrl = 'http://' + node.ip + ':' + node.couchPort + '/' + res.orig_db_name;
_this._node = node;
console.log("prepare local couch url: ", localCouchUrl);
resolve(_this.prepare(localCouchUrl));
}).catch(function () {
......
import {Injectable} from '@angular/core';
import {Rest} from './rest';
import { Device } from './device';
import {Device} from './device';
import {DeviceInfo} from '../api/device-info';
import {Node} from '../api/node';
declare var emit:any;
......@@ -10,6 +11,7 @@ export class Repository {
protected _db:any;
protected _params:any;
protected _node:Node = null;
get db() {
return this._db;
......@@ -27,6 +29,10 @@ export class Repository {
this._params = params;
}
get localNode() {
return this._node;
}
constructor(
protected rest:Rest ,
protected device:Device
......@@ -100,6 +106,7 @@ export class Repository {
.then(node => {
let res = this.parseUrl(response.db_url);
let localCouchUrl = 'http://' + node.ip + ':' + node.couchPort + '/' + res.orig_db_name;
this._node = node;
console.log("prepare local couch url: ", localCouchUrl);
resolve(this.prepare(localCouchUrl));
}).catch(() => {
......