consul/ui/javascripts/app/router.js

79 lines
2.2 KiB
JavaScript
Raw Normal View History

2014-04-25 17:49:36 +00:00
window.App = Ember.Application.create({
2014-06-05 17:24:03 +00:00
rootElement: "#app",
currentPath: ''
});
Ember.Application.initializer({
name: 'settings',
initialize: function(container, application) {
application.set('settings', App.Settings.create());
}
2014-04-25 17:49:36 +00:00
});
// Wrap localstorage with an ember object
App.Settings = Ember.Object.extend({
unknownProperty: function(key) {
return localStorage[key];
},
setUnknownProperty: function(key, value) {
if(Ember.isNone(value)) {
delete localStorage[key];
} else {
localStorage[key] = value;
}
this.notifyPropertyChange(key);
return value;
},
clear: function() {
this.beginPropertyChanges();
for (var i=0, l=localStorage.length; i<l; i++){
this.set(localStorage.key(i));
}
localStorage.clear();
this.endPropertyChanges();
}
});
2014-04-30 18:02:20 +00:00
2014-04-25 17:49:36 +00:00
App.Router.map(function() {
// Our parent datacenter resource sets the namespace
// for the entire application
2014-04-25 17:49:36 +00:00
this.resource("dc", {path: "/:dc"}, function() {
// Services represent a consul service
2014-04-25 17:49:36 +00:00
this.resource("services", { path: "/services" }, function(){
// Show an individual service
2014-04-25 17:49:36 +00:00
this.route("show", { path: "/:name" });
});
// Nodes represent a consul node
2014-04-25 17:49:36 +00:00
this.resource("nodes", { path: "/nodes" }, function() {
// Show an individual node
2014-04-25 17:49:36 +00:00
this.route("show", { path: "/:name" });
});
// Key/Value
2014-04-29 17:34:13 +00:00
this.resource("kv", { path: "/kv" }, function(){
2014-04-29 18:49:07 +00:00
this.route("index", { path: "/" });
// List keys. This is more like an index
2014-05-04 21:05:00 +00:00
this.route("show", { path: "/*key" });
// Edit a specific key
2014-05-04 21:05:00 +00:00
this.route("edit", { path: "/*key/edit" });
2014-08-21 21:44:17 +00:00
});
// ACLs
this.resource("acls", { path: "/acls" }, function(){
this.route("show", { path: "/:name" });
});
// Shows a page explaining that ACLs haven't been set-up
this.route("aclsdisabled", { path: "/aclsdisabled" });
// Shows a page explaining that the ACL key being used isn't
// authorized
this.route("unauthorized", { path: "/unauthorized" });
2014-04-25 17:49:36 +00:00
});
// Shows a datacenter picker. If you only have one
// it just redirects you through.
2014-04-25 17:49:36 +00:00
this.route("index", { path: "/" });
});