ui: add locking session below lock

This commit is contained in:
Jack Pearkes 2014-06-06 14:26:30 -04:00
parent 06f7630e29
commit 23cc6a3a5e
3 changed files with 60 additions and 36 deletions

View File

@ -212,6 +212,7 @@
<div class="col-md-6 col-lg-7 border-left">
<div class="padded-border">
<div class="panel">
<div {{ bind-attr class=":panel-bar isLoading:bg-orange:bg-green isLocked:bg-light-gray" }}></div>
<div class="panel-heading">
@ -222,7 +223,7 @@
KEY LOCKED
</small>
{{/if}}
</h3>
</h4>
</div>
<div class="panel-body panel-form">
@ -239,9 +240,24 @@
</form>
</div>
</div>
{{#if model.isLocked}}
<h5>Lock Session</h5>
{{#link-to 'nodes.show' model.session.Node tagName="div" href=false class="list-group-item list-condensed-link" }}
<div class="bg-light-gray list-bar-horizontal"></div>
<div class="name">
{{session.Node}}
<small class="pull-right">
{{session.ID}}
</small>
</div>
{{/link-to}}
{{/if}}
</div>
</div>
</div>
</div>
</script>

View File

@ -161,6 +161,7 @@ App.KvEditRoute = App.BaseRoute.extend({
// Return a promise hash to get the data for both columns
return Ember.RSVP.hash({
dc: dc,
key: Ember.$.getJSON('/v1/kv/' + key + '?dc=' + dc).then(function(data) {
// Convert the returned data to a Key
return App.Key.create().setProperties(data[0]);
@ -172,13 +173,19 @@ App.KvEditRoute = App.BaseRoute.extend({
});
return objs;
}),
}).then(function(models) {
// If the key is locked, add the session
if (models.key.get('isLocked') == true) {
models.session = Ember.$.getJSON('/v1/session/info/' + key.Session + '/&dc=' + dc)
}
});
},
// Load the session on the key, if there is one
afterModel: function(models) {
if (models.key.get('isLocked')) {
return Ember.$.getJSON('/v1/session/info/' + models.key.Session + '?dc=' + models.dc).then(function(data) {
models.session = data[0]
return models
});
} else {
return models
}
},
setupController: function(controller, models) {
@ -192,6 +199,7 @@ App.KvEditRoute = App.BaseRoute.extend({
controller.set('isRoot', parentKeys.isRoot);
controller.set('siblings', models.keys);
controller.set('rootKey', this.rootKey);
controller.set('session', models.session);
}
});

View File