mirror of https://github.com/hashicorp/consul
ui: use ember object to wrap localstorag
parent
c2830c0f74
commit
a133d9ecba
|
@ -0,0 +1,6 @@
|
||||||
|
- ACL management
|
||||||
|
- KV takes ?token=ACCESS_KEY
|
||||||
|
- There is a default token
|
||||||
|
- Allow setting a token
|
||||||
|
- store the token in local storage
|
||||||
|
- return error (notification) if the write fails
|
|
@ -1,13 +1,41 @@
|
||||||
window.App = Ember.Application.create({
|
window.App = Ember.Application.create({
|
||||||
rootElement: "#app",
|
rootElement: "#app",
|
||||||
currentPath: '',
|
currentPath: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
Ember.Application.initializer({
|
||||||
|
name: 'settings',
|
||||||
|
|
||||||
initialize: function(container, application) {
|
initialize: function(container, application) {
|
||||||
console.log("initialize");
|
application.set('settings', App.Settings.create());
|
||||||
console.log(localStorage.getItem("foobars"));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
App.Router.map(function() {
|
App.Router.map(function() {
|
||||||
// Our parent datacenter resource sets the namespace
|
// Our parent datacenter resource sets the namespace
|
||||||
|
|
|
@ -304,8 +304,9 @@ App.NodesRoute = App.BaseRoute.extend({
|
||||||
App.AclsRoute = App.BaseRoute.extend({
|
App.AclsRoute = App.BaseRoute.extend({
|
||||||
model: function(params) {
|
model: function(params) {
|
||||||
var dc = this.modelFor('dc').dc;
|
var dc = this.modelFor('dc').dc;
|
||||||
|
var token = App.get('settings.token');
|
||||||
// Return a promise containing the ACLS
|
// Return a promise containing the ACLS
|
||||||
return Ember.$.getJSON(formatUrl('/v1/acl/list', dc, "")).then(function(data) {
|
return Ember.$.getJSON(formatUrl('/v1/acl/list', dc, token)).then(function(data) {
|
||||||
objs = [];
|
objs = [];
|
||||||
data.map(function(obj){
|
data.map(function(obj){
|
||||||
objs.push(App.Acl.create(obj));
|
objs.push(App.Acl.create(obj));
|
||||||
|
|
Loading…
Reference in New Issue