Skip to content

Commit

Permalink
implement connection delete function. rockstor#560
Browse files Browse the repository at this point in the history
  • Loading branch information
priyaganti committed Apr 17, 2016
1 parent 0e9aaea commit 0c226ee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
{{#each connections}}
<tr id="{{this.uuid}}">
<td class="accordion-toggle" data-toggle="collapse" data-parent="#OrderPackages" data-target=".packageDetails1"><a> {{this.name}}</a>&nbsp;&nbsp; <a href="#add-connection"><i class="glyphicon glyphicon-pencil"></i></a>
<a href=""><i class="glyphicon glyphicon-trash"></i></a></td>
<a id="{{this.id}}" data-action="delete" rel="tooltip" title="Delete connection"><i class="glyphicon glyphicon-trash"></i></a></td>
<td>{{this.uuid}}</td>
<td>{{this.state}}&nbsp;&nbsp;
<input type="checkbox" data-connection-id="{{this.id}}" data-size="mini" {{getState this.state}}>
<input type="checkbox" data-connection-id="{{this.id}}" data-name="{{this.name}}" data-size="mini" {{getState this.state}}>
<div class="command-status" data-connection-id="{{this.id}}">&nbsp;</div>
<div class="simple-overlay" id="{{this.id}}-err-popup"><div class="overlay-content"></div></div>
</td>
Expand Down Expand Up @@ -109,6 +109,6 @@
<div>
{{pagination}}
</div>

</div> <!-- col-md-12 -->
</div> <!-- row -->
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
NewNetworksView = Backbone.View.extend({

events: {
"click a[data-action=delete]": "deleteConnection",
'switchChange.bootstrapSwitch': 'switchStatus'
},

Expand Down Expand Up @@ -110,6 +111,29 @@ NewNetworksView = Backbone.View.extend({
errPopupContent.html(msg);
statusEl.click(function(){ errPopup.overlay().load(); });
},

deleteConnection: function(event){
alert("Are you sure to delete the connection?");
var _this = this;
var button = $(event.currentTarget);
var connectionId = button.attr('id');
console.log("connection id is: ", connectionId);
if (buttonDisabled(button)) return false;
disableButton(button);
$.ajax({
url: "/api/network/connections/" + connectionId,
type: "DELETE",
dataType: "json",
success: function() {
_this.collection.fetch({reset: true});
enableButton(button);
app_router.navigate('network2', {trigger: true})
},
error: function(xhr, status, error) {
enableButton(button);
}
});
},

initHandlebarHelpers: function(){
Handlebars.registerHelper('getState', function(state){
Expand Down

0 comments on commit 0c226ee

Please sign in to comment.