@@ -152,6 +152,16 @@ var ApiClient = {
152
152
getCsrfToken : function ( ) {
153
153
return jQuery ( "meta[name='_csrf']" ) . attr ( "content" ) ;
154
154
} ,
155
+ baseUrl : null ,
156
+ getBaseUrl : function ( ) {
157
+ if ( ApiClient . baseUrl == null ) {
158
+ ApiClient . baseUrl = jQuery ( "meta[name='_url_base']" ) . attr ( "content" ) ;
159
+ }
160
+ return ApiClient . baseUrl ;
161
+ } ,
162
+ buildUrl : function ( url ) {
163
+ return ApiClient . getBaseUrl ( ) + url ;
164
+ } ,
155
165
// Returns the CSRF Header name
156
166
getCsrfHeader : function ( ) {
157
167
var headerName = jQuery ( "meta[name='_csrf_header']" ) . attr ( "content" ) ;
@@ -164,7 +174,7 @@ var ApiClient = {
164
174
consume : function ( viewId , params , successCallback ) {
165
175
jQuery . ajax ( {
166
176
type : 'POST' ,
167
- url : '/ api/consumer/view/' + viewId ,
177
+ url : ApiClient . buildUrl ( ' api/consumer/view/' + viewId ) ,
168
178
dataType : 'json' ,
169
179
contentType : 'application/json' ,
170
180
data : JSON . stringify ( params ) ,
@@ -191,7 +201,7 @@ var ApiClient = {
191
201
seekTimestamp : function ( viewId , unixTimestamp , callback ) {
192
202
jQuery . ajax ( {
193
203
type : 'POST' ,
194
- url : '/ api/consumer/view/' + viewId + '/timestamp/' + unixTimestamp ,
204
+ url : ApiClient . buildUrl ( ' api/consumer/view/' + viewId + '/timestamp/' + unixTimestamp ) ,
195
205
dataType : 'json' ,
196
206
headers : ApiClient . getCsrfHeader ( ) ,
197
207
success : callback ,
@@ -201,7 +211,7 @@ var ApiClient = {
201
211
setConsumerState : function ( viewId , partitionOffsetJson , callback ) {
202
212
jQuery . ajax ( {
203
213
type : 'POST' ,
204
- url : '/ api/consumer/view/' + viewId + '/offsets' ,
214
+ url : ApiClient . buildUrl ( ' api/consumer/view/' + viewId + '/offsets' ) ,
205
215
data : partitionOffsetJson ,
206
216
dataType : 'json' ,
207
217
headers : ApiClient . getCsrfHeader ( ) ,
@@ -219,64 +229,64 @@ var ApiClient = {
219
229
*/
220
230
getPartitionsForView : function ( viewId , callback ) {
221
231
jQuery
222
- . getJSON ( '/ api/view/' + viewId + '/partitions' , '' , callback )
232
+ . getJSON ( ApiClient . buildUrl ( ' api/view/' + viewId + '/partitions' ) , '' , callback )
223
233
. fail ( ApiClient . defaultErrorHandler ) ;
224
234
} ,
225
235
226
236
// Retrieve cluster node info
227
237
getClusterNodes : function ( clusterId , callback ) {
228
238
jQuery
229
- . getJSON ( '/ api/cluster/' + clusterId + '/nodes' , '' , callback )
239
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/nodes' ) , '' , callback )
230
240
. fail ( ApiClient . defaultErrorHandler ) ;
231
241
} ,
232
242
getTopicDetails : function ( clusterId , topic , callback ) {
233
243
jQuery
234
- . getJSON ( '/ api/cluster/' + clusterId + '/topic/' + topic + '/details' , '' , callback )
244
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/topic/' + topic + '/details' ) , '' , callback )
235
245
. fail ( ApiClient . defaultErrorHandler ) ;
236
246
} ,
237
247
getAllTopicsDetails : function ( clusterId , callback ) {
238
248
jQuery
239
- . getJSON ( '/ api/cluster/' + clusterId + '/topics/details' , '' , callback )
249
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/topics/details' ) , '' , callback )
240
250
. fail ( ApiClient . defaultErrorHandler ) ;
241
251
} ,
242
252
getTopics : function ( clusterId , callback ) {
243
253
jQuery
244
- . getJSON ( '/ api/cluster/' + clusterId + '/topics/list' , '' , callback )
254
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/topics/list' ) , '' , callback )
245
255
. fail ( ApiClient . defaultErrorHandler ) ;
246
256
} ,
247
257
getTopicConfig : function ( clusterId , topic , callback ) {
248
258
jQuery
249
- . getJSON ( '/ api/cluster/' + clusterId + '/topic/' + topic + '/config' , '' , callback )
259
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/topic/' + topic + '/config' ) , '' , callback )
250
260
. fail ( ApiClient . defaultErrorHandler ) ;
251
261
} ,
252
262
getBrokerConfig : function ( clusterId , brokerId , callback ) {
253
263
jQuery
254
- . getJSON ( '/ api/cluster/' + clusterId + '/broker/' + brokerId + '/config' , '' , callback )
264
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/broker/' + brokerId + '/config' ) , '' , callback )
255
265
. fail ( ApiClient . defaultErrorHandler ) ;
256
266
} ,
257
267
getAllConsumers : function ( clusterId , callback ) {
258
268
jQuery
259
- . getJSON ( '/ api/cluster/' + clusterId + '/consumers' , '' , callback )
269
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/consumers' ) , '' , callback )
260
270
. fail ( ApiClient . defaultErrorHandler ) ;
261
271
} ,
262
272
getAllConsumersWithDetails : function ( clusterId , callback ) {
263
273
jQuery
264
- . getJSON ( '/ api/cluster/' + clusterId + '/consumersAndDetails' , '' , callback )
274
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/consumersAndDetails' ) , '' , callback )
265
275
. fail ( ApiClient . defaultErrorHandler ) ;
266
276
} ,
267
277
getConsumerDetails : function ( clusterId , consumerGroupId , callback ) {
268
278
jQuery
269
- . getJSON ( '/ api/cluster/' + clusterId + '/consumer/' + consumerGroupId + '/details' , '' , callback )
279
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/consumer/' + consumerGroupId + '/details' ) , '' , callback )
270
280
. fail ( ApiClient . defaultErrorHandler ) ;
271
281
} ,
272
282
getConsumerOffsets : function ( clusterId , consumerGroupId , callback ) {
273
283
jQuery
274
- . getJSON ( '/ api/cluster/' + clusterId + '/consumer/' + consumerGroupId + '/offsets' , '' , callback )
284
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/consumer/' + consumerGroupId + '/offsets' ) , '' , callback )
275
285
. fail ( ApiClient . defaultErrorHandler ) ;
276
286
} ,
277
287
getConsumerOffsetsWithTailPositions : function ( clusterId , consumerGroupId , callback ) {
278
288
jQuery
279
- . getJSON ( '/ api/cluster/' + clusterId + '/consumer/' + consumerGroupId + '/offsetsAndTailPositions' , '' , callback )
289
+ . getJSON ( ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/consumer/' + consumerGroupId + '/offsetsAndTailPositions' ) , '' , callback )
280
290
. fail ( ApiClient . defaultErrorHandler ) ;
281
291
} ,
282
292
removeConsumer : function ( clusterId , consumerId , callback ) {
@@ -286,7 +296,7 @@ var ApiClient = {
286
296
} ) ;
287
297
jQuery . ajax ( {
288
298
type : 'POST' ,
289
- url : '/ api/cluster/' + clusterId + '/consumer/remove' ,
299
+ url : ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/consumer/remove' ) ,
290
300
data : payload ,
291
301
dataType : 'json' ,
292
302
headers : ApiClient . getCsrfHeader ( ) ,
@@ -305,7 +315,7 @@ var ApiClient = {
305
315
} ) ;
306
316
jQuery . ajax ( {
307
317
type : 'POST' ,
308
- url : '/ api/cluster/' + clusterId + '/create/topic' ,
318
+ url : ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/create/topic' ) ,
309
319
data : payload ,
310
320
dataType : 'json' ,
311
321
headers : ApiClient . getCsrfHeader ( ) ,
@@ -326,7 +336,7 @@ var ApiClient = {
326
336
var payload = JSON . stringify ( payloadJson ) ;
327
337
jQuery . ajax ( {
328
338
type : 'POST' ,
329
- url : '/ api/cluster/' + clusterId + '/modify/topic' ,
339
+ url : ApiClient . buildUrl ( ' api/cluster/' + clusterId + '/modify/topic' ) ,
330
340
data : payload ,
331
341
dataType : 'json' ,
332
342
headers : ApiClient . getCsrfHeader ( ) ,
0 commit comments