mirror of https://github.com/status-im/consul.git
Add delete folder button to web UI
This commit is contained in:
parent
6440fc77b6
commit
5089be1af0
|
@ -151,6 +151,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<button {{ action "createKey"}} {{bind-attr disabled=newKey.isInvalid }} {{ bind-attr class=":btn newKey.isValid:btn-success:btn-default" }}>Create</button>
|
<button {{ action "createKey"}} {{bind-attr disabled=newKey.isInvalid }} {{ bind-attr class=":btn newKey.isValid:btn-success:btn-default" }}>Create</button>
|
||||||
|
<button {{ action "deleteFolder"}} {{bind-attr disabled=isRoot }} {{ bind-attr class=":btn :pull-right isLoading:btn-warning:btn-danger" }}>Delete folder</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -211,7 +212,7 @@
|
||||||
</div>
|
</div>
|
||||||
<button {{ action "updateKey"}} {{bind-attr disabled=isLoading }} {{ bind-attr class=":btn isLoading:btn-warning:btn-success" }}>Update</button>
|
<button {{ action "updateKey"}} {{bind-attr disabled=isLoading }} {{ bind-attr class=":btn isLoading:btn-warning:btn-success" }}>Update</button>
|
||||||
<button {{ action "cancelEdit"}} {{bind-attr disabled=isLoading }} {{ bind-attr class=":btn isLoading:btn-warning:btn-default" }}>Cancel</button>
|
<button {{ action "cancelEdit"}} {{bind-attr disabled=isLoading }} {{ bind-attr class=":btn isLoading:btn-warning:btn-default" }}>Cancel</button>
|
||||||
<button {{ action "deleteKey"}} {{bind-attr disabled=isLoading }} {{ bind-attr class=":btn :pull-right isLoading:btn-warning:btn-danger" }}>Delete</button>
|
<button {{ action "deleteKey"}} {{bind-attr disabled=isLoading }} {{ bind-attr class=":btn :pull-right isLoading:btn-warning:btn-danger" }}>Delete key</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -109,7 +109,26 @@ App.KvShowController.reopen({
|
||||||
// Render the error message on the form if the request failed
|
// Render the error message on the form if the request failed
|
||||||
controller.set('errorMessage', 'Received error while processing: ' + response.statusText)
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText)
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteFolder: function() {
|
||||||
|
this.set('isLoading', true);
|
||||||
|
|
||||||
|
var key = this.get("model");
|
||||||
|
var controller = this;
|
||||||
|
|
||||||
|
// Delete the folder
|
||||||
|
Ember.$.ajax({
|
||||||
|
url: ("/v1/kv/" + key.get('parentKey') + '?recurse'),
|
||||||
|
type: 'DELETE'
|
||||||
|
}).then(function(response) {
|
||||||
|
// Tranisiton back up a level
|
||||||
|
controller.transitionToRoute('kv.show', key.get('grandParentKey'));
|
||||||
|
controller.set('isLoading', false);
|
||||||
|
}).fail(function(response) {
|
||||||
|
// Render the error message on the form if the request failed
|
||||||
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -151,13 +170,10 @@ App.KvEditController = Ember.Controller.extend({
|
||||||
|
|
||||||
deleteKey: function() {
|
deleteKey: function() {
|
||||||
this.set('isLoading', true);
|
this.set('isLoading', true);
|
||||||
|
|
||||||
|
var dc = this.get('dc').get('datacenter');
|
||||||
var key = this.get("model");
|
var key = this.get("model");
|
||||||
var controller = this;
|
var controller = this;
|
||||||
var dc = this.get('dc').get('datacenter');
|
|
||||||
|
|
||||||
// Get the parent for the transition back up a level
|
|
||||||
// after the delete
|
|
||||||
var parent = key.get('parentKey');
|
|
||||||
|
|
||||||
// Delete the key
|
// Delete the key
|
||||||
Ember.$.ajax({
|
Ember.$.ajax({
|
||||||
|
@ -165,13 +181,12 @@ App.KvEditController = Ember.Controller.extend({
|
||||||
type: 'DELETE'
|
type: 'DELETE'
|
||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
// Tranisiton back up a level
|
// Tranisiton back up a level
|
||||||
controller.transitionToRoute('kv.show', parent);
|
controller.transitionToRoute('kv.show', key.get('parentKey'));
|
||||||
controller.set('isLoading', false);
|
controller.set('isLoading', false);
|
||||||
}).fail(function(response) {
|
}).fail(function(response) {
|
||||||
// Render the error message on the form if the request failed
|
// Render the error message on the form if the request failed
|
||||||
controller.set('errorMessage', 'Received error while processing: ' + response.statusText)
|
controller.set('errorMessage', 'Received error while processing: ' + response.statusText)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,11 @@ App.BaseRoute = Ember.Route.extend({
|
||||||
grandParentKey = parts.join("/") + "/";
|
grandParentKey = parts.join("/") + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
return {grandParent: grandParentKey, parent: parentKey}
|
return {
|
||||||
|
parent: parentKey,
|
||||||
|
grandParent: grandParentKey,
|
||||||
|
isRoot: parentKey === '/'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
removeDuplicateKeys: function(keys, matcher) {
|
removeDuplicateKeys: function(keys, matcher) {
|
||||||
|
@ -131,6 +135,7 @@ App.KvShowRoute = App.BaseRoute.extend({
|
||||||
controller.set('content', models.keys);
|
controller.set('content', models.keys);
|
||||||
controller.set('parentKey', parentKeys.parent);
|
controller.set('parentKey', parentKeys.parent);
|
||||||
controller.set('grandParentKey', parentKeys.grandParent);
|
controller.set('grandParentKey', parentKeys.grandParent);
|
||||||
|
controller.set('isRoot', parentKeys.isRoot);
|
||||||
controller.set('newKey', App.Key.create());
|
controller.set('newKey', App.Key.create());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue