Browse Source

use the item location to address the correct node

Mark deVilliers 2 years ago
parent
commit
381bd03ba0
2 changed files with 25 additions and 8 deletions
  1. 20 3
      ui/search.js
  2. 5 5
      ui/src/Search.elm

+ 20 - 3
ui/search.js

@@ -10687,7 +10687,18 @@ var _user$project$Search$getTimeSeriesEncoder = function (key) {
10687 10687
 		});
10688 10688
 };
10689 10689
 var _user$project$Search$metadataURL = 'http://localhost:8081';
10690
-var _user$project$Search$nodeURL = 'http://localhost:8080';
10690
+var _user$project$Search$nodeURLFromLocation = function (location) {
10691
+	return A2(
10692
+		_elm_lang$core$Basics_ops['++'],
10693
+		'http://',
10694
+		A2(
10695
+			_elm_lang$core$Basics_ops['++'],
10696
+			location.ipAddress,
10697
+			A2(
10698
+				_elm_lang$core$Basics_ops['++'],
10699
+				':',
10700
+				_elm_lang$core$Basics$toString(location.ipPort))));
10701
+};
10691 10702
 var _user$project$Search$initialModel = {all: _elm_lang$core$Maybe$Nothing, filter: _elm_lang$core$Maybe$Nothing};
10692 10703
 var _user$project$Search$unsafeDrawGraph = _elm_lang$core$Native_Platform.outgoingPort(
10693 10704
 	'unsafeDrawGraph',
@@ -10739,7 +10750,10 @@ var _user$project$Search$requestAccess = function (item) {
10739 10750
 		{
10740 10751
 			method: 'PUT',
10741 10752
 			headers: {ctor: '[]'},
10742
-			url: A2(_elm_lang$core$Basics_ops['++'], _user$project$Search$nodeURL, '/entitlements/requests/'),
10753
+			url: A2(
10754
+				_elm_lang$core$Basics_ops['++'],
10755
+				_user$project$Search$nodeURLFromLocation(item.location),
10756
+				'/entitlements/requests/'),
10743 10757
 			body: _elm_lang$http$Http$jsonBody(
10744 10758
 				_user$project$Search$entitlementRequestEncoder(item)),
10745 10759
 			expect: _elm_lang$http$Http$expectJson(_user$project$Decoders$decodeEntitlement),
@@ -10758,7 +10772,10 @@ var _user$project$Search$ViewGraphCompleted = F2(
10758 10772
 var _user$project$Search$getTimeSeriesData = function (item) {
10759 10773
 	var request = A3(
10760 10774
 		_elm_lang$http$Http$post,
10761
-		A2(_elm_lang$core$Basics_ops['++'], _user$project$Search$nodeURL, '/data/'),
10775
+		A2(
10776
+			_elm_lang$core$Basics_ops['++'],
10777
+			_user$project$Search$nodeURLFromLocation(item.location),
10778
+			'/data/'),
10762 10779
 		_elm_lang$http$Http$jsonBody(
10763 10780
 			_user$project$Search$getTimeSeriesEncoder(item.key)),
10764 10781
 		_user$project$Decoders$decodeDataResponse);

+ 5 - 5
ui/src/Search.elm

@@ -147,9 +147,9 @@ prepareGraphData items =
147 147
 -- RPC
148 148
 
149 149
 
150
-nodeURL : String
151
-nodeURL =
152
-    "http://localhost:8080"
150
+nodeURLFromLocation : Decoders.Location -> String
151
+nodeURLFromLocation location =
152
+    "http://" ++ location.ipAddress ++ ":" ++ toString (location.ipPort)
153 153
 
154 154
 
155 155
 metadataURL : String
@@ -175,7 +175,7 @@ getTimeSeriesData : Decoders.Item -> Cmd Msg
175 175
 getTimeSeriesData item =
176 176
     let
177 177
         request =
178
-            Http.post (nodeURL ++ "/data/") (Http.jsonBody (getTimeSeriesEncoder item.key)) Decoders.decodeDataResponse
178
+            Http.post (nodeURLFromLocation (item.location) ++ "/data/") (Http.jsonBody (getTimeSeriesEncoder item.key)) Decoders.decodeDataResponse
179 179
     in
180 180
         Http.send (ViewGraphCompleted item) request
181 181
 
@@ -195,7 +195,7 @@ requestAccess item =
195 195
             Http.request
196 196
                 { method = "PUT"
197 197
                 , headers = []
198
-                , url = nodeURL ++ "/entitlements/requests/"
198
+                , url = nodeURLFromLocation (item.location) ++ "/entitlements/requests/"
199 199
                 , body = Http.jsonBody (entitlementRequestEncoder item)
200 200
                 , expect = Http.expectJson Decoders.decodeEntitlement
201 201
                 , timeout = Nothing