Skip to content

Commit

Permalink
#1623 Eslint Rockstor views
Browse files Browse the repository at this point in the history
Signed-off-by: Mirko Arena <mirko.arena@gmail.com>
  • Loading branch information
MFlyer committed Feb 13, 2017
1 parent b3918e0 commit 6d4eee6
Show file tree
Hide file tree
Showing 80 changed files with 8,262 additions and 7,841 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Expand Up @@ -59,5 +59,5 @@ function lintJob() {
return gulp.src(jsfiles)
.pipe(eslint('./.eslintrc.js'))
.pipe(eslint.format())
.pipe(eslint.failOnError());
.pipe(eslint.failAfterError());
}
Expand Up @@ -25,54 +25,56 @@
*/

AccessKeysView = RockstorLayoutView.extend({
events: {
"click a[data-action=delete]": "deleteAccessKey"
},
events: {
'click a[data-action=delete]': 'deleteAccessKey'
},

initialize: function() {
this.constructor.__super__.initialize.apply(this, arguments);
this.template = window.JST.access_keys_access_keys;
this.collection = new AccessKeyCollection();
this.dependencies.push(this.collection);
this.collection.on("reset", this.renderAccessKeys, this);
},
initialize: function() {
this.constructor.__super__.initialize.apply(this, arguments);
this.template = window.JST.access_keys_access_keys;
this.collection = new AccessKeyCollection();
this.dependencies.push(this.collection);
this.collection.on('reset', this.renderAccessKeys, this);
},

render: function() {
this.fetch(this.renderAccessKeys, this);
return this;
},
render: function() {
this.fetch(this.renderAccessKeys, this);
return this;
},

renderAccessKeys: function() {
$(this.el).html(this.template({
accessKeys: this.collection.toJSON(),
collection: this.collection,
collectionNotEmpty: !this.collection.isEmpty(),
}));

this.renderDataTables();
},
renderAccessKeys: function() {
$(this.el).html(this.template({
accessKeys: this.collection.toJSON(),
collection: this.collection,
collectionNotEmpty: !this.collection.isEmpty(),
}));

deleteAccessKey: function(event) {
var _this = this;
var button = $(event.currentTarget);
if (buttonDisabled(button)) return false;
var name = button.attr('data-name');
var id = button.attr('data-id');
if(confirm("Delete access key: " + name + " ...Are you sure?")){
disableButton(button);
$.ajax({
url: "/api/oauth_app/" + id,
type: "DELETE",
dataType: "json",
success: function() {
_this.collection.fetch({reset: true});
enableButton(button);
},
error: function(xhr, status, error) {
enableButton(button);
}
});
}
this.renderDataTables();
},

},
deleteAccessKey: function(event) {
var _this = this;
var button = $(event.currentTarget);
if (buttonDisabled(button)) return false;
var name = button.attr('data-name');
var id = button.attr('data-id');
if (confirm('Delete access key: ' + name + ' ...Are you sure?')) {
disableButton(button);
$.ajax({
url: '/api/oauth_app/' + id,
type: 'DELETE',
dataType: 'json',
success: function() {
_this.collection.fetch({
reset: true
});
enableButton(button);
},
error: function(xhr, status, error) {
enableButton(button);
}
});
}

},
});
Expand Up @@ -26,54 +26,61 @@


AddAccessKeyView = RockstorLayoutView.extend({
events: {
'click #js-cancel': 'cancel'
},
events: {
'click #js-cancel': 'cancel'
},

initialize: function() {
this.constructor.__super__.initialize.apply(this, arguments);
this.template = window.JST.access_keys_add_access_key;
},
initialize: function() {
this.constructor.__super__.initialize.apply(this, arguments);
this.template = window.JST.access_keys_add_access_key;
},

render: function() {
var _this = this;
$(this.el).html(this.template());
this.$('#add-access-key-form :input').tooltip({placement: 'right'});
this.$('#add-access-key-form').validate({
onfocusout: false,
onkeyup: false,
rules: {
access_key_name: 'required',
},
submitHandler: function() {
var button = _this.$('#create-access-key');
if (buttonDisabled(button)) return false;
var name = _this.$('#name').val();
disableButton(button);
$.ajax({
url: "/api/oauth_app",
type: "POST",
dataType: "json",
data: {name: name},
success: function() {
enableButton(button);
_this.$('#add-access-key-form :input').tooltip('hide');
app_router.navigate('access-keys', {trigger: true})
},
error: function(xhr, status, error) {
enableButton(button);
},
render: function() {
var _this = this;
$(this.el).html(this.template());
this.$('#add-access-key-form :input').tooltip({
placement: 'right'
});
}
});
return this;
},

cancel: function(event) {
event.preventDefault();
this.$('#add-access-key-form :input').tooltip('hide');
app_router.navigate('access-keys', {trigger: true});
}
this.$('#add-access-key-form').validate({
onfocusout: false,
onkeyup: false,
rules: {
access_key_name: 'required',
},
submitHandler: function() {
var button = _this.$('#create-access-key');
if (buttonDisabled(button)) return false;
var name = _this.$('#name').val();
disableButton(button);
$.ajax({
url: '/api/oauth_app',
type: 'POST',
dataType: 'json',
data: {
name: name
},
success: function() {
enableButton(button);
_this.$('#add-access-key-form :input').tooltip('hide');
app_router.navigate('access-keys', {
trigger: true
});
},
error: function(xhr, status, error) {
enableButton(button);
},
});
}
});
return this;
},

});
cancel: function(event) {
event.preventDefault();
this.$('#add-access-key-form :input').tooltip('hide');
app_router.navigate('access-keys', {
trigger: true
});
}

});

0 comments on commit 6d4eee6

Please sign in to comment.