Stefan Huber

dist

1 import { Rest } from './rest'; 1 import { Rest } from './rest';
2 import { Device } from './device'; 2 import { Device } from './device';
3 import { DeviceInfo } from '../api/device-info'; 3 import { DeviceInfo } from '../api/device-info';
4 +import { Node } from '../api/node';
4 export declare class Repository { 5 export declare class Repository {
5 protected rest: Rest; 6 protected rest: Rest;
6 protected device: Device; 7 protected device: Device;
7 protected _db: any; 8 protected _db: any;
8 protected _params: any; 9 protected _params: any;
10 + protected _node: Node;
9 db: any; 11 db: any;
10 params: any; 12 params: any;
13 + readonly localNode: Node;
11 constructor(rest: Rest, device: Device); 14 constructor(rest: Rest, device: Device);
12 findById(id: string): Promise<any>; 15 findById(id: string): Promise<any>;
13 findByIds(ids: Array<string>): Promise<Array<any>>; 16 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._node = null;
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, "localNode", {
41 + get: function () {
42 + return this._node;
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 };
...@@ -105,6 +113,7 @@ var Repository = (function () { ...@@ -105,6 +113,7 @@ var Repository = (function () {
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 var localCouchUrl = 'http://' + node.ip + ':' + node.couchPort + '/' + res.orig_db_name; 115 var localCouchUrl = 'http://' + node.ip + ':' + node.couchPort + '/' + res.orig_db_name;
116 + _this._node = node;
108 console.log("prepare local couch url: ", localCouchUrl); 117 console.log("prepare local couch url: ", localCouchUrl);
109 resolve(_this.prepare(localCouchUrl)); 118 resolve(_this.prepare(localCouchUrl));
110 }).catch(function () { 119 }).catch(function () {
......
1 import {Injectable} from '@angular/core'; 1 import {Injectable} from '@angular/core';
2 import {Rest} from './rest'; 2 import {Rest} from './rest';
3 -import { Device } from './device'; 3 +import {Device} from './device';
4 import {DeviceInfo} from '../api/device-info'; 4 import {DeviceInfo} from '../api/device-info';
5 +import {Node} from '../api/node';
5 6
6 declare var emit:any; 7 declare var emit:any;
7 8
...@@ -10,6 +11,7 @@ export class Repository { ...@@ -10,6 +11,7 @@ export class Repository {
10 11
11 protected _db:any; 12 protected _db:any;
12 protected _params:any; 13 protected _params:any;
14 + protected _node:Node = null;
13 15
14 get db() { 16 get db() {
15 return this._db; 17 return this._db;
...@@ -27,6 +29,10 @@ export class Repository { ...@@ -27,6 +29,10 @@ export class Repository {
27 this._params = params; 29 this._params = params;
28 } 30 }
29 31
32 + get localNode() {
33 + return this._node;
34 + }
35 +
30 constructor( 36 constructor(
31 protected rest:Rest , 37 protected rest:Rest ,
32 protected device:Device 38 protected device:Device
...@@ -100,6 +106,7 @@ export class Repository { ...@@ -100,6 +106,7 @@ export class Repository {
100 .then(node => { 106 .then(node => {
101 let res = this.parseUrl(response.db_url); 107 let res = this.parseUrl(response.db_url);
102 let localCouchUrl = 'http://' + node.ip + ':' + node.couchPort + '/' + res.orig_db_name; 108 let localCouchUrl = 'http://' + node.ip + ':' + node.couchPort + '/' + res.orig_db_name;
109 + this._node = node;
103 console.log("prepare local couch url: ", localCouchUrl); 110 console.log("prepare local couch url: ", localCouchUrl);
104 resolve(this.prepare(localCouchUrl)); 111 resolve(this.prepare(localCouchUrl));
105 }).catch(() => { 112 }).catch(() => {
......