diff --git a/ui/index.html b/ui/index.html index 4102c50b1..469a9f1ca 100644 --- a/ui/index.html +++ b/ui/index.html @@ -9,6 +9,13 @@ + + diff --git a/ui/javascripts/app/controllers.js b/ui/javascripts/app/controllers.js index fdb2d972e..ef1cb527d 100644 --- a/ui/javascripts/app/controllers.js +++ b/ui/javascripts/app/controllers.js @@ -86,7 +86,7 @@ KvBaseController = Ember.ObjectController.extend({ var token = App.get('settings.token'); Ember.$.ajax({ - url: (formatUrl('/v1/kv/' + parent + '?keys', dc, token)), + url: (formatUrl(consulHost + '/v1/kv/' + parent + '?keys', dc, token)), type: 'GET' }).then(function(data) { controller.transitionToRoute('kv.show', parent); @@ -127,7 +127,7 @@ App.KvShowController = KvBaseController.extend(Ember.Validations.Mixin, { // Put the Key and the Value retrieved from the form Ember.$.ajax({ - url: (formatUrl("/v1/kv/" + newKey.get('Key'), dc, token)), + url: (formatUrl(consulHost + "/v1/kv/" + newKey.get('Key'), dc, token)), type: 'PUT', data: newKey.get('Value') }).then(function(response) { @@ -155,7 +155,7 @@ App.KvShowController = KvBaseController.extend(Ember.Validations.Mixin, { if (window.confirm("Are you sure you want to delete this folder?")) { // Delete the folder Ember.$.ajax({ - url: (formatUrl("/v1/kv/" + controller.get('parentKey') + '?recurse', dc, token)), + url: (formatUrl(consulHost + "/v1/kv/" + controller.get('parentKey') + '?recurse', dc, token)), type: 'DELETE' }).then(function(response) { controller.transitionToNearestParent(grandParent); @@ -186,7 +186,7 @@ App.KvEditController = KvBaseController.extend({ // Put the key and the decoded (plain text) value // from the form. Ember.$.ajax({ - url: (formatUrl("/v1/kv/" + key.get('Key'), dc, token)), + url: (formatUrl(consulHost + "/v1/kv/" + key.get('Key'), dc, token)), type: 'PUT', data: key.get('valueDecoded') }).then(function(response) { @@ -215,7 +215,7 @@ App.KvEditController = KvBaseController.extend({ // Delete the key Ember.$.ajax({ - url: (formatUrl("/v1/kv/" + key.get('Key'), dc, token)), + url: (formatUrl(consulHost + "/v1/kv/" + key.get('Key'), dc, token)), type: 'DELETE' }).then(function(data) { controller.transitionToNearestParent(parent); @@ -285,7 +285,7 @@ App.NodesShowController = Ember.ObjectController.extend({ if (window.confirm("Are you sure you want to deregister this node?")) { // Deregister node Ember.$.ajax({ - url: formatUrl('/v1/catalog/deregister', dc, token), + url: formatUrl(consulHost + '/v1/catalog/deregister', dc, token), type: 'PUT', data: JSON.stringify({ 'Datacenter': dc, @@ -313,10 +313,10 @@ App.NodesShowController = Ember.ObjectController.extend({ if (window.confirm("Are you sure you want to invalidate this session?")) { // Delete the session Ember.$.ajax({ - url: (formatUrl("/v1/session/destroy/" + sessionId, dc, token)), + url: (formatUrl(consulHost + "/v1/session/destroy/" + sessionId, dc, token)), type: 'PUT' }).then(function(response) { - return Ember.$.getJSON(formatUrl('/v1/session/node/' + node.Node, dc, token)).then(function(data) { + return Ember.$.getJSON(formatUrl(consulHost + '/v1/session/node/' + node.Node, dc, token)).then(function(data) { controller.set('sessions', data); }); }).fail(function(response) { @@ -381,7 +381,7 @@ App.AclsController = Ember.ArrayController.extend({ // Create the ACL Ember.$.ajax({ - url: formatUrl('/v1/acl/create', dc, token), + url: formatUrl(consulHost + '/v1/acl/create', dc, token), type: 'PUT', data: JSON.stringify(newAcl) }).then(function(response) { @@ -389,7 +389,7 @@ App.AclsController = Ember.ArrayController.extend({ controller.transitionToRoute('acls.show', response.ID); // Get the ACL again, including the newly created one - Ember.$.getJSON(formatUrl('/v1/acl/list', dc, token)).then(function(data) { + Ember.$.getJSON(formatUrl(consulHost + '/v1/acl/list', dc, token)).then(function(data) { var objs = []; data.map(function(obj){ objs.push(App.Acl.create(obj)); @@ -441,7 +441,7 @@ App.AclsShowController = Ember.ObjectController.extend({ controller.transitionToRoute('services'); Ember.$.ajax({ - url: formatUrl('/v1/acl/clone/'+ acl.ID, dc, token), + url: formatUrl(consulHost + '/v1/acl/clone/'+ acl.ID, dc, token), type: 'PUT' }).then(function(response) { controller.transitionToRoute('acls.show', response.ID); @@ -464,10 +464,10 @@ App.AclsShowController = Ember.ObjectController.extend({ if (window.confirm("Are you sure you want to delete this token?")) { Ember.$.ajax({ - url: formatUrl('/v1/acl/destroy/'+ acl.ID, dc, token), + url: formatUrl(consulHost + '/v1/acl/destroy/'+ acl.ID, dc, token), type: 'PUT' }).then(function(response) { - Ember.$.getJSON(formatUrl('/v1/acl/list', dc, token)).then(function(data) { + Ember.$.getJSON(formatUrl(consulHost + '/v1/acl/list', dc, token)).then(function(data) { objs = []; data.map(function(obj){ if (obj.ID === "anonymous") { @@ -500,7 +500,7 @@ App.AclsShowController = Ember.ObjectController.extend({ // Update the ACL Ember.$.ajax({ - url: formatUrl('/v1/acl/update', dc, token), + url: formatUrl(consulHost + '/v1/acl/update', dc, token), type: 'PUT', data: JSON.stringify(acl) }).then(function(response) { diff --git a/ui/javascripts/app/routes.js b/ui/javascripts/app/routes.js index 1a2c4e03b..c5406a103 100644 --- a/ui/javascripts/app/routes.js +++ b/ui/javascripts/app/routes.js @@ -69,7 +69,7 @@ App.BaseRoute = Ember.Route.extend({ App.IndexRoute = App.BaseRoute.extend({ // Retrieve the list of datacenters model: function(params) { - return Ember.$.getJSON('/v1/catalog/datacenters').then(function(data) { + return Ember.$.getJSON(consulHost + '/v1/catalog/datacenters').then(function(data) { return data; }); }, @@ -94,8 +94,8 @@ App.DcRoute = App.BaseRoute.extend({ // dcs and nodes used in the header return Ember.RSVP.hash({ dc: params.dc, - dcs: Ember.$.getJSON('/v1/catalog/datacenters'), - nodes: Ember.$.getJSON(formatUrl('/v1/internal/ui/nodes', params.dc, token)).then(function(data) { + dcs: Ember.$.getJSON(consulHost + '/v1/catalog/datacenters'), + nodes: Ember.$.getJSON(formatUrl(consulHost + '/v1/internal/ui/nodes', params.dc, token)).then(function(data) { var objs = []; // Merge the nodes into a list and create objects out of them @@ -132,7 +132,7 @@ App.KvShowRoute = App.BaseRoute.extend({ // and the original key requested in params return Ember.RSVP.hash({ key: key, - keys: Ember.$.getJSON(formatUrl('/v1/kv/' + key + '?keys&seperator=/', dc, token)).then(function(data) { + keys: Ember.$.getJSON(formatUrl(consulHost + '/v1/kv/' + key + '?keys&seperator=/', dc, token)).then(function(data) { var objs = []; data.map(function(obj){ objs.push(App.Key.create({Key: obj})); @@ -167,11 +167,11 @@ App.KvEditRoute = App.BaseRoute.extend({ return Ember.RSVP.hash({ dc: dc, token: token, - key: Ember.$.getJSON(formatUrl('/v1/kv/' + key, dc, token)).then(function(data) { + key: Ember.$.getJSON(formatUrl(consulHost + '/v1/kv/' + key, dc, token)).then(function(data) { // Convert the returned data to a Key return App.Key.create().setProperties(data[0]); }), - keys: keysPromise = Ember.$.getJSON(formatUrl('/v1/kv/' + parentKeys.parent + '?keys&seperator=/', dc, token)).then(function(data) { + keys: keysPromise = Ember.$.getJSON(formatUrl(consulHost + '/v1/kv/' + parentKeys.parent + '?keys&seperator=/', dc, token)).then(function(data) { var objs = []; data.map(function(obj){ objs.push(App.Key.create({Key: obj})); @@ -184,7 +184,7 @@ App.KvEditRoute = App.BaseRoute.extend({ // Load the session on the key, if there is one afterModel: function(models) { if (models.key.get('isLocked')) { - return Ember.$.getJSON(formatUrl('/v1/session/info/' + models.key.Session, models.dc, models.token)).then(function(data) { + return Ember.$.getJSON(formatUrl(consulHost + '/v1/session/info/' + models.key.Session, models.dc, models.token)).then(function(data) { models.session = data[0]; return models; }); @@ -214,7 +214,7 @@ App.ServicesRoute = App.BaseRoute.extend({ var token = App.get('settings.token'); // Return a promise to retrieve all of the services - return Ember.$.getJSON(formatUrl('/v1/internal/ui/services', dc, token)).then(function(data) { + return Ember.$.getJSON(formatUrl(consulHost + '/v1/internal/ui/services', dc, token)).then(function(data) { var objs = []; data.map(function(obj){ objs.push(App.Service.create(obj)); @@ -235,7 +235,7 @@ App.ServicesShowRoute = App.BaseRoute.extend({ // Here we just use the built-in health endpoint, as it gives us everything // we need. - return Ember.$.getJSON(formatUrl('/v1/health/service/' + params.name, dc, token)).then(function(data) { + return Ember.$.getJSON(formatUrl(consulHost + '/v1/health/service/' + params.name, dc, token)).then(function(data) { var objs = []; data.map(function(obj){ objs.push(App.Node.create(obj)); @@ -266,10 +266,10 @@ App.NodesShowRoute = App.BaseRoute.extend({ return Ember.RSVP.hash({ dc: dc, token: token, - node: Ember.$.getJSON(formatUrl('/v1/internal/ui/node/' + params.name, dc, token)).then(function(data) { + node: Ember.$.getJSON(formatUrl(consulHost + '/v1/internal/ui/node/' + params.name, dc, token)).then(function(data) { return App.Node.create(data); }), - nodes: Ember.$.getJSON(formatUrl('/v1/internal/ui/node/' + params.name, dc, token)).then(function(data) { + nodes: Ember.$.getJSON(formatUrl(consulHost + '/v1/internal/ui/node/' + params.name, dc, token)).then(function(data) { return App.Node.create(data); }) }); @@ -277,7 +277,7 @@ App.NodesShowRoute = App.BaseRoute.extend({ // Load the sessions for the node afterModel: function(models) { - return Ember.$.getJSON(formatUrl('/v1/session/node/' + models.node.Node, models.dc, models.token)).then(function(data) { + return Ember.$.getJSON(formatUrl(consulHost + '/v1/session/node/' + models.node.Node, models.dc, models.token)).then(function(data) { models.sessions = data; return models; }); @@ -301,7 +301,7 @@ App.NodesRoute = App.BaseRoute.extend({ var token = App.get('settings.token'); // Return a promise containing the nodes - return Ember.$.getJSON(formatUrl('/v1/internal/ui/nodes', dc, token)).then(function(data) { + return Ember.$.getJSON(formatUrl(consulHost + '/v1/internal/ui/nodes', dc, token)).then(function(data) { var objs = []; data.map(function(obj){ objs.push(App.Node.create(obj)); @@ -320,7 +320,7 @@ App.AclsRoute = App.BaseRoute.extend({ var dc = this.modelFor('dc').dc; var token = App.get('settings.token'); // Return a promise containing the ACLS - return Ember.$.getJSON(formatUrl('/v1/acl/list', dc, token)).then(function(data) { + return Ember.$.getJSON(formatUrl(consulHost + '/v1/acl/list', dc, token)).then(function(data) { var objs = []; data.map(function(obj){ if (obj.ID === "anonymous") { @@ -361,7 +361,7 @@ App.AclsShowRoute = App.BaseRoute.extend({ // Return a promise hash of the node and nodes return Ember.RSVP.hash({ dc: dc, - acl: Ember.$.getJSON(formatUrl('/v1/acl/info/'+ params.id, dc, token)).then(function(data) { + acl: Ember.$.getJSON(formatUrl(consulHost + '/v1/acl/info/'+ params.id, dc, token)).then(function(data) { return App.Acl.create(data[0]); }) });