");
- div.attr('class','widget-ph');
- if (widget.maximized) {
- div.attr("data-ss-colspan", widgetDef.maxCols);
- div.attr("data-ss-rowspan", widgetDef.maxRows);
- } else {
- div.attr("data-ss-colspan", widgetDef.cols);
- div.attr("data-ss-rowspan", widgetDef.rows);
- }
- div.attr("data-widget-name", widget.name);
- container.append(div);
- var position_div = $('
');
- div.append(position_div);
- position_div.append(view.render().el);
-
- // Add widget view to widget list
- widgetViews.push(view);
- }
+ var div = null;
+ var widgetDef = RockStorWidgets.findByName(widget.name);
+ var viewName = widgetDef.view;
+ if (!_.isUndefined(window[viewName] && !_.isNull(window[viewName]))) {
+ // Create widget view
+ var view = new window[viewName]({
+ displayName: widgetDef.displayName,
+ name: widget.name,
+ cleanupArray: widgetViews,
+ parentView: this,
+ maximized: widget.maximized
+ });
+
+ // create shapeshift div for widget and render
+ div = $('
');
+ div.attr('class', 'widget-ph');
+ if (widget.maximized) {
+ div.attr('data-ss-colspan', widgetDef.maxCols);
+ div.attr('data-ss-rowspan', widgetDef.maxRows);
+ } else {
+ div.attr('data-ss-colspan', widgetDef.cols);
+ div.attr('data-ss-rowspan', widgetDef.rows);
+ }
+ div.attr('data-widget-name', widget.name);
+ container.append(div);
+ var position_div = $('
');
+ div.append(position_div);
+ position_div.append(view.render().el);
+
+ // Add widget view to widget list
+ widgetViews.push(view);
+ }
},
findWidgetView: function(name) {
- var i=0, found=false;
- for (i=0; i
+ * Copyright (c) 2012-2017 RockStor, Inc.
* This file is part of RockStor.
*
* RockStor is free software; you can redistribute it and/or modify
@@ -27,68 +27,68 @@
InitView = RockstorLayoutView.extend({
initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
+ this.constructor.__super__.initialize.apply(this, arguments);
},
scanNetwork: function() {
- var _this = this;
- $.ajax({
- url: "/api/network/refresh",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.networkInterfaces.fetch();
- }
- });
+ var _this = this;
+ $.ajax({
+ url: '/api/network/refresh',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.networkInterfaces.fetch();
+ }
+ });
},
saveAppliance: function() {
- var _this = this;
- // create current appliance if not created already
- if (this.appliances.length > 0) {
- var current_appliance = this.appliances.find(function(appliance) {
- return appliance.get('current_appliance') == true;
- });
- }
- if (_.isUndefined(current_appliance)) {
- var new_appliance = new Appliance();
- new_appliance.save(
- {
- hostname: RockStorGlobals.hostname,
- ip: RockStorGlobals.ip,
- current_appliance: true
- },
- {
- success: function(model, response, options) {
- setup_done = true;
- _this.scanDisks();
- },
- error: function(model, xhr, options) {
- var msg = xhr.responseText;
- try {
- msg = JSON.parse(msg).detail;
- } catch(err) {
- }
- }
- }
- );
- } else {
- app_router.navigate('home', {trigger: true}) ;
- }
+ var _this = this;
+ // create current appliance if not created already
+ if (this.appliances.length > 0) {
+ var current_appliance = this.appliances.find(function(appliance) {
+ return appliance.get('current_appliance') == true;
+ });
+ }
+ if (_.isUndefined(current_appliance)) {
+ var new_appliance = new Appliance();
+ new_appliance.save({
+ hostname: RockStorGlobals.hostname,
+ ip: RockStorGlobals.ip,
+ current_appliance: true
+ }, {
+ success: function(model, response, options) {
+ setup_done = true;
+ _this.scanDisks();
+ },
+ error: function(model, xhr, options) {
+ var msg = xhr.responseText;
+ try {
+ msg = JSON.parse(msg).detail;
+ } catch (err) {
+ console.log(err);
+ }
+ }
+ });
+ } else {
+ app_router.navigate('home', {
+ trigger: true
+ });
+ }
},
scanDisks: function() {
- var _this = this;
- $.ajax({
- url: "/api/disks/scan",
- type: "POST"
- }).done(function() {
- _this.goToRoot();
- });
+ var _this = this;
+ $.ajax({
+ url: '/api/disks/scan',
+ type: 'POST'
+ }).done(function() {
+ _this.goToRoot();
+ });
},
goToRoot: function() {
- window.location.replace("/");
+ window.location.replace('/');
},
@@ -99,97 +99,92 @@ LoginView = InitView.extend({
tagName: 'div',
events: {
- 'click #sign_in': 'login',
+ 'click #sign_in': 'login',
},
initialize: function() {
- this.login_template = window.JST.home_login_template;
- this.user_create_template = window.JST.home_user_create_template;
- this.networkInterfaces = new NetworkConnectionCollection();
- this.networkInterfaces.pageSize = RockStorGlobals.maxPageSize;
- this.networkInterfaces.on("reset", this.saveAppliance, this);
- this.appliances = new ApplianceCollection();
+ this.login_template = window.JST.home_login_template;
+ this.user_create_template = window.JST.home_user_create_template;
+ this.networkInterfaces = new NetworkConnectionCollection();
+ this.networkInterfaces.pageSize = RockStorGlobals.maxPageSize;
+ this.networkInterfaces.on('reset', this.saveAppliance, this);
+ this.appliances = new ApplianceCollection();
},
render: function() {
- var _this = this;
- if (RockStorGlobals.setup_user) {
- } else {
- $(this.el).append(this.user_create_template());
- this.validator = this.$("#user-create-form").validate({
- onfocusout: false,
- onkeyup: false,
- rules: {
- username: "required",
- password: "required",
- hostname: "required",
- password_confirmation: {
- required: "true",
- equalTo: "#password"
- }
- },
- messages: {
- password_confirmation: {
- equalTo: "The passwords do not match"
- }
- },
- submitHandler: function() {
- var username = _this.$("#username").val();
- var password = _this.$("#password").val();
- RockStorGlobals.hostname = _this.$('#hostname').val();
-
- var setupUserModel = Backbone.Model.extend({
- urlRoot: "/setup_user",
- });
- var user = new setupUserModel();
- user.save(
- {
- username: username,
- password: password,
- is_active: true
- },
- {
- success: function(model, response, options) {
- _this.makeLoginRequest(username, password);
- },
- error: function(model, xhr, options) {
- }
- }
- );
-
- return false;
- }
- });
- }
- return this;
+ var _this = this;
+ if (!RockStorGlobals.setup_user) {
+ $(this.el).append(this.user_create_template());
+ this.validator = this.$('#user-create-form').validate({
+ onfocusout: false,
+ onkeyup: false,
+ rules: {
+ username: 'required',
+ password: 'required',
+ hostname: 'required',
+ password_confirmation: {
+ required: 'true',
+ equalTo: '#password'
+ }
+ },
+ messages: {
+ password_confirmation: {
+ equalTo: 'The passwords do not match'
+ }
+ },
+ submitHandler: function() {
+ var username = _this.$('#username').val();
+ var password = _this.$('#password').val();
+ RockStorGlobals.hostname = _this.$('#hostname').val();
+
+ var setupUserModel = Backbone.Model.extend({
+ urlRoot: '/setup_user',
+ });
+ var user = new setupUserModel();
+ user.save({
+ username: username,
+ password: password,
+ is_active: true
+ }, {
+ success: function(model, response, options) {
+ _this.makeLoginRequest(username, password);
+ },
+ error: function(model, xhr, options) {}
+ });
+
+ return false;
+ }
+ });
+ }
+ return this;
},
login: function(event) {
- if (!_.isUndefined(event) && !_.isNull(event)) {
- event.preventDefault();
- }
- this.makeLoginRequest(this.$("#username").val(), this.$("#password").val());
+ if (!_.isUndefined(event) && !_.isNull(event)) {
+ event.preventDefault();
+ }
+ this.makeLoginRequest(this.$('#username').val(), this.$('#password').val());
},
makeLoginRequest: function(username, password) {
- var _this = this;
- $.ajax({
- url: "/api/login",
- type: "POST",
- dataType: "json",
- data: {
- username: username,
- password: password
- },
- success: function(data, status, xhr) {
- _this.scanNetwork();
-
- },
- error: function(xhr, status, error) {
- _this.$(".messages").html("Login incorrect! ");
- }
- });
+ var _this = this;
+ $.ajax({
+ url: '/api/login',
+ type: 'POST',
+ dataType: 'json',
+ data: {
+ username: username,
+ password: password
+ },
+ success: function(data, status, xhr) {
+ _this.scanNetwork();
+
+ },
+ error: function(xhr, status, error) {
+ _this.$('.messages').html('Login incorrect! ');
+ }
+ });
},
});
@@ -199,102 +194,104 @@ SetupView = InitView.extend({
tagName: 'div',
events: {
- 'click #next-page': 'nextPage',
- 'click #prev-page': 'prevPage'
+ 'click #next-page': 'nextPage',
+ 'click #prev-page': 'prevPage'
},
initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.setup_setup;
- this.pages = [null, SetupDisksView, SetupSystemView];
- this.sidebars = [null, "disks"];
- this.current_page = 1;
- this.current_view = null;
- this.appliances = new ApplianceCollection();
- this.appliances.pageSize = RockStorGlobals.maxPageSize;
- this.dependencies.push(this.appliances);
-
- //next three lines are supposed to refresh connection state?
- this.networkInterfaces = new NetworkConnectionCollection();
- this.networkInterfaces.pageSize = RockStorGlobals.maxPageSize;
- this.networkInterfaces.on("reset", this.saveAppliance, this);
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.setup_setup;
+ this.pages = [null, SetupDisksView, SetupSystemView];
+ this.sidebars = [null, 'disks'];
+ this.current_page = 1;
+ this.current_view = null;
+ this.appliances = new ApplianceCollection();
+ this.appliances.pageSize = RockStorGlobals.maxPageSize;
+ this.dependencies.push(this.appliances);
+
+ //next three lines are supposed to refresh connection state?
+ this.networkInterfaces = new NetworkConnectionCollection();
+ this.networkInterfaces.pageSize = RockStorGlobals.maxPageSize;
+ this.networkInterfaces.on('reset', this.saveAppliance, this);
},
render: function() {
- $(this.el).html(this.template());
- var _this = this;
- this.fetch(this.renderCurrentPage, this);
- return this;
+ $(this.el).html(this.template());
+ var _this = this;
+ this.fetch(this.renderCurrentPage, this);
+ return this;
},
renderCurrentPage: function() {
- opts = {
- appliances: this.appliances
- };
- this.renderSidebar("setup", this.sidebars[this.current_page]);
- this.current_view = new this.pages[this.current_page](opts);
- this.$('#current-page-inner').html(this.current_view.render().el);
+ opts = {
+ appliances: this.appliances
+ };
+ this.renderSidebar('setup', this.sidebars[this.current_page]);
+ this.current_view = new this.pages[this.current_page](opts);
+ this.$('#current-page-inner').html(this.current_view.render().el);
},
nextPage: function() {
- if (this.current_page < this.pages.length-1) {
- this.current_page = this.current_page + 1;
- this.renderCurrentPage();
- this.modifyButtonText();
- this.setCurrentStepTitle(this.current_page, this.current_page-1);
- } else {
- this.save();
- }
+ if (this.current_page < this.pages.length - 1) {
+ this.current_page = this.current_page + 1;
+ this.renderCurrentPage();
+ this.modifyButtonText();
+ this.setCurrentStepTitle(this.current_page, this.current_page - 1);
+ } else {
+ this.save();
+ }
},
prevPage: function() {
- if (this.current_page > 1) {
- this.current_page = this.current_page - 1;
- this.renderCurrentPage();
- this.modifyButtonText();
- this.setCurrentStepTitle(this.current_page, this.current_page+1);
- }
+ if (this.current_page > 1) {
+ this.current_page = this.current_page - 1;
+ this.renderCurrentPage();
+ this.modifyButtonText();
+ this.setCurrentStepTitle(this.current_page, this.current_page + 1);
+ }
},
modifyButtonText: function() {
- if (this.lastPage()) {
- this.$('#next-page').html('Finish');
- } else {
- this.$('#next-page').html('Next');
- }
+ if (this.lastPage()) {
+ this.$('#next-page').html('Finish');
+ } else {
+ this.$('#next-page').html('Next');
+ }
},
lastPage: function() {
- return (this.current_page == (this.pages.length - 1));
+ return (this.current_page == (this.pages.length - 1));
},
save: function() {
- // hostname is the last page, so check if the form is filled
- this.current_view.$('#set-hostname-form').submit();
- if (!_.isUndefined(RockStorGlobals.hostname) &&
+ // hostname is the last page, so check if the form is filled
+ this.current_view.$('#set-hostname-form').submit();
+ if (!_.isUndefined(RockStorGlobals.hostname) &&
!_.isNull(RockStorGlobals.hostname)) {
- var button = this.$('#next-page');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- this.scanNetwork();
- }
+ var button = this.$('#next-page');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ this.scanNetwork();
+ }
},
setCurrentStepTitle: function(new_step, old_step) {
- old_step_str = old_step + '';
- old_sel_str = '#setup-titles li[data-step="' + old_step_str + '"]';
- this.$(old_sel_str).removeClass('current-step');
- new_step_str = new_step + '';
- new_sel_str = '#setup-titles li[data-step="' + new_step_str + '"]';
- this.$(new_sel_str).addClass('current-step');
+ old_step_str = old_step + '';
+ old_sel_str = '#setup-titles li[data-step="' + old_step_str + '"]';
+ this.$(old_sel_str).removeClass('current-step');
+ new_step_str = new_step + '';
+ new_sel_str = '#setup-titles li[data-step="' + new_step_str + '"]';
+ this.$(new_sel_str).addClass('current-step');
},
renderSidebar: function(name, selected) {
- var sidenavTemplate = window.JST["common_sidenav_" + name];
- $("#sidebar-inner").html(sidenavTemplate({selected: selected}));
+ var sidenavTemplate = window.JST['common_sidenav_' + name];
+ $('#sidebar-inner').html(sidenavTemplate({
+ selected: selected
+ }));
}
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/logs.js b/src/rockstor/storageadmin/static/storageadmin/js/views/logs.js
index 8de2b7fef..323fb43a1 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/logs.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/logs.js
@@ -61,7 +61,7 @@ LogsView = RockstorLayoutView.extend({
},
getRotatedLogs: function(data) {
- //Handles rotated logs list got on connection to data_collector
+ //Handles rotated logs list got on connection to data_collector
var _this = this;
var reader_options = '';
var downloader_divs = '';
@@ -71,20 +71,20 @@ LogsView = RockstorLayoutView.extend({
var rotated_log_descriptor = val.log.replace(val.logfamily, _this.avail_logs[val.logfamily]);
if (val.log.indexOf('.gz') < 0) reader_options += '' + rotated_log_descriptor + ' ';
downloader_divs += '';
- downloader_divs += ' ' + rotated_log_descriptor + '
';
+ downloader_divs += ' ' + rotated_log_descriptor + ' ';
});
- reader_options += ''
+ reader_options += '';
$('#logs_options').append(reader_options);
$('#avail_logs').append(downloader_divs);
},
ModalClose: function(event) {
- //When LogReader modal window close emit to ensure any running tail -f get killed
+ //When LogReader modal window close emit to ensure any running tail -f get killed
RockStorSocket.logManager.emit('livereading', 'kill');
},
-
+
ModalSwitchSize: function(event) {
- //LogReader modal window func to move small/large and viceversa
+ //LogReader modal window func to move small/large and viceversa
event.preventDefault();
var modal_container = $('#log_reader').children().first();
var resize_icon = $(event.currentTarget).children().first();
@@ -98,7 +98,7 @@ LogsView = RockstorLayoutView.extend({
},
ModalResizeText: function(event) {
- //LogReader modal window func to resize code text size
+ //LogReader modal window func to resize code text size
event.preventDefault();
var resize_emitter = event.currentTarget.id;
var size_delta = resize_emitter == 'code_increase_size' ? 1 : -1;
@@ -107,24 +107,24 @@ LogsView = RockstorLayoutView.extend({
},
getLogsArchive: function(data) {
- //Handle Logs tar archive based
- //If request sent from Archive builder show a link for download
- //Otherwise if from LogReader link auto-download archive
+ //Handle Logs tar archive based
+ //If request sent from Archive builder show a link for download
+ //Otherwise if from LogReader link auto-download archive
var _this = this;
if (data.recipient == 'download_response') {
var response_text = 'Logs Archive ready for download - ';
- response_text += '
Click to download '
+ response_text += '
Click to download ';
$('#' + data.recipient).html(response_text);
} else {
- //On Log Reader we use a fake hidden link and after log download request
- //we trigger a click on it
- $('#reader-log-download').attr('href', data.archive_name);
- $('#reader-log-download')[0].click();
+ //On Log Reader we use a fake hidden link and after log download request
+ //we trigger a click on it
+ $('#reader-log-download').attr('href', data.archive_name);
+ $('#reader-log-download')[0].click();
}
},
getLogContent: function(data) {
- //When data is pushed from backend data_collector add it to LogReader and autoscroll to the end
+ //When data is pushed from backend data_collector add it to LogReader and autoscroll to the end
var _this = this;
_this.updateLogProgress(data.current_rows, data.total_rows);
$('#system_log').append(data.chunk_content);
@@ -135,8 +135,8 @@ LogsView = RockstorLayoutView.extend({
},
getLogSize: function(data) {
- //Get log file size while selecting reader (cat,tail, etc) and log
- //If log file size greater than 500kB && reader is cat alerts user about possible long reading time
+ //Get log file size while selecting reader (cat,tail, etc) and log
+ //If log file size greater than 500kB && reader is cat alerts user about possible long reading time
log_size = (parseInt(data) / 1024).toFixed(2);
if (log_size > 500) {
var size_warning = '
';
@@ -147,7 +147,7 @@ LogsView = RockstorLayoutView.extend({
},
RequestLogSize: function(event) {
- //Call backend data_collector and ask for current log size
+ //Call backend data_collector and ask for current log size
$('.logsizealert').fadeOut(100, function() {
$(this).remove();
});
@@ -158,7 +158,7 @@ LogsView = RockstorLayoutView.extend({
},
updateLogProgress: function(partial, total) {
- //Nicely update progressbar in LogReader modal
+ //Nicely update progressbar in LogReader modal
$('#reader_progress').addClass('progress-bar-striped');
current_rows = parseInt(partial);
total_rows = parseInt(total);
@@ -202,28 +202,28 @@ LogsView = RockstorLayoutView.extend({
},
LogBaskets: function(event) {
- //This function serves divs switching between Available Logs and Logs download queue
+ //This function serves divs switching between Available Logs and Logs download queue
var _this = this;
event.preventDefault();
$('#download_response').empty();
var parent_div = $(event.currentTarget).parent().attr('id');
var dest_div = parent_div == 'avail_logs' ? '#download_logs' : '#avail_logs';
- var is_rotated = ($(event.currentTarget).attr('rotated') === 'true');
+ var is_rotated = ($(event.currentTarget).attr('rotated') === 'true');
$(event.currentTarget).fadeTo(500, 0, function() {
- //If selected log is a rotated one append to list bottom
- //otherwise append to top
- if (is_rotated) {
- $(dest_div).append(event.currentTarget);
- } else {
- $(dest_div).prepend(event.currentTarget);
- }
+ //If selected log is a rotated one append to list bottom
+ //otherwise append to top
+ if (is_rotated) {
+ $(dest_div).append(event.currentTarget);
+ } else {
+ $(dest_div).prepend(event.currentTarget);
+ }
$(event.currentTarget).fadeTo(500, 1);
_this.ShowLogDownload();
});
},
LoadServerLogs: function() {
- //On user action for log reading append some info to LogReader modal, open it and ask backend for data
+ //On user action for log reading append some info to LogReader modal, open it and ask backend for data
$('#live-log').addClass('disabled'); // prevent users from submitting multiple reading requests same time
$('#logsize').empty();
var _this = this;
@@ -255,26 +255,26 @@ LogsView = RockstorLayoutView.extend({
initHandlebarHelpers: function() {
var _this = this;
_this.avail_logs = {
- "rockstor": "Rockstor Logs",
- "supervisord": "Supervisord (Process monitor)",
- "dmesg": "Dmesg (Kernel)",
- "nmbd": "Nmbd (Samba)",
- "smbd": "Smbd (Samba)",
- "winbindd": "Winbindd (Samba)",
- "nginx": "Nginx (WebUI)",
- "nginx_stdout": "Nginx stdout (WebUI)",
- "nginx_stderr": "Nginx stderr (WebUI)",
- "gunicorn": "Gunicorn (WebUI)",
- "gunicorn_stdout": "Gunicorn stdout (WebUI)",
- "gunicorn_stderr": "Gunicorn stderr (WebUI)",
- "yum": "Yum (System updates)"
+ 'rockstor': 'Rockstor Logs',
+ 'supervisord': 'Supervisord (Process monitor)',
+ 'dmesg': 'Dmesg (Kernel)',
+ 'nmbd': 'Nmbd (Samba)',
+ 'smbd': 'Smbd (Samba)',
+ 'winbindd': 'Winbindd (Samba)',
+ 'nginx': 'Nginx (WebUI)',
+ 'nginx_stdout': 'Nginx stdout (WebUI)',
+ 'nginx_stderr': 'Nginx stderr (WebUI)',
+ 'gunicorn': 'Gunicorn (WebUI)',
+ 'gunicorn_stdout': 'Gunicorn stdout (WebUI)',
+ 'gunicorn_stderr': 'Gunicorn stderr (WebUI)',
+ 'yum': 'Yum (System updates)'
};
Handlebars.registerHelper('print_logs_divs', function() {
var html = '';
$.each(_this.avail_logs, function(key, val) {
html += '
';
- html += ' ' + val + '
';
+ html += '
' + val + '
';
});
return new Handlebars.SafeString(html);
});
@@ -284,7 +284,7 @@ LogsView = RockstorLayoutView.extend({
$.each(_this.avail_logs, function(key, val) {
html += '
' + val + ' ';
});
- html += ''
+ html += '';
return new Handlebars.SafeString(html);
});
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/network.js b/src/rockstor/storageadmin/static/storageadmin/js/views/network.js
index ad7907d8e..8fb81423f 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/network.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/network.js
@@ -27,157 +27,161 @@
NetworkView = Backbone.View.extend({
events: {
- "click a[data-action=delete]": "deleteConnection",
- 'switchChange.bootstrapSwitch': 'switchStatus'
+ 'click a[data-action=delete]': 'deleteConnection',
+ 'switchChange.bootstrapSwitch': 'switchStatus'
},
initialize: function() {
- this.template = window.JST.network_network;
- this.collection = new NetworkConnectionCollection();
- this.collection.on('reset', this.renderNetwork, this);
- this.devices = new NetworkDeviceCollection();
- this.devices.on('reset', this.renderNetwork, this);
- this.initHandlebarHelpers();
+ this.template = window.JST.network_network;
+ this.collection = new NetworkConnectionCollection();
+ this.collection.on('reset', this.renderNetwork, this);
+ this.devices = new NetworkDeviceCollection();
+ this.devices.on('reset', this.renderNetwork, this);
+ this.initHandlebarHelpers();
},
render: function() {
- var _this = this;
- this.collection.fetch();
- this.devices.fetch();
- return this;
+ var _this = this;
+ this.collection.fetch();
+ this.devices.fetch();
+ return this;
},
renderNetwork: function() {
- var _this = this;
- this.pc = [];
- this.cc = [];
- for (var i = 0; i < this.collection.length; i++) {
- var c = this.collection.at(i);
- if (c.get('master')) {
- this.cc.push(c.toJSON());
- } else {
- this.pc.push(c.toJSON());
- }
- }
+ var _this = this;
+ this.pc = [];
+ this.cc = [];
+ for (var i = 0; i < this.collection.length; i++) {
+ var c = this.collection.at(i);
+ if (c.get('master')) {
+ this.cc.push(c.toJSON());
+ } else {
+ this.pc.push(c.toJSON());
+ }
+ }
- $(this.el).empty();
- $(this.el).append(this.template({
- collection: this.collection,
- connections: this.collection.toJSON(),
- parent_connections: this.pc,
- child_connections: this.cc,
- devices: this.devices.toJSON()
- }));
- setApplianceName();
+ $(this.el).empty();
+ $(this.el).append(this.template({
+ collection: this.collection,
+ connections: this.collection.toJSON(),
+ parent_connections: this.pc,
+ child_connections: this.cc,
+ devices: this.devices.toJSON()
+ }));
+ setApplianceName();
- //Initialize bootstrap switch
- this.$("[type='checkbox']").bootstrapSwitch();
- this.$("[type='checkbox']").bootstrapSwitch('onColor','success'); //left side text color
- this.$("[type='checkbox']").bootstrapSwitch('offColor','danger'); //right side text color
+ //Initialize bootstrap switch
+ this.$('[type=\'checkbox\']').bootstrapSwitch();
+ this.$('[type=\'checkbox\']').bootstrapSwitch('onColor', 'success'); //left side text color
+ this.$('[type=\'checkbox\']').bootstrapSwitch('offColor', 'danger'); //right side text color
},
- switchStatus: function(event,state){
- var connectionId = $(event.target).attr('data-connection-id');
- if (state){
- this.toggleConnection(connectionId, 'up');
- }else {
- this.toggleConnection(connectionId, 'down');
- }
+ switchStatus: function(event, state) {
+ var connectionId = $(event.target).attr('data-connection-id');
+ if (state) {
+ this.toggleConnection(connectionId, 'up');
+ } else {
+ this.toggleConnection(connectionId, 'down');
+ }
},
toggleConnection: function(connectionId, switchState) {
- var _this = this;
- $.ajax({
- url: "api/network/connections/" + connectionId + "/" + switchState,
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(connectionId, false);
- _this.render();
- },
- error: function(xhr, status, error) {
- _this.setStatusError(connectionId, xhr);
- }
- });
+ var _this = this;
+ $.ajax({
+ url: 'api/network/connections/' + connectionId + '/' + switchState,
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(connectionId, false);
+ _this.render();
+ },
+ error: function(xhr, status, error) {
+ _this.setStatusError(connectionId, xhr);
+ }
+ });
},
setStatusLoading: function(connectionId, show) {
- var statusEl = this.$('div.command-status[data-connection-id="' + connectionId + '"]');
- if (show) {
- statusEl.html('
');
- } else {
- statusEl.empty();
- }
+ var statusEl = this.$('div.command-status[data-connection-id="' + connectionId + '"]');
+ if (show) {
+ statusEl.html('
');
+ } else {
+ statusEl.empty();
+ }
},
setStatusError: function(connectionId, xhr) {
- var statusEl = this.$('div.command-status[data-connection-id="' + connectionId + '"]');
- var msg = parseXhrError(xhr);
- // remove any existing error popups
- $('body').find('#' + connectionId + 'err-popup').remove();
- // add icon and popup
- statusEl.empty();
- var icon = $('
').addClass('icon-exclamation-sign').attr('rel', '#' + connectionId + '-err-popup');
- statusEl.append(icon);
- var errPopup = this.$('#' + connectionId + '-err-popup');
- var errPopupContent = this.$('#' + connectionId + '-err-popup > div');
- errPopupContent.html(msg);
- statusEl.click(function(){ errPopup.overlay().load(); });
+ var statusEl = this.$('div.command-status[data-connection-id="' + connectionId + '"]');
+ var msg = parseXhrError(xhr);
+ // remove any existing error popups
+ $('body').find('#' + connectionId + 'err-popup').remove();
+ // add icon and popup
+ statusEl.empty();
+ var icon = $('').addClass('icon-exclamation-sign').attr('rel', '#' + connectionId + '-err-popup');
+ statusEl.append(icon);
+ var errPopup = this.$('#' + connectionId + '-err-popup');
+ var errPopupContent = this.$('#' + connectionId + '-err-popup > div');
+ errPopupContent.html(msg);
+ statusEl.click(function() {
+ errPopup.overlay().load();
+ });
},
- deleteConnection: function(event){
- if (confirm("Are you sure to delete the connection?")) {
- var _this = this;
- var button = $(event.currentTarget);
- var connectionId = button.attr('id');
- 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);
- _this.render();
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- }
+ deleteConnection: function(event) {
+ if (confirm('Are you sure to delete the connection?')) {
+ var _this = this;
+ var button = $(event.currentTarget);
+ var connectionId = button.attr('id');
+ 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);
+ _this.render();
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ }
},
- initHandlebarHelpers: function(){
- var _this = this;
- Handlebars.registerHelper('getState', function(state){
- var html = '';
- if(state == 'activated'){
- html = 'checked';
- }
- return new Handlebars.SafeString(html);
- });
- Handlebars.registerHelper('belongsToConnection', function(connectionId, deviceConnectionId){
- if(connectionId == deviceConnectionId){
- return true;
- }
- for (var i = 0; i < _this.cc.length; i++) {
- if (_this.cc[i].master == connectionId &&
- _this.cc[i].id == deviceConnectionId) {
- return true;
- }
- }
- return false;
- });
- Handlebars.registerHelper('hasChildren', function(connection, opts) {
- for (var i = 0; i < _this.cc.length; i++) {
- if (_this.cc[i].master == connection.id) {
- return opts.fn(this);
- }
- }
- return opts.inverse(this);
- });
+ initHandlebarHelpers: function() {
+ var _this = this;
+ Handlebars.registerHelper('getState', function(state) {
+ var html = '';
+ if (state == 'activated') {
+ html = 'checked';
+ }
+ return new Handlebars.SafeString(html);
+ });
+ Handlebars.registerHelper('belongsToConnection', function(connectionId, deviceConnectionId) {
+ if (connectionId == deviceConnectionId) {
+ return true;
+ }
+ for (var i = 0; i < _this.cc.length; i++) {
+ if (_this.cc[i].master == connectionId &&
+ _this.cc[i].id == deviceConnectionId) {
+ return true;
+ }
+ }
+ return false;
+ });
+ Handlebars.registerHelper('hasChildren', function(connection, opts) {
+ for (var i = 0; i < _this.cc.length; i++) {
+ if (_this.cc[i].master == connection.id) {
+ return opts.fn(this);
+ }
+ }
+ return opts.inverse(this);
+ });
}
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/nfs_advanced_edit.js b/src/rockstor/storageadmin/static/storageadmin/js/views/nfs_advanced_edit.js
index f9c36ad2b..ce410b89b 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/nfs_advanced_edit.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/nfs_advanced_edit.js
@@ -25,77 +25,83 @@
*/
NFSAdvancedEditView = RockstorLayoutView.extend({
- events: {
- "click #cancel": "cancel"
- },
+ events: {
+ 'click #cancel': 'cancel'
+ },
- initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.nfs_advanced_edit;
- this.collection = new AdvancedNFSExportCollection();
- this.dependencies.push(this.collection);
- },
+ initialize: function() {
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.nfs_advanced_edit;
+ this.collection = new AdvancedNFSExportCollection();
+ this.dependencies.push(this.collection);
+ },
- render: function() {
- this.fetch(this.renderAdvancedEdit, this);
- return this;
- },
+ render: function() {
+ this.fetch(this.renderAdvancedEdit, this);
+ return this;
+ },
- renderAdvancedEdit: function() {
- var _this = this;
- var ro_str = '';
- var rw_str = '';
+ renderAdvancedEdit: function() {
+ var _this = this;
+ var ro_str = '';
+ var rw_str = '';
- this.collection.each(function(nfsExport) {
- var prefix = "Normally added -- ";
- var n = prefix.length;
- var s = nfsExport.get('export_str');
- if (s.indexOf(prefix) == 0) {
- ro_str = ro_str + s.substring(n, s.length) + '\n';
- } else {
- rw_str = rw_str + s + '\n';
- }
- });
- $(this.el).html(this.template({
- shares: this.shares,
- collection: this.collection,
- ro_str: ro_str,
- rw_str: rw_str
- }));
- $('#advanced-edit-form').validate({
- onfocusout: false,
- onkeyup: false,
-
- submitHandler: function() {
- var button = $('#submit-advanced-edit');
- var nfsText = _this.$('#nfs-text').val();
- var entries = [];
- if (!_.isNull(nfsText) && nfsText.trim() != '') entries = nfsText.trim().split('\n');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- $.ajax({
- url: '/api/adv-nfs-exports',
- type: 'POST',
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({ entries: entries }),
- success: function() {
- enableButton(button);
- app_router.navigate('nfs-exports', {trigger: true});
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
+ this.collection.each(function(nfsExport) {
+ var prefix = 'Normally added -- ';
+ var n = prefix.length;
+ var s = nfsExport.get('export_str');
+ if (s.indexOf(prefix) == 0) {
+ ro_str = ro_str + s.substring(n, s.length) + '\n';
+ } else {
+ rw_str = rw_str + s + '\n';
+ }
});
+ $(this.el).html(this.template({
+ shares: this.shares,
+ collection: this.collection,
+ ro_str: ro_str,
+ rw_str: rw_str
+ }));
+ $('#advanced-edit-form').validate({
+ onfocusout: false,
+ onkeyup: false,
+
+ submitHandler: function() {
+ var button = $('#submit-advanced-edit');
+ var nfsText = _this.$('#nfs-text').val();
+ var entries = [];
+ if (!_.isNull(nfsText) && nfsText.trim() != '') entries = nfsText.trim().split('\n');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ $.ajax({
+ url: '/api/adv-nfs-exports',
+ type: 'POST',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ entries: entries
+ }),
+ success: function() {
+ enableButton(button);
+ app_router.navigate('nfs-exports', {
+ trigger: true
+ });
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
- return false;
- }
- });
- },
+ return false;
+ }
+ });
+ },
- cancel: function(event) {
- event.preventDefault();
- app_router.navigate('nfs-exports', {trigger: true});
- }
+ cancel: function(event) {
+ event.preventDefault();
+ app_router.navigate('nfs-exports', {
+ trigger: true
+ });
+ }
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/nfs_exports.js b/src/rockstor/storageadmin/static/storageadmin/js/views/nfs_exports.js
index 8563d0cdf..0b1f4a17f 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/nfs_exports.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/nfs_exports.js
@@ -24,164 +24,168 @@
*
*/
-NFSExportsView = RockstorLayoutView.extend({
- events: {
- 'click .delete-nfs-export': 'deleteNfsExport',
- 'switchChange.bootstrapSwitch': 'switchStatus',
- },
-
- initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.nfs_nfs_exports;
- this.module_name = 'nfs_exports';
- this.collection = new NFSExportGroupCollection();
- this.dependencies.push(this.collection);
- this.appliances = new ApplianceCollection();
- this.dependencies.push(this.appliances);
- this.serviceName = 'nfs';
- this.service = new Service({name: this.serviceName});
- this.dependencies.push(this.service);
- this.updateFreq = 5000;
- this.collection.on('reset', this.renderNFSExportGroups, this);
- this.initHandlebarHelpers();
- },
-
- render: function() {
- var _this = this;
- this.fetch(this.renderNFSExportGroups, this);
- return this;
- },
-
- renderNFSExportGroups: function() {
- var currentAppliance = this.appliances.find(function(appliance) {
- return appliance.get('current_appliance') == true;
- });
- $(this.el).html(this.template({
- collection: this.collection,
- nfsCollection: this.collection.toJSON(),
- collectionNotEmpty: !this.collection.isEmpty(),
- service: this.service,
- currentAppliance: currentAppliance,
- currentApplianceIp: currentAppliance.get('ip')
- }));
-
- this.renderDataTables();
-
- //initalize Bootstrap Switch
- this.$("[type='checkbox']").bootstrapSwitch();
- this.$('input[name="nfs-export-checkbox"]').bootstrapSwitch('state', this.service.get('status'), true);
- this.$("[type='checkbox']").bootstrapSwitch('onColor','success'); //left side text color
- this.$("[type='checkbox']").bootstrapSwitch('offColor','danger'); //right side text color
-
- // Display NFS Export Service Warning
- if (!this.service.get('status')) {
- this.$('#nfs-warning').show();
- } else {
- this.$('#nfs-warning').hide();
- }
- },
-
- switchStatus: function(event,state){
- if (state){
- this.startService();
- }else {
- this.stopService();
- }
- },
-
- deleteNfsExport: function(event) {
- var _this = this;
- if (event) event.preventDefault();
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- if(confirm("Delete nfs-export... Are you sure? ")){
- disableButton(button);
- var id = $(event.currentTarget).data('id');
- $.ajax({
- url: '/api/nfs-exports/' + id,
- type: 'DELETE',
- dataType: 'json',
- contentType: 'application/json',
- success: function() {
- _this.render();
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- }
- },
-
- startService: function() {
- var _this = this;
- this.setStatusLoading(this.serviceName, true);
- $.ajax({
- url: "/api/sm/services/nfs/start",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(_this.serviceName, false);
- _this.$('#nfs-warning').hide();
- },
- error: function(xhr, status, error) {
- _this.setStatusError(_this.serviceName, xhr);
- _this.$('#nfs-warning').show();
- }
- });
- },
-
- stopService: function() {
- var _this = this;
- this.setStatusLoading(this.serviceName, true);
- $.ajax({
- url: "/api/sm/services/nfs/stop",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(_this.serviceName, false);
- _this.$('#nfs-warning').show();
- },
- error: function(xhr, status, error) {
- _this.setStatusError(_this.serviceName, xhr);
- _this.$('#nfs-warning').hide();
- }
- });
- },
-
- setStatusLoading: function(serviceName, show) {
- var statusEl = this.$('div.command-status[data-service-name="'+serviceName+'"]');
- if (show) {
- statusEl.html(' ');
- } else {
- statusEl.empty();
- }
- },
-
- setStatusError: function(serviceName, xhr) {
- var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
- var msg = parseXhrError(xhr);
- // remove any existing error popups
- $('body').find('#' + serviceName + 'err-popup').remove();
- // add icon and popup
- statusEl.empty();
- var icon = $('').addClass('icon-exclamation-sign').attr('rel', '#' + serviceName + '-err-popup');
- statusEl.append(icon);
- var errPopup = this.$('#' + serviceName + '-err-popup');
- var errPopupContent = this.$('#' + serviceName + '-err-popup > div');
- errPopupContent.html(msg);
- statusEl.click(function(){ errPopup.overlay().load(); });
- },
-
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('showNfsShares', function(index, nfsExports){
- if (index < (nfsExports.length - 1)) {
- return ',';
- }
- });
-
- Handlebars.registerHelper('showWritableOption', function(editable){
- return editable == 'rw' ? 'Writable' : 'Read-only'
- });
- }
+NFSExportsView = RockstorLayoutView.extend({
+ events: {
+ 'click .delete-nfs-export': 'deleteNfsExport',
+ 'switchChange.bootstrapSwitch': 'switchStatus',
+ },
+
+ initialize: function() {
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.nfs_nfs_exports;
+ this.module_name = 'nfs_exports';
+ this.collection = new NFSExportGroupCollection();
+ this.dependencies.push(this.collection);
+ this.appliances = new ApplianceCollection();
+ this.dependencies.push(this.appliances);
+ this.serviceName = 'nfs';
+ this.service = new Service({
+ name: this.serviceName
+ });
+ this.dependencies.push(this.service);
+ this.updateFreq = 5000;
+ this.collection.on('reset', this.renderNFSExportGroups, this);
+ this.initHandlebarHelpers();
+ },
+
+ render: function() {
+ var _this = this;
+ this.fetch(this.renderNFSExportGroups, this);
+ return this;
+ },
+
+ renderNFSExportGroups: function() {
+ var currentAppliance = this.appliances.find(function(appliance) {
+ return appliance.get('current_appliance') == true;
+ });
+ $(this.el).html(this.template({
+ collection: this.collection,
+ nfsCollection: this.collection.toJSON(),
+ collectionNotEmpty: !this.collection.isEmpty(),
+ service: this.service,
+ currentAppliance: currentAppliance,
+ currentApplianceIp: currentAppliance.get('ip')
+ }));
+
+ this.renderDataTables();
+
+ //initalize Bootstrap Switch
+ this.$('[type=\'checkbox\']').bootstrapSwitch();
+ this.$('input[name="nfs-export-checkbox"]').bootstrapSwitch('state', this.service.get('status'), true);
+ this.$('[type=\'checkbox\']').bootstrapSwitch('onColor', 'success'); //left side text color
+ this.$('[type=\'checkbox\']').bootstrapSwitch('offColor', 'danger'); //right side text color
+
+ // Display NFS Export Service Warning
+ if (!this.service.get('status')) {
+ this.$('#nfs-warning').show();
+ } else {
+ this.$('#nfs-warning').hide();
+ }
+ },
+
+ switchStatus: function(event, state) {
+ if (state) {
+ this.startService();
+ } else {
+ this.stopService();
+ }
+ },
+
+ deleteNfsExport: function(event) {
+ var _this = this;
+ if (event) event.preventDefault();
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ if (confirm('Delete nfs-export... Are you sure? ')) {
+ disableButton(button);
+ var id = $(event.currentTarget).data('id');
+ $.ajax({
+ url: '/api/nfs-exports/' + id,
+ type: 'DELETE',
+ dataType: 'json',
+ contentType: 'application/json',
+ success: function() {
+ _this.render();
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ }
+ },
+
+ startService: function() {
+ var _this = this;
+ this.setStatusLoading(this.serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/nfs/start',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(_this.serviceName, false);
+ _this.$('#nfs-warning').hide();
+ },
+ error: function(xhr, status, error) {
+ _this.setStatusError(_this.serviceName, xhr);
+ _this.$('#nfs-warning').show();
+ }
+ });
+ },
+
+ stopService: function() {
+ var _this = this;
+ this.setStatusLoading(this.serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/nfs/stop',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(_this.serviceName, false);
+ _this.$('#nfs-warning').show();
+ },
+ error: function(xhr, status, error) {
+ _this.setStatusError(_this.serviceName, xhr);
+ _this.$('#nfs-warning').hide();
+ }
+ });
+ },
+
+ setStatusLoading: function(serviceName, show) {
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ if (show) {
+ statusEl.html(' ');
+ } else {
+ statusEl.empty();
+ }
+ },
+
+ setStatusError: function(serviceName, xhr) {
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ var msg = parseXhrError(xhr);
+ // remove any existing error popups
+ $('body').find('#' + serviceName + 'err-popup').remove();
+ // add icon and popup
+ statusEl.empty();
+ var icon = $('').addClass('icon-exclamation-sign').attr('rel', '#' + serviceName + '-err-popup');
+ statusEl.append(icon);
+ var errPopup = this.$('#' + serviceName + '-err-popup');
+ var errPopupContent = this.$('#' + serviceName + '-err-popup > div');
+ errPopupContent.html(msg);
+ statusEl.click(function() {
+ errPopup.overlay().load();
+ });
+ },
+
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('showNfsShares', function(index, nfsExports) {
+ if (index < (nfsExports.length - 1)) {
+ return ',';
+ }
+ });
+
+ Handlebars.registerHelper('showWritableOption', function(editable) {
+ return editable == 'rw' ? 'Writable' : 'Read-only';
+ });
+ }
});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/add_disks.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/add_disks.js
index 5745ff45b..da09e3e05 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/add_disks.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/add_disks.js
@@ -129,3 +129,4 @@ PoolAddDisks = RockstorWizardPage.extend({
});
}
});
+
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/add_disks_raid.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/add_disks_raid.js
index 136645676..9cd319eb7 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/add_disks_raid.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/add_disks_raid.js
@@ -1,31 +1,28 @@
PoolAddDisksRaid = RockstorWizardPage.extend({
- initialize: function() {
- this.template = window.JST.pool_resize_add_disks_raid;
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
- this.initHandlebarHelpers();
- },
-
- save: function() {
- var _this = this;
- var json = this.$('#raid-change-form').getJSON();
- if (json.raidChange == 'yes') {
- this.model.set('raidChange', true);
- } else {
- this.model.set('raidChange', false);
- }
- return $.Deferred().resolve();
- },
-
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_poolName_raidLevel', function(){
- var html = '';
- html += this.model.get('pool').get('name') + ' is ' + this.model.get('pool').get('raid');
- return new Handlebars.SafeString(html);
- });
-
- }
-});
+ initialize: function() {
+ this.template = window.JST.pool_resize_add_disks_raid;
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.initHandlebarHelpers();
+ },
+ save: function() {
+ var _this = this;
+ var json = this.$('#raid-change-form').getJSON();
+ if (json.raidChange == 'yes') {
+ this.model.set('raidChange', true);
+ } else {
+ this.model.set('raidChange', false);
+ }
+ return $.Deferred().resolve();
+ },
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_poolName_raidLevel', function() {
+ var html = '';
+ html += this.model.get('pool').get('name') + ' is ' + this.model.get('pool').get('raid');
+ return new Handlebars.SafeString(html);
+ });
+ }
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/choice.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/choice.js
index 4bec88a71..7a1599056 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/choice.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/choice.js
@@ -1,42 +1,42 @@
PoolResizeChoice = RockstorWizardPage.extend({
- initialize: function() {
- this.template = window.JST.pool_resize_choice;
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
- this.initHandlebarHelpers();
- },
-
- events: {
- 'click #change-raid': 'changeRaid',
- 'click #add-disks': 'addDisks',
- 'click #remove-disks': 'removeDisks',
- },
-
- changeRaid: function() {
- this.model.set('choice', 'raid');
- this.evAgg.trigger('nextPage');
- return false;
- },
-
- addDisks: function() {
- this.model.set('choice', 'add');
- this.evAgg.trigger('nextPage');
- return false;
- },
-
- removeDisks: function() {
- this.model.set('choice', 'remove');
- this.parent.nextPage();
- return false;
- },
-
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_poolName', function(){
- var poolName = '';
- poolName = this.model.get('pool').get('name');
- return new Handlebars.SafeString(poolName);
- });
-
- }
-
-});
+ initialize: function() {
+ this.template = window.JST.pool_resize_choice;
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.initHandlebarHelpers();
+ },
+
+ events: {
+ 'click #change-raid': 'changeRaid',
+ 'click #add-disks': 'addDisks',
+ 'click #remove-disks': 'removeDisks',
+ },
+
+ changeRaid: function() {
+ this.model.set('choice', 'raid');
+ this.evAgg.trigger('nextPage');
+ return false;
+ },
+
+ addDisks: function() {
+ this.model.set('choice', 'add');
+ this.evAgg.trigger('nextPage');
+ return false;
+ },
+
+ removeDisks: function() {
+ this.model.set('choice', 'remove');
+ this.parent.nextPage();
+ return false;
+ },
+
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_poolName', function() {
+ var poolName = '';
+ poolName = this.model.get('pool').get('name');
+ return new Handlebars.SafeString(poolName);
+ });
+
+ }
+
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/pool_resize_wizard.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/pool_resize_wizard.js
index 2ffe4381a..82303d225 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/pool_resize_wizard.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/pool_resize_wizard.js
@@ -26,69 +26,69 @@
PoolResizeWizardView = WizardView.extend({
initialize: function() {
- WizardView.prototype.initialize.apply(this, arguments);
- this.pages = [];
+ WizardView.prototype.initialize.apply(this, arguments);
+ this.pages = [];
},
setCurrentPage: function() {
- var choice = this.model.get('choice');
- var page = null;
- if (_.isUndefined(this.pages[this.currentPageNum]) ||
+ var choice = this.model.get('choice');
+ var page = null;
+ if (_.isUndefined(this.pages[this.currentPageNum]) ||
_.isNull(this.pages[this.currentPageNum])) {
- if (_.isUndefined(choice)) {
- this.pages[0] = PoolResizeChoice;
- } else if (choice == 'add') {
- this.pages[1] = PoolAddDisksRaid;
- this.pages[2] = PoolAddDisks;
- this.pages[3] = PoolResizeSummary;
- this.pages[4] = PoolRemoveDisksComplete;
+ if (_.isUndefined(choice)) {
+ this.pages[0] = PoolResizeChoice;
+ } else if (choice == 'add') {
+ this.pages[1] = PoolAddDisksRaid;
+ this.pages[2] = PoolAddDisks;
+ this.pages[3] = PoolResizeSummary;
+ this.pages[4] = PoolRemoveDisksComplete;
} else if (choice == 'remove') {
- this.pages[1] = PoolRemoveDisks;
- this.pages[2] = PoolResizeSummary;
- this.pages[3] = PoolRemoveDisksComplete;
+ this.pages[1] = PoolRemoveDisks;
+ this.pages[2] = PoolResizeSummary;
+ this.pages[3] = PoolRemoveDisksComplete;
} else if (choice == 'raid') {
- this.pages[1] = PoolRaidChange;
- this.pages[2] = PoolResizeSummary;
- this.pages[3] = PoolRemoveDisksComplete;
+ this.pages[1] = PoolRaidChange;
+ this.pages[2] = PoolResizeSummary;
+ this.pages[3] = PoolRemoveDisksComplete;
}
- }
- this.currentPage = new this.pages[this.currentPageNum]({
- model: this.model,
- parent: this,
- evAgg: this.evAgg
- });
+ }
+ this.currentPage = new this.pages[this.currentPageNum]({
+ model: this.model,
+ parent: this,
+ evAgg: this.evAgg
+ });
},
lastPage: function() {
- return ((this.pages.length > 1)
- && ((this.pages.length-1) == this.currentPageNum));
+ return ((this.pages.length > 1) &&
+ ((this.pages.length - 1) == this.currentPageNum));
},
modifyButtonText: function() {
- switch(this.currentPageNum) {
- case 0:
+ switch (this.currentPageNum) {
+ case 0:
this.$('#ph-wizard-buttons').hide();
this.model.unset('choice');
this.pages = [];
this.setCurrentPage();
break;
- default:
+ default:
this.$('#ph-wizard-buttons').show();
break;
- }
- if (this.pages[this.currentPageNum] == PoolResizeSummary) {
- this.$('#next-page').html('Resize');
- } else if (this.lastPage()) {
- this.$('#prev-page').hide();
- this.$('#next-page').html('Finish');
- } else {
- this.$('#next-page').html('Next');
- }
+ }
+ if (this.pages[this.currentPageNum] == PoolResizeSummary) {
+ this.$('#next-page').html('Resize');
+ } else if (this.lastPage()) {
+ this.$('#prev-page').hide();
+ this.$('#next-page').html('Finish');
+ } else {
+ this.$('#next-page').html('Next');
+ }
},
finish: function() {
- this.parent.$('#pool-resize-raid-overlay').overlay().close();
- this.parent.render();
+ this.parent.$('#pool-resize-raid-overlay').overlay().close();
+ this.parent.render();
},
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/raid_change.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/raid_change.js
index 7d70dfefe..f442ec67e 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/raid_change.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/raid_change.js
@@ -26,65 +26,65 @@
PoolRaidChange = RockstorWizardPage.extend({
- initialize: function() {
- this.disks = new DiskCollection();
- this.disks.setPageSize(100);
- this.template = window.JST.pool_resize_raid_change;
- this.disks_template = window.JST.common_disks_table;
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
- this.disks.on('reset', this.renderDisks, this);
- this.initHandlebarHelpers();
- },
+ initialize: function() {
+ this.disks = new DiskCollection();
+ this.disks.setPageSize(100);
+ this.template = window.JST.pool_resize_raid_change;
+ this.disks_template = window.JST.common_disks_table;
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.disks.on('reset', this.renderDisks, this);
+ this.initHandlebarHelpers();
+ },
- render: function() {
- $(this.el).html(this.template({
- model: this.model,
- raidLevel: this.model.get('pool').get('raid'),
- }));
- this.disks.fetch();
- return this;
- },
+ render: function() {
+ $(this.el).html(this.template({
+ model: this.model,
+ raidLevel: this.model.get('pool').get('raid'),
+ }));
+ this.disks.fetch();
+ return this;
+ },
- renderDisks: function() {
- var _this = this;
- var disks = this.disks.filter(function(disk) {
- return disk.available();
- }, this);
- this.$('#raid-change-form').validate({
- rules: {
- 'raid-level': {
- required: true
- }
- },
- messages: {
- 'raid-level': 'Please select a RAID level'
- }
- });
- },
+ renderDisks: function() {
+ var _this = this;
+ var disks = this.disks.filter(function(disk) {
+ return disk.available();
+ }, this);
+ this.$('#raid-change-form').validate({
+ rules: {
+ 'raid-level': {
+ required: true
+ }
+ },
+ messages: {
+ 'raid-level': 'Please select a RAID level'
+ }
+ });
+ },
- save: function() {
- var valid = $('#raid-change-form').valid();
- if (valid) {
- var raidLevel = this.$('#raid-level').val();
- this.model.set('raidLevel', raidLevel);
- return $.Deferred().resolve();
- }
- return $.Deferred().reject();
- },
+ save: function() {
+ var valid = $('#raid-change-form').valid();
+ if (valid) {
+ var raidLevel = this.$('#raid-level').val();
+ this.model.set('raidLevel', raidLevel);
+ return $.Deferred().resolve();
+ }
+ return $.Deferred().reject();
+ },
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_raid_levels', function(){
- var html = '';
- var _this = this;
- var levels = ['raid0', 'raid1', 'raid10', 'raid5', 'raid6'];
- _.each(levels, function(level) {
- if (_this.raidLevel != level) {
- html += '' + level + ' ';
- }
- });
- return new Handlebars.SafeString(html);
- });
- }
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_raid_levels', function() {
+ var html = '';
+ var _this = this;
+ var levels = ['raid0', 'raid1', 'raid10', 'raid5', 'raid6'];
+ _.each(levels, function(level) {
+ if (_this.raidLevel != level) {
+ html += '' + level + ' ';
+ }
+ });
+ return new Handlebars.SafeString(html);
+ });
+ }
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/remove_disks.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/remove_disks.js
index 28997f6a0..c93be7335 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/remove_disks.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/remove_disks.js
@@ -26,11 +26,11 @@
PoolRemoveDisks = RockstorWizardPage.extend({
events: {
- "click #checkAll": "selectAllCheckboxes",
+ 'click #checkAll': 'selectAllCheckboxes',
'click [class="diskname"]': 'clickCheckbox',
},
- initialize: function () {
+ initialize: function() {
this.disks = new DiskCollection();
this.disks.setPageSize(100);
this.template = window.JST.pool_resize_remove_disks;
@@ -40,53 +40,55 @@ PoolRemoveDisks = RockstorWizardPage.extend({
this.initHandlebarHelpers();
},
- render: function () {
+ render: function() {
RockstorWizardPage.prototype.render.apply(this, arguments);
this.disks.fetch();
return this;
},
- renderDisks: function () {
- var disks = this.disks.filter(function (disk) {
+ renderDisks: function() {
+ var disks = this.disks.filter(function(disk) {
return disk.get('pool_name') == this.model.get('pool').get('name');
}, this);
//convert the array elements which are backbone models/collections to JSON object
for (var i = 0; i < disks.length; i++) {
disks[i] = disks[i].toJSON();
}
- this.$('#ph-disks-table').html(this.disks_template({disks: disks}));
+ this.$('#ph-disks-table').html(this.disks_template({
+ disks: disks
+ }));
},
- selectAllCheckboxes: function (event) {
- $("#checkAll").change(function () {
- $("input:checkbox").prop('checked', $(this).prop("checked"));
- $("input:checkbox").closest("tr").toggleClass("row-highlight", this.checked);
+ selectAllCheckboxes: function(event) {
+ $('#checkAll').change(function() {
+ $('input:checkbox').prop('checked', $(this).prop('checked'));
+ $('input:checkbox').closest('tr').toggleClass('row-highlight', this.checked);
});
},
- clickCheckbox: function (event) {
- $("input:checkbox").change(function () {
- $(this).closest("tr").toggleClass("row-highlight", this.checked);
+ clickCheckbox: function(event) {
+ $('input:checkbox').change(function() {
+ $(this).closest('tr').toggleClass('row-highlight', this.checked);
});
},
- save: function () {
+ save: function() {
var _this = this;
- var checked = this.$(".diskname:checked").length;
+ var checked = this.$('.diskname:checked').length;
var diskNames = [];
- this.$(".diskname:checked").each(function (i) {
+ this.$('.diskname:checked').each(function(i) {
diskNames.push($(this).val());
});
this.model.set('diskNames', diskNames);
return $.Deferred().resolve();
},
- initHandlebarHelpers: function () {
- Handlebars.registerHelper('mathHelper', function (value, options) {
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('mathHelper', function(value, options) {
return parseInt(value) + 1;
});
- Handlebars.registerHelper('humanReadableSize', function(diskSize){
+ Handlebars.registerHelper('humanReadableSize', function(diskSize) {
return humanize.filesize(diskSize * 1024);
});
}
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/remove_disks_complete.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/remove_disks_complete.js
index 59508ac90..abd698789 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/remove_disks_complete.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/remove_disks_complete.js
@@ -1,23 +1,22 @@
PoolRemoveDisksComplete = RockstorWizardPage.extend({
- initialize: function() {
- this.template = window.JST.pool_resize_remove_disks_complete;
- this.initHandlebarHelpers();
- },
+ initialize: function() {
+ this.template = window.JST.pool_resize_remove_disks_complete;
+ this.initHandlebarHelpers();
+ },
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_breadCrumbs', function(){
- var html = '';
- if (this.model.get('choice') == 'add') {
- html += ' Change RAID level?
Select disks to add
';
- } else if (this.model.get('choice') == 'remove') {
- html += 'Select disks to remove
';
- } else if (this.model.get('choice') == 'raid') {
- html += 'Select RAID level and add disks
';
- }
- return new Handlebars.SafeString(html);
- });
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_breadCrumbs', function() {
+ var html = '';
+ if (this.model.get('choice') == 'add') {
+ html += 'Change RAID level?
Select disks to add
';
+ } else if (this.model.get('choice') == 'remove') {
+ html += 'Select disks to remove
';
+ } else if (this.model.get('choice') == 'raid') {
+ html += 'Select RAID level and add disks
';
+ }
+ return new Handlebars.SafeString(html);
+ });
- }
-
-});
+ }
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/summary.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/summary.js
index 96245c7d7..9ddd839c7 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/summary.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool/resize/summary.js
@@ -27,115 +27,114 @@
PoolResizeSummary = RockstorWizardPage.extend({
- initialize: function() {
- this.template = window.JST.pool_resize_summary;
- var choice = this.model.get('choice');
- var raidLevel = null;
- var poolDisks = _.map(this.model.get('pool').get('disks'), function(disk) {
- return disk.name;
- });
- if (choice == 'add') {
- this.newRaidLevel = this.model.get('raidChange') ? this.model.get('raidLevel') :
- this.model.get('pool').get('raid');
- this.newDisks = _.union(poolDisks, this.model.get('diskNames'));
- } else if (choice == 'remove') {
- this.newRaidLevel = this.model.get('pool').get('raid');
- this.newDisks = _.difference(poolDisks, this.model.get('diskNames'));
- } else if (choice == 'raid') {
- this.newRaidLevel = this.model.get('raidLevel');
- this.newDisks = _.union(poolDisks, this.model.get('diskNames'));
- }
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
- this.initHandlebarHelpers();
- },
+ initialize: function() {
+ this.template = window.JST.pool_resize_summary;
+ var choice = this.model.get('choice');
+ var raidLevel = null;
+ var poolDisks = _.map(this.model.get('pool').get('disks'), function(disk) {
+ return disk.name;
+ });
+ if (choice == 'add') {
+ this.newRaidLevel = this.model.get('raidChange') ? this.model.get('raidLevel') :
+ this.model.get('pool').get('raid');
+ this.newDisks = _.union(poolDisks, this.model.get('diskNames'));
+ } else if (choice == 'remove') {
+ this.newRaidLevel = this.model.get('pool').get('raid');
+ this.newDisks = _.difference(poolDisks, this.model.get('diskNames'));
+ } else if (choice == 'raid') {
+ this.newRaidLevel = this.model.get('raidLevel');
+ this.newDisks = _.union(poolDisks, this.model.get('diskNames'));
+ }
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.initHandlebarHelpers();
+ },
- render: function() {
- $(this.el).html(this.template({
- model: this.model,
- poolName: this.model.get('pool').get('name'),
- raidLevel: this.model.get('pool').get('raid'),
- newRaidLevel: this.newRaidLevel,
- newDisks: this.newDisks
- }));
- return this;
- },
+ render: function() {
+ $(this.el).html(this.template({
+ model: this.model,
+ poolName: this.model.get('pool').get('name'),
+ raidLevel: this.model.get('pool').get('raid'),
+ newRaidLevel: this.newRaidLevel,
+ newDisks: this.newDisks
+ }));
+ return this;
+ },
- save: function() {
- var _this = this;
- document.getElementById('next-page').disabled = true;
- var choice = this.model.get('choice');
- var raidLevel = null;
- if (choice == 'add') {
- raidLevel = this.model.get('raidChange') ? this.model.get('raidLevel') :
- this.model.get('pool').get('raid');
- return $.ajax({
- url: '/api/pools/' + this.model.get('pool').get('name')+'/add',
- type: 'PUT',
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({
- 'disks': this.model.get('diskNames'),
- 'raid_level': raidLevel
- }),
- success: function() {
- document.getElementById('next-page').disabled = false;
- },
- error: function(request, status, error) {
- }
- });
- } else if (choice == 'remove') {
- return $.ajax({
- url: '/api/pools/' + this.model.get('pool').get('name')+'/remove',
- type: 'PUT',
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({
- 'disks': this.model.get('diskNames'),
- 'raid_level': this.model.get('pool').get('raid')
- }),
- success: function() {
- document.getElementById('next-page').disabled = false;
- },
- error: function(request, status, error) {
- }
- });
- } else if (choice == 'raid') {
- return $.ajax({
- url: '/api/pools/' + this.model.get('pool').get('name')+'/add',
- type: 'PUT',
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({
- 'disks': this.model.get('diskNames'),
- 'raid_level': this.model.get('raidLevel')
- }),
- success: function() {
- document.getElementById('next-page').disabled = false;
- },
- error: function(request, status, error) {
- }
- });
- }
- },
+ save: function() {
+ var _this = this;
+ document.getElementById('next-page').disabled = true;
+ var choice = this.model.get('choice');
+ var raidLevel = null;
+ if (choice == 'add') {
+ raidLevel = this.model.get('raidChange') ? this.model.get('raidLevel') :
+ this.model.get('pool').get('raid');
+ return $.ajax({
+ url: '/api/pools/' + this.model.get('pool').get('name') + '/add',
+ type: 'PUT',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ 'disks': this.model.get('diskNames'),
+ 'raid_level': raidLevel
+ }),
+ success: function() {
+ document.getElementById('next-page').disabled = false;
+ },
+ error: function(request, status, error) {}
+ });
+ } else if (choice == 'remove') {
+ return $.ajax({
+ url: '/api/pools/' + this.model.get('pool').get('name') + '/remove',
+ type: 'PUT',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ 'disks': this.model.get('diskNames'),
+ 'raid_level': this.model.get('pool').get('raid')
+ }),
+ success: function() {
+ document.getElementById('next-page').disabled = false;
+ },
+ error: function(request, status, error) {}
+ });
+ } else if (choice == 'raid') {
+ return $.ajax({
+ url: '/api/pools/' + this.model.get('pool').get('name') + '/add',
+ type: 'PUT',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ 'disks': this.model.get('diskNames'),
+ 'raid_level': this.model.get('raidLevel')
+ }),
+ success: function() {
+ document.getElementById('next-page').disabled = false;
+ },
+ error: function(request, status, error) {}
+ });
+ }
+ },
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_diskSet', function(){
- var html = '';
- html += _.map(this.model.get('pool').get('disks'), function(disk) { return disk.name; }).join(',');
- return new Handlebars.SafeString(html);
- });
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_diskSet', function() {
+ var html = '';
+ html += _.map(this.model.get('pool').get('disks'), function(disk) {
+ return disk.name;
+ }).join(',');
+ return new Handlebars.SafeString(html);
+ });
- Handlebars.registerHelper('display_breadCrumbs', function(){
- var html = '';
- if (this.model.get('choice') == 'add') {
- html += 'Change RAID level?
Select disks to add
';
- } else if (this.model.get('choice') == 'remove') {
- html += 'Select disks to remove
';
- } else if (this.model.get('choice') == 'raid') {
- html += 'Select RAID level and add disks
';
- }
- return new Handlebars.SafeString(html);
- });
+ Handlebars.registerHelper('display_breadCrumbs', function() {
+ var html = '';
+ if (this.model.get('choice') == 'add') {
+ html += 'Change RAID level?
Select disks to add
';
+ } else if (this.model.get('choice') == 'remove') {
+ html += 'Select disks to remove
';
+ } else if (this.model.get('choice') == 'raid') {
+ html += 'Select RAID level and add disks
';
+ }
+ return new Handlebars.SafeString(html);
+ });
- }
-});
+ }
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool_details_layout_view.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool_details_layout_view.js
index 1d2fe6b8d..ff367339d 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool_details_layout_view.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool_details_layout_view.js
@@ -34,13 +34,19 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
this.template = window.JST.pool_pool_details_layout;
this.resize_pool_info_template = window.JST.pool_resize_pool_info;
this.compression_info_template = window.JST.pool_compression_info;
- this.pool = new Pool({poolName: this.poolName});
+ this.pool = new Pool({
+ poolName: this.poolName
+ });
// create poolscrub models
- this.poolscrubs = new PoolscrubCollection([],{snapType: 'admin'});
+ this.poolscrubs = new PoolscrubCollection([], {
+ snapType: 'admin'
+ });
this.poolscrubs.pageSize = 5;
this.poolscrubs.setUrl(this.poolName);
// create pool re-balance models
- this.poolrebalances = new PoolRebalanceCollection([],{snapType: 'admin'});
+ this.poolrebalances = new PoolRebalanceCollection([], {
+ snapType: 'admin'
+ });
this.poolrebalances.pageSize = 5;
this.poolrebalances.setUrl(this.poolName);
@@ -50,17 +56,23 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
this.disks = new DiskCollection();
this.disks.pageSize = RockStorGlobals.maxPageSize;
this.dependencies.push(this.disks);
- this.cOpts = {'no': 'Dont enable compression', 'zlib': 'zlib', 'lzo': 'lzo'};
+ this.cOpts = {
+ 'no': 'Dont enable compression',
+ 'zlib': 'zlib',
+ 'lzo': 'lzo'
+ };
this.initHandlebarHelpers();
- this.poolShares = new PoolShareCollection([], {poolName: this.poolName});
+ this.poolShares = new PoolShareCollection([], {
+ poolName: this.poolName
+ });
},
events: {
'click #delete-pool': 'deletePool',
- "click #js-confirm-pool-delete": "confirmPoolDelete",
- "click #js-resize-pool": "resizePool",
- "click #js-submit-resize": "resizePoolSubmit",
- "click #js-resize-cancel": "resizePoolCancel",
+ 'click #js-confirm-pool-delete': 'confirmPoolDelete',
+ 'click #js-resize-pool': 'resizePool',
+ 'click #js-submit-resize': 'resizePoolSubmit',
+ 'click #js-resize-cancel': 'resizePoolCancel',
},
render: function() {
@@ -80,10 +92,22 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
isPoolRoleRoot: poolRoleIsRoot,
}));
- this.subviews['pool-info'] = new PoolInfoModule({ model: this.pool.toJSON() });
- this.subviews['pool-usage'] = new PoolUsageModule({ model: this.pool });
- this.subviews['pool-scrubs'] = new PoolScrubTableModule({poolscrubs: this.poolscrubs, pool: this.pool, parentView: this });
- this.subviews['pool-rebalances'] = new PoolRebalanceTableModule({poolrebalances: this.poolrebalances, pool: this.pool, parentView: this });
+ this.subviews['pool-info'] = new PoolInfoModule({
+ model: this.pool.toJSON()
+ });
+ this.subviews['pool-usage'] = new PoolUsageModule({
+ model: this.pool
+ });
+ this.subviews['pool-scrubs'] = new PoolScrubTableModule({
+ poolscrubs: this.poolscrubs,
+ pool: this.pool,
+ parentView: this
+ });
+ this.subviews['pool-rebalances'] = new PoolRebalanceTableModule({
+ poolrebalances: this.poolrebalances,
+ pool: this.pool,
+ parentView: this
+ });
this.pool.on('change', this.subviews['pool-info'].render, this.subviews['pool-info']);
this.pool.on('change', this.subviews['pool-usage'].render, this.subviews['pool-usage']);
this.poolscrubs.on('change', this.subviews['pool-scrubs'].render, this.subviews['pool-scrubs']);
@@ -99,64 +123,75 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
}));
this.$('#ph-resize-pool-info').html(
- this.resize_pool_info_template({
- pool: this.pool.toJSON()
- })
+ this.resize_pool_info_template({
+ pool: this.pool.toJSON()
+ })
);
- this.$("ul.nav.nav-tabs").tabs("div.css-panes > div");
+ this.$('ul.nav.nav-tabs').tabs('div.css-panes > div');
if (!_.isUndefined(this.cView) && this.cView == 'resize') {
// scroll to resize section
$('#content').scrollTop($('#ph-resize-pool-info').offset().top);
}
//$('#pool-resize-raid-modal').modal({show: false});
- $('#pool-resize-raid-overlay').overlay({load: false});
+ $('#pool-resize-raid-overlay').overlay({
+ load: false
+ });
//Bootstrap Inline Edit
$.fn.editable.defaults.mode = 'inline';
var compr = this.pool.get('compression');
var poolName = this.pool.get('poolName');
var mntOptn = this.pool.get('mnt_options');
- var url = "/api/pools/" + poolName + "/remount";
+ var url = '/api/pools/' + poolName + '/remount';
$('#comprOptn').editable({
value: compr,
- source: [{value: 'no', text: 'no'},
- {value: 'zlib', text: 'zlib'},
- {value: 'lzo', text: 'lzo'}
- ],
- success: function(response, newCompr){
- $.ajax({
- url: url,
- type: "PUT",
- dataType: "json",
- data: {
- "compression": newCompr,
- "mnt_options": mntOptn
- },
- });
- }
+ source: [{
+ value: 'no',
+ text: 'no'
+ },
+ {
+ value: 'zlib',
+ text: 'zlib'
+ },
+ {
+ value: 'lzo',
+ text: 'lzo'
+ }
+ ],
+ success: function(response, newCompr) {
+ $.ajax({
+ url: url,
+ type: 'PUT',
+ dataType: 'json',
+ data: {
+ 'compression': newCompr,
+ 'mnt_options': mntOptn
+ },
+ });
+ }
});
$('#mntOptions').editable({
title: 'Edit Mount Options',
emptytext: 'None',
- success: function(response, newMntOptns){
+ success: function(response, newMntOptns) {
$.ajax({
url: url,
- type: "PUT",
- dataType: "json",
+ type: 'PUT',
+ dataType: 'json',
data: {
- "compression": compr,
- "mnt_options": newMntOptns
+ 'compression': compr,
+ 'mnt_options': newMntOptns
},
});
}
});
- $("#comp-mnt-optns-table").tooltip({
+ $('#comp-mnt-optns-table').tooltip({
selector: '[data-title]',
html: true,
- placement:'right'
+ placement: 'right'
});
},
@@ -174,16 +209,18 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
if (buttonDisabled(button)) return false;
disableButton(button);
- var url = "/api/pools/" + this.poolName + "/force";
+ var url = '/api/pools/' + this.poolName + '/force';
$.ajax({
url: url,
- type: "DELETE",
- dataType: "json",
+ type: 'DELETE',
+ dataType: 'json',
success: function() {
enableButton(button);
_this.$('#delete-pool-modal').modal('hide');
$('.modal-backdrop').remove();
- app_router.navigate('pools', {trigger: true})
+ app_router.navigate('pools', {
+ trigger: true
+ });
},
error: function(xhr, status, error) {
enableButton(button);
@@ -194,7 +231,9 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
resizePool: function(event) {
event.preventDefault();
var wizardView = new PoolResizeWizardView({
- model: new Backbone.Model({ pool: this.pool }),
+ model: new Backbone.Model({
+ pool: this.pool
+ }),
title: 'Resize Pool / Change RAID level for ' + this.pool.get('name'),
parent: this
});
@@ -206,29 +245,32 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
event.preventDefault();
var button = this.$('#js-submit-resize');
if (buttonDisabled(button)) return false;
- if(confirm(" Are you sure about Resizing this pool?")){
+ if (confirm(' Are you sure about Resizing this pool?')) {
disableButton(button);
var _this = this;
var raid_level = $('#raid_level').val();
var disk_names = [];
- var err_msg = "Please select atleast one disk";
- var n = _this.$(".disknew:checked").length;
- var m = _this.$(".diskadded:unchecked").length;
+ var err_msg = 'Please select atleast one disk';
+ var n = _this.$('.disknew:checked').length;
+ var m = _this.$('.diskadded:unchecked').length;
var resize_msg = ('Resize is initiated. A balance process is kicked off to redistribute data. It could take a while. You can check the status in the Balances tab. Its finish marks the success of resize.');
- if(n >= 0){
+ if (n >= 0) {
$('#pool-resize-raid-modal').modal('show');
- } else if(m > 0) {
- _this.$(".diskadded:unchecked").each(function(i) {
+ } else if (m > 0) {
+ _this.$('.diskadded:unchecked').each(function(i) {
if (i < m) {
disk_names.push($(this).val());
}
});
$.ajax({
- url: '/api/pools/'+_this.pool.get('name')+'/remove',
+ url: '/api/pools/' + _this.pool.get('name') + '/remove',
type: 'PUT',
dataType: 'json',
contentType: 'application/json',
- data: JSON.stringify({"disks": disk_names, "raid_level": raid_level}),
+ data: JSON.stringify({
+ 'disks': disk_names,
+ 'raid_level': raid_level
+ }),
success: function() {
_this.hideResizeTooltips();
alert(resize_msg);
@@ -251,28 +293,33 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
resizePoolCancel: function(event) {
event.preventDefault();
this.hideResizeTooltips();
- this.$('#ph-resize-pool-info').html(this.resize_pool_info_template({pool: this.pool}));
+ this.$('#ph-resize-pool-info').html(this.resize_pool_info_template({
+ pool: this.pool
+ }));
},
resizePoolModalSubmit: function(event) {
var _this = this;
var raid_level = $('#raid_level').val();
var disk_names = [];
- var err_msg = "Please select atleast one disk";
- var n = _this.$(".disknew:checked").length;
- var m = _this.$(".diskadded:unchecked").length;
+ var err_msg = 'Please select atleast one disk';
+ var n = _this.$('.disknew:checked').length;
+ var m = _this.$('.diskadded:unchecked').length;
var resize_msg = ('Resize is initiated. A balance process is kicked off to redistribute data. It could take a while. You can check the status in the Balances tab. Its finish marks the success of resize.');
- _this.$(".disknew:checked").each(function(i) {
+ _this.$('.disknew:checked').each(function(i) {
if (i < n) {
disk_names.push($(this).val());
}
});
$.ajax({
- url: '/api/pools/'+_this.pool.get('name')+'/add',
+ url: '/api/pools/' + _this.pool.get('name') + '/add',
type: 'PUT',
dataType: 'json',
contentType: 'application/json',
- data: JSON.stringify({"disks": disk_names, "raid_level": raid_level}),
+ data: JSON.stringify({
+ 'disks': disk_names,
+ 'raid_level': raid_level
+ }),
success: function() {
_this.hideResizeTooltips();
alert(resize_msg);
@@ -294,7 +341,7 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
this.$('#ph-resize-pool-info #raid_level').tooltip({
html: true,
placement: 'top',
- title: "You can transition raid level of this pool to change it's redundancy profile.",
+ title: 'You can transition raid level of this pool to change it\'s redundancy profile.',
});
},
@@ -312,13 +359,13 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
}
},
- initHandlebarHelpers: function(){
+ initHandlebarHelpers: function() {
- Handlebars.registerHelper('getPoolCreationDate', function(date){
+ Handlebars.registerHelper('getPoolCreationDate', function(date) {
return moment(date).format(RS_DATE_FORMAT);
});
- Handlebars.registerHelper('humanReadableSize', function(size){
+ Handlebars.registerHelper('humanReadableSize', function(size) {
return humanize.filesize(size * 1024);
});
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool_info_module.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool_info_module.js
index 3bc453d5f..af137bb0f 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool_info_module.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool_info_module.js
@@ -25,12 +25,10 @@
*/
PoolInfoModule = RockstorModuleView.extend({
-
- initialize: function() {
- this.template = window.JST.pool_pool_info_module;
- this.module_name = 'pool-info';
- },
-
-});
+ initialize: function() {
+ this.template = window.JST.pool_pool_info_module;
+ this.module_name = 'pool-info';
+ },
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool_rebalance_table.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool_rebalance_table.js
index ed443dcc6..63baf29a8 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool_rebalance_table.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool_rebalance_table.js
@@ -24,116 +24,114 @@
*
*/
-PoolRebalanceTableModule = RockstorModuleView.extend({
- events: {
- "click #js-poolrebalance-start": "start",
- "click #js-poolrebalance-cancel": "cancel"
- },
+PoolRebalanceTableModule = RockstorModuleView.extend({
+ events: {
+ 'click #js-poolrebalance-start': 'start',
+ 'click #js-poolrebalance-cancel': 'cancel'
+ },
- initialize: function() {
- this.template = window.JST.pool_poolrebalance_table_template;
- this.startRebalanceTemplate = window.JST.pool_poolrebalance_start_template;
- this.module_name = 'poolrebalances';
- this.pool = this.options.pool;
- this.poolrebalances = this.options.poolrebalances;
- this.collection = this.options.poolrebalances;
- this.collection.on("reset", this.render, this);
- this.parentView = this.options.parentView;
- this.initHandlebarHelpers();
- },
+ initialize: function() {
+ this.template = window.JST.pool_poolrebalance_table_template;
+ this.startRebalanceTemplate = window.JST.pool_poolrebalance_start_template;
+ this.module_name = 'poolrebalances';
+ this.pool = this.options.pool;
+ this.poolrebalances = this.options.poolrebalances;
+ this.collection = this.options.poolrebalances;
+ this.collection.on('reset', this.render, this);
+ this.parentView = this.options.parentView;
+ this.initHandlebarHelpers();
+ },
- render: function() {
- var _this = this;
- $(this.el).empty();
- $(this.el).append(this.template({
- collection: this.collection,
- collectionNotEmpty: !this.collection.isEmpty(),
- pool: this.pool,
- }));
- this.$('[rel=tooltip]').tooltip({
- placement: 'bottom'
- });
- return this;
- },
+ render: function() {
+ var _this = this;
+ $(this.el).empty();
+ $(this.el).append(this.template({
+ collection: this.collection,
+ collectionNotEmpty: !this.collection.isEmpty(),
+ pool: this.pool,
+ }));
+ this.$('[rel=tooltip]').tooltip({
+ placement: 'bottom'
+ });
+ return this;
+ },
- setPoolName: function(poolName) {
- this.collection.setUrl(poolName);
- },
+ setPoolName: function(poolName) {
+ this.collection.setUrl(poolName);
+ },
- start: function(event) {
- var _this = this;
- event.preventDefault();
- $(this.el).html(this.startRebalanceTemplate({
- pool: this.pool,
- }));
+ start: function(event) {
+ var _this = this;
+ event.preventDefault();
+ $(this.el).html(this.startRebalanceTemplate({
+ pool: this.pool,
+ }));
- this.validator = this.$('#pool-rebalance-form').validate({
- onfocusout: false,
- onkeyup: false,
- rules: {
- },
- submitHandler: function() {
- var button = _this.$('#start_rebalance');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- var n = _this.$("#forcebalance:checked").val();
- var postdata = '';
- if(n == 'on') {
- postdata = '{"force": "true"}';
- }
- $.ajax({
- url: '/api/pools/'+_this.pool.get('name')+'/balance',
- type: 'POST',
- data: postdata,
- success: function() {
- _this.$('#pool-rebalance-form :input').tooltip('hide');
- enableButton(button);
- _this.collection.fetch({
- success: function(collection, response, options) {
- }
- });
- },
- error: function(jqXHR) {
- _this.$('#pool-rebalance-form :input').tooltip('hide');
- enableButton(button);
- }
- });
- return false;
- }
- });
- },
+ this.validator = this.$('#pool-rebalance-form').validate({
+ onfocusout: false,
+ onkeyup: false,
+ rules: {},
+ submitHandler: function() {
+ var button = _this.$('#start_rebalance');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ var n = _this.$('#forcebalance:checked').val();
+ var postdata = '';
+ if (n == 'on') {
+ postdata = '{"force": "true"}';
+ }
+ $.ajax({
+ url: '/api/pools/' + _this.pool.get('name') + '/balance',
+ type: 'POST',
+ data: postdata,
+ success: function() {
+ _this.$('#pool-rebalance-form :input').tooltip('hide');
+ enableButton(button);
+ _this.collection.fetch({
+ success: function(collection, response, options) {}
+ });
+ },
+ error: function(jqXHR) {
+ _this.$('#pool-rebalance-form :input').tooltip('hide');
+ enableButton(button);
+ }
+ });
+ return false;
+ }
+ });
+ },
- cancel: function(event) {
- event.preventDefault();
- this.render();
- },
+ cancel: function(event) {
+ event.preventDefault();
+ this.render();
+ },
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_poolRebalance_table', function(){
- var html = '';
- this.collection.each(function(poolrebalance, index) {
- html += '';
- html += '' + poolrebalance.get('id') + ' ';
- html += '' + poolrebalance.get('status') + ' ';
- html += '';
- if (poolrebalance.get('start_time')) {
- html += moment(poolrebalance.get('start_time')).format(RS_DATE_FORMAT);
- }
- html += ' ';
- html += '' + poolrebalance.get('percent_done') + ' ';
- html += ''
- if(poolrebalance.get('message') != null){
- html += poolrebalance.get('message');
- }
- html += ' '
- html += ' ';
- });
- return new Handlebars.SafeString(html);
- });
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_poolRebalance_table', function() {
+ var html = '';
+ this.collection.each(function(poolrebalance, index) {
+ html += '';
+ html += '' + poolrebalance.get('id') + ' ';
+ html += '' + poolrebalance.get('status') + ' ';
+ html += '';
+ if (poolrebalance.get('start_time')) {
+ html += moment(poolrebalance.get('start_time')).format(RS_DATE_FORMAT);
+ }
+ html += ' ';
+ html += '' + poolrebalance.get('percent_done') + ' ';
+ html += '';
+ if (poolrebalance.get('message') != null) {
+ html += poolrebalance.get('message');
+ }
+ html += ' ';
+ html += ' ';
+ });
+ return new Handlebars.SafeString(html);
+ });
- }
+ }
});
//Add pagination
-Cocktail.mixin(PoolRebalanceTableModule, PaginationMixin);
+Cocktail.mixin(PoolRebalanceTableModule, PaginationMixin);
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool_scrub_table.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool_scrub_table.js
index 8ef506dc1..38419f382 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool_scrub_table.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool_scrub_table.js
@@ -24,116 +24,114 @@
*
*/
-PoolScrubTableModule = RockstorModuleView.extend({
- events: {
- "click #js-poolscrub-start": "start",
- "click #js-poolscrub-cancel": "cancel"
- },
+PoolScrubTableModule = RockstorModuleView.extend({
+ events: {
+ 'click #js-poolscrub-start': 'start',
+ 'click #js-poolscrub-cancel': 'cancel'
+ },
- initialize: function() {
- this.template = window.JST.pool_poolscrub_table_template;
- this.startScrubTemplate = window.JST.pool_poolscrub_start_template;
- this.module_name = 'poolscrubs';
- this.pool = this.options.pool;
- this.poolscrubs = this.options.poolscrubs;
- this.collection = this.options.poolscrubs;
- this.collection.on("reset", this.render, this);
- this.parentView = this.options.parentView;
- this.initHandlebarHelpers();
- },
+ initialize: function() {
+ this.template = window.JST.pool_poolscrub_table_template;
+ this.startScrubTemplate = window.JST.pool_poolscrub_start_template;
+ this.module_name = 'poolscrubs';
+ this.pool = this.options.pool;
+ this.poolscrubs = this.options.poolscrubs;
+ this.collection = this.options.poolscrubs;
+ this.collection.on('reset', this.render, this);
+ this.parentView = this.options.parentView;
+ this.initHandlebarHelpers();
+ },
- render: function() {
- var _this = this;
- $(this.el).empty();
- $(this.el).append(this.template({
- collection: this.collection,
- collectionNotEmpty: !this.collection.isEmpty(),
- pool: this.pool,
- }));
- this.$('[rel=tooltip]').tooltip({
- placement: 'bottom'
- });
- return this;
- },
+ render: function() {
+ var _this = this;
+ $(this.el).empty();
+ $(this.el).append(this.template({
+ collection: this.collection,
+ collectionNotEmpty: !this.collection.isEmpty(),
+ pool: this.pool,
+ }));
+ this.$('[rel=tooltip]').tooltip({
+ placement: 'bottom'
+ });
+ return this;
+ },
- setPoolName: function(poolName) {
- this.collection.setUrl(poolName);
- },
+ setPoolName: function(poolName) {
+ this.collection.setUrl(poolName);
+ },
- start: function(event) {
- var _this = this;
- event.preventDefault();
- $(this.el).html(this.startScrubTemplate({
- pool: this.pool,
- }));
+ start: function(event) {
+ var _this = this;
+ event.preventDefault();
+ $(this.el).html(this.startScrubTemplate({
+ pool: this.pool,
+ }));
- this.validator = this.$('#pool-scrub-form').validate({
- onfocusout: false,
- onkeyup: false,
- rules: {
- },
- submitHandler: function() {
- var button = _this.$('#start_scrub');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- var n = _this.$("#forcescrub:checked").val();
- var postdata = '';
- if(n == 'on') {
- postdata = '{"force": "true"}';
- }
- $.ajax({
- url: '/api/pools/'+_this.pool.get('name')+'/scrub',
- type: 'POST',
- data: postdata,
- success: function() {
- _this.$('#pool-scrub-form :input').tooltip('hide');
- enableButton(button);
- _this.collection.fetch({
- success: function(collection, response, options) {
- }
- });
- },
- error: function(jqXHR) {
- _this.$('#pool-scrub-form :input').tooltip('hide');
- enableButton(button);
- }
- });
- return false;
- }
- });
- },
+ this.validator = this.$('#pool-scrub-form').validate({
+ onfocusout: false,
+ onkeyup: false,
+ rules: {},
+ submitHandler: function() {
+ var button = _this.$('#start_scrub');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ var n = _this.$('#forcescrub:checked').val();
+ var postdata = '';
+ if (n == 'on') {
+ postdata = '{"force": "true"}';
+ }
+ $.ajax({
+ url: '/api/pools/' + _this.pool.get('name') + '/scrub',
+ type: 'POST',
+ data: postdata,
+ success: function() {
+ _this.$('#pool-scrub-form :input').tooltip('hide');
+ enableButton(button);
+ _this.collection.fetch({
+ success: function(collection, response, options) {}
+ });
+ },
+ error: function(jqXHR) {
+ _this.$('#pool-scrub-form :input').tooltip('hide');
+ enableButton(button);
+ }
+ });
+ return false;
+ }
+ });
+ },
- cancel: function(event) {
- event.preventDefault();
- this.render();
- },
+ cancel: function(event) {
+ event.preventDefault();
+ this.render();
+ },
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_poolScrub_table', function(){
- var html = '';
- this.collection.each(function(poolscrub, index) {
- html += '';
- html += '' + poolscrub.get('id') + ' ';
- html += '' + poolscrub.get('status') + ' ';
- html += '';
- if (poolscrub.get('start_time')) {
- html += moment(poolscrub.get('start_time')).format(RS_DATE_FORMAT);
- }
- html += ' ';
- html += '';
- if (poolscrub.get('end_time')) {
- html += moment(poolscrub.get('end_time')).format(RS_DATE_FORMAT);
- }
- html += ' ';
- html += '' + humanize.filesize(poolscrub.get('kb_scrubbed')*1024) + ' ';
- html += ' ';
- });
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_poolScrub_table', function() {
+ var html = '';
+ this.collection.each(function(poolscrub, index) {
+ html += '';
+ html += '' + poolscrub.get('id') + ' ';
+ html += '' + poolscrub.get('status') + ' ';
+ html += '';
+ if (poolscrub.get('start_time')) {
+ html += moment(poolscrub.get('start_time')).format(RS_DATE_FORMAT);
+ }
+ html += ' ';
+ html += '';
+ if (poolscrub.get('end_time')) {
+ html += moment(poolscrub.get('end_time')).format(RS_DATE_FORMAT);
+ }
+ html += ' ';
+ html += '' + humanize.filesize(poolscrub.get('kb_scrubbed') * 1024) + ' ';
+ html += ' ';
+ });
- return new Handlebars.SafeString(html);
- });
- }
+ return new Handlebars.SafeString(html);
+ });
+ }
});
//Add pagination
-Cocktail.mixin(PoolScrubTableModule, PaginationMixin);
+Cocktail.mixin(PoolScrubTableModule, PaginationMixin);
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pool_usage_module.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pool_usage_module.js
index 7c30f9589..7000d942a 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pool_usage_module.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pool_usage_module.js
@@ -25,44 +25,41 @@
*/
PoolUsageModule = RockstorModuleView.extend({
- initialize: function() {
- this.template = window.JST.pool_pool_usage_module;
- this.module_name = 'pool-usage';
- },
+ initialize: function() {
+ this.template = window.JST.pool_pool_usage_module;
+ this.module_name = 'pool-usage';
+ },
- render: function() {
- $(this.el).html(this.template({
- module_name: this.module_name,
- model: this.model,
- collection: this.collection
- }));
- this.renderGraph();
- return this;
- },
-
- renderGraph: function() {
- // Pie chart
- var w = 350; //width
- var h = 130; //height
- var outerRadius = 50;
- var innerRadius = 0;
-
- total = parseInt(this.model.get('size')*1024);
- used = parseInt((this.model.get('size') - this.model.get('reclaimable') - this.model.get('free'))*1024);
- free = this.model.get('free')*1024;
+ render: function() {
+ $(this.el).html(this.template({
+ module_name: this.module_name,
+ model: this.model,
+ collection: this.collection
+ }));
+ this.renderGraph();
+ return this;
+ },
- var dataset = [free, used]
- var dataLabels = ['free', 'used']
+ renderGraph: function() {
+ // Pie chart
+ var w = 350; //width
+ var h = 130; //height
+ var outerRadius = 50;
+ var innerRadius = 0;
- var svg = d3.select(this.el).select("#chart")
- .append("svg")
- .attr("width", w)
- .attr("height", h);
-
- displayUsagePieChart(svg, outerRadius, innerRadius, w, h, dataset, dataLabels);
+ total = parseInt(this.model.get('size') * 1024);
+ used = parseInt((this.model.get('size') - this.model.get('reclaimable') - this.model.get('free')) * 1024);
+ free = this.model.get('free') * 1024;
- }
-});
+ var dataset = [free, used];
+ var dataLabels = ['free', 'used'];
+ var svg = d3.select(this.el).select('#chart')
+ .append('svg')
+ .attr('width', w)
+ .attr('height', h);
+ displayUsagePieChart(svg, outerRadius, innerRadius, w, h, dataset, dataLabels);
+ }
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/pools.js b/src/rockstor/storageadmin/static/storageadmin/js/views/pools.js
index 1a74f19e5..3dae0f427 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/pools.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/pools.js
@@ -219,3 +219,4 @@ PoolsView = RockstorLayoutView.extend({
});
}
});
+
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/reboot.js b/src/rockstor/storageadmin/static/storageadmin/js/views/reboot.js
index dab4e74f8..5281e5c60 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/reboot.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/reboot.js
@@ -26,116 +26,116 @@
RebootView = RockstorLayoutView.extend({
- initialize: function() {
- // call initialize of base
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.common_navbar;
- this.paginationTemplate = window.JST.common_pagination;
- this.timeLeft = 300;
- this.isStopped=false;
+ initialize: function() {
+ // call initialize of base
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.common_navbar;
+ this.paginationTemplate = window.JST.common_pagination;
+ this.timeLeft = 300;
+ this.isStopped = false;
},
- render: function() {
- var _this = this;
-
- $('#reboot-modal').modal({
- keyboard: false,
- backdrop: 'static',
- show: false
- });
-
- if (confirm('Are you sure you want to Reboot the system? All network access will be lost temporarily. Click OK to continue or Cancel to go back.')) {
- $('#reboot-modal').modal('show');
- this.startForceRefreshTimer();
-
- $.ajax({
- url: "/api/commands/reboot",
- type: "POST",
- dataType: "json",
- global: false, // dont show global loading indicator
- success: function(data, status, xhr) {
- _this.checkIfUp();
- },
- error: function(xhr, status, error) {
- _this.checkIfUp();
-
- }
- });
- }else{
- location.reload(history.go(-1));
- }
- return this;
- },
-
- checkIfUp: function() {
- var _this = this;
- this.isUpTimer = window.setInterval(function() {
- $.ajax({
- url: "/api/sm/sprobes/loadavg?limit=1&format=json",
- type: "GET",
- dataType: "json",
- global: false, // dont show global loading indicator
- success: function(data, status, xhr) {
- if(_this.isStopped){
- _this.displayUserMsg2();
+ render: function() {
+ var _this = this;
+
+ $('#reboot-modal').modal({
+ keyboard: false,
+ backdrop: 'static',
+ show: false
+ });
+
+ if (confirm('Are you sure you want to Reboot the system? All network access will be lost temporarily. Click OK to continue or Cancel to go back.')) {
+ $('#reboot-modal').modal('show');
+ this.startForceRefreshTimer();
+
+ $.ajax({
+ url: '/api/commands/reboot',
+ type: 'POST',
+ dataType: 'json',
+ global: false, // dont show global loading indicator
+ success: function(data, status, xhr) {
+ _this.checkIfUp();
+ },
+ error: function(xhr, status, error) {
+ _this.checkIfUp();
+
+ }
+ });
+ } else {
location.reload(history.go(-1));
- }
+ }
+ return this;
+ },
+
+ checkIfUp: function() {
+ var _this = this;
+ this.isUpTimer = window.setInterval(function() {
+ $.ajax({
+ url: '/api/sm/sprobes/loadavg?limit=1&format=json',
+ type: 'GET',
+ dataType: 'json',
+ global: false, // dont show global loading indicator
+ success: function(data, status, xhr) {
+ if (_this.isStopped) {
+ _this.displayUserMsg2();
+ location.reload(history.go(-1));
+ }
+
+ },
+ error: function(xhr, status, error) {
+ _this.isStopped = true;
+ }
+ });
+ }, 5000);
+ },
+
+
+
+ // countdown timeLeft seconds and then force a window reload
+ startForceRefreshTimer: function() {
+ var _this = this;
+ this.forceRefreshTimer = window.setInterval(function() {
+ _this.timeLeft = _this.timeLeft - 1;
+ _this.showTimeRemaining();
+ if (_this.timeLeft <= 0) {
+ _this.reloadWindow();
+
+ }
+ }, 1000);
+ },
- },
- error: function(xhr, status, error) {
- _this.isStopped=true;
+ showTimeRemaining: function() {
+ mins = Math.floor(this.timeLeft / 60);
+ sec = this.timeLeft - (mins * 60);
+ sec = sec >= 10 ? '' + sec : '0' + sec;
+ $('#reboot-time-left').html(mins + ':' + sec);
+ if (mins <= 1 && !this.userMsgDisplayed) {
+ this.displayUserMsg();
+ this.userMsgDisplayed = true;
}
- });
- }, 5000);
- },
-
-
-
- // countdown timeLeft seconds and then force a window reload
- startForceRefreshTimer: function() {
- var _this = this;
- this.forceRefreshTimer = window.setInterval(function() {
- _this.timeLeft = _this.timeLeft - 1;
- _this.showTimeRemaining();
- if (_this.timeLeft <= 0) {
- _this.reloadWindow();
-
- }
- }, 1000);
- },
-
- showTimeRemaining: function() {
- mins = Math.floor(this.timeLeft/60);
- sec = this.timeLeft - (mins*60);
- sec = sec >=10 ? '' + sec : '0' + sec
- $('#reboot-time-left').html(mins + ':' + sec)
- if (mins <= 1 && !this.userMsgDisplayed) {
- this.displayUserMsg();
- this.userMsgDisplayed = true;
+ },
+
+ reloadWindow: function() {
+ this.clearTimers();
+ $('#reboot-modal').modal('hide');
+ location.reload(history.go(-1));
+ },
+
+ clearTimers: function() {
+ window.clearInterval(this.isUpTimer);
+ window.clearInterval(this.forceRefreshTimer);
+ },
+
+ displayUserMsg: function() {
+ $('#time-left').remove();
+ $('#reboot-user-msg').show('highlight', null, 1000);
+ },
+
+ displayUserMsg2: function() {
+ $('#reboot-message').remove();
+ $('#reboot-timer').removeAttr('src');
+ $('#reboot-time-left').remove();
+ $('#reboot-user-msg2').show('highlight', null, 1000);
}
- },
-
- reloadWindow: function() {
- this.clearTimers();
- $('#reboot-modal').modal('hide');
- location.reload(history.go(-1));
- },
-
- clearTimers: function() {
- window.clearInterval(this.isUpTimer);
- window.clearInterval(this.forceRefreshTimer);
- },
-
-displayUserMsg: function() {
- $('#time-left').remove();
- $('#reboot-user-msg').show('highlight', null, 1000);
- },
-
-displayUserMsg2: function() {
- $('#reboot-message').remove();
- $('#reboot-timer').removeAttr('src');
- $('#reboot-time-left').remove();
- $('#reboot-user-msg2').show('highlight', null, 1000);
- }
-
-});
+
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/replica_receive_trails.js b/src/rockstor/storageadmin/static/storageadmin/js/views/replica_receive_trails.js
index e2237e2d4..8d0c32b92 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/replica_receive_trails.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/replica_receive_trails.js
@@ -1,4 +1,3 @@
-
/*
*
* @licstart The following is the entire license notice for the
@@ -26,84 +25,85 @@
*/
ReplicaReceiveTrailsView = RockstorLayoutView.extend({
- events: {
- },
+ events: {},
- initialize: function() {
- // call initialize of base
- this.constructor.__super__.initialize.apply(this, arguments);
- // set template
- this.template = window.JST.replication_receive_trails;
- // add dependencies
- this.replicaShareId = this.options.replicaShareId;
- this.replicaShare = new ReplicaShare({id: this.replicaShareId});
- this.dependencies.push(this.replicaShare);
- this.collection = new ReceiveTrailCollection(null, {
- replicaShareId: this.replicaShareId
- });
- this.dependencies.push(this.collection);
- this.collection.on("reset", this.renderReplicaReceiveTrails, this);
- this.initHandlebarHelpers();
- },
+ initialize: function() {
+ // call initialize of base
+ this.constructor.__super__.initialize.apply(this, arguments);
+ // set template
+ this.template = window.JST.replication_receive_trails;
+ // add dependencies
+ this.replicaShareId = this.options.replicaShareId;
+ this.replicaShare = new ReplicaShare({
+ id: this.replicaShareId
+ });
+ this.dependencies.push(this.replicaShare);
+ this.collection = new ReceiveTrailCollection(null, {
+ replicaShareId: this.replicaShareId
+ });
+ this.dependencies.push(this.collection);
+ this.collection.on('reset', this.renderReplicaReceiveTrails, this);
+ this.initHandlebarHelpers();
+ },
- render: function() {
- this.fetch(this.renderReplicaReceiveTrails, this);
- return this;
- },
+ render: function() {
+ this.fetch(this.renderReplicaReceiveTrails, this);
+ return this;
+ },
- renderReplicaReceiveTrails: function() {
- var _this = this;
- $(this.el).html(this.template({
- replicaShare: this.replicaShare.toJSON(),
- replicaReceiveColl: this.collection.toJSON(),
- collection: this.collection,
- collectionNotEmpty: !this.collection.isEmpty(),
- }));
- // remove existing tooltips
- if (this.$('[rel=tooltip]')) {
- this.$('[rel=tooltip]').tooltip('hide');
- }
-
- this.$('[rel=tooltip]').tooltip({ placement: 'bottom'});
-
- this.renderDataTables();
- },
+ renderReplicaReceiveTrails: function() {
+ var _this = this;
+ $(this.el).html(this.template({
+ replicaShare: this.replicaShare.toJSON(),
+ replicaReceiveColl: this.collection.toJSON(),
+ collection: this.collection,
+ collectionNotEmpty: !this.collection.isEmpty(),
+ }));
+ // remove existing tooltips
+ if (this.$('[rel=tooltip]')) {
+ this.$('[rel=tooltip]').tooltip('hide');
+ }
- initHandlebarHelpers: function(){
-
- Handlebars.registerHelper('getDateFormat', function(date){
- return moment(date).format(RS_DATE_FORMAT);
- });
+ this.$('[rel=tooltip]').tooltip({
+ placement: 'bottom'
+ });
- Handlebars.registerHelper('ifStatusSuccess', function(status, opts){
- if (status != 'failed'){
- return opts.fn(this);
- }
- return opts.inverse(this);
- });
+ this.renderDataTables();
+ },
- Handlebars.registerHelper('getDuration', function(endTime, startTime){
- return moment(endTime).from(moment(startTime));
- });
-
- Handlebars.registerHelper('humanReadableSize', function(size){
- return humanize.filesize(size * 1024);
- });
+ initHandlebarHelpers: function() {
- Handlebars.registerHelper('getRate', function(endTime, startTime, kbReceived){
- var d;
- if (kbReceived){
- d = moment(endTime).diff(moment(startTime))/1000;
- } else {
- d = moment().diff(moment(startTime))/1000;
- }
- return humanize.filesize((kbReceived / d).toFixed(2) * 1024);
- });
- }
+ Handlebars.registerHelper('getDateFormat', function(date) {
+ return moment(date).format(RS_DATE_FORMAT);
+ });
-});
+ Handlebars.registerHelper('ifStatusSuccess', function(status, opts) {
+ if (status != 'failed') {
+ return opts.fn(this);
+ }
+ return opts.inverse(this);
+ });
-//Add pagination
-Cocktail.mixin(ReplicaReceiveTrailsView, PaginationMixin);
+ Handlebars.registerHelper('getDuration', function(endTime, startTime) {
+ return moment(endTime).from(moment(startTime));
+ });
+
+ Handlebars.registerHelper('humanReadableSize', function(size) {
+ return humanize.filesize(size * 1024);
+ });
+ Handlebars.registerHelper('getRate', function(endTime, startTime, kbReceived) {
+ var d;
+ if (kbReceived) {
+ d = moment(endTime).diff(moment(startTime)) / 1000;
+ } else {
+ d = moment().diff(moment(startTime)) / 1000;
+ }
+ return humanize.filesize((kbReceived / d).toFixed(2) * 1024);
+ });
+ }
+});
+
+//Add pagination
+Cocktail.mixin(ReplicaReceiveTrailsView, PaginationMixin);
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/replica_trails.js b/src/rockstor/storageadmin/static/storageadmin/js/views/replica_trails.js
index 6081ccfac..c5a3c13ee 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/replica_trails.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/replica_trails.js
@@ -1,4 +1,3 @@
-
/*
*
* @licstart The following is the entire license notice for the
@@ -26,90 +25,93 @@
*/
ReplicaTrailsView = RockstorLayoutView.extend({
- events: {
- },
+ events: {},
+
+ initialize: function() {
+ // call initialize of base
+ this.constructor.__super__.initialize.apply(this, arguments);
+ // set template
+ this.template = window.JST.replication_replica_trails;
+ // add dependencies
+ this.replicaId = this.options.replicaId;
+ this.replica = new Replica({
+ id: this.replicaId
+ });
+ this.dependencies.push(this.replica);
+ this.collection = new ReplicaTrailCollection(null, {
+ replicaId: this.replicaId
+ });
+ this.collection.pageSize = 10;
+ this.dependencies.push(this.collection);
+ this.collection.on('reset', this.renderReplicaTrails, this);
+ // has the replica been fetched? prevents renderReplicaTrails executing
+ // (because of collection reset) before replica has been fetched
+ this.replicaFetched = false;
+ this.initHandlebarHelpers();
+ },
+
+ render: function() {
+ this.fetch(this.firstFetch, this);
+ return this;
+ },
- initialize: function() {
- // call initialize of base
- this.constructor.__super__.initialize.apply(this, arguments);
- // set template
- this.template = window.JST.replication_replica_trails;
- // add dependencies
- this.replicaId = this.options.replicaId;
- this.replica = new Replica({id: this.replicaId});
- this.dependencies.push(this.replica);
- this.collection = new ReplicaTrailCollection(null, {
- replicaId: this.replicaId
- });
- this.collection.pageSize = 10;
- this.dependencies.push(this.collection);
- this.collection.on("reset", this.renderReplicaTrails, this);
- // has the replica been fetched? prevents renderReplicaTrails executing
- // (because of collection reset) before replica has been fetched
- this.replicaFetched = false;
- this.initHandlebarHelpers();
- },
+ firstFetch: function() {
+ this.replicaFetched = true;
+ this.renderReplicaTrails();
+ },
- render: function() {
- this.fetch(this.firstFetch, this);
- return this;
- },
+ renderReplicaTrails: function() {
+ if (!this.replicaFetched) return false;
+ var _this = this;
+ $(this.el).html(this.template({
+ replica: _this.replica.toJSON(),
+ replicaColl: _this.collection.toJSON(),
+ collection: _this.collection,
+ collectionNotEmpty: !this.collection.isEmpty()
+ }));
+ // remove existing tooltips
+ if (this.$('[rel=tooltip]')) {
+ this.$('[rel=tooltip]').tooltip('hide');
+ }
+ this.$('[rel=tooltip]').tooltip({
+ placement: 'bottom'
+ });
+ },
- firstFetch: function() {
- this.replicaFetched = true;
- this.renderReplicaTrails();
- },
+ initHandlebarHelpers: function() {
- renderReplicaTrails: function() {
- if (!this.replicaFetched) return false;
- var _this = this;
- $(this.el).html(this.template({
- replica: _this.replica.toJSON(),
- replicaColl: _this.collection.toJSON(),
- collection: _this.collection,
- collectionNotEmpty: !this.collection.isEmpty()
- }));
- // remove existing tooltips
- if (this.$('[rel=tooltip]')) {
- this.$('[rel=tooltip]').tooltip('hide');
- }
- this.$('[rel=tooltip]').tooltip({ placement: 'bottom'});
- },
+ Handlebars.registerHelper('getDateFormat', function(date) {
+ return moment(date).format(RS_DATE_FORMAT);
+ });
- initHandlebarHelpers: function(){
-
- Handlebars.registerHelper('getDateFormat', function(date){
- return moment(date).format(RS_DATE_FORMAT);
- });
+ Handlebars.registerHelper('ifStatusSuccess', function(status, opts) {
+ if (status != 'failed') {
+ return opts.fn(this);
+ }
+ return opts.inverse(this);
+ });
- Handlebars.registerHelper('ifStatusSuccess', function(status, opts){
- if (status != 'failed'){
- return opts.fn(this);
- }
- return opts.inverse(this);
- });
+ Handlebars.registerHelper('getDuration', function(endTime, startTime) {
+ return moment(endTime).from(moment(startTime));
+ });
- Handlebars.registerHelper('getDuration', function(endTime, startTime){
- return moment(endTime).from(moment(startTime));
- });
-
- Handlebars.registerHelper('humanReadableSize', function(size){
- return humanize.filesize(size * 1024);
- });
+ Handlebars.registerHelper('humanReadableSize', function(size) {
+ return humanize.filesize(size * 1024);
+ });
- Handlebars.registerHelper('getRate', function(endTime, startTime, kbSent){
- var d;
- if (kbSent){
- d = moment(endTime).diff(moment(startTime))/1000;
- } else {
- d = moment().diff(moment(startTime))/1000;
- }
- return humanize.filesize((kbSent / d).toFixed(2) * 1024);
- });
- }
+ Handlebars.registerHelper('getRate', function(endTime, startTime, kbSent) {
+ var d;
+ if (kbSent) {
+ d = moment(endTime).diff(moment(startTime)) / 1000;
+ } else {
+ d = moment().diff(moment(startTime)) / 1000;
+ }
+ return humanize.filesize((kbSent / d).toFixed(2) * 1024);
+ });
+ }
});
//Add pagination
-Cocktail.mixin(ReplicaTrailsView, PaginationMixin);
+Cocktail.mixin(ReplicaTrailsView, PaginationMixin);
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/replication.js b/src/rockstor/storageadmin/static/storageadmin/js/views/replication.js
index 21f21a4dd..20b132bf2 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/replication.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/replication.js
@@ -25,308 +25,327 @@
*/
ReplicationView = RockstorLayoutView.extend({
- events: {
- 'click a[data-action=delete]': 'deleteTask',
- 'switchChange.bootstrapSwitch': 'switchStatus',
- },
+ events: {
+ 'click a[data-action=delete]': 'deleteTask',
+ 'switchChange.bootstrapSwitch': 'switchStatus',
+ },
- initialize: function() {
- // call initialize of base
- this.constructor.__super__.initialize.apply(this, arguments);
- // set template
- this.template = window.JST.replication_replication;
- // add dependencies
- this.collection = new ReplicaCollection();
- this.dependencies.push(this.collection);
- this.serviceName = 'replication';
- this.replicationService = new Service({name: this.serviceName});
- this.dependencies.push(this.replicationService);
- this.replicaTrails = new ReplicaTrailCollection();
- this.replicaTrails.pageSize = RockStorGlobals.maxPageSize;
- this.dependencies.push(this.replicaTrails);
- this.appliances = new ApplianceCollection();
- this.dependencies.push(this.appliances);
- this.shares = new ShareCollection();
- this.dependencies.push(this.shares);
- this.replicaShareMap = {};
- this.replicaTrailMap = {};
- this.collection.on('reset', this.renderReplicas, this);
- this.initHandlebarHelpers();
- },
+ initialize: function() {
+ // call initialize of base
+ this.constructor.__super__.initialize.apply(this, arguments);
+ // set template
+ this.template = window.JST.replication_replication;
+ // add dependencies
+ this.collection = new ReplicaCollection();
+ this.dependencies.push(this.collection);
+ this.serviceName = 'replication';
+ this.replicationService = new Service({
+ name: this.serviceName
+ });
+ this.dependencies.push(this.replicationService);
+ this.replicaTrails = new ReplicaTrailCollection();
+ this.replicaTrails.pageSize = RockStorGlobals.maxPageSize;
+ this.dependencies.push(this.replicaTrails);
+ this.appliances = new ApplianceCollection();
+ this.dependencies.push(this.appliances);
+ this.shares = new ShareCollection();
+ this.dependencies.push(this.shares);
+ this.replicaShareMap = {};
+ this.replicaTrailMap = {};
+ this.collection.on('reset', this.renderReplicas, this);
+ this.initHandlebarHelpers();
+ },
- render: function() {
- this.fetch(this.renderReplicas, this);
- RockStorSocket.services = io.connect('/services', {'secure': true, 'force new connection': true});
- RockStorSocket.addListener(this.serviceStatusSync, this, 'services:get_services');
- return this;
- },
+ render: function() {
+ this.fetch(this.renderReplicas, this);
+ RockStorSocket.services = io.connect('/services', {
+ 'secure': true,
+ 'force new connection': true
+ });
+ RockStorSocket.addListener(this.serviceStatusSync, this, 'services:get_services');
+ return this;
+ },
- renderReplicas: function() {
- var _this = this;
- this.otherAppliances = this.appliances.filter(function(appliance) {
- return appliance.get('current_appliance') == false;
- });
- this.freeShares = this.shares.reject(function(share) {
- return !_.isUndefined(_this.collection.find(function(replica) {
- return replica.get('share') == share.get('name');
- })) ;
- });
- // remove existing tooltips
- if (this.$('[rel=tooltip]')) {
- this.$('[rel=tooltip]').tooltip('hide');
- }
- var shares = this.collection.map(function(replica) {
- return replica.get('share');
- });
- _.each(shares, function(share) {
- _this.replicaShareMap[share] = _this.collection.filter(function(replica) {
- return replica.get('share') == share;
- });
- });
- this.collection.each(function(replica, index) {
- var tmp = _this.replicaTrails.filter(function(replicaTrail) {
- return replicaTrail.get('replica') == replica.id;
- });
- _this.replicaTrailMap[replica.id] = _.sortBy(tmp, function(replicaTrail) {
- return moment(replicaTrail.get('snapshot_created')).valueOf();
- }).reverse();
- });
- var noFreeShares,
- noOtherAppliances,
- otherAppliances_FreeShares = false;
+ renderReplicas: function() {
+ var _this = this;
+ this.otherAppliances = this.appliances.filter(function(appliance) {
+ return appliance.get('current_appliance') == false;
+ });
+ this.freeShares = this.shares.reject(function(share) {
+ return !_.isUndefined(_this.collection.find(function(replica) {
+ return replica.get('share') == share.get('name');
+ }));
+ });
+ // remove existing tooltips
+ if (this.$('[rel=tooltip]')) {
+ this.$('[rel=tooltip]').tooltip('hide');
+ }
+ var shares = this.collection.map(function(replica) {
+ return replica.get('share');
+ });
+ _.each(shares, function(share) {
+ _this.replicaShareMap[share] = _this.collection.filter(function(replica) {
+ return replica.get('share') == share;
+ });
+ });
+ this.collection.each(function(replica, index) {
+ var tmp = _this.replicaTrails.filter(function(replicaTrail) {
+ return replicaTrail.get('replica') == replica.id;
+ });
+ _this.replicaTrailMap[replica.id] = _.sortBy(tmp, function(replicaTrail) {
+ return moment(replicaTrail.get('snapshot_created')).valueOf();
+ }).reverse();
+ });
+ var noFreeShares,
+ noOtherAppliances,
+ otherAppliances_FreeShares = false;
- if(this.freeShares.length == 0){
- noFreeShares = true;
- }
- if(this.otherAppliances.length == 0){
- noOtherAppliances = true;
- }
- if(this.otherAppliances.length > 0 && this.freeShares.length > 0){
- otherAppliances_FreeShares = true;
- }
- $(this.el).html(this.template({
- replicationService: this.replicationService,
- replicaColl: this.collection.toJSON(),
- collection: this.collection,
- collectionNotEmpty: !this.collection.isEmpty(),
- replicaShareMap: this.replicaShareMap,
- replicaTrailMap: this.replicaTrailMap,
- otherAppliances: this.otherAppliances,
- freeShares: this.freeShares,
- noFreeShares: noFreeShares,
- noOtherAppliances: noOtherAppliances,
- otherAppliances_FreeShares: otherAppliances_FreeShares,
- }));
+ if (this.freeShares.length == 0) {
+ noFreeShares = true;
+ }
+ if (this.otherAppliances.length == 0) {
+ noOtherAppliances = true;
+ }
+ if (this.otherAppliances.length > 0 && this.freeShares.length > 0) {
+ otherAppliances_FreeShares = true;
+ }
+ $(this.el).html(this.template({
+ replicationService: this.replicationService,
+ replicaColl: this.collection.toJSON(),
+ collection: this.collection,
+ collectionNotEmpty: !this.collection.isEmpty(),
+ replicaShareMap: this.replicaShareMap,
+ replicaTrailMap: this.replicaTrailMap,
+ otherAppliances: this.otherAppliances,
+ freeShares: this.freeShares,
+ noFreeShares: noFreeShares,
+ noOtherAppliances: noOtherAppliances,
+ otherAppliances_FreeShares: otherAppliances_FreeShares,
+ }));
- //initalize Bootstrap Switch
- this.$("[type='checkbox']").bootstrapSwitch();
- if (typeof this.current_status == 'undefined') {
- this.current_status = this.replicationService.get('status');
- }
- this.$('input[name="replica-service-checkbox"]').bootstrapSwitch('state', this.current_status, true);
- this.$("[type='checkbox']").bootstrapSwitch('onColor','success'); //left side text color
- this.$("[type='checkbox']").bootstrapSwitch('offColor','danger'); //right side text color
+ //initalize Bootstrap Switch
+ this.$('[type=\'checkbox\']').bootstrapSwitch();
+ if (typeof this.current_status == 'undefined') {
+ this.current_status = this.replicationService.get('status');
+ }
+ this.$('input[name="replica-service-checkbox"]').bootstrapSwitch('state', this.current_status, true);
+ this.$('[type=\'checkbox\']').bootstrapSwitch('onColor', 'success'); //left side text color
+ this.$('[type=\'checkbox\']').bootstrapSwitch('offColor', 'danger'); //right side text color
- // Display Service Warning
- if (!this.current_status) {
- this.$('#replication-warning').show();
- } else {
- this.$('#replication-warning').hide();
- }
+ // Display Service Warning
+ if (!this.current_status) {
+ this.$('#replication-warning').show();
+ } else {
+ this.$('#replication-warning').hide();
+ }
- this.$('[rel=tooltip]').tooltip({ placement: 'bottom'});
+ this.$('[rel=tooltip]').tooltip({
+ placement: 'bottom'
+ });
- //added ext func to sort over Replication task Enable/Disable input checkboxes
- $.fn.dataTable.ext.order['dom-checkbox'] = function ( settings, col ) {
- return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
- return $('input', td).prop('checked') ? '1' : '0';
- });
- }
- //Added columns definition for sorting purpose
- $('table.data-table').DataTable({
- "iDisplayLength": 15,
- "aLengthMenu": [[15, 30, 45, -1], [15, 30, 45, "All"]],
- "columns": [
- null,null,null,null,null,null,
- { "orderDataType": "dom-checkbox" }
- ]
- });
- },
+ //added ext func to sort over Replication task Enable/Disable input checkboxes
+ $.fn.dataTable.ext.order['dom-checkbox'] = function(settings, col) {
+ return this.api().column(col, {
+ order: 'index'
+ }).nodes().map(function(td, i) {
+ return $('input', td).prop('checked') ? '1' : '0';
+ });
+ };
+ //Added columns definition for sorting purpose
+ $('table.data-table').DataTable({
+ 'iDisplayLength': 15,
+ 'aLengthMenu': [
+ [15, 30, 45, -1],
+ [15, 30, 45, 'All']
+ ],
+ 'columns': [
+ null, null, null, null, null, null,
+ {
+ 'orderDataType': 'dom-checkbox'
+ }
+ ]
+ });
+ },
- switchStatus: function(event,state){
- //the bootsrap switch can either be Service or Status Switch
- var replicaSwitchName = $(event.target).attr('name');
- if (replicaSwitchName == "replica-service-checkbox"){
- if (state){
- this.startService();
- }else {
- this.stopService();
- }
- } else if(replicaSwitchName == "replica-task-checkbox"){
- var replicaId = $(event.target).attr('data-replica-id');
- if (state){
- this.enable(replicaId);
- }else {
- this.disable(replicaId);
- }
- }
- },
+ switchStatus: function(event, state) {
+ //the bootsrap switch can either be Service or Status Switch
+ var replicaSwitchName = $(event.target).attr('name');
+ if (replicaSwitchName == 'replica-service-checkbox') {
+ if (state) {
+ this.startService();
+ } else {
+ this.stopService();
+ }
+ } else if (replicaSwitchName == 'replica-task-checkbox') {
+ var replicaId = $(event.target).attr('data-replica-id');
+ if (state) {
+ this.enable(replicaId);
+ } else {
+ this.disable(replicaId);
+ }
+ }
+ },
- enable: function(replicaId) {
- var _this = this;
- $.ajax({
- url: '/api/sm/replicas/' + replicaId,
- type: 'PUT',
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({enabled: true}),
- success: function() {
- _this.collection.fetch({
- success: function() {
- _this.renderReplicas();
- }
- });
- },
- error: function(xhr, status, error) {
- }
- });
- },
+ enable: function(replicaId) {
+ var _this = this;
+ $.ajax({
+ url: '/api/sm/replicas/' + replicaId,
+ type: 'PUT',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ enabled: true
+ }),
+ success: function() {
+ _this.collection.fetch({
+ success: function() {
+ _this.renderReplicas();
+ }
+ });
+ },
+ error: function(xhr, status, error) {}
+ });
+ },
- disable: function(replicaId) {
- var _this = this;
- $.ajax({
- url: '/api/sm/replicas/' + replicaId,
- type: 'PUT',
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({enabled: false}),
- success: function() {
- _this.collection.fetch({
- success: function() {
- _this.renderReplicas();
- }
- });
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- },
+ disable: function(replicaId) {
+ var _this = this;
+ $.ajax({
+ url: '/api/sm/replicas/' + replicaId,
+ type: 'PUT',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ enabled: false
+ }),
+ success: function() {
+ _this.collection.fetch({
+ success: function() {
+ _this.renderReplicas();
+ }
+ });
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ },
- deleteTask: function(event) {
- var _this = this;
- if (event) { event.preventDefault(); }
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- var rTaskId = $(event.currentTarget).attr("data-task-id");
- var rTaskName = $(event.currentTarget).attr("data-task-name");
- if(confirm("Delete Replication task: " + rTaskName + ". Are you sure?")){
- $.ajax({
- url: '/api/sm/replicas/' + rTaskId,
- type: "DELETE",
- dataType: "json",
- success: function() {
- enableButton(button);
- _this.collection.fetch({
- success: function() {
- _this.renderReplicas();
- }
- });
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- }
- },
+ deleteTask: function(event) {
+ var _this = this;
+ if (event) {
+ event.preventDefault();
+ }
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ var rTaskId = $(event.currentTarget).attr('data-task-id');
+ var rTaskName = $(event.currentTarget).attr('data-task-name');
+ if (confirm('Delete Replication task: ' + rTaskName + '. Are you sure?')) {
+ $.ajax({
+ url: '/api/sm/replicas/' + rTaskId,
+ type: 'DELETE',
+ dataType: 'json',
+ success: function() {
+ enableButton(button);
+ _this.collection.fetch({
+ success: function() {
+ _this.renderReplicas();
+ }
+ });
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ }
+ },
- startService: function(){
- var _this = this;
- this.setStatusLoading(this.serviceName, true);
- $.ajax({
- url: "/api/sm/services/replication/start",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(_this.serviceName, false);
- _this.current_status = true;
- //hide replication service warning
- _this.$('#replication-warning').hide();
- },
- error: function(xhr, status, error) {
- _this.$('input[name="replica-service-checkbox"]').bootstrapSwitch('state', _this.current_status, true);
- }
- });
- },
+ startService: function() {
+ var _this = this;
+ this.setStatusLoading(this.serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/replication/start',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(_this.serviceName, false);
+ _this.current_status = true;
+ //hide replication service warning
+ _this.$('#replication-warning').hide();
+ },
+ error: function(xhr, status, error) {
+ _this.$('input[name="replica-service-checkbox"]').bootstrapSwitch('state', _this.current_status, true);
+ }
+ });
+ },
- stopService: function() {
- var _this = this;
- this.setStatusLoading(this.serviceName, true);
- $.ajax({
- url: "/api/sm/services/replication/stop",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(_this.serviceName, false);
- _this.current_status = false;
- //display replication service warning
- _this.$('#replication-warning').show();
- },
- error: function(xhr, status, error) {
- _this.$('input[name="replica-service-checkbox"]').bootstrapSwitch('state', _this.current_status, true);
- }
- });
- },
+ stopService: function() {
+ var _this = this;
+ this.setStatusLoading(this.serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/replication/stop',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(_this.serviceName, false);
+ _this.current_status = false;
+ //display replication service warning
+ _this.$('#replication-warning').show();
+ },
+ error: function(xhr, status, error) {
+ _this.$('input[name="replica-service-checkbox"]').bootstrapSwitch('state', _this.current_status, true);
+ }
+ });
+ },
- setStatusLoading: function(serviceName, show) {
- var statusEl = this.$('div.command-status[data-service-name="'+serviceName+'"]');
- if (show) {
- statusEl.html(' ');
- } else {
- statusEl.empty();
- }
- },
+ setStatusLoading: function(serviceName, show) {
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ if (show) {
+ statusEl.html(' ');
+ } else {
+ statusEl.empty();
+ }
+ },
- serviceStatusSync: function(data) {
- if (data.replication.running > 0) {
- this.current_status = false;
- this.$('#replication-warning').show();
- } else {
- this.current_status = true;
- this.$('#replication-warning').hide();
- }
- this.$('input[name="replica-service-checkbox"]').bootstrapSwitch('state', this.current_status, true);
- },
+ serviceStatusSync: function(data) {
+ if (data.replication.running > 0) {
+ this.current_status = false;
+ this.$('#replication-warning').show();
+ } else {
+ this.current_status = true;
+ this.$('#replication-warning').hide();
+ }
+ this.$('input[name="replica-service-checkbox"]').bootstrapSwitch('state', this.current_status, true);
+ },
- cleanup: function() {
- RockStorSocket.removeOneListener('services');
- },
+ cleanup: function() {
+ RockStorSocket.removeOneListener('services');
+ },
- initHandlebarHelpers: function(){
- var _this = this;
- Handlebars.registerHelper('getFrequency', function(cronTab){
- return prettyCron.toString(cronTab);
- });
+ initHandlebarHelpers: function() {
+ var _this = this;
+ Handlebars.registerHelper('getFrequency', function(cronTab) {
+ return prettyCron.toString(cronTab);
+ });
- Handlebars.registerHelper('lastBackup', function(replicaId){
- var html = '';
- if (_this.replicaTrailMap[replicaId]) {
- if (_this.replicaTrailMap[replicaId].length > 0) {
- var rt = _this.replicaTrailMap[replicaId][0];
- if (rt.get('status') == 'failed') {
- html += ' ' + rt.get('status') + ' ';
- } else if (rt.get('status') == 'pending') {
- html += '' + rt.get('status') + ' ';
- } else if (rt.get('status') == 'succeeded') {
- html += '' + moment(rt.get('end_ts')).fromNow() + ' ';
- }
- }
- }
- return new Handlebars.SafeString(html);
- });
- }
+ Handlebars.registerHelper('lastBackup', function(replicaId) {
+ var html = '';
+ if (_this.replicaTrailMap[replicaId]) {
+ if (_this.replicaTrailMap[replicaId].length > 0) {
+ var rt = _this.replicaTrailMap[replicaId][0];
+ if (rt.get('status') == 'failed') {
+ html += ' ' + rt.get('status') + ' ';
+ } else if (rt.get('status') == 'pending') {
+ html += '' + rt.get('status') + ' ';
+ } else if (rt.get('status') == 'succeeded') {
+ html += '' + moment(rt.get('end_ts')).fromNow() + ' ';
+ }
+ }
+ }
+ return new Handlebars.SafeString(html);
+ });
+ }
});
//Add pagination
-Cocktail.mixin(ReplicationView, PaginationMixin);
+Cocktail.mixin(ReplicationView, PaginationMixin);
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/replication_receive.js b/src/rockstor/storageadmin/static/storageadmin/js/views/replication_receive.js
index 5a32ae604..bebb6e295 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/replication_receive.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/replication_receive.js
@@ -25,207 +25,215 @@
*/
ReplicationReceiveView = RockstorLayoutView.extend({
- events: {
- 'switchChange.bootstrapSwitch': 'switchStatus',
- 'click a[data-action=delete]': 'deleteReceivedTask'
- },
-
- initialize: function() {
- // call initialize of base
- this.constructor.__super__.initialize.apply(this, arguments);
- // set template
- this.template = window.JST.replication_replication_receive;
- this.serviceName = 'replication';
- this.replicationService = new Service({name: this.serviceName});
- this.dependencies.push(this.replicationService);
- this.collection = new ReplicaShareCollection();
- this.dependencies.push(this.collection);
- this.replicaReceiveTrails = new ReceiveTrailCollection();
- this.replicaReceiveTrails.pageSize = RockStorGlobals.maxPageSize;
- this.dependencies.push(this.replicaReceiveTrails);
- this.updateFreq = 5000;
- this.replicaReceiveTrailMap = {};
- this.initHandlebarHelpers();
- },
-
- render: function() {
- this.fetch(this.renderReceives, this);
- return this;
- },
-
- renderReceives: function() {
- var _this = this;
- // Construct map for receive -> trail
- this.collection.each(function(replicaShare, index) {
- var tmp = _this.replicaReceiveTrails.filter(function(replicaReceiveTrail) {
- return replicaReceiveTrail.get('rshare') == replicaShare.id;
- });
- tmp = tmp.filter(function(replicaReceiveTrail) {
- return replicaReceiveTrail.get('end_ts') != null;
- });
- _this.replicaReceiveTrailMap[replicaShare.id] = _.sortBy(tmp, function(replicaReceiveTrail) {
- return moment(replicaReceiveTrail.get('end_ts')).valueOf();
- }).reverse();
- });
- $(this.el).html(this.template({
- replicationService: this.replicationService,
- replicaColl: this.collection.toJSON(),
- collection: this.collection,
- collectionNotEmpty: !this.collection.isEmpty(),
- replicaReceiveTrailMap: this.replicaReceiveTrailMap
- }));
-
- //initalize Bootstrap Switch
- this.$("[type='checkbox']").bootstrapSwitch();
- if (typeof this.current_status == 'undefined') {
- this.current_status = this.replicationService.get('status');
- }
- this.$('input[name="replica-service-checkbox"]').bootstrapSwitch('state', this.current_status, true);
- this.$("[type='checkbox']").bootstrapSwitch('onColor','success'); //left side text color
- this.$("[type='checkbox']").bootstrapSwitch('offColor','danger'); //right side text color
-
- // Display Service Warning
- if (!this.current_status) {
- this.$('#replication-warning').show();
- } else {
- this.$('#replication-warning').hide();
- }
-
- this.$('[rel=tooltip]').tooltip({ placement: 'bottom'});
- this.renderDataTables();
- },
-
- switchStatus: function(event,state){
- //the bootsrap switch can either be Service or Status Switch
- var replicaSwitchName = $(event.target).attr('name');
- if (replicaSwitchName == "replica-service-checkbox"){
- if (state){
- this.startService();
- }else {
- this.stopService();
- }
- } else if(replicaSwitchName == "replica-task-checkbox"){
- var replicaId = $(event.target).attr('data-replica-id');
- if (state){
- this.enable(replicaId);
- }else {
- this.disable(replicaId);
- }
- }
- },
-
- deleteReceivedTask: function(event) {
- var _this = this;
- if (event) { event.preventDefault(); }
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- var rId = $(event.currentTarget).attr("data-rshare-id");
- var rShare = $(event.currentTarget).attr("data-rshare-name");
- if(confirm("Delete Received Replication task: " + rShare + ". Are you sure?")){
- $.ajax({
- url: '/api/sm/replicas/rshare/' + rId,
- type: "DELETE",
- dataType: "json",
- success: function() {
- enableButton(button);
- _this.collection.fetch({
- success: function() {
- _this.renderReceives();
- }
- });
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- }
- },
-
- startService: function(event) {
- var _this = this;
- var serviceName = this.serviceName;
- this.setStatusLoading(serviceName, true);
- $.ajax({
- url: "/api/sm/services/replication/start",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(serviceName, false);
- _this.current_status = true;
- _this.$('#replication-warning').hide();
- },
- error: function(xhr, status, error) {
- _this.setStatusError(serviceName, xhr);
- }
- });
- },
-
- stopService: function(event) {
- var _this = this;
- var serviceName = this.serviceName;
- this.setStatusLoading(serviceName, true);
- $.ajax({
- url: "/api/sm/services/replication/stop",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(serviceName, false);
- _this.current_status = false;
- _this.$('#replication-warning').show();
- },
- error: function(xhr, status, error) {
- _this.setStatusError(serviceName, xhr);
- }
- });
- },
-
- setStatusLoading: function(serviceName, show) {
- var statusEl = this.$('div.command-status[data-service-name="'+serviceName+'"]');
- if (show) {
- statusEl.html(' ');
- } else {
- statusEl.empty();
- }
- },
-
- setStatusError: function(serviceName, xhr) {
- var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
- var msg = parseXhrError(xhr);
- // remove any existing error popups
- $('body').find('#' + serviceName + 'err-popup').remove();
- // add icon and popup
- statusEl.empty();
- var icon = $('').addClass('icon-exclamation-sign').attr('rel', '#' + serviceName + '-err-popup');
- statusEl.append(icon);
- var errPopup = this.$('#' + serviceName + '-err-popup');
- var errPopupContent = this.$('#' + serviceName + '-err-popup > div');
- errPopupContent.html(msg);
- statusEl.click(function(){ errPopup.overlay().load(); });
- },
-
- initHandlebarHelpers: function(){
- var _this = this;
-
- Handlebars.registerHelper('lastReceived', function(replicaId){
- var html = '';
- if (_this.replicaReceiveTrailMap[replicaId]) {
- if (_this.replicaReceiveTrailMap[replicaId].length > 0) {
- var rrt = _this.replicaReceiveTrailMap[replicaId][0];
- if (rrt.get('status') == 'failed') {
- html += ' ' + rrt.get('status') + ' ';
- } else if (rrt.get('status') == 'pending') {
- html += '' + rrt.get('status') + ' ';
-
- } else if (rrt.get('status') == 'succeeded') {
- html += '' + moment(rrt.get('end_ts')).fromNow() + ' ';
- }
- }
- }
- return new Handlebars.SafeString(html);
- });
- }
+ events: {
+ 'switchChange.bootstrapSwitch': 'switchStatus',
+ 'click a[data-action=delete]': 'deleteReceivedTask'
+ },
+
+ initialize: function() {
+ // call initialize of base
+ this.constructor.__super__.initialize.apply(this, arguments);
+ // set template
+ this.template = window.JST.replication_replication_receive;
+ this.serviceName = 'replication';
+ this.replicationService = new Service({
+ name: this.serviceName
+ });
+ this.dependencies.push(this.replicationService);
+ this.collection = new ReplicaShareCollection();
+ this.dependencies.push(this.collection);
+ this.replicaReceiveTrails = new ReceiveTrailCollection();
+ this.replicaReceiveTrails.pageSize = RockStorGlobals.maxPageSize;
+ this.dependencies.push(this.replicaReceiveTrails);
+ this.updateFreq = 5000;
+ this.replicaReceiveTrailMap = {};
+ this.initHandlebarHelpers();
+ },
+
+ render: function() {
+ this.fetch(this.renderReceives, this);
+ return this;
+ },
+
+ renderReceives: function() {
+ var _this = this;
+ // Construct map for receive -> trail
+ this.collection.each(function(replicaShare, index) {
+ var tmp = _this.replicaReceiveTrails.filter(function(replicaReceiveTrail) {
+ return replicaReceiveTrail.get('rshare') == replicaShare.id;
+ });
+ tmp = tmp.filter(function(replicaReceiveTrail) {
+ return replicaReceiveTrail.get('end_ts') != null;
+ });
+ _this.replicaReceiveTrailMap[replicaShare.id] = _.sortBy(tmp, function(replicaReceiveTrail) {
+ return moment(replicaReceiveTrail.get('end_ts')).valueOf();
+ }).reverse();
+ });
+ $(this.el).html(this.template({
+ replicationService: this.replicationService,
+ replicaColl: this.collection.toJSON(),
+ collection: this.collection,
+ collectionNotEmpty: !this.collection.isEmpty(),
+ replicaReceiveTrailMap: this.replicaReceiveTrailMap
+ }));
+
+ //initalize Bootstrap Switch
+ this.$('[type=\'checkbox\']').bootstrapSwitch();
+ if (typeof this.current_status == 'undefined') {
+ this.current_status = this.replicationService.get('status');
+ }
+ this.$('input[name="replica-service-checkbox"]').bootstrapSwitch('state', this.current_status, true);
+ this.$('[type=\'checkbox\']').bootstrapSwitch('onColor', 'success'); //left side text color
+ this.$('[type=\'checkbox\']').bootstrapSwitch('offColor', 'danger'); //right side text color
+
+ // Display Service Warning
+ if (!this.current_status) {
+ this.$('#replication-warning').show();
+ } else {
+ this.$('#replication-warning').hide();
+ }
+
+ this.$('[rel=tooltip]').tooltip({
+ placement: 'bottom'
+ });
+ this.renderDataTables();
+ },
+
+ switchStatus: function(event, state) {
+ //the bootsrap switch can either be Service or Status Switch
+ var replicaSwitchName = $(event.target).attr('name');
+ if (replicaSwitchName == 'replica-service-checkbox') {
+ if (state) {
+ this.startService();
+ } else {
+ this.stopService();
+ }
+ } else if (replicaSwitchName == 'replica-task-checkbox') {
+ var replicaId = $(event.target).attr('data-replica-id');
+ if (state) {
+ this.enable(replicaId);
+ } else {
+ this.disable(replicaId);
+ }
+ }
+ },
+
+ deleteReceivedTask: function(event) {
+ var _this = this;
+ if (event) {
+ event.preventDefault();
+ }
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ var rId = $(event.currentTarget).attr('data-rshare-id');
+ var rShare = $(event.currentTarget).attr('data-rshare-name');
+ if (confirm('Delete Received Replication task: ' + rShare + '. Are you sure?')) {
+ $.ajax({
+ url: '/api/sm/replicas/rshare/' + rId,
+ type: 'DELETE',
+ dataType: 'json',
+ success: function() {
+ enableButton(button);
+ _this.collection.fetch({
+ success: function() {
+ _this.renderReceives();
+ }
+ });
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ }
+ },
+
+ startService: function(event) {
+ var _this = this;
+ var serviceName = this.serviceName;
+ this.setStatusLoading(serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/replication/start',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(serviceName, false);
+ _this.current_status = true;
+ _this.$('#replication-warning').hide();
+ },
+ error: function(xhr, status, error) {
+ _this.setStatusError(serviceName, xhr);
+ }
+ });
+ },
+
+ stopService: function(event) {
+ var _this = this;
+ var serviceName = this.serviceName;
+ this.setStatusLoading(serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/replication/stop',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(serviceName, false);
+ _this.current_status = false;
+ _this.$('#replication-warning').show();
+ },
+ error: function(xhr, status, error) {
+ _this.setStatusError(serviceName, xhr);
+ }
+ });
+ },
+
+ setStatusLoading: function(serviceName, show) {
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ if (show) {
+ statusEl.html(' ');
+ } else {
+ statusEl.empty();
+ }
+ },
+
+ setStatusError: function(serviceName, xhr) {
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ var msg = parseXhrError(xhr);
+ // remove any existing error popups
+ $('body').find('#' + serviceName + 'err-popup').remove();
+ // add icon and popup
+ statusEl.empty();
+ var icon = $('').addClass('icon-exclamation-sign').attr('rel', '#' + serviceName + '-err-popup');
+ statusEl.append(icon);
+ var errPopup = this.$('#' + serviceName + '-err-popup');
+ var errPopupContent = this.$('#' + serviceName + '-err-popup > div');
+ errPopupContent.html(msg);
+ statusEl.click(function() {
+ errPopup.overlay().load();
+ });
+ },
+
+ initHandlebarHelpers: function() {
+ var _this = this;
+
+ Handlebars.registerHelper('lastReceived', function(replicaId) {
+ var html = '';
+ if (_this.replicaReceiveTrailMap[replicaId]) {
+ if (_this.replicaReceiveTrailMap[replicaId].length > 0) {
+ var rrt = _this.replicaReceiveTrailMap[replicaId][0];
+ if (rrt.get('status') == 'failed') {
+ html += ' ' + rrt.get('status') + ' ';
+ } else if (rrt.get('status') == 'pending') {
+ html += '' + rrt.get('status') + ' ';
+
+ } else if (rrt.get('status') == 'succeeded') {
+ html += '' + moment(rrt.get('end_ts')).fromNow() + ' ';
+ }
+ }
+ }
+ return new Handlebars.SafeString(html);
+ });
+ }
});
//Add pagination
-Cocktail.mixin(ReplicationReceiveView, PaginationMixin);
+Cocktail.mixin(ReplicationReceiveView, PaginationMixin);
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js b/src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js
index 369f501d7..8492cb3dc 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js
@@ -28,382 +28,394 @@ RockonsView = RockstorLayoutView.extend({
initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.rockons_rockons;
- this.rockons = new RockOnCollection({});
- this.rockons.pageSize = RockStorGlobals.maxPageSize;
- this.service = new Service({ name: 'docker' });
- this.dependencies.push(this.rockons, this.service);
- this.updateFreq = 15000;
- this.defTab = 0;
- this.initHandlebarHelpers();
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.rockons_rockons;
+ this.rockons = new RockOnCollection({});
+ this.rockons.pageSize = RockStorGlobals.maxPageSize;
+ this.service = new Service({
+ name: 'docker'
+ });
+ this.dependencies.push(this.rockons, this.service);
+ this.updateFreq = 15000;
+ this.defTab = 0;
+ this.initHandlebarHelpers();
},
events: {
- 'switchChange.bootstrapSwitch': 'rockonToggle',
- 'click #js-install-rockon': 'installRockon',
- 'click #js-uninstall-rockon': 'uninstallRockon',
- 'click #js-rockons-installed': 'installedRockons',
- 'click #js-update-rockons': 'updateRockons',
- 'click #js-rockon-settings': 'rockonSettings',
- 'click #js-rockon-info': 'rockonInfo'
+ 'switchChange.bootstrapSwitch': 'rockonToggle',
+ 'click #js-install-rockon': 'installRockon',
+ 'click #js-uninstall-rockon': 'uninstallRockon',
+ 'click #js-rockons-installed': 'installedRockons',
+ 'click #js-update-rockons': 'updateRockons',
+ 'click #js-rockon-settings': 'rockonSettings',
+ 'click #js-rockon-info': 'rockonInfo'
},
render: function() {
- this.service.fetch();
- this.rockons.fetch();
- this.updateStatus();
+ this.service.fetch();
+ this.rockons.fetch();
+ this.updateStatus();
- return this;
+ return this;
},
renderRockons: function() {
- var _this = this;
-
- var ui_map = {};
- var uis = this.rockons.filter(function(rockon) {
- ui_map[rockon.get('id')] = null;
- if (rockon.get('ui')) {
- var protocol = "http://";
- if (rockon.get('https')) {
- protocol = "https://";
- }
- var ui_link = protocol + window.location.hostname;
- if (rockon.get('ui_port')) {
- ui_link += ":" + rockon.get('ui_port');
- }
- if (rockon.get('link')) {
- ui_link += "/" + rockon.get('link');
- }
- ui_map[rockon.get('id')] = ui_link;
- }
- return false;
- });
- $(this.el).html(this.template({
- rockons: _this.rockons,
- rockonJson: _this.rockons.toJSON(),
- status: _this.service.get('status'),
- ui_map: ui_map
- }));
-
- if (!this.dockerServiceView) {
- this.dockerServiceView = new DockerServiceView({
- parentView: _this
- });
- }
- // Render the Rockons template with a status describing whether
- // the Rockons service has been enabled
-
- $('#docker-service-ph').append(this.dockerServiceView.render().el);
-
- $('#install-rockon-overlay').overlay({load: false});
- this.$("ul.nav.nav-tabs").tabs("div.css-panes > div");
- this.$('.nav-tabs li:eq(' + this.defTab + ') a').click();
-
- //initalize bootstrap switch
- this.$("[type='checkbox']").bootstrapSwitch();
- this.$("[type='checkbox']").bootstrapSwitch('onColor','success'); //left side text color
- this.$("[type='checkbox']").bootstrapSwitch('offColor','danger'); //right side text color
+ var _this = this;
+
+ var ui_map = {};
+ var uis = this.rockons.filter(function(rockon) {
+ ui_map[rockon.get('id')] = null;
+ if (rockon.get('ui')) {
+ var protocol = 'http://';
+ if (rockon.get('https')) {
+ protocol = 'https://';
+ }
+ var ui_link = protocol + window.location.hostname;
+ if (rockon.get('ui_port')) {
+ ui_link += ':' + rockon.get('ui_port');
+ }
+ if (rockon.get('link')) {
+ ui_link += '/' + rockon.get('link');
+ }
+ ui_map[rockon.get('id')] = ui_link;
+ }
+ return false;
+ });
+ $(this.el).html(this.template({
+ rockons: _this.rockons,
+ rockonJson: _this.rockons.toJSON(),
+ status: _this.service.get('status'),
+ ui_map: ui_map
+ }));
+
+ if (!this.dockerServiceView) {
+ this.dockerServiceView = new DockerServiceView({
+ parentView: _this
+ });
+ }
+ // Render the Rockons template with a status describing whether
+ // the Rockons service has been enabled
+
+ $('#docker-service-ph').append(this.dockerServiceView.render().el);
+
+ $('#install-rockon-overlay').overlay({
+ load: false
+ });
+ this.$('ul.nav.nav-tabs').tabs('div.css-panes > div');
+ this.$('.nav-tabs li:eq(' + this.defTab + ') a').click();
+
+ //initalize bootstrap switch
+ this.$('[type=\'checkbox\']').bootstrapSwitch();
+ this.$('[type=\'checkbox\']').bootstrapSwitch('onColor', 'success'); //left side text color
+ this.$('[type=\'checkbox\']').bootstrapSwitch('offColor', 'danger'); //right side text color
},
installRockon: function(event) {
- var _this = this;
- this.defTab = 0;
- event.preventDefault();
- var button = $(event.currentTarget);
- var rockon_id = button.attr('data-name');
- var rockon_o = _this.rockons.get(rockon_id);
- var wizardView = new RockonInstallWizardView({
- model: new Backbone.Model({ rockon: rockon_o }),
- title: rockon_o.get('name') + ' install wizard',
- parent: this
- });
- $('.overlay-content', '#install-rockon-overlay').html(wizardView.render().el);
- $('#install-rockon-overlay').overlay().load();
+ var _this = this;
+ this.defTab = 0;
+ event.preventDefault();
+ var button = $(event.currentTarget);
+ var rockon_id = button.attr('data-name');
+ var rockon_o = _this.rockons.get(rockon_id);
+ var wizardView = new RockonInstallWizardView({
+ model: new Backbone.Model({
+ rockon: rockon_o
+ }),
+ title: rockon_o.get('name') + ' install wizard',
+ parent: this
+ });
+ $('.overlay-content', '#install-rockon-overlay').html(wizardView.render().el);
+ $('#install-rockon-overlay').overlay().load();
},
uninstallRockon: function(event) {
- var _this = this;
- event.preventDefault();
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- var rockon_id = button.attr('data-name');
- var rockon_o = _this.rockons.get(rockon_id);
- if (confirm("Are you sure you want to uninstall this Rock-on (" + rockon_o.get('name') + ")?")) {
- disableButton(button);
- $.ajax({
- url: '/api/rockons/' + rockon_id + '/uninstall',
- type: 'POST',
- dataType: 'json',
- success: function() {
- _this.defTab = 0;
- _this.render();
- enableButton(button);
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- }
+ var _this = this;
+ event.preventDefault();
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ var rockon_id = button.attr('data-name');
+ var rockon_o = _this.rockons.get(rockon_id);
+ if (confirm('Are you sure you want to uninstall this Rock-on (' + rockon_o.get('name') + ')?')) {
+ disableButton(button);
+ $.ajax({
+ url: '/api/rockons/' + rockon_id + '/uninstall',
+ type: 'POST',
+ dataType: 'json',
+ success: function() {
+ _this.defTab = 0;
+ _this.render();
+ enableButton(button);
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ }
},
updateRockons: function(event) {
- var _this = this;
- event.preventDefault();
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- disableButton(button);
- $.ajax({
- url: '/api/rockons/update',
- type: 'POST',
- dataType: 'json',
- success: function() {
- _this.defTab = 1;
- _this.render();
- enableButton(button);
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
+ var _this = this;
+ event.preventDefault();
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ $.ajax({
+ url: '/api/rockons/update',
+ type: 'POST',
+ dataType: 'json',
+ success: function() {
+ _this.defTab = 1;
+ _this.render();
+ enableButton(button);
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
},
rockonSettings: function(event) {
- var _this = this;
- event.preventDefault();
- var rockon_id = _this.getRockonId(event);
- var rockon_o = _this.rockons.get(rockon_id);
- _this.stopPolling();
- var wizardView = new RockonSettingsWizardView({
- model: new Backbone.Model({ rockon: rockon_o}),
- title: rockon_o.get('name') + ' Settings',
- parent: this
- });
- $('.overlay-content', '#install-rockon-overlay').html(wizardView.render().el);
- $('#install-rockon-overlay').overlay().load();
+ var _this = this;
+ event.preventDefault();
+ var rockon_id = _this.getRockonId(event);
+ var rockon_o = _this.rockons.get(rockon_id);
+ _this.stopPolling();
+ var wizardView = new RockonSettingsWizardView({
+ model: new Backbone.Model({
+ rockon: rockon_o
+ }),
+ title: rockon_o.get('name') + ' Settings',
+ parent: this
+ });
+ $('.overlay-content', '#install-rockon-overlay').html(wizardView.render().el);
+ $('#install-rockon-overlay').overlay().load();
},
rockonInfo: function(event) {
- var _this = this;
- event.preventDefault();
- var rockon_id = _this.getRockonId(event);
- var rockon_o = _this.rockons.get(rockon_id);
- _this.stopPolling();
- var infoView = new RockonInfoView({
- model: new Backbone.Model({ rockon: rockon_o}),
- title: 'Additional information about ' + rockon_o.get('name') + ' Rock-on',
- parent: this
- });
- $('.overlay-content', '#install-rockon-overlay').html(infoView.render().el);
- $('#install-rockon-overlay').overlay().load();
+ var _this = this;
+ event.preventDefault();
+ var rockon_id = _this.getRockonId(event);
+ var rockon_o = _this.rockons.get(rockon_id);
+ _this.stopPolling();
+ var infoView = new RockonInfoView({
+ model: new Backbone.Model({
+ rockon: rockon_o
+ }),
+ title: 'Additional information about ' + rockon_o.get('name') + ' Rock-on',
+ parent: this
+ });
+ $('.overlay-content', '#install-rockon-overlay').html(infoView.render().el);
+ $('#install-rockon-overlay').overlay().load();
},
getRockonId: function(event) {
- var slider = $(event.currentTarget);
- return slider.attr('data-rockon-id');
+ var slider = $(event.currentTarget);
+ return slider.attr('data-rockon-id');
},
- rockonToggle: function(event,state){
- var rockonId = $(event.target).attr('data-rockon-id');
- if(state){
- this.startRockon(rockonId);
- }else{
- this.stopRockon(rockonId);
- }
+ rockonToggle: function(event, state) {
+ var rockonId = $(event.target).attr('data-rockon-id');
+ if (state) {
+ this.startRockon(rockonId);
+ } else {
+ this.stopRockon(rockonId);
+ }
},
startRockon: function(rockonId) {
- var _this = this;
- this.stopPolling();
- $.ajax({
- url: '/api/rockons/' + rockonId + '/start',
- type: 'POST',
- dataType: 'json',
- success: function(data, status, xhr) {
- _this.defTab = 0;
- _this.updateStatus();
- },
- error: function(data, status, xhr) {
- console.log('error while starting rockon');
- }
- });
+ var _this = this;
+ this.stopPolling();
+ $.ajax({
+ url: '/api/rockons/' + rockonId + '/start',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.defTab = 0;
+ _this.updateStatus();
+ },
+ error: function(data, status, xhr) {
+ console.log('error while starting rockon');
+ }
+ });
},
stopRockon: function(rockonId) {
- var _this = this;
- this.stopPolling();
- $.ajax({
- url: '/api/rockons/' + rockonId + '/stop',
- type: 'POST',
- dataType: 'json',
- success: function(data, status, xhr) {
- _this.defTab = 0;
- _this.updateStatus();
- },
- error: function(data, status, xhr) {
- console.log('error while stopping rockon');
- }
- });
+ var _this = this;
+ this.stopPolling();
+ $.ajax({
+ url: '/api/rockons/' + rockonId + '/stop',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.defTab = 0;
+ _this.updateStatus();
+ },
+ error: function(data, status, xhr) {
+ console.log('error while stopping rockon');
+ }
+ });
},
pendingOps: function() {
- var pending = this.rockons.find(function(rockon) {
- if ((rockon.get('status').search('pending') != -1) || (rockon.get('state').search('pending') != -1)) {
- return true;
- }
- });
- if (pending) { return true; }
- return false;
+ var pending = this.rockons.find(function(rockon) {
+ if ((rockon.get('status').search('pending') != -1) || (rockon.get('state').search('pending') != -1)) {
+ return true;
+ }
+ });
+ if (pending) {
+ return true;
+ }
+ return false;
},
updateStatus: function() {
- var _this = this;
- _this.startTime = new Date().getTime();
- _this.rockons.fetch({
- silent: true,
- success: function(data, response, options) {
- _this.renderRockons();
- if (_this.pendingOps()) {
- var ct = new Date().getTime();
- var diff = ct - _this.startTime;
- if (diff > _this.updateFreq) {
- _this.updateStatus();
- } else {
- _this.timeoutId = window.setTimeout( function() {
- _this.updateStatus();
- }, _this.updateFreq - diff);
- }
- } else {
- _this.stopPolling();
- }
- }
- });
+ var _this = this;
+ _this.startTime = new Date().getTime();
+ _this.rockons.fetch({
+ silent: true,
+ success: function(data, response, options) {
+ _this.renderRockons();
+ if (_this.pendingOps()) {
+ var ct = new Date().getTime();
+ var diff = ct - _this.startTime;
+ if (diff > _this.updateFreq) {
+ _this.updateStatus();
+ } else {
+ _this.timeoutId = window.setTimeout(function() {
+ _this.updateStatus();
+ }, _this.updateFreq - diff);
+ }
+ } else {
+ _this.stopPolling();
+ }
+ }
+ });
},
stopPolling: function() {
- if (!_.isUndefined(this.timeoutId)) {
- window.clearInterval(this.timeoutId);
- }
+ if (!_.isUndefined(this.timeoutId)) {
+ window.clearInterval(this.timeoutId);
+ }
},
installedRockons: function(event) {
- if (this.pendingOps()) {
- this.updateStatus();
- }
+ if (this.pendingOps()) {
+ this.updateStatus();
+ }
},
//@todo: cleanup after figuring out how to track the installed variable.
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_installedRockons', function(){
- var html = '';
- _this = this;
- var installed = 0;
- this.rockons.each(function(rockon, index) {
- if (rockon.get('state') == 'installed' || rockon.get('state').match('pending')) {
- installed += 1;
- html += '';
- if (rockon.get('state').search('pending') > -1 || rockon.get('status').search('pending') > -1) {
- var text = 'Installing ...';
- if (rockon.get('state') == 'pending_uninstall') {
- text = 'Uninstalling ...';
- } else if (rockon.get('status') == 'pending_start') {
- text = 'Starting ...';
- } else if (rockon.get('status') == 'pending_stop') {
- text = 'Stopping ...';
- }
- html += '
';
- html += '
';
- html += '
';
- html += '
';
- html += '
' + text + '
';
- html += '
';
- html += '
';
- html += '
';
- }
- html += '
';
- html += '
';
- html += '
' + rockon.get('name') + ' ';
- html += '
' + rockon.get('description') + '
';
- html += '
Current status: ' + rockon.get('status') + ' ';
- html += '
';
- html += '
';
- html += '
';
- if (rockon.get('state') == 'installed' && !rockon.get('status').match('pending')) {
- if (rockon.get('status') == 'started') {
- html += '
';
- } else {
- html += '
';
- }
- html += '
 ';
- if (rockon.get('more_info')) {
- html += '
';
- }
- html += '
';
- if (_this.ui_map[rockon.get('id')]) {
- if (rockon.get('status') == 'started') {
- html += '
' + rockon.get('name') + ' UI ';
- } else {
- html += '
' + rockon.get('name') + ' UI ';
- }
- }
- if (rockon.get('status') != 'started') {
- html += '
Uninstall ';
- }
-
- }
- html += '
';
- html += '
';
- html += '
';
- }
- });
- if (installed == 0) {
- html += '';
- html += '
';
- html += '
';
- html += '
There are no Rock-ons installed currently. ';
- html += '';
- html += '
';
- html += '
';
- }
- return new Handlebars.SafeString(html);
- });
-
- Handlebars.registerHelper('display_allRockons', function(){
- var html = '';
- var all = 0;
- this.rockons.each(function(rockon, index) {
- if (rockon.get('state') == 'available' || rockon.get('state') == 'install_failed') {
- all += 1;
- html += '';
- html += '
';
- html += '
';
- html += '
' + rockon.get('name') + ' ';
- html += '
' + rockon.get('description') + '
';
- if (rockon.get('state') == 'install_failed') {
- html += '
Failed to install in the previous attempt. Here\'s how you can proceed.';
- html += '
';
- html += 'Check logs in /opt/rockstor/var/log for clues. ';
- html += 'Install again. ';
- html += 'If the problem persists, post on the Forum or email support@rockstor.com ';
- html += ' ';
- }
- html += '
Install ';
- html += '
';
- html += '
';
- html += '
';
- }
- });
- if (all == 0) {
- html += '';
- html += '
';
- html += '
';
- html += '
Click on Update button to check for new Rock-ons. ';
- html += '';
- html += '
';
- html += '
';
- }
- return new Handlebars.SafeString(html);
- });
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_installedRockons', function() {
+ var html = '';
+ _this = this;
+ var installed = 0;
+ this.rockons.each(function(rockon, index) {
+ if (rockon.get('state') == 'installed' || rockon.get('state').match('pending')) {
+ installed += 1;
+ html += '';
+ if (rockon.get('state').search('pending') > -1 || rockon.get('status').search('pending') > -1) {
+ var text = 'Installing ...';
+ if (rockon.get('state') == 'pending_uninstall') {
+ text = 'Uninstalling ...';
+ } else if (rockon.get('status') == 'pending_start') {
+ text = 'Starting ...';
+ } else if (rockon.get('status') == 'pending_stop') {
+ text = 'Stopping ...';
+ }
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
' + text + '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ }
+ html += '
';
+ html += '
';
+ html += '
' + rockon.get('name') + ' ';
+ html += '
' + rockon.get('description') + '
';
+ html += '
Current status: ' + rockon.get('status') + ' ';
+ html += '
';
+ html += '
';
+ html += '
';
+ if (rockon.get('state') == 'installed' && !rockon.get('status').match('pending')) {
+ if (rockon.get('status') == 'started') {
+ html += '
';
+ } else {
+ html += '
';
+ }
+ html += '
 ';
+ if (rockon.get('more_info')) {
+ html += '
';
+ }
+ html += '
';
+ if (_this.ui_map[rockon.get('id')]) {
+ if (rockon.get('status') == 'started') {
+ html += '
' + rockon.get('name') + ' UI ';
+ } else {
+ html += '
' + rockon.get('name') + ' UI ';
+ }
+ }
+ if (rockon.get('status') != 'started') {
+ html += '
Uninstall ';
+ }
+
+ }
+ html += '
';
+ html += '
';
+ html += '
';
+ }
+ });
+ if (installed == 0) {
+ html += '';
+ html += '
';
+ html += '
';
+ html += '
There are no Rock-ons installed currently. ';
+ html += '';
+ html += '
';
+ html += '
';
+ }
+ return new Handlebars.SafeString(html);
+ });
+
+ Handlebars.registerHelper('display_allRockons', function() {
+ var html = '';
+ var all = 0;
+ this.rockons.each(function(rockon, index) {
+ if (rockon.get('state') == 'available' || rockon.get('state') == 'install_failed') {
+ all += 1;
+ html += '';
+ html += '
';
+ html += '
';
+ html += '
' + rockon.get('name') + ' ';
+ html += '
' + rockon.get('description') + '
';
+ if (rockon.get('state') == 'install_failed') {
+ html += '
Failed to install in the previous attempt. Here\'s how you can proceed.';
+ html += '
';
+ html += 'Check logs in /opt/rockstor/var/log for clues. ';
+ html += 'Install again. ';
+ html += 'If the problem persists, post on the Forum or email support@rockstor.com ';
+ html += ' ';
+ }
+ html += '
Install ';
+ html += '
';
+ html += '
';
+ html += '
';
+ }
+ });
+ if (all == 0) {
+ html += '';
+ html += '
';
+ html += '
';
+ html += '
Click on Update button to check for new Rock-ons. ';
+ html += '';
+ html += '
';
+ html += '
';
+ }
+ return new Handlebars.SafeString(html);
+ });
}
});
@@ -411,258 +423,278 @@ RockonsView = RockstorLayoutView.extend({
RockonInstallWizardView = WizardView.extend({
initialize: function() {
- WizardView.prototype.initialize.apply(this, arguments);
- this.pages = [];
- this.rockon = this.model.get('rockon');
- this.volumes = new RockOnVolumeCollection(null, {rid: this.rockon.id});
- this.ports = new RockOnPortCollection(null, {rid: this.rockon.id});
- this.custom_config = new RockOnCustomConfigCollection(null, {rid: this.rockon.id});
- this.environment = new RockOnEnvironmentCollection(null, {rid: this.rockon.id});
+ WizardView.prototype.initialize.apply(this, arguments);
+ this.pages = [];
+ this.rockon = this.model.get('rockon');
+ this.volumes = new RockOnVolumeCollection(null, {
+ rid: this.rockon.id
+ });
+ this.ports = new RockOnPortCollection(null, {
+ rid: this.rockon.id
+ });
+ this.custom_config = new RockOnCustomConfigCollection(null, {
+ rid: this.rockon.id
+ });
+ this.environment = new RockOnEnvironmentCollection(null, {
+ rid: this.rockon.id
+ });
},
fetchVolumes: function() {
- var _this = this;
- this.volumes.fetch({
- success: function () {
- _this.model.set('volumes', _this.volumes);
- _this.fetchPorts();
- }
- });
+ var _this = this;
+ this.volumes.fetch({
+ success: function() {
+ _this.model.set('volumes', _this.volumes);
+ _this.fetchPorts();
+ }
+ });
},
fetchPorts: function() {
- var _this = this;
- this.ports.fetch({
- success: function() {
- _this.model.set('ports', _this.ports);
- _this.fetchCustomConfig();
- }
- });
+ var _this = this;
+ this.ports.fetch({
+ success: function() {
+ _this.model.set('ports', _this.ports);
+ _this.fetchCustomConfig();
+ }
+ });
},
fetchCustomConfig: function() {
- var _this = this;
- this.custom_config.fetch({
- success: function() {
- _this.model.set('custom_config', _this.custom_config);
- _this.fetchEnvironment();
- }
- });
+ var _this = this;
+ this.custom_config.fetch({
+ success: function() {
+ _this.model.set('custom_config', _this.custom_config);
+ _this.fetchEnvironment();
+ }
+ });
},
fetchEnvironment: function() {
- var _this = this;
- this.environment.fetch({
- success: function() {
- _this.model.set('environment', _this.environment);
- _this.addPages();
- }
- });
+ var _this = this;
+ this.environment.fetch({
+ success: function() {
+ _this.model.set('environment', _this.environment);
+ _this.addPages();
+ }
+ });
},
render: function() {
- this.fetchVolumes();
- return this;
+ this.fetchVolumes();
+ return this;
},
addPages: function() {
- if (this.volumes.length > 0) {
- this.pages.push(RockonShareChoice);
- }
- if (this.ports.length > 0) {
- this.pages.push(RockonPortChoice);
- }
- if (this.environment.length > 0) {
- this.pages.push(RockonEnvironment);
- }
- if (this.custom_config.length > 0) {
- this.pages.push(RockonCustomChoice);
- }
- this.pages.push.apply(this.pages, [RockonInstallSummary, RockonInstallComplete]);
- WizardView.prototype.render.apply(this, arguments);
- return this;
+ if (this.volumes.length > 0) {
+ this.pages.push(RockonShareChoice);
+ }
+ if (this.ports.length > 0) {
+ this.pages.push(RockonPortChoice);
+ }
+ if (this.environment.length > 0) {
+ this.pages.push(RockonEnvironment);
+ }
+ if (this.custom_config.length > 0) {
+ this.pages.push(RockonCustomChoice);
+ }
+ this.pages.push.apply(this.pages, [RockonInstallSummary, RockonInstallComplete]);
+ WizardView.prototype.render.apply(this, arguments);
+ return this;
},
setCurrentPage: function() {
- this.currentPage = new this.pages[this.currentPageNum]({
- model: this.model,
- parent: this,
- evAgg: this.evAgg
- });
+ this.currentPage = new this.pages[this.currentPageNum]({
+ model: this.model,
+ parent: this,
+ evAgg: this.evAgg
+ });
},
modifyButtonText: function() {
- if (this.currentPageNum == (this.pages.length - 2)) {
- this.$('#next-page').html('Submit');
- } else if (this.currentPageNum == (this.pages.length - 1)) {
- this.$('#prev-page').hide();
- this.$('#next-page').html('Close');
- } else if (this.currentPageNum == 0) {
- this.$('#prev-page').hide();
- } else {
- this.$('#prev-page').show();
- this.$('#next-page').html('Next');
- this.$('#ph-wizard-buttons').show();
- }
+ if (this.currentPageNum == (this.pages.length - 2)) {
+ this.$('#next-page').html('Submit');
+ } else if (this.currentPageNum == (this.pages.length - 1)) {
+ this.$('#prev-page').hide();
+ this.$('#next-page').html('Close');
+ } else if (this.currentPageNum == 0) {
+ this.$('#prev-page').hide();
+ } else {
+ this.$('#prev-page').show();
+ this.$('#next-page').html('Next');
+ this.$('#ph-wizard-buttons').show();
+ }
},
lastPage: function() {
- return ((this.pages.length > 1)
- && ((this.pages.length-1) == this.currentPageNum));
+ return ((this.pages.length > 1) &&
+ ((this.pages.length - 1) == this.currentPageNum));
},
finish: function() {
- this.parent.$('#install-rockon-overlay').overlay().close();
- this.parent.render();
+ this.parent.$('#install-rockon-overlay').overlay().close();
+ this.parent.render();
}
});
RockonShareChoice = RockstorWizardPage.extend({
initialize: function() {
- this.template = window.JST.rockons_install_choice;
- this.vol_template = window.JST.rockons_vol_form;
- this.rockon = this.model.get('rockon');
- this.volumes = this.model.get('volumes');
- this.shares = new ShareCollection();
- this.shares.setPageSize(100);
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
- this.shares.on('reset', this.renderVolumes, this);
+ this.template = window.JST.rockons_install_choice;
+ this.vol_template = window.JST.rockons_vol_form;
+ this.rockon = this.model.get('rockon');
+ this.volumes = this.model.get('volumes');
+ this.shares = new ShareCollection();
+ this.shares.setPageSize(100);
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.shares.on('reset', this.renderVolumes, this);
},
render: function() {
- RockstorWizardPage.prototype.render.apply(this, arguments);
- this.shares.fetch();
- return this;
+ RockstorWizardPage.prototype.render.apply(this, arguments);
+ this.shares.fetch();
+ return this;
},
renderVolumes: function() {
- this.$('#ph-vols-table').html(this.vol_template({volumes: this.volumes.toJSON(), shares: this.shares.toJSON()}));
- //form validation
- this.volForm = this.$('#vol-select-form');
- var rules = {};
- var messages = {};
- this.volumes.each(function(volume) {
- rules[volume.id] = { required: true };
- messages[volume.id] = "Please read the tooltip and make the right selection";
- });
- this.validator = this.volForm.validate({
- rules: rules,
- messages: messages
- });
+ this.$('#ph-vols-table').html(this.vol_template({
+ volumes: this.volumes.toJSON(),
+ shares: this.shares.toJSON()
+ }));
+ //form validation
+ this.volForm = this.$('#vol-select-form');
+ var rules = {};
+ var messages = {};
+ this.volumes.each(function(volume) {
+ rules[volume.id] = {
+ required: true
+ };
+ messages[volume.id] = 'Please read the tooltip and make the right selection';
+ });
+ this.validator = this.volForm.validate({
+ rules: rules,
+ messages: messages
+ });
},
save: function() {
- // Validate the form
- if (!this.volForm.valid()) {
- this.validator.showErrors();
- return $.Deferred().reject();
- }
-
- var share_map = {};
- var volumes = this.volumes.filter(function(volume) {
- share_map[volume.get('dest_dir')] = this.$('#' + volume.id).val();
- return volume;
- }, this);
- this.model.set('share_map', share_map);
- return $.Deferred().resolve();
+ // Validate the form
+ if (!this.volForm.valid()) {
+ this.validator.showErrors();
+ return $.Deferred().reject();
+ }
+
+ var share_map = {};
+ var volumes = this.volumes.filter(function(volume) {
+ share_map[volume.get('dest_dir')] = this.$('#' + volume.id).val();
+ return volume;
+ }, this);
+ this.model.set('share_map', share_map);
+ return $.Deferred().resolve();
},
});
RockonPortChoice = RockstorWizardPage.extend({
initialize: function() {
- this.template = window.JST.rockons_port_choice;
- this.port_template = window.JST.rockons_ports_form;
- this.ports = this.model.get('ports');
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.template = window.JST.rockons_port_choice;
+ this.port_template = window.JST.rockons_ports_form;
+ this.ports = this.model.get('ports');
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
},
render: function() {
- RockstorWizardPage.prototype.render.apply(this, arguments);
- this.$('#ph-ports-form').html(this.port_template({ports: this.ports.toJSON()}));
-
- // Add form validation
- this.portForm = this.$('#port-select-form');
- var rules = {};
- var messages = {};
- this.ports.each(function(port) {
- rules[port.id] = { required: true, number: true };
- messages[port.id] = "Please enter a valid port number";
- });
- this.validator = this.portForm.validate({
- rules: rules,
- messages: messages
- });
- return this;
+ RockstorWizardPage.prototype.render.apply(this, arguments);
+ this.$('#ph-ports-form').html(this.port_template({
+ ports: this.ports.toJSON()
+ }));
+
+ // Add form validation
+ this.portForm = this.$('#port-select-form');
+ var rules = {};
+ var messages = {};
+ this.ports.each(function(port) {
+ rules[port.id] = {
+ required: true,
+ number: true
+ };
+ messages[port.id] = 'Please enter a valid port number';
+ });
+ this.validator = this.portForm.validate({
+ rules: rules,
+ messages: messages
+ });
+ return this;
},
save: function() {
- // Validate the form
- if (!this.portForm.valid()) {
- this.validator.showErrors();
- // return rejected promise so that the wizard doesn't proceed to the next page.
- return $.Deferred().reject();
- }
-
- var port_map = {};
- var cports = this.ports.filter(function(port) {
- port_map[this.$('#' + port.id).val()] = port.get('containerp');
- return port;
- }, this);
- this.model.set('port_map', port_map);
- return $.Deferred().resolve();
+ // Validate the form
+ if (!this.portForm.valid()) {
+ this.validator.showErrors();
+ // return rejected promise so that the wizard doesn't proceed to the next page.
+ return $.Deferred().reject();
+ }
+
+ var port_map = {};
+ var cports = this.ports.filter(function(port) {
+ port_map[this.$('#' + port.id).val()] = port.get('containerp');
+ return port;
+ }, this);
+ this.model.set('port_map', port_map);
+ return $.Deferred().resolve();
},
});
RockonCustomChoice = RockstorWizardPage.extend({
initialize: function() {
- this.template = window.JST.rockons_custom_choice;
- this.cc_template = window.JST.rockons_cc_form;
- this.custom_config = this.model.get('custom_config');
+ this.template = window.JST.rockons_custom_choice;
+ this.cc_template = window.JST.rockons_cc_form;
+ this.custom_config = this.model.get('custom_config');
this.initHandlebarHelpers();
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
},
render: function() {
- RockstorWizardPage.prototype.render.apply(this, arguments);
- //@todo: working only for the ownCloud and Discourse rockons. Fix to work for the rest
- this.$('#ph-cc-form').html(this.cc_template({cc: this.custom_config.toJSON()}));
- this.cc_form = this.$('#custom-choice-form');
- var rules = {};
- var messages = {};
- this.custom_config.each(function(cc) {
- rules[cc.id] = "required";
- messages[cc.id] = "This is a required field.";
- });
- this.validator = this.cc_form.validate({
- rules: rules,
- messages: messages
- });
- return this;
+ RockstorWizardPage.prototype.render.apply(this, arguments);
+ //@todo: working only for the ownCloud and Discourse rockons. Fix to work for the rest
+ this.$('#ph-cc-form').html(this.cc_template({
+ cc: this.custom_config.toJSON()
+ }));
+ this.cc_form = this.$('#custom-choice-form');
+ var rules = {};
+ var messages = {};
+ this.custom_config.each(function(cc) {
+ rules[cc.id] = 'required';
+ messages[cc.id] = 'This is a required field.';
+ });
+ this.validator = this.cc_form.validate({
+ rules: rules,
+ messages: messages
+ });
+ return this;
},
save: function() {
- if (!this.cc_form.valid()) {
- this.validator.showErrors();
- return $.Deferred().reject();
- }
- var cc_map = {};
- var cconfigs = this.custom_config.filter(function(cc) {
- cc_map[cc.get('key')] = this.$('#' + cc.id).val();
- return cc;
- }, this);
- this.model.set('cc_map', cc_map);
- return $.Deferred().resolve();
+ if (!this.cc_form.valid()) {
+ this.validator.showErrors();
+ return $.Deferred().reject();
+ }
+ var cc_map = {};
+ var cconfigs = this.custom_config.filter(function(cc) {
+ cc_map[cc.get('key')] = this.$('#' + cc.id).val();
+ return cc;
+ }, this);
+ this.model.set('cc_map', cc_map);
+ return $.Deferred().resolve();
},
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('findInputType', function(ccLabel){
- if (ccLabel.match(/password/i)) {
- return true;
- }
- return false;
- });
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('findInputType', function(ccLabel) {
+ if (ccLabel.match(/password/i)) {
+ return true;
+ }
+ return false;
+ });
}
});
@@ -674,275 +706,290 @@ RockonEnvironment = RockonCustomChoice.extend({
},
save: function() {
- if (!this.cc_form.valid()) {
- this.validator.showErrors();
- return $.Deferred().reject();
- }
- var env_map = {};
- var envars = this.custom_config.filter(function(cvar) {
- env_map[cvar.get('key')] = this.$('#' + cvar.id).val();
- return cvar;
- }, this);
- this.model.set('env_map', env_map);
- return $.Deferred().resolve();
+ if (!this.cc_form.valid()) {
+ this.validator.showErrors();
+ return $.Deferred().reject();
+ }
+ var env_map = {};
+ var envars = this.custom_config.filter(function(cvar) {
+ env_map[cvar.get('key')] = this.$('#' + cvar.id).val();
+ return cvar;
+ }, this);
+ this.model.set('env_map', env_map);
+ return $.Deferred().resolve();
}
});
RockonInstallSummary = RockstorWizardPage.extend({
initialize: function() {
- this.template = window.JST.rockons_install_summary;
- this.table_template = window.JST.rockons_summary_table;
- this.share_map = this.model.get('share_map');
- this.port_map = this.model.get('port_map');
- this.cc_map = this.model.get('cc_map');
- this.env_map = this.model.get('env_map');
- this.ports = this.model.get('ports');
- this.environment = this.model.get('environment');
- this.cc = this.model.get('custom_config');
- this.rockon = this.model.get('rockon');
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.template = window.JST.rockons_install_summary;
+ this.table_template = window.JST.rockons_summary_table;
+ this.share_map = this.model.get('share_map');
+ this.port_map = this.model.get('port_map');
+ this.cc_map = this.model.get('cc_map');
+ this.env_map = this.model.get('env_map');
+ this.ports = this.model.get('ports');
+ this.environment = this.model.get('environment');
+ this.cc = this.model.get('custom_config');
+ this.rockon = this.model.get('rockon');
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
},
render: function() {
- RockstorWizardPage.prototype.render.apply(this, arguments);
- this.$('#ph-summary-table').html(this.table_template({
- share_map: this.share_map,
- port_map: this.port_map,
- cc_map: this.cc_map,
- env_map: this.env_map}));
- return this;
+ RockstorWizardPage.prototype.render.apply(this, arguments);
+ this.$('#ph-summary-table').html(this.table_template({
+ share_map: this.share_map,
+ port_map: this.port_map,
+ cc_map: this.cc_map,
+ env_map: this.env_map
+ }));
+ return this;
},
save: function() {
- var _this = this;
- //$('button#next-page').prop('disable', true);
- document.getElementById('next-page').disabled = true;
- return $.ajax({
- url: '/api/rockons/' + this.rockon.id + '/install',
- type: 'POST',
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({
- 'ports': this.port_map,
- 'shares': this.share_map,
- 'cc': this.cc_map,
- 'environment': this.env_map
- }),
- success: function() {
- document.getElementById('next-page').disabled = false;
- },
- error: function(request, status, error) { }
- });
+ var _this = this;
+ //$('button#next-page').prop('disable', true);
+ document.getElementById('next-page').disabled = true;
+ return $.ajax({
+ url: '/api/rockons/' + this.rockon.id + '/install',
+ type: 'POST',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ 'ports': this.port_map,
+ 'shares': this.share_map,
+ 'cc': this.cc_map,
+ 'environment': this.env_map
+ }),
+ success: function() {
+ document.getElementById('next-page').disabled = false;
+ },
+ error: function(request, status, error) {}
+ });
},
});
RockonInstallComplete = RockstorWizardPage.extend({
initialize: function() {
- this.template = window.JST.rockons_install_complete;
- this.port_map = this.model.get('port_map');
- this.share_map = this.model.get('share_map');
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.template = window.JST.rockons_install_complete;
+ this.port_map = this.model.get('port_map');
+ this.share_map = this.model.get('share_map');
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
},
render: function() {
- $(this.el).html(this.template({
- model: this.model,
- port_map: this.port_map,
- share_map: this.share_map
- }));
- return this;
+ $(this.el).html(this.template({
+ model: this.model,
+ port_map: this.port_map,
+ share_map: this.share_map
+ }));
+ return this;
}
});
RockonInfoView = WizardView.extend({
initialize: function() {
- WizardView.prototype.initialize.apply(this, arguments);
- this.pages = [RockonInfoSummary,];
+ WizardView.prototype.initialize.apply(this, arguments);
+ this.pages = [RockonInfoSummary, ];
},
render: function() {
- WizardView.prototype.render.apply(this, arguments);
- return this;
+ WizardView.prototype.render.apply(this, arguments);
+ return this;
},
modifyButtonText: function() {
- this.$('#prev-page').hide();
- this.$('#next-page').hide();
+ this.$('#prev-page').hide();
+ this.$('#next-page').hide();
}
});
RockonSettingsWizardView = WizardView.extend({
initialize: function() {
- WizardView.prototype.initialize.apply(this, arguments);
- this.pages = [RockonSettingsSummary,];
- this.rockon = this.model.get('rockon');
- this.volumes = new RockOnVolumeCollection(null, {rid: this.rockon.id});
- this.ports = new RockOnPortCollection(null, {rid: this.rockon.id});
- this.custom_config = new RockOnCustomConfigCollection(null, {rid: this.rockon.id});
- this.environment = new RockOnEnvironmentCollection(null, {rid: this.rockon.id});
- this.shares = {};
- this.model.set('shares', this.shares);
+ WizardView.prototype.initialize.apply(this, arguments);
+ this.pages = [RockonSettingsSummary, ];
+ this.rockon = this.model.get('rockon');
+ this.volumes = new RockOnVolumeCollection(null, {
+ rid: this.rockon.id
+ });
+ this.ports = new RockOnPortCollection(null, {
+ rid: this.rockon.id
+ });
+ this.custom_config = new RockOnCustomConfigCollection(null, {
+ rid: this.rockon.id
+ });
+ this.environment = new RockOnEnvironmentCollection(null, {
+ rid: this.rockon.id
+ });
+ this.shares = {};
+ this.model.set('shares', this.shares);
},
fetchVolumes: function() {
- var _this = this;
- this.volumes.fetch({
- success: function () {
- _this.model.set('volumes', _this.volumes);
- _this.fetchPorts();
- }
- });
+ var _this = this;
+ this.volumes.fetch({
+ success: function() {
+ _this.model.set('volumes', _this.volumes);
+ _this.fetchPorts();
+ }
+ });
},
fetchPorts: function() {
- var _this = this;
- this.ports.fetch({
- success: function() {
- _this.model.set('ports', _this.ports);
- _this.fetchCustomConfig();
- }
- });
+ var _this = this;
+ this.ports.fetch({
+ success: function() {
+ _this.model.set('ports', _this.ports);
+ _this.fetchCustomConfig();
+ }
+ });
},
fetchCustomConfig: function() {
- var _this = this;
- this.custom_config.fetch({
- success: function() {
- _this.model.set('custom_config', _this.custom_config);
- _this.fetchEnvironment();
- }
- });
+ var _this = this;
+ this.custom_config.fetch({
+ success: function() {
+ _this.model.set('custom_config', _this.custom_config);
+ _this.fetchEnvironment();
+ }
+ });
},
fetchEnvironment: function() {
- var _this = this;
- this.environment.fetch({
- success: function() {
- _this.model.set('environment', _this.environment);
- _this.addPages();
- }
- });
+ var _this = this;
+ this.environment.fetch({
+ success: function() {
+ _this.model.set('environment', _this.environment);
+ _this.addPages();
+ }
+ });
},
render: function() {
- this.fetchVolumes();
- return this;
+ this.fetchVolumes();
+ return this;
},
addPages: function() {
- if (this.rockon.get('volume_add_support')) {
- this.pages.push.apply(this.pages,
- [RockonAddShare, RockonSettingsSummary,
- RockonSettingsComplete]);
- }
- WizardView.prototype.render.apply(this, arguments);
- return this;
+ if (this.rockon.get('volume_add_support')) {
+ this.pages.push.apply(this.pages, [RockonAddShare, RockonSettingsSummary,
+ RockonSettingsComplete
+ ]);
+ }
+ WizardView.prototype.render.apply(this, arguments);
+ return this;
},
setCurrentPage: function() {
- this.currentPage = new this.pages[this.currentPageNum]({
- model: this.model,
- parent: this,
- evAgg: this.evAgg
- });
+ this.currentPage = new this.pages[this.currentPageNum]({
+ model: this.model,
+ parent: this,
+ evAgg: this.evAgg
+ });
},
modifyButtonText: function() {
- if (this.currentPageNum == 0) {
- this.$('#prev-page').hide();
- this.$('#next-page').html('Add Storage');
- if (!this.rockon.get('volume_add_support')) {
- this.$('#next-page').hide();
- }else{
- if(this.rockon.get('status') == "started") {
- var _this = this;
- this.$('#next-page').click(function(){
- //disabling the button so that the backbone event is not triggered after the alert click.
- _this.$('#next-page').prop("disabled",true);
- alert("Rock-on must be turned off to add storage.");
- });
- }
- }
- } else if (this.currentPageNum == (this.pages.length - 2)) {
- this.$('#prev-page').html('Add Storage');
- this.$('#next-page').html('Next');
- } else if (this.currentPageNum == (this.pages.length - 1)) {
- this.$('#prev-page').hide();
- this.$('#next-page').html('Submit');
- } else {
- this.$('#prev-page').show();
- this.$('#next-page').html('Next');
- this.$('#ph-wizard-buttons').show();
- }
+ if (this.currentPageNum == 0) {
+ this.$('#prev-page').hide();
+ this.$('#next-page').html('Add Storage');
+ if (!this.rockon.get('volume_add_support')) {
+ this.$('#next-page').hide();
+ } else {
+ if (this.rockon.get('status') == 'started') {
+ var _this = this;
+ this.$('#next-page').click(function() {
+ //disabling the button so that the backbone event is not triggered after the alert click.
+ _this.$('#next-page').prop('disabled', true);
+ alert('Rock-on must be turned off to add storage.');
+ });
+ }
+ }
+ } else if (this.currentPageNum == (this.pages.length - 2)) {
+ this.$('#prev-page').html('Add Storage');
+ this.$('#next-page').html('Next');
+ } else if (this.currentPageNum == (this.pages.length - 1)) {
+ this.$('#prev-page').hide();
+ this.$('#next-page').html('Submit');
+ } else {
+ this.$('#prev-page').show();
+ this.$('#next-page').html('Next');
+ this.$('#ph-wizard-buttons').show();
+ }
},
lastPage: function() {
- return ((this.pages.length > 1)
- && ((this.pages.length-1) == this.currentPageNum));
+ return ((this.pages.length > 1) &&
+ ((this.pages.length - 1) == this.currentPageNum));
},
finish: function() {
- this.parent.$('#install-rockon-overlay').overlay().close();
- this.parent.render();
+ this.parent.$('#install-rockon-overlay').overlay().close();
+ this.parent.render();
}
});
RockonAddShare = RockstorWizardPage.extend({
initialize: function() {
- this.template = window.JST.rockons_add_shares;
- this.sub_template = window.JST.rockons_add_shares_form;
- this.shares = new ShareCollection();
- this.shares.setPageSize(100);
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
- this.shares.on('reset', this.renderShares, this);
+ this.template = window.JST.rockons_add_shares;
+ this.sub_template = window.JST.rockons_add_shares_form;
+ this.shares = new ShareCollection();
+ this.shares.setPageSize(100);
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.shares.on('reset', this.renderShares, this);
},
render: function() {
- RockstorWizardPage.prototype.render.apply(this, arguments);
- this.shares.fetch();
- return this;
+ RockstorWizardPage.prototype.render.apply(this, arguments);
+ this.shares.fetch();
+ return this;
},
renderShares: function() {
- this.share_map = this.model.get('shares');
- this.volumes = this.model.get('volumes');
- this.used_shares = [];
- var _this = this;
- this.volumes.each(function(volume, index) {
- _this.used_shares.push(volume.get('share_name'));
- });
- for (var s in this.share_map) {
- this.used_shares.push(s);
- }
- this.filtered_shares = this.shares.filter(function(share) {
- if (_this.used_shares.indexOf(share.get('name')) == -1) {
- return share;
- }
- }, this);
- this.$('#ph-add-shares-form').html(this.sub_template({
- shares: this.filtered_shares.map(function(s) { return s.toJSON() })
- }));
- this.share_form = this.$('#vol-select-form');
- this.validator = this.share_form.validate({
- rules: { "volume": "required",
- "share": "required" },
- messages: { "volume": "Must be a valid unix path. Eg: /data/media",
- "share": "Select an appropriate Share to map"}
- });
- return this;
+ this.share_map = this.model.get('shares');
+ this.volumes = this.model.get('volumes');
+ this.used_shares = [];
+ var _this = this;
+ this.volumes.each(function(volume, index) {
+ _this.used_shares.push(volume.get('share_name'));
+ });
+ for (var s in this.share_map) {
+ this.used_shares.push(s);
+ }
+ this.filtered_shares = this.shares.filter(function(share) {
+ if (_this.used_shares.indexOf(share.get('name')) == -1) {
+ return share;
+ }
+ }, this);
+ this.$('#ph-add-shares-form').html(this.sub_template({
+ shares: this.filtered_shares.map(function(s) {
+ return s.toJSON();
+ })
+ }));
+ this.share_form = this.$('#vol-select-form');
+ this.validator = this.share_form.validate({
+ rules: {
+ 'volume': 'required',
+ 'share': 'required'
+ },
+ messages: {
+ 'volume': 'Must be a valid unix path. Eg: /data/media',
+ 'share': 'Select an appropriate Share to map'
+ }
+ });
+ return this;
},
save: function() {
- if (!this.share_form.valid()) {
- this.validator.showErrors();
- return $.Deferred().reject();
- }
- this.share_map = this.model.get('shares');
- this.share_map[this.$('#volume').val()] = this.$('#share').val();
- this.model.set('shares', this.share_map);
- return $.Deferred().resolve();
+ if (!this.share_form.valid()) {
+ this.validator.showErrors();
+ return $.Deferred().reject();
+ }
+ this.share_map = this.model.get('shares');
+ this.share_map[this.$('#volume').val()] = this.$('#share').val();
+ this.model.set('shares', this.share_map);
+ return $.Deferred().resolve();
}
@@ -950,88 +997,88 @@ RockonAddShare = RockstorWizardPage.extend({
RockonInfoSummary = RockstorWizardPage.extend({
initialize: function() {
- this.template = window.JST.rockons_settings_summary;
- this.sub_template = window.JST.rockons_more_info;
- this.rockon = this.model.get('rockon');
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.template = window.JST.rockons_settings_summary;
+ this.sub_template = window.JST.rockons_more_info;
+ this.rockon = this.model.get('rockon');
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
},
render: function() {
- RockstorWizardPage.prototype.render.apply(this, arguments);
- this.$('#ph-settings-summary-table').html(this.sub_template({
- rockonMoreInfo: this.rockon.get('more_info')
- }));
- return this;
+ RockstorWizardPage.prototype.render.apply(this, arguments);
+ this.$('#ph-settings-summary-table').html(this.sub_template({
+ rockonMoreInfo: this.rockon.get('more_info')
+ }));
+ return this;
}
});
RockonSettingsSummary = RockstorWizardPage.extend({
initialize: function() {
- this.template = window.JST.rockons_settings_summary;
- this.sub_template = window.JST.rockons_settings_summary_table;
- this.rockon = this.model.get('rockon');
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
- this.initHandlebarHelpers();
+ this.template = window.JST.rockons_settings_summary;
+ this.sub_template = window.JST.rockons_settings_summary_table;
+ this.rockon = this.model.get('rockon');
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.initHandlebarHelpers();
},
render: function() {
- RockstorWizardPage.prototype.render.apply(this, arguments);
- this.$('#ph-settings-summary-table').html(this.sub_template({
- model: this.model,
- volumes: this.model.get('volumes').toJSON(),
- new_volumes: this.model.get('shares'),
- ports: this.model.get('ports').toJSON(),
- cc: this.model.get('custom_config').toJSON(),
- env: this.model.get('environment').toJSON(),
- rockon: this.model.get('rockon')
- }));
- return this;
+ RockstorWizardPage.prototype.render.apply(this, arguments);
+ this.$('#ph-settings-summary-table').html(this.sub_template({
+ model: this.model,
+ volumes: this.model.get('volumes').toJSON(),
+ new_volumes: this.model.get('shares'),
+ ports: this.model.get('ports').toJSON(),
+ cc: this.model.get('custom_config').toJSON(),
+ env: this.model.get('environment').toJSON(),
+ rockon: this.model.get('rockon')
+ }));
+ return this;
},
//@todo: remove this helper after finding out where new volumes is being used.
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_newVolumes', function(){
- var html = '';
- for (share in this.new_volumes) {
- html += '';
- html += 'Share ';
- html += '' + this.new_volumes[share] + ' ';
- html += '' + share + ' ';
- html += ' ';
- }
- return new Handlebars.SafeString(html);
- });
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_newVolumes', function() {
+ var html = '';
+ for (share in this.new_volumes) {
+ html += '';
+ html += 'Share ';
+ html += '' + this.new_volumes[share] + ' ';
+ html += '' + share + ' ';
+ html += ' ';
+ }
+ return new Handlebars.SafeString(html);
+ });
}
});
RockonSettingsComplete = RockstorWizardPage.extend({
initialize: function() {
- this.template = window.JST.rockons_update_complete;
- this.rockon = this.model.get('rockon');
- this.shares = this.model.get('shares');
- RockstorWizardPage.prototype.initialize.apply(this, arguments);
+ this.template = window.JST.rockons_update_complete;
+ this.rockon = this.model.get('rockon');
+ this.shares = this.model.get('shares');
+ RockstorWizardPage.prototype.initialize.apply(this, arguments);
},
render: function() {
- $(this.el).html(this.template({
- model: this.model
- }));
- return this;
+ $(this.el).html(this.template({
+ model: this.model
+ }));
+ return this;
},
save: function() {
- var _this = this;
- if (document.getElementById('next-page').disabled) return false;
- document.getElementById('next-page').disabled = true;
- return $.ajax({
- url: '/api/rockons/' + this.rockon.id + '/update',
- type: 'POST',
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({
- 'shares': this.shares
- }),
- success: function() {}
- });
+ var _this = this;
+ if (document.getElementById('next-page').disabled) return false;
+ document.getElementById('next-page').disabled = true;
+ return $.ajax({
+ url: '/api/rockons/' + this.rockon.id + '/update',
+ type: 'POST',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ 'shares': this.shares
+ }),
+ success: function() {}
+ });
}
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/rollback.js b/src/rockstor/storageadmin/static/storageadmin/js/views/rollback.js
index b21cd0715..fb0d9a0df 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/rollback.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/rollback.js
@@ -25,107 +25,115 @@
*/
RollbackView = RockstorLayoutView.extend({
- events: {
- 'click #js-cancel': 'cancel',
- 'click #js-confirm-rollback-submit': 'confirmRollback'
- },
+ events: {
+ 'click #js-cancel': 'cancel',
+ 'click #js-confirm-rollback-submit': 'confirmRollback'
+ },
- initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- // Templates
- this.template = window.JST.share_rollback;
- this.snapshot_list_template = window.JST.share_rollback_snapshot_list;
- // Dependencies
- this.share = new Share({shareName: this.options.shareName});
- this.collection = new SnapshotCollection();
- this.collection.pageSize = 10;
- this.collection.setUrl(this.options.shareName);
- this.dependencies.push(this.share);
- this.dependencies.push(this.collection);
- this.collection.on('reset', this.renderSnapshotList, this);
- this.initHandlebarHelpers();
- },
+ initialize: function() {
+ this.constructor.__super__.initialize.apply(this, arguments);
+ // Templates
+ this.template = window.JST.share_rollback;
+ this.snapshot_list_template = window.JST.share_rollback_snapshot_list;
+ // Dependencies
+ this.share = new Share({
+ shareName: this.options.shareName
+ });
+ this.collection = new SnapshotCollection();
+ this.collection.pageSize = 10;
+ this.collection.setUrl(this.options.shareName);
+ this.dependencies.push(this.share);
+ this.dependencies.push(this.collection);
+ this.collection.on('reset', this.renderSnapshotList, this);
+ this.initHandlebarHelpers();
+ },
- render: function() {
- this.fetch(this.renderRollback, this);
- return this;
- },
+ render: function() {
+ this.fetch(this.renderRollback, this);
+ return this;
+ },
- renderRollback: function() {
- var _this = this;
- $(this.el).html(this.template({
- collection: this.collection,
- shareName: this.share.get('name'),
- }));
- this.renderSnapshotList();
- this.$('#rollback-form').validate({
- onfocusout: false,
- onkeyup: false,
- rules: {
- snapshot: "required",
- },
- submitHandler: function() {
- var button = _this.$('#rollback-share');
- var snapName = _this.$('input:radio[name=snapshot]:checked').val();
- // set snap name in confirm dialog
- _this.$('#confirm-snap-name').html(snapName);
- // show confirm dialog
- _this.$('#confirm-rollback').modal();
- return false;
- }
- });
+ renderRollback: function() {
+ var _this = this;
+ $(this.el).html(this.template({
+ collection: this.collection,
+ shareName: this.share.get('name'),
+ }));
+ this.renderSnapshotList();
+ this.$('#rollback-form').validate({
+ onfocusout: false,
+ onkeyup: false,
+ rules: {
+ snapshot: 'required',
+ },
+ submitHandler: function() {
+ var button = _this.$('#rollback-share');
+ var snapName = _this.$('input:radio[name=snapshot]:checked').val();
+ // set snap name in confirm dialog
+ _this.$('#confirm-snap-name').html(snapName);
+ // show confirm dialog
+ _this.$('#confirm-rollback').modal();
+ return false;
+ }
+ });
- },
+ },
- renderSnapshotList: function() {
- this.$('#ph-snapshot-list').html(this.snapshot_list_template({
- rollbackSnaps: this.collection.toJSON(),
- collection: this.collection,
- collectionNotEmpty: !this.collection.isEmpty(),
- }));
- },
+ renderSnapshotList: function() {
+ this.$('#ph-snapshot-list').html(this.snapshot_list_template({
+ rollbackSnaps: this.collection.toJSON(),
+ collection: this.collection,
+ collectionNotEmpty: !this.collection.isEmpty(),
+ }));
+ },
- confirmRollback: function(event) {
- var _this = this;
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- disableButton(button);
- var snapName = this.$('input:radio[name=snapshot]:checked').val();
- $.ajax({
- url: '/api/shares/' + _this.share.get('name') + '/rollback',
- type: "POST",
- dataType: "json",
- contentType: 'application/json',
- data: JSON.stringify({name: snapName}),
- success: function() {
- enableButton(button);
- _this.$('#confirm-rollback').modal('hide');
- $('.modal-backdrop').remove();
- app_router.navigate('shares/' + _this.share.get('name'), {trigger: true})
+ confirmRollback: function(event) {
+ var _this = this;
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ var snapName = this.$('input:radio[name=snapshot]:checked').val();
+ $.ajax({
+ url: '/api/shares/' + _this.share.get('name') + '/rollback',
+ type: 'POST',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ name: snapName
+ }),
+ success: function() {
+ enableButton(button);
+ _this.$('#confirm-rollback').modal('hide');
+ $('.modal-backdrop').remove();
+ app_router.navigate('shares/' + _this.share.get('name'), {
+ trigger: true
+ });
- },
- error: function(xhr, status, error) {
- enableButton(button);
- },
- });
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ },
+ });
- },
+ },
- cancel: function(event) {
- if (event) event.preventDefault();
- app_router.navigate('shares/' + this.share.get('name'), {trigger: true})
- },
+ cancel: function(event) {
+ if (event) event.preventDefault();
+ app_router.navigate('shares/' + this.share.get('name'), {
+ trigger: true
+ });
+ },
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('getDate', function(toc){
- return moment(toc).format(RS_DATE_FORMAT);
- });
- Handlebars.registerHelper('humanReadableSize', function(size){
- return humanize.filesize(size * 1024);
- });
- }
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('getDate', function(toc) {
+ return moment(toc).format(RS_DATE_FORMAT);
+ });
+ Handlebars.registerHelper('humanReadableSize', function(size) {
+ return humanize.filesize(size * 1024);
+ });
+ }
});
//Add pagination
-Cocktail.mixin(RollbackView, PaginationMixin);
+Cocktail.mixin(RollbackView, PaginationMixin);
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/samba.js b/src/rockstor/storageadmin/static/storageadmin/js/views/samba.js
index e21527704..a9137f9fd 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/samba.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/samba.js
@@ -24,190 +24,194 @@
*
*/
-SambaView = RockstorLayoutView.extend({
- events: {
- 'switchChange.bootstrapSwitch': 'switchStatus',
- 'click .delete-samba-export' : 'deleteSambaExport'
- },
-
- initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.samba_samba;
- this.module_name = 'samba';
- this.collection = new SambaCollection();
- this.dependencies.push(this.collection);
- this.serviceName = 'smb';
- this.service = new Service({name: this.serviceName});
- this.dependencies.push(this.service);
- this.shares = new ShareCollection();
- this.dependencies.push(this.shares);
- this.updateFreq = 5000;
- this.collection.on("reset", this.renderSamba, this);
- this.initHandlebarHelpers();
- },
-
- render: function() {
- var _this = this;
- this.fetch(this.renderSamba, this);
- return this;
- },
-
- renderSamba: function() {
- this.freeShares = this.shares.reject(function(share) {
- s = this.collection.find(function(sambaShare) {
- return (sambaShare.get('share') == share.get('name'));
- });
- return !_.isUndefined(s);
- }, this);
-
- //check if there are shares in the system
- var sharesExistBool = false;
- if(this.shares.length > 0){
- sharesExistBool = true;
- }
- //check if there are free shares not associated with samba.
- var freeSharesBool = false;
- if(this.freeShares){
- freeSharesBool = true;
- }
- //set a variable to true if both conditions are satisfied
- var verifySharesBool = false;
- if(freeSharesBool && sharesExistBool){
- verifySharesBool = true;
- }
-
- $(this.el).html(this.template({
- samba: this.collection.toJSON(),
- collection: this.collection,
- collectionNotEmpty: !this.collection.isEmpty(),
- service: this.service,
- freeShares: this.freeShares,
- sharesNotEmpty : verifySharesBool
- }));
-
- this.renderDataTables();
-
- //initalize Bootstrap Switch
- this.$("[type='checkbox']").bootstrapSwitch();
- this.$('input[name="samba-export-checkbox"]').bootstrapSwitch('state', this.service.get('status'), true);
- this.$("[type='checkbox']").bootstrapSwitch('onColor','success'); //left side text color
- this.$("[type='checkbox']").bootstrapSwitch('offColor','danger'); //right side text color
-
- // Display NFS Export Service Warning
- if (!this.service.get('status')) {
- this.$('#samba-warning').show();
- } else {
- this.$('#samba-warning').hide();
- }
- },
-
- switchStatus: function(event,state){
- if (state){
- this.startService();
- }else {
- this.stopService();
- }
- },
-
- deleteSambaExport: function(event) {
- var _this = this;
- if (event) event.preventDefault();
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- if(confirm("Delete samba export... Are you sure? ")){
- disableButton(button)
- var id = $(event.currentTarget).data('id');
- $.ajax({
- url: '/api/samba/' + id,
- type: 'DELETE',
- dataType: 'json',
- contentType: 'application/json',
- success: function() {
- _this.render();
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- }
- },
-
- startService: function() {
- var _this = this;
- this.setStatusLoading(this.serviceName, true);
- $.ajax({
- url: "/api/sm/services/smb/start",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(_this.serviceName, false);
- _this.$('#samba-warning').hide();
- },
- error: function(xhr, status, error) {
- _this.setStatusError(_this.serviceName, xhr);
- _this.$('#samba-warning').show();
- }
- });
- },
-
- stopService: function() {
- var _this = this;
- this.setStatusLoading(this.serviceName, true);
- $.ajax({
- url: "/api/sm/services/smb/stop",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(_this.serviceName, false);
- _this.$('#samba-warning').show();
- },
- error: function(xhr, status, error) {
- _this.setStatusError(_this.serviceName, xhr);
- _this.$('#samba-warning').hide();
- }
- });
- },
-
- setStatusLoading: function(serviceName, show) {
- var statusEl = this.$('div.command-status[data-service-name="'+serviceName+'"]');
- if (show) {
- statusEl.html(' ');
- } else {
- statusEl.empty();
- }
- },
-
- setStatusError: function(serviceName, xhr) {
- var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
- var msg = parseXhrError(xhr);
- // remove any existing error popups
- $('body').find('#' + serviceName + 'err-popup').remove();
- // add icon and popup
- statusEl.empty();
- var icon = $('').addClass('icon-exclamation-sign').attr('rel', '#' + serviceName + '-err-popup');
- statusEl.append(icon);
- var errPopup = this.$('#' + serviceName + '-err-popup');
- var errPopupContent = this.$('#' + serviceName + '-err-popup > div');
- errPopupContent.html(msg);
- statusEl.click(function(){ errPopup.overlay().load(); });
- },
-
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('getAdminUsers', function(adminUsers){
- var html = '';
- var userNames = _.reduce(adminUsers, function(s, user, i, list) {
- if (i < (list.length-1)) {
- return s + user.username + ',';
- } else{
- return s + user.username;
- }
- }, '');
- if(userNames.length != 0){
- html += userNames;
- }else {
- html += ' --';
- }
- return new Handlebars.SafeString(html);
- });
- }
+SambaView = RockstorLayoutView.extend({
+ events: {
+ 'switchChange.bootstrapSwitch': 'switchStatus',
+ 'click .delete-samba-export': 'deleteSambaExport'
+ },
+
+ initialize: function() {
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.samba_samba;
+ this.module_name = 'samba';
+ this.collection = new SambaCollection();
+ this.dependencies.push(this.collection);
+ this.serviceName = 'smb';
+ this.service = new Service({
+ name: this.serviceName
+ });
+ this.dependencies.push(this.service);
+ this.shares = new ShareCollection();
+ this.dependencies.push(this.shares);
+ this.updateFreq = 5000;
+ this.collection.on('reset', this.renderSamba, this);
+ this.initHandlebarHelpers();
+ },
+
+ render: function() {
+ var _this = this;
+ this.fetch(this.renderSamba, this);
+ return this;
+ },
+
+ renderSamba: function() {
+ this.freeShares = this.shares.reject(function(share) {
+ s = this.collection.find(function(sambaShare) {
+ return (sambaShare.get('share') == share.get('name'));
+ });
+ return !_.isUndefined(s);
+ }, this);
+
+ //check if there are shares in the system
+ var sharesExistBool = false;
+ if (this.shares.length > 0) {
+ sharesExistBool = true;
+ }
+ //check if there are free shares not associated with samba.
+ var freeSharesBool = false;
+ if (this.freeShares) {
+ freeSharesBool = true;
+ }
+ //set a variable to true if both conditions are satisfied
+ var verifySharesBool = false;
+ if (freeSharesBool && sharesExistBool) {
+ verifySharesBool = true;
+ }
+
+ $(this.el).html(this.template({
+ samba: this.collection.toJSON(),
+ collection: this.collection,
+ collectionNotEmpty: !this.collection.isEmpty(),
+ service: this.service,
+ freeShares: this.freeShares,
+ sharesNotEmpty: verifySharesBool
+ }));
+
+ this.renderDataTables();
+
+ //initalize Bootstrap Switch
+ this.$('[type=\'checkbox\']').bootstrapSwitch();
+ this.$('input[name="samba-export-checkbox"]').bootstrapSwitch('state', this.service.get('status'), true);
+ this.$('[type=\'checkbox\']').bootstrapSwitch('onColor', 'success'); //left side text color
+ this.$('[type=\'checkbox\']').bootstrapSwitch('offColor', 'danger'); //right side text color
+
+ // Display NFS Export Service Warning
+ if (!this.service.get('status')) {
+ this.$('#samba-warning').show();
+ } else {
+ this.$('#samba-warning').hide();
+ }
+ },
+
+ switchStatus: function(event, state) {
+ if (state) {
+ this.startService();
+ } else {
+ this.stopService();
+ }
+ },
+
+ deleteSambaExport: function(event) {
+ var _this = this;
+ if (event) event.preventDefault();
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ if (confirm('Delete samba export... Are you sure? ')) {
+ disableButton(button);
+ var id = $(event.currentTarget).data('id');
+ $.ajax({
+ url: '/api/samba/' + id,
+ type: 'DELETE',
+ dataType: 'json',
+ contentType: 'application/json',
+ success: function() {
+ _this.render();
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ }
+ },
+
+ startService: function() {
+ var _this = this;
+ this.setStatusLoading(this.serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/smb/start',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(_this.serviceName, false);
+ _this.$('#samba-warning').hide();
+ },
+ error: function(xhr, status, error) {
+ _this.setStatusError(_this.serviceName, xhr);
+ _this.$('#samba-warning').show();
+ }
+ });
+ },
+
+ stopService: function() {
+ var _this = this;
+ this.setStatusLoading(this.serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/smb/stop',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(_this.serviceName, false);
+ _this.$('#samba-warning').show();
+ },
+ error: function(xhr, status, error) {
+ _this.setStatusError(_this.serviceName, xhr);
+ _this.$('#samba-warning').hide();
+ }
+ });
+ },
+
+ setStatusLoading: function(serviceName, show) {
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ if (show) {
+ statusEl.html(' ');
+ } else {
+ statusEl.empty();
+ }
+ },
+
+ setStatusError: function(serviceName, xhr) {
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ var msg = parseXhrError(xhr);
+ // remove any existing error popups
+ $('body').find('#' + serviceName + 'err-popup').remove();
+ // add icon and popup
+ statusEl.empty();
+ var icon = $('').addClass('icon-exclamation-sign').attr('rel', '#' + serviceName + '-err-popup');
+ statusEl.append(icon);
+ var errPopup = this.$('#' + serviceName + '-err-popup');
+ var errPopupContent = this.$('#' + serviceName + '-err-popup > div');
+ errPopupContent.html(msg);
+ statusEl.click(function() {
+ errPopup.overlay().load();
+ });
+ },
+
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('getAdminUsers', function(adminUsers) {
+ var html = '';
+ var userNames = _.reduce(adminUsers, function(s, user, i, list) {
+ if (i < (list.length - 1)) {
+ return s + user.username + ',';
+ } else {
+ return s + user.username;
+ }
+ }, '');
+ if (userNames.length != 0) {
+ html += userNames;
+ } else {
+ html += ' --';
+ }
+ return new Handlebars.SafeString(html);
+ });
+ }
});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/scheduled_tasks.js b/src/rockstor/storageadmin/static/storageadmin/js/views/scheduled_tasks.js
index 18672d730..b9a7887c0 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/scheduled_tasks.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/scheduled_tasks.js
@@ -25,164 +25,172 @@
*/
ScheduledTasksView = RockstorLayoutView.extend({
- events: {
- 'click .toggle-task': 'toggleEnabled',
- 'click a[data-action=delete]': 'deleteTask'
- },
+ events: {
+ 'click .toggle-task': 'toggleEnabled',
+ 'click a[data-action=delete]': 'deleteTask'
+ },
- initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.scheduled_tasks_task_defs;
- this.collection = new TaskDefCollection();
- this.tasks = new TaskCollection();
- this.dependencies.push(this.collection);
- this.dependencies.push(this.tasks);
- this.collection.on('reset', this.renderScheduledTasks, this);
- this.taskMap = {};
- this.initHandlebarHelpers();
- },
+ initialize: function() {
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.scheduled_tasks_task_defs;
+ this.collection = new TaskDefCollection();
+ this.tasks = new TaskCollection();
+ this.dependencies.push(this.collection);
+ this.dependencies.push(this.tasks);
+ this.collection.on('reset', this.renderScheduledTasks, this);
+ this.taskMap = {};
+ this.initHandlebarHelpers();
+ },
- render: function() {
- this.fetch(this.renderScheduledTasks, this);
- return this;
- },
+ render: function() {
+ this.fetch(this.renderScheduledTasks, this);
+ return this;
+ },
- renderScheduledTasks: function() {
- var _this = this;
- this.collection.each(function(taskDef, index) {
- var tmp = _this.tasks.filter(function(task) {
- return task.get('task_def') == taskDef.id;
- });
- _this.taskMap[taskDef.id] = _.sortBy(tmp, function(task) {
- return moment(task.get('start')).valueOf();
- }).reverse();
- });
- // remove existing tooltips
- if (this.$('[rel=tooltip]')) {
- this.$('[rel=tooltip]').tooltip('hide');
- }
- $(this.el).html(this.template({
- collection: this.collection,
- collectionNotEmpty: !this.collection.isEmpty(),
- taskMap: this.taskMap
- }));
- this.$('[rel=tooltip]').tooltip({ placement: 'bottom'});
+ renderScheduledTasks: function() {
+ var _this = this;
+ this.collection.each(function(taskDef, index) {
+ var tmp = _this.tasks.filter(function(task) {
+ return task.get('task_def') == taskDef.id;
+ });
+ _this.taskMap[taskDef.id] = _.sortBy(tmp, function(task) {
+ return moment(task.get('start')).valueOf();
+ }).reverse();
+ });
+ // remove existing tooltips
+ if (this.$('[rel=tooltip]')) {
+ this.$('[rel=tooltip]').tooltip('hide');
+ }
+ $(this.el).html(this.template({
+ collection: this.collection,
+ collectionNotEmpty: !this.collection.isEmpty(),
+ taskMap: this.taskMap
+ }));
+ this.$('[rel=tooltip]').tooltip({
+ placement: 'bottom'
+ });
- this.renderDataTables();
- },
+ this.renderDataTables();
+ },
- toggleEnabled: function(event) {
- var _this = this;
- if (event) { event.preventDefault(); }
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- disableButton(button);
- var taskId = $(event.currentTarget).attr("data-task-id");
- var enabled = $(event.currentTarget).attr('data-action') == 'enable'
- ? true : false;
- $.ajax({
- url: '/api/sm/tasks/' + taskId,
- type: 'PUT',
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({enabled: enabled}),
- success: function() {
- enableButton(button);
- _this.collection.fetch({
- success: function() {
- _this.renderScheduledTasks();
- }
- });
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- },
+ toggleEnabled: function(event) {
+ var _this = this;
+ if (event) {
+ event.preventDefault();
+ }
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ var taskId = $(event.currentTarget).attr('data-task-id');
+ var enabled = $(event.currentTarget).attr('data-action') == 'enable' ?
+ true : false;
+ $.ajax({
+ url: '/api/sm/tasks/' + taskId,
+ type: 'PUT',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ enabled: enabled
+ }),
+ success: function() {
+ enableButton(button);
+ _this.collection.fetch({
+ success: function() {
+ _this.renderScheduledTasks();
+ }
+ });
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ },
- deleteTask: function(event) {
- var _this = this;
- if (event) { event.preventDefault(); }
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- var taskId = $(event.currentTarget).attr("data-task-id");
- var taskName = $(event.currentTarget).attr("data-task-name");
- if(confirm("Delete task: " + taskName + ". Are you sure?")){
- $.ajax({
- url: '/api/sm/tasks/' + taskId,
- type: "DELETE",
- dataType: "json",
- success: function() {
- enableButton(button);
- _this.collection.fetch({
- success: function() {
- _this.renderScheduledTasks();
- }
- });
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- }
- },
+ deleteTask: function(event) {
+ var _this = this;
+ if (event) {
+ event.preventDefault();
+ }
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ var taskId = $(event.currentTarget).attr('data-task-id');
+ var taskName = $(event.currentTarget).attr('data-task-name');
+ if (confirm('Delete task: ' + taskName + '. Are you sure?')) {
+ $.ajax({
+ url: '/api/sm/tasks/' + taskId,
+ type: 'DELETE',
+ dataType: 'json',
+ success: function() {
+ enableButton(button);
+ _this.collection.fetch({
+ success: function() {
+ _this.renderScheduledTasks();
+ }
+ });
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ }
+ },
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_scheduledTasks_table', function(adminBool){
- var html = '',
- _this = this;
- this.collection.each(function(t) {
- var taskId = t.get('id'),
- taskName = t.get('name'),
- taskType = t.get('task_type'),
- jsonMeta = t.get('json_meta'),
- tId = t.id,
- taskMapId = _this.taskMap[tId];
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_scheduledTasks_table', function(adminBool) {
+ var html = '',
+ _this = this;
+ this.collection.each(function(t) {
+ var taskId = t.get('id'),
+ taskName = t.get('name'),
+ taskType = t.get('task_type'),
+ jsonMeta = t.get('json_meta'),
+ tId = t.id,
+ taskMapId = _this.taskMap[tId];
- html += '';
- html += '' + taskName + ' ';
- html += '' + taskType + ' ';
- if (taskType == 'snapshot') {
- html += '(' + JSON.parse(jsonMeta).share + ')';
- } else {
- html += '(' + JSON.parse(jsonMeta).pool + ')';
- }
- html += ' ';
- html += '' + prettyCron.toString(t.get('crontab')) + ' ';
- html += '' + render_cronwindow(t.get('crontabwindow')) + ' ';
- html += '';
- if (t.get('enabled')) {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '';
- if (taskMapId) {
- if (taskMapId.length > 0) {
- var task = taskMapId[0],
- taskState = task.get('state');
+ html += ' ';
+ html += '' + taskName + ' ';
+ html += '' + taskType + ' ';
+ if (taskType == 'snapshot') {
+ html += '(' + JSON.parse(jsonMeta).share + ')';
+ } else {
+ html += '(' + JSON.parse(jsonMeta).pool + ')';
+ }
+ html += ' ';
+ html += '' + prettyCron.toString(t.get('crontab')) + ' ';
+ html += '' + render_cronwindow(t.get('crontabwindow')) + ' ';
+ html += '';
+ if (t.get('enabled')) {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '';
+ if (taskMapId) {
+ if (taskMapId.length > 0) {
+ var task = taskMapId[0],
+ taskState = task.get('state');
- if (taskState != 'scheduled' && taskState != 'pending' && taskState != 'running' && taskState != 'finished') {
- html += ' ' + taskState + ' ';
- } else if (taskState == 'finished') {
- html += '' + moment(task.get('end')).fromNow() + ' ';
- } else {
- html += '' + taskState + ' ';
- }
- }
- }
- html += ' ';
- html += '';
- html += ' ';
- html += ' ';
+ if (taskState != 'scheduled' && taskState != 'pending' && taskState != 'running' && taskState != 'finished') {
+ html += ' ' + taskState + ' ';
+ } else if (taskState == 'finished') {
+ html += '' + moment(task.get('end')).fromNow() + ' ';
+ } else {
+ html += '' + taskState + ' ';
+ }
+ }
+ }
+ html += ' ';
+ html += '';
+ html += ' ';
+ html += ' ';
- html += ' ';
- html += ' ';
- });
- return new Handlebars.SafeString(html);
- });
- }
+ html += '';
+ html += '';
+ });
+ return new Handlebars.SafeString(html);
+ });
+ }
});
//Add pagination
@@ -190,29 +198,31 @@ Cocktail.mixin(ScheduledTasksView, PaginationMixin);
//Adding new inline func to render crontabwindow in a nice way and not just like a string
- function render_cronwindow(cwindow) {
- var rendercwindow;
- if (!cwindow || cwindow == "*-*-*-*-*-*") {
- rendercwindow = 'Run always'; //render always without other checks
- } else {
- var cwindow = cwindow.split('-');
- for (var i = 0; i < 4; i++) {
- if (cwindow[i] != '*' && cwindow[i].length == 1) { cwindow[i] = '0' + cwindow[i]; }
- }
- rendercwindow = ' ';
- if (cwindow[0] != '*') { //if hour start isn't always value the same do min start and hour min stop
- rendercwindow += 'from ' + cwindow[0] + ':' + cwindow[1];
- rendercwindow += ' to ' + cwindow[2] + ':' + cwindow[3];
- } else {
- rendercwindow += ' every hour';
- }
- rendercwindow += ' - ';
- if (cwindow[4] != '*') { //as for hour start, if day start isn't star then day stop too
- var dayname = ['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'];
- rendercwindow += dayname[cwindow[4]] + ' to ' + dayname[cwindow[5]];
- } else {
- rendercwindow += ' on every day';
- }
- }
- return rendercwindow;
- }
+function render_cronwindow(cwindow) {
+ var rendercwindow;
+ if (!cwindow || cwindow == '*-*-*-*-*-*') {
+ rendercwindow = 'Run always'; //render always without other checks
+ } else {
+ cwindow = cwindow.split('-');
+ for (var i = 0; i < 4; i++) {
+ if (cwindow[i] != '*' && cwindow[i].length == 1) {
+ cwindow[i] = '0' + cwindow[i];
+ }
+ }
+ rendercwindow = ' ';
+ if (cwindow[0] != '*') { //if hour start isn't always value the same do min start and hour min stop
+ rendercwindow += 'from ' + cwindow[0] + ':' + cwindow[1];
+ rendercwindow += ' to ' + cwindow[2] + ':' + cwindow[3];
+ } else {
+ rendercwindow += ' every hour';
+ }
+ rendercwindow += ' - ';
+ if (cwindow[4] != '*') { //as for hour start, if day start isn't star then day stop too
+ var dayname = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
+ rendercwindow += dayname[cwindow[4]] + ' to ' + dayname[cwindow[5]];
+ } else {
+ rendercwindow += ' on every day';
+ }
+ }
+ return rendercwindow;
+}
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/services.js b/src/rockstor/storageadmin/static/storageadmin/js/views/services.js
index 0c7543d50..a98389ef7 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/services.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/services.js
@@ -44,9 +44,9 @@ ServicesView = Backbone.View.extend({
this.smTs = null; // current timestamp of sm service
this.configurable_services = ['nis', 'ntpd', 'active-directory', 'ldap', 'snmpd', 'docker', 'smartd', 'smb', 'nut', 'replication', 'shellinaboxd', 'rockstor'];
this.tooltipMap = {
- 'active-directory': 'By turning this service on, the system will attempt to join the Active Directory domain using the credentials provided during configuration.',
- 'rockstor-bootstrap': 'Service responsible for bootstrapping Rockstor when the system starts.',
- 'ztask-daemon': 'Background service for tasks like Pool scrub.'
+ 'active-directory': 'By turning this service on, the system will attempt to join the Active Directory domain using the credentials provided during configuration.',
+ 'rockstor-bootstrap': 'Service responsible for bootstrapping Rockstor when the system starts.',
+ 'ztask-daemon': 'Background service for tasks like Pool scrub.'
};
this.initHandlebarHelpers();
},
@@ -103,28 +103,28 @@ ServicesView = Backbone.View.extend({
}));
//Initialize bootstrap switch
- this.$("[type='checkbox']").bootstrapSwitch();
- this.$("[type='checkbox']").bootstrapSwitch('onColor', 'success'); //left side text color
- this.$("[type='checkbox']").bootstrapSwitch('offColor', 'danger'); //right side text color
+ this.$('[type=\'checkbox\']').bootstrapSwitch();
+ this.$('[type=\'checkbox\']').bootstrapSwitch('onColor', 'success'); //left side text color
+ this.$('[type=\'checkbox\']').bootstrapSwitch('offColor', 'danger'); //right side text color
//added ext func to sort over input checkbox - found on DataTables pages
$.fn.dataTable.ext.order['dom-checkbox'] = function(settings, col) {
- return this.api().column(col, {
- order: 'index'
- }).nodes().map(function(td, i) {
- return $('input', td).prop('checked') ? '1' : '0';
- });
- }
- //Added columns definition for sorting purpose
+ return this.api().column(col, {
+ order: 'index'
+ }).nodes().map(function(td, i) {
+ return $('input', td).prop('checked') ? '1' : '0';
+ });
+ };
+ //Added columns definition for sorting purpose
$('table.data-table').DataTable({
- "iDisplayLength": 15,
- "aLengthMenu": [
+ 'iDisplayLength': 15,
+ 'aLengthMenu': [
[15, 30, 45, -1],
- [15, 30, 45, "All"]
+ [15, 30, 45, 'All']
],
- "columns": [
+ 'columns': [
null, {
- "orderDataType": "dom-checkbox"
+ 'orderDataType': 'dom-checkbox'
}
]
});
@@ -144,9 +144,9 @@ ServicesView = Backbone.View.extend({
var _this = this;
$.ajax({
- url: "/api/sm/services/" + serviceName + "/start",
- type: "POST",
- dataType: "json",
+ url: '/api/sm/services/' + serviceName + '/start',
+ type: 'POST',
+ dataType: 'json',
success: function(data, status, xhr) {
_this.setStatusLoading(serviceName, false);
if (serviceName == 'active-directory') {
@@ -163,9 +163,9 @@ ServicesView = Backbone.View.extend({
var _this = this;
$.ajax({
- url: "/api/sm/services/" + serviceName + "/stop",
- type: "POST",
- dataType: "json",
+ url: '/api/sm/services/' + serviceName + '/stop',
+ type: 'POST',
+ dataType: 'json',
success: function(data, status, xhr) {
_this.setStatusLoading(serviceName, false);
if (serviceName == 'active-directory') {
@@ -231,7 +231,7 @@ ServicesView = Backbone.View.extend({
}
return opts.inverse(this);
});
-
+
Handlebars.registerHelper('ifTooltipExist', function(serviceName, opts) {
if (serviceName in _this.tooltipMap) {
return opts.fn(this);
@@ -240,4 +240,4 @@ ServicesView = Backbone.View.extend({
}
});
}
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/setup_system.js b/src/rockstor/storageadmin/static/storageadmin/js/views/setup_system.js
index d2aff64db..ffd6e7e4b 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/setup_system.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/setup_system.js
@@ -25,33 +25,34 @@
*/
SetupSystemView = Backbone.View.extend({
- tagName: 'div',
-
- initialize: function() {
- this.template = window.JST.setup_system;
- this.sysinfo = this.options.sysinfo;
- },
+ tagName: 'div',
- render: function() {
- this.renderSystemSetup();
- return this;
- },
+ initialize: function() {
+ this.template = window.JST.setup_system;
+ this.sysinfo = this.options.sysinfo;
+ },
- renderSystemSetup: function() {
- var _this = this;
- $(this.el).html(this.template({sysinfo: this.sysinfo}));
- this.$('#set-hostname-form').validate({
- onfocusout: false,
- onkeyup: false,
- rules: {
- hostname: 'required'
- },
- submitHandler: function() {
- RockStorGlobals.hostname = _this.$('#hostname').val();
- return false;
- }
- });
- }
+ render: function() {
+ this.renderSystemSetup();
+ return this;
+ },
-});
+ renderSystemSetup: function() {
+ var _this = this;
+ $(this.el).html(this.template({
+ sysinfo: this.sysinfo
+ }));
+ this.$('#set-hostname-form').validate({
+ onfocusout: false,
+ onkeyup: false,
+ rules: {
+ hostname: 'required'
+ },
+ submitHandler: function() {
+ RockStorGlobals.hostname = _this.$('#hostname').val();
+ return false;
+ }
+ });
+ }
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/sftp.js b/src/rockstor/storageadmin/static/storageadmin/js/views/sftp.js
index 63349bb3f..5c7bdfe37 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/sftp.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/sftp.js
@@ -24,185 +24,189 @@
*
*/
-SFTPView = RockstorLayoutView.extend({
+SFTPView = RockstorLayoutView.extend({
events: {
- 'switchChange.bootstrapSwitch': 'switchStatus',
- 'click .delete-sftp-share': 'deleteSFTP'
+ 'switchChange.bootstrapSwitch': 'switchStatus',
+ 'click .delete-sftp-share': 'deleteSFTP'
},
initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.sftp_sftp;
- this.module_name = 'sftp';
- this.collection = new SFTPCollection();
- this.dependencies.push(this.collection);
- this.serviceName = 'sftp';
- this.service = new Service({name: this.serviceName});
- this.dependencies.push(this.service);
- this.shares = new ShareCollection();
- this.dependencies.push(this.shares);
- this.updateFreq = 5000;
- this.initHandlebarHelpers();
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.sftp_sftp;
+ this.module_name = 'sftp';
+ this.collection = new SFTPCollection();
+ this.dependencies.push(this.collection);
+ this.serviceName = 'sftp';
+ this.service = new Service({
+ name: this.serviceName
+ });
+ this.dependencies.push(this.service);
+ this.shares = new ShareCollection();
+ this.dependencies.push(this.shares);
+ this.updateFreq = 5000;
+ this.initHandlebarHelpers();
},
render: function() {
- var _this = this;
- this.fetch(this.renderSFTP, this);
- return this;
+ var _this = this;
+ this.fetch(this.renderSFTP, this);
+ return this;
},
renderSFTP: function() {
- this.freeShares = this.shares.reject(function(share) {
- s = this.collection.find(function(sftpShare) {
- return (sftpShare.get('share') == share.get('name'));
- });
- return !_.isUndefined(s);
- }, this);
-
- //check if there are shares in the system
- var sharesExistBool = false;
- if(this.shares.length > 0){
- sharesExistBool = true;
- }
- //check if there are free shares not associated with afp.
- var freeSharesBool = false;
- if(this.freeShares){
- freeSharesBool = true;
- }
- //set a variable to true if both conditions are satisfied
- var verifySharesBool = false;
- if(freeSharesBool && sharesExistBool){
- verifySharesBool = true;
- }
-
- $(this.el).html(this.template({
- sftpShare: this.collection.toJSON(),
- collection: this.collection,
- collectionNotEmpty: !this.collection.isEmpty(),
- freeShares: this.freeShares,
- sharesNotEmpty: verifySharesBool,
- service: this.service
- }));
-
- this.renderDataTables();
-
- //initalize Bootstrap Switch
- this.$("[type='checkbox']").bootstrapSwitch();
- this.$('input[name="sftp-service-checkbox"]').bootstrapSwitch('state', this.service.get('status'), true);
- this.$("[type='checkbox']").bootstrapSwitch('onColor','success'); //left side text color
- this.$("[type='checkbox']").bootstrapSwitch('offColor','danger'); //right side text color
-
- // Display NFS Export Service Warning
- if (!this.service.get('status')) {
- this.$('#sftp-warning').show();
- } else {
- this.$('#sftp-warning').hide();
- }
+ this.freeShares = this.shares.reject(function(share) {
+ s = this.collection.find(function(sftpShare) {
+ return (sftpShare.get('share') == share.get('name'));
+ });
+ return !_.isUndefined(s);
+ }, this);
+
+ //check if there are shares in the system
+ var sharesExistBool = false;
+ if (this.shares.length > 0) {
+ sharesExistBool = true;
+ }
+ //check if there are free shares not associated with afp.
+ var freeSharesBool = false;
+ if (this.freeShares) {
+ freeSharesBool = true;
+ }
+ //set a variable to true if both conditions are satisfied
+ var verifySharesBool = false;
+ if (freeSharesBool && sharesExistBool) {
+ verifySharesBool = true;
+ }
+
+ $(this.el).html(this.template({
+ sftpShare: this.collection.toJSON(),
+ collection: this.collection,
+ collectionNotEmpty: !this.collection.isEmpty(),
+ freeShares: this.freeShares,
+ sharesNotEmpty: verifySharesBool,
+ service: this.service
+ }));
+
+ this.renderDataTables();
+
+ //initalize Bootstrap Switch
+ this.$('[type=\'checkbox\']').bootstrapSwitch();
+ this.$('input[name="sftp-service-checkbox"]').bootstrapSwitch('state', this.service.get('status'), true);
+ this.$('[type=\'checkbox\']').bootstrapSwitch('onColor', 'success'); //left side text color
+ this.$('[type=\'checkbox\']').bootstrapSwitch('offColor', 'danger'); //right side text color
+
+ // Display NFS Export Service Warning
+ if (!this.service.get('status')) {
+ this.$('#sftp-warning').show();
+ } else {
+ this.$('#sftp-warning').hide();
+ }
},
- switchStatus: function(event,state){
- if (state){
- this.startService();
- }else {
- this.stopService();
- }
+ switchStatus: function(event, state) {
+ if (state) {
+ this.startService();
+ } else {
+ this.stopService();
+ }
},
deleteSFTP: function(event) {
- var _this = this;
- if (event) event.preventDefault();
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- if(confirm("Delete sftp entry ... Are you sure? ")){
- disableButton(button)
- var id = $(event.currentTarget).data('id');
-
- $.ajax({
- url: '/api/sftp/' + id,
- type: 'DELETE',
- dataType: 'json',
- contentType: 'application/json',
- success: function() {
- _this.render();
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
-
- }
+ var _this = this;
+ if (event) event.preventDefault();
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ if (confirm('Delete sftp entry ... Are you sure? ')) {
+ disableButton(button);
+ var id = $(event.currentTarget).data('id');
+
+ $.ajax({
+ url: '/api/sftp/' + id,
+ type: 'DELETE',
+ dataType: 'json',
+ contentType: 'application/json',
+ success: function() {
+ _this.render();
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+
+ }
},
startService: function() {
- var _this = this;
- this.setStatusLoading(this.serviceName, true);
- $.ajax({
- url: "/api/sm/services/sftp/start",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(_this.serviceName, false);
- _this.$('#sftp-warning').hide();
- },
- error: function(xhr, status, error) {
- _this.setStatusError(_this.serviceName, xhr);
- _this.$('#sftp-warning').show();
- }
- });
+ var _this = this;
+ this.setStatusLoading(this.serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/sftp/start',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(_this.serviceName, false);
+ _this.$('#sftp-warning').hide();
+ },
+ error: function(xhr, status, error) {
+ _this.setStatusError(_this.serviceName, xhr);
+ _this.$('#sftp-warning').show();
+ }
+ });
},
stopService: function() {
- var _this = this;
- this.setStatusLoading(this.serviceName, true);
- $.ajax({
- url: "/api/sm/services/sftp/stop",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(_this.serviceName, false);
- _this.$('#sftp-warning').show();
- },
- error: function(xhr, status, error) {
- _this.setStatusError(_this.serviceName, xhr);
- _this.$('#sftp-warning').hide();
- }
- });
+ var _this = this;
+ this.setStatusLoading(this.serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/sftp/stop',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(_this.serviceName, false);
+ _this.$('#sftp-warning').show();
+ },
+ error: function(xhr, status, error) {
+ _this.setStatusError(_this.serviceName, xhr);
+ _this.$('#sftp-warning').hide();
+ }
+ });
},
setStatusLoading: function(serviceName, show) {
- var statusEl = this.$('div.command-status[data-service-name="'+serviceName+'"]');
- if (show) {
- statusEl.html(' ');
- } else {
- statusEl.empty();
- }
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ if (show) {
+ statusEl.html(' ');
+ } else {
+ statusEl.empty();
+ }
},
setStatusError: function(serviceName, xhr) {
- var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
- var msg = parseXhrError(xhr);
- // remove any existing error popups
- $('body').find('#' + serviceName + 'err-popup').remove();
- // add icon and popup
- statusEl.empty();
- var icon = $('').addClass('icon-exclamation-sign').attr('rel', '#' + serviceName + '-err-popup');
- statusEl.append(icon);
- var errPopup = this.$('#' + serviceName + '-err-popup');
- var errPopupContent = this.$('#' + serviceName + '-err-popup > div');
- errPopupContent.html(msg);
- statusEl.click(function(){ errPopup.overlay().load(); });
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ var msg = parseXhrError(xhr);
+ // remove any existing error popups
+ $('body').find('#' + serviceName + 'err-popup').remove();
+ // add icon and popup
+ statusEl.empty();
+ var icon = $('').addClass('icon-exclamation-sign').attr('rel', '#' + serviceName + '-err-popup');
+ statusEl.append(icon);
+ var errPopup = this.$('#' + serviceName + '-err-popup');
+ var errPopupContent = this.$('#' + serviceName + '-err-popup > div');
+ errPopupContent.html(msg);
+ statusEl.click(function() {
+ errPopup.overlay().load();
+ });
},
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('displaySftpPermission', function(sftpEditable){
- var html = '';
- if (sftpEditable == 'ro') {
- html += 'Read only';
- } else {
- html += 'Writable';
- }
- return new Handlebars.SafeString(html);
- });
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('displaySftpPermission', function(sftpEditable) {
+ var html = '';
+ if (sftpEditable == 'ro') {
+ html += 'Read only';
+ } else {
+ html += 'Writable';
+ }
+ return new Handlebars.SafeString(html);
+ });
}
});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/share_details_layout_view.js b/src/rockstor/storageadmin/static/storageadmin/js/views/share_details_layout_view.js
index 2070bae86..a2b539d63 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/share_details_layout_view.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/share_details_layout_view.js
@@ -24,537 +24,566 @@
*
*/
ShareDetailsLayoutView = RockstorLayoutView.extend({
- id: "share-details-container",
- events: {
- "click #js-acl-edit": "editAcl",
- "click #js-acl-save": "saveAcl",
- "click #js-acl-cancel": "cancelAcl",
- "click input[name='perms[]']": "showPermStr",
- "click #js-edit-compression": "editCompression",
- "click #js-edit-compression-cancel": "editCompressionCancel",
- "click #js-submit-compression": "updateCompression",
- "click #js-delete": "deleteShare",
- "click #js-cancel": "cancel",
- "click #js-confirm-share-delete": "confirmShareDelete",
- },
-
- initialize: function() {
- // call initialize of base
- this.constructor.__super__.initialize.apply(this, arguments);
- this.shareName = this.options.shareName;
- this.template = window.JST.share_share_details_layout;
- this.rollback_btn_template = window.JST.share_share_details_rollback_btn;
- this.shareAclTemplate = window.JST.share_share_acl;
- this.shareAclEditTemplate = window.JST.share_share_acl_edit;
- this.compression_info_template = window.JST.share_compression_info;
- this.compression_info_edit_template = window.JST.share_compression_info_edit;
- this.appliances = new ApplianceCollection();
- this.appliances.pageSize = RockStorGlobals.maxPageSize;
-
- // create models
- this.share = new Share({shareName: this.shareName});
- this.snapshots = new SnapshotCollection([]);
- this.snapshots.setUrl(this.shareName);
-
- this.users = new UserCollection();
- this.users.pageSize = RockStorGlobals.maxPageSize;
- this.groups = new GroupCollection();
- this.groups.pageSize = RockStorGlobals.maxPageSize;
- // add dependencies
- this.dependencies.push(this.share);
- this.dependencies.push(this.snapshots);
- this.dependencies.push(this.users);
- this.dependencies.push(this.groups);
- //this.dependencies.push(this.iscsi_target);
- this.dependencies.push(this.appliances);
- this.modify_choices = [
- {name: 'ro', value: 'ro'},
- {name: 'rw', value: 'rw'},
- ];
- this.sync_choices = [
- {name: 'async', value: 'async'},
- {name: 'sync', value: 'sync'},
- ];
- this.nsecurity_choices = [
- {name: 'secure', value: 'secure'},
- {name: 'insecure', value: 'insecure'},
- ];
- this.on('snapshotsModified', this.renderRollbackBtn, this);
- this.cOpts = {'no': 'Dont enable compression', 'zlib': 'zlib', 'lzo': 'lzo'};
- this.cView = this.options.cView;
- this.initHandlebarHelpers();
- },
-
- render: function() {
- this.fetch(this.renderSubViews, this);
- return this;
- },
-
- renderSubViews: function() {
- var current_appliance = this.appliances.find(function(appliance) {
- return appliance.get('current_appliance') == true;
- });
+ id: 'share-details-container',
+ events: {
+ 'click #js-acl-edit': 'editAcl',
+ 'click #js-acl-save': 'saveAcl',
+ 'click #js-acl-cancel': 'cancelAcl',
+ 'click input[name=\'perms[]\']': 'showPermStr',
+ 'click #js-edit-compression': 'editCompression',
+ 'click #js-edit-compression-cancel': 'editCompressionCancel',
+ 'click #js-submit-compression': 'updateCompression',
+ 'click #js-delete': 'deleteShare',
+ 'click #js-cancel': 'cancel',
+ 'click #js-confirm-share-delete': 'confirmShareDelete',
+ },
+
+ initialize: function() {
+ // call initialize of base
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.shareName = this.options.shareName;
+ this.template = window.JST.share_share_details_layout;
+ this.rollback_btn_template = window.JST.share_share_details_rollback_btn;
+ this.shareAclTemplate = window.JST.share_share_acl;
+ this.shareAclEditTemplate = window.JST.share_share_acl_edit;
+ this.compression_info_template = window.JST.share_compression_info;
+ this.compression_info_edit_template = window.JST.share_compression_info_edit;
+ this.appliances = new ApplianceCollection();
+ this.appliances.pageSize = RockStorGlobals.maxPageSize;
+
+ // create models
+ this.share = new Share({
+ shareName: this.shareName
+ });
+ this.snapshots = new SnapshotCollection([]);
+ this.snapshots.setUrl(this.shareName);
+
+ this.users = new UserCollection();
+ this.users.pageSize = RockStorGlobals.maxPageSize;
+ this.groups = new GroupCollection();
+ this.groups.pageSize = RockStorGlobals.maxPageSize;
+ // add dependencies
+ this.dependencies.push(this.share);
+ this.dependencies.push(this.snapshots);
+ this.dependencies.push(this.users);
+ this.dependencies.push(this.groups);
+ //this.dependencies.push(this.iscsi_target);
+ this.dependencies.push(this.appliances);
+ this.modify_choices = [{
+ name: 'ro',
+ value: 'ro'
+ },
+ {
+ name: 'rw',
+ value: 'rw'
+ },
+ ];
+ this.sync_choices = [{
+ name: 'async',
+ value: 'async'
+ },
+ {
+ name: 'sync',
+ value: 'sync'
+ },
+ ];
+ this.nsecurity_choices = [{
+ name: 'secure',
+ value: 'secure'
+ },
+ {
+ name: 'insecure',
+ value: 'insecure'
+ },
+ ];
+ this.on('snapshotsModified', this.renderRollbackBtn, this);
+ this.cOpts = {
+ 'no': 'Dont enable compression',
+ 'zlib': 'zlib',
+ 'lzo': 'lzo'
+ };
+ this.cView = this.options.cView;
+ this.initHandlebarHelpers();
+ },
+
+ render: function() {
+ this.fetch(this.renderSubViews, this);
+ return this;
+ },
+
+ renderSubViews: function() {
+ var current_appliance = this.appliances.find(function(appliance) {
+ return appliance.get('current_appliance') == true;
+ });
var systemShare = false;
if (parseInt(this.share.get('id')) < 3 && this.share.get('pool')['role'] == 'root') {
systemShare = true;
}
- this.subviews['share-usage'] = new ShareUsageModule({ share: this.share });
- this.subviews['snapshots'] = new SnapshotsTableModule({
- snapshots: this.snapshots,
- share: this.share,
- parentView: this
- });
- this.share.on('change', this.subviews['share-usage'].render, this.subviews['share-usage']);
- $(this.el).html(this.template({
- share: this.share,
- shareName: this.share.get('name'),
- shareUsage: humanize.filesize(this.share.get('rusage')*1024),
- snapshots: this.snapshots,
- permStr: this.parsePermStr(this.share.get("perms")),
- modify_choices: this.modify_choices,
- sync_choices: this.sync_choices,
- nsecurity_choices: this.nsecurity_choices,
+ this.subviews['share-usage'] = new ShareUsageModule({
+ share: this.share
+ });
+ this.subviews['snapshots'] = new SnapshotsTableModule({
+ snapshots: this.snapshots,
+ share: this.share,
+ parentView: this
+ });
+ this.share.on('change', this.subviews['share-usage'].render, this.subviews['share-usage']);
+ $(this.el).html(this.template({
+ share: this.share,
+ shareName: this.share.get('name'),
+ shareUsage: humanize.filesize(this.share.get('rusage') * 1024),
+ snapshots: this.snapshots,
+ permStr: this.parsePermStr(this.share.get('perms')),
+ modify_choices: this.modify_choices,
+ sync_choices: this.sync_choices,
+ nsecurity_choices: this.nsecurity_choices,
isSystemShare: systemShare
- }));
- this.renderRollbackBtn();
- this.renderAcl();
- this.$('#ph-share-usage').html(this.subviews['share-usage'].render().el);
- this.$('#ph-snapshots').html(this.subviews['snapshots'].render().el);
- this.shareCompressBool = false;
- if(_.isNull(this.share.get('compression_algo')) || this.share.get('compression_algo') == 'no'){
- this.shareCompressBool = true;
- }
- if (!_.isUndefined(this.cView) && this.cView == 'edit') {
- this.$('#ph-compression-info').html(this.compression_info_edit_template({
- share: this.share,
- cOpts: this.cOpts
- }));
- this.showCompressionTooltips();
- } else {
- this.$('#ph-compression-info').html(this.compression_info_template({
- share: this.share,
- shareCompression: this.share.get('compression_algo'),
- shareCompressionNull: this.shareCompressBool,
- }));
- }
- this.$("ul.nav.nav-tabs").tabs("div.css-panes > div");
- this.attachActions();
- },
-
- renderRollbackBtn: function() {
- var foundWritableSnapshot,
- rollbackBtnDisabler = false;
- if (!_.isUndefined(this.snapshots.find(function(s) { return s.get('writable') == true;}))) {
- foundWritableSnapshot = true;
- }
- if(this.snapshots.isEmpty() || !foundWritableSnapshot){
- rollbackBtnDisabler = true;
- }
- this.$('#rollback-btn-ph').html(this.rollback_btn_template({
- foundWritableSnapshot: foundWritableSnapshot,
- shareName: this.share.get('name'),
- rollbackBtnDisabler: rollbackBtnDisabler,
- }));
-
- },
-
- attachActions: function() {
- var _this = this;
- // attach overlays
- this.$('#js-access-control').overlay();
- // create snapshot form submit action
- this.$('#create-snapshot').click(function() {
- var button = _this.$('#create-snapshot');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- $.ajax({
- url: "/api/shares/" + _this.share.get('name') + "/snapshots/" + $('#snapshot-name').val(),
- type: "POST",
- dataType: "json"
- }).done(function() {
- enableButton(button);
- _this.$('#js-snapshot-popup').overlay().close();
- _this.snapshots.fetch();
- //_this.$('#snapshots').empty().append(_this.snapshotsTableView.render().el);
- }).fail(function() {
- enableButton(button);
- });
- });
- },
-
- deleteShare: function(event){
- var _this = this;
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- // show modal
- _this.$('#delete-share-modal').modal();
- return false;
- },
-
- confirmShareDelete: function(event) {
- var _this = this;
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- disableButton(button);
- var url = "/api/shares/" + _this.share.get('name');
- if($("#force-delete").prop("checked")){
- url += "/force";
- }
- $.ajax({
- url: url,
- type: "DELETE",
- dataType: "json",
- success: function() {
- enableButton(button);
- _this.$('#delete-share-modal').modal('hide');
- $('.modal-backdrop').remove();
- app_router.navigate('shares', {trigger: true})
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- },
- cancel: function(event) {
- if (event) event.preventDefault();
- app_router.navigate('shares', {trigger: true})
- },
-
- renderAcl: function() {
- this.$("#ph-access-control").html(this.shareAclTemplate({
- share: this.share,
- shareOwner: this.share.get("owner"),
- shareGroup: this.share.get("group"),
- sharePerms: this.share.get("perms"),
- permStr: this.parsePermStr(this.share.get("perms")),
- }));
- },
-
- editAcl: function(event) {
- event.preventDefault();
- this.$("#ph-access-control").html(this.shareAclEditTemplate({
- share: this.share.toJSON(),
- permStr: this.parsePermStr(this.share.get("perms")),
- users: this.users.toJSON(),
- groups: this.groups.toJSON(),
- sharePerms: this.share.get("perms"),
- }));
- },
-
- saveAcl: function(event) {
- event.preventDefault();
- var _this = this;
- var button = _this.$('#js-acl-save');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- var permStr = this.createPermStr();
- var data = {
- owner: this.$("#share-owner").val(),
- group: this.$("#share-group").val(),
- perms: permStr
- }
- $.ajax({
- url: "/api/shares/"+this.share.get("name")+"/acl",
- type: "POST",
- data: data,
- dataType: "json",
- success: function() {
- enableButton(button);
- _this.share.fetch({
- success: function() {
- _this.renderAcl();
- }
- });
- },
- error: function(request, status, error) {
- enableButton(button);
- }
- });
- },
-
- cancelAcl: function(event) {
- event.preventDefault();
- this.$("#ph-access-control").html(this.shareAclTemplate({
- share: this.share,
- permStr: this.parsePermStr(this.share.get("perms")),
- }));
- },
-
- parsePermStr: function(perms) {
- var p = "";
- for (var i=0; i<3; i++) {
- var tmp = parseInt(perms.charAt(i)).toString(2);
- p = (tmp.length == 3) ? p.concat(tmp) :
- (tmp.length == 2) ? p.concat("0").concat(tmp) :
- p.concat("00").concat(tmp);
- }
- return p;
- },
-
- createPermStr: function() {
- var perms = [];
- this.$("input[name='perms[]']:checked").each(function() {
- perms.push($(this).val());
- });
- var us = ["owner","group","other"];
- var ps = ["r","w","x"];
- var permStr = "";
- _.each(us, function(u) {
- var t = "";
- _.each(ps, function(p) {
- var s = u + "-" + p;
- t = t + (perms.indexOf(s) != -1 ? "1" : "0");
- });
- permStr = permStr + parseInt(t,2);
- });
- return permStr;
- },
-
- showPermStr: function() {
- this.$("#permStrEdit").html(this.createPermStr());
- },
-
- showCompressionTooltips: function() {
- this.$('#ph-compression-info #compression').tooltip({
- html: true,
- placement: 'top',
- title: "Choose a compression algorithm for this Share. By default, parent pool's compression algorithm is applied. If you like to set pool wide compression, don't choose anything here. If you want finer control of this particular Share's compression algorithm, you can set it here.zlib: slower but higher compression ratio.lzo: faster compression/decompression, but compression ratio is lower than zlib."
- });
- },
-
- hideCompressionTooltips: function() {
- this.$('#ph-compression-info #compression').tooltip('hide');
- },
-
- editCompression: function(event) {
- event.preventDefault();
- this.$('#ph-compression-info').html(this.compression_info_edit_template({
- share: this.share,
- cOpts: this.cOpts
- }));
- this.showCompressionTooltips();
- },
-
- editCompressionCancel: function(event) {
- event.preventDefault();
- this.hideCompressionTooltips();
- this.$('#ph-compression-info').html(this.compression_info_template({
- share: this.share,
- shareCompression: this.share.get('compression_algo'),
- shareCompressionNull: this.shareCompressBool,
- }));
- },
-
- updateCompression: function(event) {
- var _this = this;
- event.preventDefault();
- var button = this.$('#js-submit-compression');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- $.ajax({
- url: "/api/shares/" + this.share.get('name'),
- type: "PUT",
- dataType: "json",
- data: {
- "compression": this.$('#compression').val(),
- },
- success: function() {
- _this.hideCompressionTooltips();
- _this.share.fetch({
- success: function(collection, response, options) {
- _this.cView = 'view';
- _this.renderSubViews();
- }
- });
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
- },
-
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_share_compressOptions', function(){
- var html = '',
- _this = this;
- _.each(_.keys(_this.cOpts), function(c) {
- if (_this.share.get('compression_algo') == c) {
- html += '' + _this.cOpts[c] + ' ';
- } else {
- html += '' + _this.cOpts[c] + ' ';
- }
- });
- return new Handlebars.SafeString(html);
- });
-
- Handlebars.registerHelper('view_read_permissions', function(){
- var html = '';
- html += ' ';
- if (this.permStr[0] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[3] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[6] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- return new Handlebars.SafeString(html);
- });
-
- Handlebars.registerHelper('view_write_permissions', function(){
- var html = '';
- html += '
';
- if (this.permStr[1] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[4] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[7] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- return new Handlebars.SafeString(html);
- });
-
- Handlebars.registerHelper('view_execute_permissions', function(){
- var html = '';
- html += '
';
- if (this.permStr[2] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[5] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[8] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- return new Handlebars.SafeString(html);
- });
-
-
- Handlebars.registerHelper('showOwnerOption', function(userName, shareOwner){
- if(userName == shareOwner){
- return 'selected = "selected"';
- }
- });
-
- Handlebars.registerHelper('showGroupOption', function(groupName, shareGroup){
- if(groupName == shareGroup){
- return 'selected = "selected"';
- }
- });
-
- Handlebars.registerHelper('edit_read_permissions', function(){
- var html = '';
- html += '
';
- if (this.permStr[0] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[3] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[6] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- return new Handlebars.SafeString(html);
- });
-
- Handlebars.registerHelper('edit_write_permissions', function(){
- var html = '';
- html += '
';
- if (this.permStr[1] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[4] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[7] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- return new Handlebars.SafeString(html);
- });
-
- Handlebars.registerHelper('edit_execute_permissions', function(){
- var html = '';
- html += '
';
- if (this.permStr[2] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[5] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- html += '
';
- if (this.permStr[8] == "1") {
- html += ' ';
- } else {
- html += ' ';
- }
- html += ' ';
- return new Handlebars.SafeString(html);
- });
- }
-
-});
+ }));
+ this.renderRollbackBtn();
+ this.renderAcl();
+ this.$('#ph-share-usage').html(this.subviews['share-usage'].render().el);
+ this.$('#ph-snapshots').html(this.subviews['snapshots'].render().el);
+ this.shareCompressBool = false;
+ if (_.isNull(this.share.get('compression_algo')) || this.share.get('compression_algo') == 'no') {
+ this.shareCompressBool = true;
+ }
+ if (!_.isUndefined(this.cView) && this.cView == 'edit') {
+ this.$('#ph-compression-info').html(this.compression_info_edit_template({
+ share: this.share,
+ cOpts: this.cOpts
+ }));
+ this.showCompressionTooltips();
+ } else {
+ this.$('#ph-compression-info').html(this.compression_info_template({
+ share: this.share,
+ shareCompression: this.share.get('compression_algo'),
+ shareCompressionNull: this.shareCompressBool,
+ }));
+ }
+ this.$('ul.nav.nav-tabs').tabs('div.css-panes > div');
+ this.attachActions();
+ },
+
+ renderRollbackBtn: function() {
+ var foundWritableSnapshot,
+ rollbackBtnDisabler = false;
+ if (!_.isUndefined(this.snapshots.find(function(s) {
+ return s.get('writable') == true;
+ }))) {
+ foundWritableSnapshot = true;
+ }
+ if (this.snapshots.isEmpty() || !foundWritableSnapshot) {
+ rollbackBtnDisabler = true;
+ }
+ this.$('#rollback-btn-ph').html(this.rollback_btn_template({
+ foundWritableSnapshot: foundWritableSnapshot,
+ shareName: this.share.get('name'),
+ rollbackBtnDisabler: rollbackBtnDisabler,
+ }));
+
+ },
+
+ attachActions: function() {
+ var _this = this;
+ // attach overlays
+ this.$('#js-access-control').overlay();
+ // create snapshot form submit action
+ this.$('#create-snapshot').click(function() {
+ var button = _this.$('#create-snapshot');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ $.ajax({
+ url: '/api/shares/' + _this.share.get('name') + '/snapshots/' + $('#snapshot-name').val(),
+ type: 'POST',
+ dataType: 'json'
+ }).done(function() {
+ enableButton(button);
+ _this.$('#js-snapshot-popup').overlay().close();
+ _this.snapshots.fetch();
+ //_this.$('#snapshots').empty().append(_this.snapshotsTableView.render().el);
+ }).fail(function() {
+ enableButton(button);
+ });
+ });
+ },
+
+ deleteShare: function(event) {
+ var _this = this;
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ // show modal
+ _this.$('#delete-share-modal').modal();
+ return false;
+ },
+
+ confirmShareDelete: function(event) {
+ var _this = this;
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ var url = '/api/shares/' + _this.share.get('name');
+ if ($('#force-delete').prop('checked')) {
+ url += '/force';
+ }
+ $.ajax({
+ url: url,
+ type: 'DELETE',
+ dataType: 'json',
+ success: function() {
+ enableButton(button);
+ _this.$('#delete-share-modal').modal('hide');
+ $('.modal-backdrop').remove();
+ app_router.navigate('shares', {
+ trigger: true
+ });
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ },
+ cancel: function(event) {
+ if (event) event.preventDefault();
+ app_router.navigate('shares', {
+ trigger: true
+ });
+ },
+
+ renderAcl: function() {
+ this.$('#ph-access-control').html(this.shareAclTemplate({
+ share: this.share,
+ shareOwner: this.share.get('owner'),
+ shareGroup: this.share.get('group'),
+ sharePerms: this.share.get('perms'),
+ permStr: this.parsePermStr(this.share.get('perms')),
+ }));
+ },
+
+ editAcl: function(event) {
+ event.preventDefault();
+ this.$('#ph-access-control').html(this.shareAclEditTemplate({
+ share: this.share.toJSON(),
+ permStr: this.parsePermStr(this.share.get('perms')),
+ users: this.users.toJSON(),
+ groups: this.groups.toJSON(),
+ sharePerms: this.share.get('perms'),
+ }));
+ },
+
+ saveAcl: function(event) {
+ event.preventDefault();
+ var _this = this;
+ var button = _this.$('#js-acl-save');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ var permStr = this.createPermStr();
+ var data = {
+ owner: this.$('#share-owner').val(),
+ group: this.$('#share-group').val(),
+ perms: permStr
+ };
+ $.ajax({
+ url: '/api/shares/' + this.share.get('name') + '/acl',
+ type: 'POST',
+ data: data,
+ dataType: 'json',
+ success: function() {
+ enableButton(button);
+ _this.share.fetch({
+ success: function() {
+ _this.renderAcl();
+ }
+ });
+ },
+ error: function(request, status, error) {
+ enableButton(button);
+ }
+ });
+ },
+
+ cancelAcl: function(event) {
+ event.preventDefault();
+ this.$('#ph-access-control').html(this.shareAclTemplate({
+ share: this.share,
+ permStr: this.parsePermStr(this.share.get('perms')),
+ }));
+ },
+
+ parsePermStr: function(perms) {
+ var p = '';
+ for (var i = 0; i < 3; i++) {
+ var tmp = parseInt(perms.charAt(i)).toString(2);
+ p = (tmp.length == 3) ? p.concat(tmp) :
+ (tmp.length == 2) ? p.concat('0').concat(tmp) :
+ p.concat('00').concat(tmp);
+ }
+ return p;
+ },
+
+ createPermStr: function() {
+ var perms = [];
+ this.$('input[name=\'perms[]\']:checked').each(function() {
+ perms.push($(this).val());
+ });
+ var us = ['owner', 'group', 'other'];
+ var ps = ['r', 'w', 'x'];
+ var permStr = '';
+ _.each(us, function(u) {
+ var t = '';
+ _.each(ps, function(p) {
+ var s = u + '-' + p;
+ t = t + (perms.indexOf(s) != -1 ? '1' : '0');
+ });
+ permStr = permStr + parseInt(t, 2);
+ });
+ return permStr;
+ },
+
+ showPermStr: function() {
+ this.$('#permStrEdit').html(this.createPermStr());
+ },
+
+ showCompressionTooltips: function() {
+ this.$('#ph-compression-info #compression').tooltip({
+ html: true,
+ placement: 'top',
+ title: 'Choose a compression algorithm for this Share. By default, parent pool\'s compression algorithm is applied.
If you like to set pool wide compression, don\'t choose anything here. If you want finer control of this particular Share\'s compression algorithm, you can set it here.
zlib: slower but higher compression ratio.
lzo: faster compression/decompression, but compression ratio is lower than zlib.'
+ });
+ },
+
+ hideCompressionTooltips: function() {
+ this.$('#ph-compression-info #compression').tooltip('hide');
+ },
+
+ editCompression: function(event) {
+ event.preventDefault();
+ this.$('#ph-compression-info').html(this.compression_info_edit_template({
+ share: this.share,
+ cOpts: this.cOpts
+ }));
+ this.showCompressionTooltips();
+ },
+
+ editCompressionCancel: function(event) {
+ event.preventDefault();
+ this.hideCompressionTooltips();
+ this.$('#ph-compression-info').html(this.compression_info_template({
+ share: this.share,
+ shareCompression: this.share.get('compression_algo'),
+ shareCompressionNull: this.shareCompressBool,
+ }));
+ },
+
+ updateCompression: function(event) {
+ var _this = this;
+ event.preventDefault();
+ var button = this.$('#js-submit-compression');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ $.ajax({
+ url: '/api/shares/' + this.share.get('name'),
+ type: 'PUT',
+ dataType: 'json',
+ data: {
+ 'compression': this.$('#compression').val(),
+ },
+ success: function() {
+ _this.hideCompressionTooltips();
+ _this.share.fetch({
+ success: function(collection, response, options) {
+ _this.cView = 'view';
+ _this.renderSubViews();
+ }
+ });
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
+ },
+
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_share_compressOptions', function() {
+ var html = '',
+ _this = this;
+ _.each(_.keys(_this.cOpts), function(c) {
+ if (_this.share.get('compression_algo') == c) {
+ html += '
' + _this.cOpts[c] + ' ';
+ } else {
+ html += '
' + _this.cOpts[c] + ' ';
+ }
+ });
+ return new Handlebars.SafeString(html);
+ });
+
+ Handlebars.registerHelper('view_read_permissions', function() {
+ var html = '';
+ html += '
';
+ if (this.permStr[0] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[3] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[6] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ return new Handlebars.SafeString(html);
+ });
+
+ Handlebars.registerHelper('view_write_permissions', function() {
+ var html = '';
+ html += '
';
+ if (this.permStr[1] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[4] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[7] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ return new Handlebars.SafeString(html);
+ });
+
+ Handlebars.registerHelper('view_execute_permissions', function() {
+ var html = '';
+ html += '
';
+ if (this.permStr[2] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[5] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[8] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ return new Handlebars.SafeString(html);
+ });
+
+
+ Handlebars.registerHelper('showOwnerOption', function(userName, shareOwner) {
+ if (userName == shareOwner) {
+ return 'selected = "selected"';
+ }
+ });
+
+ Handlebars.registerHelper('showGroupOption', function(groupName, shareGroup) {
+ if (groupName == shareGroup) {
+ return 'selected = "selected"';
+ }
+ });
+
+ Handlebars.registerHelper('edit_read_permissions', function() {
+ var html = '';
+ html += '
';
+ if (this.permStr[0] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[3] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[6] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ return new Handlebars.SafeString(html);
+ });
+
+ Handlebars.registerHelper('edit_write_permissions', function() {
+ var html = '';
+ html += '
';
+ if (this.permStr[1] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[4] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[7] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ return new Handlebars.SafeString(html);
+ });
+
+ Handlebars.registerHelper('edit_execute_permissions', function() {
+ var html = '';
+ html += '
';
+ if (this.permStr[2] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[5] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ html += '
';
+ if (this.permStr[8] == '1') {
+ html += ' ';
+ } else {
+ html += ' ';
+ }
+ html += ' ';
+ return new Handlebars.SafeString(html);
+ });
+ }
+
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/share_usage_module.js b/src/rockstor/storageadmin/static/storageadmin/js/views/share_usage_module.js
index 46f796ab5..7e4152fa4 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/share_usage_module.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/share_usage_module.js
@@ -25,208 +25,220 @@
*/
ShareUsageModule = RockstorModuleView.extend({
- events: {
- "click #js-resize": "edit",
- "click #js-resize-save": "save",
- "click #js-resize-cancel": "cancel",
-
- },
-
- initialize: function() {
- this.template = window.JST.share_share_usage_module;
- this.editTemplate = window.JST.share_share_usage_edit;
- this.module_name = 'share-usage';
- this.share = this.options.share;
- this.initHandlebarHelpers();
- },
-
- render: function() {
- $(this.el).html(this.template({
- collection: this.collection,
- module_name: this.module_name,
- share: this.share,
- poolName: this.share.get('pool').name,
- shareCreatedDate: moment(this.share.get("toc")).format(RS_DATE_FORMAT),
- }));
- this.renderGraph();
- //this.renderBar();
- return this;
- },
-
- renderBar: function() {
- var _this = this;
- var w = 300;
- var h = 100;
- var padding = [10,10,10,1];
- var barHeight = 50;
-
- total = parseInt(this.share.get('size')*1024);
- used = parseInt(this.share.get('rusage')*1024);
- free = total - used;
- var dataSet = [used, free];
- var data = [Math.round((used/total)*100), Math.round((free/total)*100)];
- //var data = [70,30]; //convert to percentages
- var dataLabels = ['used', 'free']
- var colors = {
- used: {fill: "rgb(128,128,128)", stroke: "rgb(221,221,221)"},
- free: {fill: "rgb(168,247,171)", stroke: "rgb(221,221,221)"},
- };
-
- var svg = d3.select(this.el).select("#chart")
- .append("svg")
- .attr("width", w + padding[1] + padding[3])
- .attr("height", h + padding[0] + padding[2]);
-
- var xScale = d3.scale.linear().domain([0, 100]).range([0, w]);
- var xOffset = function(i) {
- return i == 0 ? 0 : xScale(data[i-1]);
- }
-
- var gridContainer = svg.append("g")
- .attr("transform", function(d,i) {
- return "translate(" + padding[3] + "," + padding[0] + ")";
- });
- gridContainer.selectAll("rect")
- .data(data)
- .enter()
- .append("rect")
- .attr("y",0)
- .attr("height", barHeight)
- .attr("x", function(d, i) { return xOffset(i); })
- .attr("width", function(d) { return xScale(d); })
- .attr("fill", function(d, i) {
- return colors[dataLabels[i]].fill;
- })
- .attr("stroke", function(d, i) {
- return colors[dataLabels[i]].stroke;
- })
-
- var labels = gridContainer.selectAll("g.labels")
- .data(dataLabels)
- .enter()
- .append("g")
- .attr("transform", function(d,i) {
- return "translate(0," + (barHeight + 5 + i*30)+ ")";
- });
-
- labels.append("rect")
- .attr("width", 13)
- .attr("height", 13)
- .attr("fill", function(d, i) {
- return colors[d].fill;
- })
- .attr("stroke", function(d, i) {
- return colors[d].stroke;
- });
-
- labels.append("text")
- .attr("text-anchor", "left")
- .attr("class", "legend")
- .attr("transform", function(d,i) {
- return "translate(16,13)";
- })
- .text(function(d,i) {
- return data[i] + '% ' + d + ' - ' + humanize.filesize(dataSet[i]);;
- });
- },
-
- renderGraph: function() {
- var w = 350; //width
- h = 100; //height
- var outerRadius = 20;
- var innerRadius = 0;
-
- total = parseInt(this.share.get('size')*1024);
- used = parseInt(this.share.get('rusage')*1024);
- free = total - used;
- var dataset = [free, used];
- var dataLabels = ["free", "used"];
-
- var svg = d3.select(this.el).select("#chart")
- .append("svg")
- .attr("width", w)
- .attr("height", h);
-
- displayUsagePieChart(svg, outerRadius, innerRadius, w, h, dataset, dataLabels, total);
-
- },
-
- edit: function(event) {
- event.preventDefault();
- $(this.el).html(this.editTemplate({
- share: this.share,
- newSizeVal: humanize.filesize(this.share.get('size')*1024).replace(/[^0-9\.]+/g,""),
- }));
- },
-
- save: function(event) {
- var _this = this;
- event.preventDefault();
- var button = _this.$('#js-resize-save');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- var size = this.$('#new-size').val();
-
- var sizeFormat = $('#size_format').val();
- if(sizeFormat == 'KB'){
- size = size;
- }else if(sizeFormat == 'MB'){
- size = size*1024;
- }else if(sizeFormat == 'GB'){
- size = size*1024*1024;
- }else if(sizeFormat == 'TB'){
- size = size*1024*1024*1024;
- }
- $.ajax({
- url: "/api/shares/" + this.share.get('name'),
- type: "PUT",
- dataType: "json",
- data: { "size": size},
- success: function() {
- enableButton(button);
- _this.share.fetch({
- success: function() {
- _this.render();
- }
- });
- },
- error: function(request, status, error) {
- enableButton(button);
- }
- });
- },
-
- cancel: function(event) {
- event.preventDefault();
- this.render();
- },
-
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_shareResize_units', function(){
- var html = '';
- html += '
KB ';
- html += '
MB ';
- html += '
GB ';
- html += '
TB ';
- return new Handlebars.SafeString(html);
- });
- }
-
-
-});
+ events: {
+ 'click #js-resize': 'edit',
+ 'click #js-resize-save': 'save',
+ 'click #js-resize-cancel': 'cancel',
+
+ },
+
+ initialize: function() {
+ this.template = window.JST.share_share_usage_module;
+ this.editTemplate = window.JST.share_share_usage_edit;
+ this.module_name = 'share-usage';
+ this.share = this.options.share;
+ this.initHandlebarHelpers();
+ },
+
+ render: function() {
+ $(this.el).html(this.template({
+ collection: this.collection,
+ module_name: this.module_name,
+ share: this.share,
+ poolName: this.share.get('pool').name,
+ shareCreatedDate: moment(this.share.get('toc')).format(RS_DATE_FORMAT),
+ }));
+ this.renderGraph();
+ //this.renderBar();
+ return this;
+ },
+
+ renderBar: function() {
+ var _this = this;
+ var w = 300;
+ var h = 100;
+ var padding = [10, 10, 10, 1];
+ var barHeight = 50;
+
+ total = parseInt(this.share.get('size') * 1024);
+ used = parseInt(this.share.get('rusage') * 1024);
+ free = total - used;
+ var dataSet = [used, free];
+ var data = [Math.round((used / total) * 100), Math.round((free / total) * 100)];
+ //var data = [70,30]; //convert to percentages
+ var dataLabels = ['used', 'free'];
+ var colors = {
+ used: {
+ fill: 'rgb(128,128,128)',
+ stroke: 'rgb(221,221,221)'
+ },
+ free: {
+ fill: 'rgb(168,247,171)',
+ stroke: 'rgb(221,221,221)'
+ },
+ };
+
+ var svg = d3.select(this.el).select('#chart')
+ .append('svg')
+ .attr('width', w + padding[1] + padding[3])
+ .attr('height', h + padding[0] + padding[2]);
+
+ var xScale = d3.scale.linear().domain([0, 100]).range([0, w]);
+ var xOffset = function(i) {
+ return i == 0 ? 0 : xScale(data[i - 1]);
+ };
+
+ var gridContainer = svg.append('g')
+ .attr('transform', function(d, i) {
+ return 'translate(' + padding[3] + ',' + padding[0] + ')';
+ });
+ gridContainer.selectAll('rect')
+ .data(data)
+ .enter()
+ .append('rect')
+ .attr('y', 0)
+ .attr('height', barHeight)
+ .attr('x', function(d, i) {
+ return xOffset(i);
+ })
+ .attr('width', function(d) {
+ return xScale(d);
+ })
+ .attr('fill', function(d, i) {
+ return colors[dataLabels[i]].fill;
+ })
+ .attr('stroke', function(d, i) {
+ return colors[dataLabels[i]].stroke;
+ });
+
+ var labels = gridContainer.selectAll('g.labels')
+ .data(dataLabels)
+ .enter()
+ .append('g')
+ .attr('transform', function(d, i) {
+ return 'translate(0,' + (barHeight + 5 + i * 30) + ')';
+ });
+
+ labels.append('rect')
+ .attr('width', 13)
+ .attr('height', 13)
+ .attr('fill', function(d, i) {
+ return colors[d].fill;
+ })
+ .attr('stroke', function(d, i) {
+ return colors[d].stroke;
+ });
+
+ labels.append('text')
+ .attr('text-anchor', 'left')
+ .attr('class', 'legend')
+ .attr('transform', function(d, i) {
+ return 'translate(16,13)';
+ })
+ .text(function(d, i) {
+ return data[i] + '% ' + d + ' - ' + humanize.filesize(dataSet[i]);
+ });
+ },
+
+ renderGraph: function() {
+ var w = 350; //width
+ h = 100; //height
+ var outerRadius = 20;
+ var innerRadius = 0;
+
+ total = parseInt(this.share.get('size') * 1024);
+ used = parseInt(this.share.get('rusage') * 1024);
+ free = total - used;
+ var dataset = [free, used];
+ var dataLabels = ['free', 'used'];
+
+ var svg = d3.select(this.el).select('#chart')
+ .append('svg')
+ .attr('width', w)
+ .attr('height', h);
+
+ displayUsagePieChart(svg, outerRadius, innerRadius, w, h, dataset, dataLabels, total);
+
+ },
+
+ edit: function(event) {
+ event.preventDefault();
+ $(this.el).html(this.editTemplate({
+ share: this.share,
+ newSizeVal: humanize.filesize(this.share.get('size') * 1024).replace(/[^0-9\.]+/g, ''),
+ }));
+ },
+
+ save: function(event) {
+ var _this = this;
+ event.preventDefault();
+ var button = _this.$('#js-resize-save');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ var size = this.$('#new-size').val();
+
+ var sizeFormat = $('#size_format').val();
+ if (sizeFormat == 'KB') {
+ size = size * 1;
+ } else if (sizeFormat == 'MB') {
+ size = size * 1024;
+ } else if (sizeFormat == 'GB') {
+ size = size * 1024 * 1024;
+ } else if (sizeFormat == 'TB') {
+ size = size * 1024 * 1024 * 1024;
+ }
+ $.ajax({
+ url: '/api/shares/' + this.share.get('name'),
+ type: 'PUT',
+ dataType: 'json',
+ data: {
+ 'size': size
+ },
+ success: function() {
+ enableButton(button);
+ _this.share.fetch({
+ success: function() {
+ _this.render();
+ }
+ });
+ },
+ error: function(request, status, error) {
+ enableButton(button);
+ }
+ });
+ },
+
+ cancel: function(event) {
+ event.preventDefault();
+ this.render();
+ },
+
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_shareResize_units', function() {
+ var html = '';
+ html += '
KB ';
+ html += '
MB ';
+ html += '
GB ';
+ html += '
TB ';
+ return new Handlebars.SafeString(html);
+ });
+ }
+
+
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/shares.js b/src/rockstor/storageadmin/static/storageadmin/js/views/shares.js
index 9d7cc1e5d..56c8da9ba 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/shares.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/shares.js
@@ -172,3 +172,4 @@ SharesView = RockstorLayoutView.extend({
});
}
});
+
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/shell.js b/src/rockstor/storageadmin/static/storageadmin/js/views/shell.js
index c3e594d12..3a991bc95 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/shell.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/shell.js
@@ -25,117 +25,121 @@
*/
ShellView = RockstorLayoutView.extend({
- events: {
- 'switchChange.bootstrapSwitch': 'switchStatus',
- 'click #fullscreen': 'FullScreenSwitch'
- },
-
- initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.shell_shell;
- this.serviceName = 'shellinaboxd';
- this.service = new Service({name: this.serviceName});
- this.dependencies.push(this.service);
- },
+ events: {
+ 'switchChange.bootstrapSwitch': 'switchStatus',
+ 'click #fullscreen': 'FullScreenSwitch'
+ },
- render: function() {
- var _this = this;
- this.fetch(this.renderShell, this);
- return this;
- },
-
- renderShell: function(){
-
- $(this.el).html(this.template({
- service: this.service
- }));
+ initialize: function() {
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.shell_shell;
+ this.serviceName = 'shellinaboxd';
+ this.service = new Service({
+ name: this.serviceName
+ });
+ this.dependencies.push(this.service);
+ },
- //initalize Bootstrap Switch
- this.$("[type='checkbox']").bootstrapSwitch();
- this.$('input[name="shell-export-checkbox"]').bootstrapSwitch('state', this.service.get('status'), true);
- this.$("[type='checkbox']").bootstrapSwitch('onColor','success'); //left side text color
- this.$("[type='checkbox']").bootstrapSwitch('offColor','danger'); //right side text color
+ render: function() {
+ var _this = this;
+ this.fetch(this.renderShell, this);
+ return this;
+ },
- // Display Shell In a Box Service Warning
- if (!this.service.get('status')) {
- this.$('#shell-warning').show();
- this.$('div[name="shell-container"]').show();
- } else {
- this.$('#rockstor-shell')[0].src="/shell";
- this.$('#rockstor-shell').show();
- this.$('#fullscreen').show();
- }
- },
-
- FullScreenSwitch: function(){
- //nicely switch our console between normal size and fullscreen
- //fullscreen requires crossbrowser checks
- //Back to normal size just with ESC, as suggested by browser
- var rockstor_shell = this.$('#rockstor-shell')[0];
- if (rockstor_shell.requestFullscreen) {
- rockstor_shell.requestFullscreen();
- } else if (rockstor_shell.webkitRequestFullscreen) {
- rockstor_shell.webkitRequestFullscreen();
- } else if (rockstor_shell.mozRequestFullScreen) {
- rockstor_shell.mozRequestFullScreen();
- } else if (rockstor_shell.msRequestFullscreen) {
- rockstor_shell.msRequestFullscreen();
- }
- },
-
- switchStatus: function(event,state){
- if (state){
- this.startService();
- }
- },
+ renderShell: function() {
- startService: function() {
- var _this = this;
- this.setStatusLoading(this.serviceName, true);
- $.ajax({
- url: "/api/sm/services/shellinaboxd/start",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.setStatusLoading(_this.serviceName, false);
- _this.$('div[name="shell-container"]').hide();
- _this.$('#shell-warning').hide();
- _this.$('#rockstor-shell')[0].src="/shell";
- _this.$('#rockstor-shell').show();
- _this.$('#fullscreen').show();
-
- },
- error: function(xhr, status, error) {
- _this.setStatusError(_this.serviceName, xhr);
- _this.$('div[name="shell-container"]').show();
- _this.$('#shell-warning').show();
- }
- });
- },
+ $(this.el).html(this.template({
+ service: this.service
+ }));
- setStatusLoading: function(serviceName, show) {
- var statusEl = this.$('div.command-status[data-service-name="'+serviceName+'"]');
- if (show) {
- statusEl.html('
');
- } else {
- statusEl.empty();
- }
- },
+ //initalize Bootstrap Switch
+ this.$('[type=\'checkbox\']').bootstrapSwitch();
+ this.$('input[name="shell-export-checkbox"]').bootstrapSwitch('state', this.service.get('status'), true);
+ this.$('[type=\'checkbox\']').bootstrapSwitch('onColor', 'success'); //left side text color
+ this.$('[type=\'checkbox\']').bootstrapSwitch('offColor', 'danger'); //right side text color
- setStatusError: function(serviceName, xhr) {
- var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
- var msg = parseXhrError(xhr);
- // remove any existing error popups
- $('body').find('#' + serviceName + 'err-popup').remove();
- // add icon and popup
- statusEl.empty();
- var icon = $('
').addClass('icon-exclamation-sign').attr('rel', '#' + serviceName + '-err-popup');
- statusEl.append(icon);
- var errPopup = this.$('#' + serviceName + '-err-popup');
- var errPopupContent = this.$('#' + serviceName + '-err-popup > div');
- errPopupContent.html(msg);
- statusEl.click(function(){ errPopup.overlay().load(); });
- },
+ // Display Shell In a Box Service Warning
+ if (!this.service.get('status')) {
+ this.$('#shell-warning').show();
+ this.$('div[name="shell-container"]').show();
+ } else {
+ this.$('#rockstor-shell')[0].src = '/shell';
+ this.$('#rockstor-shell').show();
+ this.$('#fullscreen').show();
+ }
+ },
+
+ FullScreenSwitch: function() {
+ //nicely switch our console between normal size and fullscreen
+ //fullscreen requires crossbrowser checks
+ //Back to normal size just with ESC, as suggested by browser
+ var rockstor_shell = this.$('#rockstor-shell')[0];
+ if (rockstor_shell.requestFullscreen) {
+ rockstor_shell.requestFullscreen();
+ } else if (rockstor_shell.webkitRequestFullscreen) {
+ rockstor_shell.webkitRequestFullscreen();
+ } else if (rockstor_shell.mozRequestFullScreen) {
+ rockstor_shell.mozRequestFullScreen();
+ } else if (rockstor_shell.msRequestFullscreen) {
+ rockstor_shell.msRequestFullscreen();
+ }
+ },
+
+ switchStatus: function(event, state) {
+ if (state) {
+ this.startService();
+ }
+ },
+
+ startService: function() {
+ var _this = this;
+ this.setStatusLoading(this.serviceName, true);
+ $.ajax({
+ url: '/api/sm/services/shellinaboxd/start',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.setStatusLoading(_this.serviceName, false);
+ _this.$('div[name="shell-container"]').hide();
+ _this.$('#shell-warning').hide();
+ _this.$('#rockstor-shell')[0].src = '/shell';
+ _this.$('#rockstor-shell').show();
+ _this.$('#fullscreen').show();
+
+ },
+ error: function(xhr, status, error) {
+ _this.setStatusError(_this.serviceName, xhr);
+ _this.$('div[name="shell-container"]').show();
+ _this.$('#shell-warning').show();
+ }
+ });
+ },
+
+ setStatusLoading: function(serviceName, show) {
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ if (show) {
+ statusEl.html(' ');
+ } else {
+ statusEl.empty();
+ }
+ },
+
+ setStatusError: function(serviceName, xhr) {
+ var statusEl = this.$('div.command-status[data-service-name="' + serviceName + '"]');
+ var msg = parseXhrError(xhr);
+ // remove any existing error popups
+ $('body').find('#' + serviceName + 'err-popup').remove();
+ // add icon and popup
+ statusEl.empty();
+ var icon = $('').addClass('icon-exclamation-sign').attr('rel', '#' + serviceName + '-err-popup');
+ statusEl.append(icon);
+ var errPopup = this.$('#' + serviceName + '-err-popup');
+ var errPopupContent = this.$('#' + serviceName + '-err-popup > div');
+ errPopupContent.html(msg);
+ statusEl.click(function() {
+ errPopup.overlay().load();
+ });
+ },
});
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/shutdown.js b/src/rockstor/storageadmin/static/storageadmin/js/views/shutdown.js
index 6944ac078..670a00a45 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/shutdown.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/shutdown.js
@@ -26,105 +26,105 @@
ShutdownView = RockstorLayoutView.extend({
- initialize: function() {
- // call initialize of base
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.common_navbar;
- this.paginationTemplate = window.JST.common_pagination;
- this.timeLeft = 180;
- },
+ initialize: function() {
+ // call initialize of base
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.common_navbar;
+ this.paginationTemplate = window.JST.common_pagination;
+ this.timeLeft = 180;
+ },
- render: function() {
- var _this = this;
- $('#shutdown-modal').modal({
- keyboard: false,
- backdrop: 'static',
- show: false
- });
- if (confirm('Are you sure you want to Shutdown the system? All network access will be lost. Click OK to continue or Cancel to go back.')) {
- $('#shutdown-modal').modal('show');
- this.startForceRefreshTimer();
+ render: function() {
+ var _this = this;
+ $('#shutdown-modal').modal({
+ keyboard: false,
+ backdrop: 'static',
+ show: false
+ });
+ if (confirm('Are you sure you want to Shutdown the system? All network access will be lost. Click OK to continue or Cancel to go back.')) {
+ $('#shutdown-modal').modal('show');
+ this.startForceRefreshTimer();
- $.ajax({
- url: "/api/commands/shutdown",
- type: "POST",
- dataType: "json",
- global: false, // dont show global loading indicator
- success: function(data, status, xhr) {
- _this.checkIfUp();
- },
- error: function(xhr, status, error) {
- _this.checkIfUp();
- }
- });
- } else {
- location.reload(history.go(-1));
- }
- return this;
- },
-
- checkIfUp: function() {
- var _this = this;
- this.isUpTimer = window.setInterval(function() {
- $.ajax({
- url: "/api/sm/sprobes/loadavg?limit=1&format=json",
- type: "GET",
- dataType: "json",
- global: false, // dont show global loading indicator
- success: function(data, status, xhr) {
- // _this.reloadWindow();
- },
- error: function(xhr, status, error) {
- _this.displayUserMsg2();
+ $.ajax({
+ url: '/api/commands/shutdown',
+ type: 'POST',
+ dataType: 'json',
+ global: false, // dont show global loading indicator
+ success: function(data, status, xhr) {
+ _this.checkIfUp();
+ },
+ error: function(xhr, status, error) {
+ _this.checkIfUp();
+ }
+ });
+ } else {
+ location.reload(history.go(-1));
}
- });
- }, 5000);
- },
+ return this;
+ },
- // countdown timeLeft seconds and then force a window reload
- startForceRefreshTimer: function() {
- var _this = this;
- this.forceRefreshTimer = window.setInterval(function() {
- _this.timeLeft = _this.timeLeft - 1;
- _this.showTimeRemaining();
- if (_this.timeLeft <= 0) {
- _this.reloadWindow();
- }
- }, 1000);
- },
+ checkIfUp: function() {
+ var _this = this;
+ this.isUpTimer = window.setInterval(function() {
+ $.ajax({
+ url: '/api/sm/sprobes/loadavg?limit=1&format=json',
+ type: 'GET',
+ dataType: 'json',
+ global: false, // dont show global loading indicator
+ success: function(data, status, xhr) {
+ // _this.reloadWindow();
+ },
+ error: function(xhr, status, error) {
+ _this.displayUserMsg2();
+ }
+ });
+ }, 5000);
+ },
- showTimeRemaining: function() {
- mins = Math.floor(this.timeLeft/60);
- sec = this.timeLeft - (mins*60);
- sec = sec >=10 ? '' + sec : '0' + sec
- $('#time-left').html(mins + ':' + sec)
- if (mins <= 1 && !this.userMsgDisplayed) {
- this.displayUserMsg();
- this.userMsgDisplayed = true;
- }
- },
+ // countdown timeLeft seconds and then force a window reload
+ startForceRefreshTimer: function() {
+ var _this = this;
+ this.forceRefreshTimer = window.setInterval(function() {
+ _this.timeLeft = _this.timeLeft - 1;
+ _this.showTimeRemaining();
+ if (_this.timeLeft <= 0) {
+ _this.reloadWindow();
+ }
+ }, 1000);
+ },
- reloadWindow: function() {
- this.clearTimers();
+ showTimeRemaining: function() {
+ mins = Math.floor(this.timeLeft / 60);
+ sec = this.timeLeft - (mins * 60);
+ sec = sec >= 10 ? '' + sec : '0' + sec;
+ $('#time-left').html(mins + ':' + sec);
+ if (mins <= 1 && !this.userMsgDisplayed) {
+ this.displayUserMsg();
+ this.userMsgDisplayed = true;
+ }
+ },
- },
+ reloadWindow: function() {
+ this.clearTimers();
- clearTimers: function() {
- window.clearInterval(this.isUpTimer);
- window.clearInterval(this.forceRefreshTimer);
- },
+ },
-displayUserMsg: function() {
- $('#time-left').remove();
- $('#user-msg').show('highlight', null, 1000);
- },
+ clearTimers: function() {
+ window.clearInterval(this.isUpTimer);
+ window.clearInterval(this.forceRefreshTimer);
+ },
-displayUserMsg2: function() {
- $('#message').remove();
- $('#timer').removeAttr('src');
- $('#time-left').remove();
- $('#user-msg').remove();
- $('#user-msg2').show('highlight', null, 1000);
- }
+ displayUserMsg: function() {
+ $('#time-left').remove();
+ $('#user-msg').show('highlight', null, 1000);
+ },
+
+ displayUserMsg2: function() {
+ $('#message').remove();
+ $('#timer').removeAttr('src');
+ $('#time-left').remove();
+ $('#user-msg').remove();
+ $('#user-msg2').show('highlight', null, 1000);
+ }
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/smartcustom_disks.js b/src/rockstor/storageadmin/static/storageadmin/js/views/smartcustom_disks.js
index f8e10b3cd..4be91575e 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/smartcustom_disks.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/smartcustom_disks.js
@@ -29,7 +29,7 @@ SmartcustomDiskView = RockstorLayoutView.extend({
'click #cancel': 'cancel'
},
- initialize: function () {
+ initialize: function() {
this.constructor.__super__.initialize.apply(this, arguments);
this.template = window.JST.disk_smartcustom_disks;
this.disks = new DiskCollection();
@@ -37,21 +37,21 @@ SmartcustomDiskView = RockstorLayoutView.extend({
this.dependencies.push(this.disks);
},
- render: function () {
+ render: function() {
this.fetch(this.renderDisksForm, this);
return this;
},
- renderDisksForm: function () {
+ renderDisksForm: function() {
if (this.$('[rel=tooltip]')) {
- this.$("[rel=tooltip]").tooltip('hide');
+ this.$('[rel=tooltip]').tooltip('hide');
}
var _this = this;
var disk_name = this.diskName;
- var serialNumber = this.disks.find(function (d) {
+ var serialNumber = this.disks.find(function(d) {
return (d.get('name') == disk_name);
}).get('serial');
- var currentSmartCustom = this.disks.find(function (d) {
+ var currentSmartCustom = this.disks.find(function(d) {
return (d.get('name') == disk_name);
}).get('smart_options');
@@ -67,15 +67,15 @@ SmartcustomDiskView = RockstorLayoutView.extend({
});
var err_msg = '';
- var smartcustom_err_msg = function () {
+ var smartcustom_err_msg = function() {
return err_msg;
};
- $.validator.addMethod('validateSmartCustom', function (value) {
+ $.validator.addMethod('validateSmartCustom', function(value) {
var smartcustom_options = $('#smartcustom_options').val().trim();
- var devOptions = ["auto", "test", "ata", "scsi", "sat", "sat,12", "sat,16", "sat,auto", "usbprolific", "usbjmicron", "usbjmicron,0", "usbjmicron,p", "usbjmicron,x", "usbjmicron,x,1", "usbcypress", "usbsunplus"];
- var devOptionsRaid = ["3ware", "areca", "hpt", "cciss", "megaraid", "aacraid"];
- var toleranceOptions = ["normal", "conservative", "permissive", "verypermissive"];
+ var devOptions = ['auto', 'test', 'ata', 'scsi', 'sat', 'sat,12', 'sat,16', 'sat,auto', 'usbprolific', 'usbjmicron', 'usbjmicron,0', 'usbjmicron,p', 'usbjmicron,x', 'usbjmicron,x,1', 'usbcypress', 'usbsunplus'];
+ var devOptionsRaid = ['3ware', 'areca', 'hpt', 'cciss', 'megaraid', 'aacraid'];
+ var toleranceOptions = ['normal', 'conservative', 'permissive', 'verypermissive'];
// RegExp patters for the following RAID target devices:
// 3ware /dev/twe, /dev/twa, /dev/twl followed by 0-15
// Areca sata /dev/sg[2-9] but for hpahcisr and hpsa drivers /dev/sg[0-9]* (lsscsi -g to help)
@@ -91,7 +91,7 @@ SmartcustomDiskView = RockstorLayoutView.extend({
err_msg = 'Invalid character found, expecting only letters, numbers, and \'-\',\'/\' and \'space.\'';
return false;
}
- if ((!smartcustom_options.includes("-d ")) && (!smartcustom_options.includes("-T "))) {
+ if ((!smartcustom_options.includes('-d ')) && (!smartcustom_options.includes('-T '))) {
err_msg = 'Must contain either -d or -T options or both.';
return false;
}
@@ -104,27 +104,27 @@ SmartcustomDiskView = RockstorLayoutView.extend({
// Move to repeat and semantic checks
//
// Check for only one instance of "-d ".
- var first_d_option = smartcustom_options.indexOf("-d ");
- if (first_d_option != -1 && smartcustom_options.lastIndexOf("-d") != first_d_option) {
+ var first_d_option = smartcustom_options.indexOf('-d ');
+ if (first_d_option != -1 && smartcustom_options.lastIndexOf('-d') != first_d_option) {
err_msg = 'Only one occurrence of the -d switch is permitted.';
return false;
}
// Note that multiple instances of -T are valid.
// Validate each option.
// Find elements of given options via split by space.
- var option_array = smartcustom_options.split(" ");
- if ((option_array[0] != "-d") && (option_array[0] != "-T")) {
+ var option_array = smartcustom_options.split(' ');
+ if ((option_array[0] != '-d') && (option_array[0] != '-T')) {
err_msg = 'Please begin with either \'-d \' or \'-T \'';
return false;
}
// true if option is Device switch "-d"
function isDevSwitch(option) {
- return (option == "-d");
+ return (option == '-d');
}
// true if option is Tolerance switch ie "-T"
function isToleranceSwitch(option) {
- return (option == "-T");
+ return (option == '-T');
}
// true if not recognized as a dev option (non Raid)
@@ -141,7 +141,7 @@ SmartcustomDiskView = RockstorLayoutView.extend({
// Consider improving to use string.match(regexp) to match whole option.
// Currently only validates pre ',' in for example 3ware,5
function isNotRaidOption(option) {
- var without_values = option.substring(0, option.indexOf(","));
+ var without_values = option.substring(0, option.indexOf(','));
return (devOptionsRaid.indexOf(without_values) == -1);
}
@@ -163,7 +163,7 @@ SmartcustomDiskView = RockstorLayoutView.extend({
// rogue spaces are empty array elements after split so test for them
function isRogueSpace(option) {
- return (option.toString() == "");
+ return (option.toString() == '');
}
// test for any rogue spaces
@@ -179,23 +179,23 @@ SmartcustomDiskView = RockstorLayoutView.extend({
var unknown_switches_found = [];
var dev_switch_found = false;
var tol_switch_found = false;
- option_array.forEach(function (option) {
+ option_array.forEach(function(option) {
// filter our various options before assessing them as valid.
- if (option.charAt(0) == "-") { // option is a switch
+ if (option.charAt(0) == '-') { // option is a switch
if (isDevSwitch(option)) {
- option_type = "dev";
+ option_type = 'dev';
dev_switch_found = true;
} else if (isToleranceSwitch(option)) {
- option_type = "tol";
+ option_type = 'tol';
tol_switch_found = true;
} else { // unknown switch
- option_type = "unknown";
+ option_type = 'unknown';
unknown_switches_found.push(option);
}
- } else if (option_type == "dev") {
+ } else if (option_type == 'dev') {
// collect all options proceeded by a -d option
dev_options_found.push(option);
- } else if (option_type == "tol") {
+ } else if (option_type == 'tol') {
// collect all options proceeded by a -T option
tol_options_found.push(option);
} else {
@@ -204,7 +204,7 @@ SmartcustomDiskView = RockstorLayoutView.extend({
}
});
// Report any unknown switches.
- if (unknown_switches_found != "") {
+ if (unknown_switches_found != '') {
err_msg = 'One or more unknown switches found: \'' + unknown_switches_found.toString() + '\', supported switches are \'-d\' and \'-T\'';
return false;
}
@@ -212,7 +212,7 @@ SmartcustomDiskView = RockstorLayoutView.extend({
// Note this should never trigger as the last unknown_switches_found
// should trigger first. We have a later one to catch unknown options
// after known triggers.
- if (unknown_options_found != "") {
+ if (unknown_options_found != '') {
err_msg = 'The following options of an unknown type were entered:' +
' \'' + unknown_options_found.toString() + '\', supported ' +
'options are ' + devOptions.toString() + '\n' +
@@ -223,14 +223,14 @@ SmartcustomDiskView = RockstorLayoutView.extend({
// Filter our dev options first by absolute known / allowed options
// filter the resulting array by the less strict known raid options
var unknown_dev_options_found = dev_options_found.filter(isNotDevOption).filter(isNotRaidOption).filter(isNotRaidTarget);
- if (unknown_dev_options_found != "") {
+ if (unknown_dev_options_found != '') {
err_msg = 'The following unknown \'-d\' options were found \'' +
unknown_dev_options_found.toString() + '\'';
return false;
}
// Filter out unknown Tolerance options
var unknown_tol_options_found = tol_options_found.filter(isNotToleranceOption);
- if (unknown_tol_options_found != "") {
+ if (unknown_tol_options_found != '') {
err_msg = 'The following unknown \'-T\' options were found \'' +
unknown_tol_options_found.toString() + '\'. Available options' +
' are ' + toleranceOptions.toString();
@@ -248,7 +248,7 @@ SmartcustomDiskView = RockstorLayoutView.extend({
if (dev_options_found.length == 2) {
if ((!isNotRaidOption(dev_options_found[0])) && (!isNotRaidTarget(dev_options_found[1]))) {
// we have a raid option followed by a raid target dev
- return true
+ return true;
}
}
err_msg = 'Only one \'-d\' option is supported';
@@ -265,7 +265,7 @@ SmartcustomDiskView = RockstorLayoutView.extend({
smartcustom_options: 'validateSmartCustom',
},
- submitHandler: function () {
+ submitHandler: function() {
var button = $('#smartcustom-disk');
if (buttonDisabled(button)) return false;
disableButton(button);
@@ -277,13 +277,15 @@ SmartcustomDiskView = RockstorLayoutView.extend({
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(_this.$('#add-smartcustom-disk-form').getJSON()),
- success: function () {
+ success: function() {
enableButton(button);
_this.$('#add-smartcustom-disk-form :input').tooltip('hide');
- app_router.navigate('disks', {trigger: true});
+ app_router.navigate('disks', {
+ trigger: true
+ });
},
- error: function (xhr, status, error) {
+ error: function(xhr, status, error) {
enableButton(button);
}
});
@@ -293,10 +295,12 @@ SmartcustomDiskView = RockstorLayoutView.extend({
});
},
- cancel: function (event) {
+ cancel: function(event) {
event.preventDefault();
this.$('#add-smartcustom-disk-form :input').tooltip('hide');
- app_router.navigate('disks', {trigger: true});
+ app_router.navigate('disks', {
+ trigger: true
+ });
}
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/snapshots.js b/src/rockstor/storageadmin/static/storageadmin/js/views/snapshots.js
index f23927361..091a5937c 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/snapshots.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/snapshots.js
@@ -25,304 +25,316 @@
*/
SnapshotsView = SnapshotsCommonView.extend({
events: {
- "click #js-snapshot-add": "add",
- "click #js-snapshot-cancel": "cancel",
- "click .js-snapshot-delete": "deleteSnapshot",
- "click .js-snapshot-clone": "cloneSnapshot",
- "click .js-snapshot-select": "selectSnapshot",
- "click .js-snapshot-select-all": "selectAllSnapshots",
- "click #js-snapshot-delete-multiple": "deleteMultipleSnapshots"
+ 'click #js-snapshot-add': 'add',
+ 'click #js-snapshot-cancel': 'cancel',
+ 'click .js-snapshot-delete': 'deleteSnapshot',
+ 'click .js-snapshot-clone': 'cloneSnapshot',
+ 'click .js-snapshot-select': 'selectSnapshot',
+ 'click .js-snapshot-select-all': 'selectAllSnapshots',
+ 'click #js-snapshot-delete-multiple': 'deleteMultipleSnapshots'
},
initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.share_snapshots;
- this.addTemplate = window.JST.share_snapshot_add_template;
- this.module_name = 'snapshots';
- this.snapshots = this.options.snapshots;
- this.collection = new SnapshotsCollection();
- this.shares = new ShareCollection();
- this.dependencies.push(this.shares);
- this.dependencies.push(this.collection);
- this.selectedSnapshots = [];
- this.replicaShareMap = {};
- this.snapShares = [];
-
- this.modify_choices = [
- {name: 'yes', value: 'yes'},
- {name: 'no', value: 'no'},
- ];
- this.parentView = this.options.parentView;
- this.collection.on("reset", this.renderSnapshots, this);
- this.initHandlebarHelpers();
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.share_snapshots;
+ this.addTemplate = window.JST.share_snapshot_add_template;
+ this.module_name = 'snapshots';
+ this.snapshots = this.options.snapshots;
+ this.collection = new SnapshotsCollection();
+ this.shares = new ShareCollection();
+ this.dependencies.push(this.shares);
+ this.dependencies.push(this.collection);
+ this.selectedSnapshots = [];
+ this.replicaShareMap = {};
+ this.snapShares = [];
+
+ this.modify_choices = [{
+ name: 'yes',
+ value: 'yes'
+ },
+ {
+ name: 'no',
+ value: 'no'
+ },
+ ];
+ this.parentView = this.options.parentView;
+ this.collection.on('reset', this.renderSnapshots, this);
+ this.initHandlebarHelpers();
},
render: function() {
- this.fetch(this.renderSnapshots, this);
- return this;
+ this.fetch(this.renderSnapshots, this);
+ return this;
},
renderSnapshots: function() {
- var _this = this;
- $(this.el).empty();
-
- var snapshots = _this.collection.toJSON();
- for(var i = 0; i < snapshots.length; i++){
- var shareMatch = _this.shares.find(function(share){
- return share.get('id') == snapshots[i].share;
- });
- snapshots[i].share = shareMatch.get('name');
- }
- $(this.el).append(_this.template({
- snapshots: snapshots,
- snapshotsNotEmpty: !_this.collection.isEmpty(),
- collection: _this.collection,
- }));
-
- this.$('[rel=tooltip]').tooltip({
- placement: 'bottom'
- });
-
- this.renderDataTables();
-
- return this;
+ var _this = this;
+ $(this.el).empty();
+
+ var snapshots = _this.collection.toJSON();
+ for (var i = 0; i < snapshots.length; i++) {
+ var shareMatch = _this.shares.find(function(share) {
+ return share.get('id') == snapshots[i].share;
+ });
+ snapshots[i].share = shareMatch.get('name');
+ }
+ $(this.el).append(_this.template({
+ snapshots: snapshots,
+ snapshotsNotEmpty: !_this.collection.isEmpty(),
+ collection: _this.collection,
+ }));
+
+ this.$('[rel=tooltip]').tooltip({
+ placement: 'bottom'
+ });
+
+ this.renderDataTables();
+
+ return this;
},
setShareName: function(shareName) {
- this.collection.setUrl(shareName);
+ this.collection.setUrl(shareName);
},
add: function(event) {
- var _this = this;
- event.preventDefault();
- $(this.el).html(this.addTemplate({
- snapshots: this.collection,
- }));
- this.$('#shares').chosen();
- var err_msg = '';
- var name_err_msg = function() {
- return err_msg;
- }
-
- $.validator.addMethod('validateSnapshotName', function(value) {
- var snapshot_name = $('#snapshot_name').val();
- if (/^[A-Za-z0-9_.-]+$/.test(snapshot_name) == false) {
- err_msg = 'Please enter a valid snapshot name.';
- return false;
- }
- return true;
- }, name_err_msg);
-
- this.$('#add-snapshot-form :input').tooltip({placement: 'right'});
- this.validator = this.$('#add-snapshot-form').validate({
- onfocusout: false,
- onkeyup: false,
- rules: {
- snapshot_name: 'validateSnapshotName',
- shares: 'required'
- },
- submitHandler: function() {
- var button = _this.$('#js-snapshot-save');
- var shareName = $("#shares").val();
- if (buttonDisabled(button)) return false;
- disableButton(button);
- $.ajax({
- url: "/api/shares/" + shareName+ "/snapshots/" + _this.$('#snapshot_name').val(),
- type: "POST",
- dataType: "json",
- contentType: 'application/json',
- data: JSON.stringify(_this.$('#add-snapshot-form').getJSON()),
- success: function() {
- _this.$('#add-snapshot-form :input').tooltip('hide');
- enableButton(button);
- _this.collection.fetch({
- success: function(collection, response, options) {
- }
- });
- },
- error: function(xhr, status, error) {
- _this.$('#add-snapshot-form :input').tooltip('hide');
- enableButton(button);
- }
- });
-
- return false;
- }
- });
+ var _this = this;
+ event.preventDefault();
+ $(this.el).html(this.addTemplate({
+ snapshots: this.collection,
+ }));
+ this.$('#shares').chosen();
+ var err_msg = '';
+ var name_err_msg = function() {
+ return err_msg;
+ };
+
+ $.validator.addMethod('validateSnapshotName', function(value) {
+ var snapshot_name = $('#snapshot_name').val();
+ if (/^[A-Za-z0-9_.-]+$/.test(snapshot_name) == false) {
+ err_msg = 'Please enter a valid snapshot name.';
+ return false;
+ }
+ return true;
+ }, name_err_msg);
+
+ this.$('#add-snapshot-form :input').tooltip({
+ placement: 'right'
+ });
+ this.validator = this.$('#add-snapshot-form').validate({
+ onfocusout: false,
+ onkeyup: false,
+ rules: {
+ snapshot_name: 'validateSnapshotName',
+ shares: 'required'
+ },
+ submitHandler: function() {
+ var button = _this.$('#js-snapshot-save');
+ var shareName = $('#shares').val();
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ $.ajax({
+ url: '/api/shares/' + shareName + '/snapshots/' + _this.$('#snapshot_name').val(),
+ type: 'POST',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify(_this.$('#add-snapshot-form').getJSON()),
+ success: function() {
+ _this.$('#add-snapshot-form :input').tooltip('hide');
+ enableButton(button);
+ _this.collection.fetch({
+ success: function(collection, response, options) {}
+ });
+ },
+ error: function(xhr, status, error) {
+ _this.$('#add-snapshot-form :input').tooltip('hide');
+ enableButton(button);
+ }
+ });
+
+ return false;
+ }
+ });
},
deleteSnapshot: function(event) {
- event.preventDefault();
- var _this = this;
- var name = $(event.currentTarget).attr('data-name');
- var shareName = $(event.currentTarget).attr('data-share-name');
- var esize = $(event.currentTarget).attr('data-size');
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- if(confirm("Deleting snapshot("+ name +") deletes "+ esize +" of data permanently. Do you really want to delete it?")){
- disableButton(button);
- $.ajax({
- url: "/api/shares/" + shareName + "/snapshots/" + name,
- type: "DELETE",
- success: function() {
- enableButton(button)
- _this.$('[rel=tooltip]').tooltip('hide');
- _this.selectedSnapshots = [];
- _this.collection.fetch({reset: true});
-
- },
- error: function(xhr, status, error) {
- enableButton(button);
- _this.$('[rel=tooltip]').tooltip('hide');
- }
- });
- }
+ event.preventDefault();
+ var _this = this;
+ var name = $(event.currentTarget).attr('data-name');
+ var shareName = $(event.currentTarget).attr('data-share-name');
+ var esize = $(event.currentTarget).attr('data-size');
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ if (confirm('Deleting snapshot(' + name + ') deletes ' + esize + ' of data permanently. Do you really want to delete it?')) {
+ disableButton(button);
+ $.ajax({
+ url: '/api/shares/' + shareName + '/snapshots/' + name,
+ type: 'DELETE',
+ success: function() {
+ enableButton(button);
+ _this.$('[rel=tooltip]').tooltip('hide');
+ _this.selectedSnapshots = [];
+ _this.collection.fetch({
+ reset: true
+ });
+
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ _this.$('[rel=tooltip]').tooltip('hide');
+ }
+ });
+ }
},
cloneSnapshot: function(event) {
- if (event) event.preventDefault();
- // Remove current tooltips to prevent them hanging around
- // even after new page has loaded.
- this.$('[rel=tooltip]').tooltip('hide');
- var name = $(event.currentTarget).attr('data-name');
- var shareName = $(event.currentTarget).attr('data-share-name');
- var url = 'shares/' + shareName + '/snapshots/' +
- name + '/create-clone';
- app_router.navigate(url, {trigger: true});
+ if (event) event.preventDefault();
+ // Remove current tooltips to prevent them hanging around
+ // even after new page has loaded.
+ this.$('[rel=tooltip]').tooltip('hide');
+ var name = $(event.currentTarget).attr('data-name');
+ var shareName = $(event.currentTarget).attr('data-share-name');
+ var url = 'shares/' + shareName + '/snapshots/' +
+ name + '/create-clone';
+ app_router.navigate(url, {
+ trigger: true
+ });
},
deleteMultipleSnapshots: function(event) {
- var _this = this;
- event.preventDefault();
- var button = $(event.currentTarget);
- if (buttonDisabled(button)) return false;
- if (this.selectedSnapshots.length == 0) {
- alert('Select at least one snapshot to delete');
- } else {
- var confirmMsg = null;
- if (this.selectedSnapshots.length == 1) {
- confirmMsg = 'Deleting snapshot ';
- } else {
- confirmMsg = 'Deleting snapshots ';
- }
- var snapNames = _.reduce(this.selectedSnapshots, function(str, snap) {
- return str + snap.get('name') + ',';
- }, '', this);
- snapNames = snapNames.slice(0, snapNames.length-1);
-
- var snapIds = _.reduce(this.selectedSnapshots, function(str, snap) {
- return str + snap.id + ',';
- }, '', this);
- snapIds = snapIds.slice(0, snapIds.length-1);
-
- var totalSize = _.reduce(this.selectedSnapshots, function(sum, snap) {
- return sum + snap.get('eusage');
- }, 0, this);
-
- var totalSizeStr = humanize.filesize(totalSize*1024);
-
- if (confirm(confirmMsg + snapNames + ' deletes ' + totalSizeStr + ' of data. Are you sure?')) {
- disableButton(button);
-
- _.each(this.selectedSnapshots, function(s) {
- var name = s.get('name');
-
- _this.shares.each(function(share, index) {
- if(s.get('share')== share.get('id')){
- var shareName = share.get('name');
- $.ajax({
- url: "/api/shares/" + shareName + "/snapshots/" + name,
- type: "DELETE",
- success: function() {
- enableButton(button)
- _this.$('[rel=tooltip]').tooltip('hide');
- _this.selectedSnapshots = [];
- _this.collection.fetch({reset: true});
-
- },
- error: function(xhr, status, error) {
- enableButton(button)
- _this.$('[rel=tooltip]').tooltip('hide');
- }
- });
-
- }
- });
- });
- }
-
- }
+ var _this = this;
+ event.preventDefault();
+ var button = $(event.currentTarget);
+ if (buttonDisabled(button)) return false;
+ if (this.selectedSnapshots.length == 0) {
+ alert('Select at least one snapshot to delete');
+ } else {
+ var confirmMsg = null;
+ if (this.selectedSnapshots.length == 1) {
+ confirmMsg = 'Deleting snapshot ';
+ } else {
+ confirmMsg = 'Deleting snapshots ';
+ }
+ var snapNames = _.reduce(this.selectedSnapshots, function(str, snap) {
+ return str + snap.get('name') + ',';
+ }, '', this);
+ snapNames = snapNames.slice(0, snapNames.length - 1);
+
+ var snapIds = _.reduce(this.selectedSnapshots, function(str, snap) {
+ return str + snap.id + ',';
+ }, '', this);
+ snapIds = snapIds.slice(0, snapIds.length - 1);
+
+ var totalSize = _.reduce(this.selectedSnapshots, function(sum, snap) {
+ return sum + snap.get('eusage');
+ }, 0, this);
+
+ var totalSizeStr = humanize.filesize(totalSize * 1024);
+
+ if (confirm(confirmMsg + snapNames + ' deletes ' + totalSizeStr + ' of data. Are you sure?')) {
+ disableButton(button);
+
+ _.each(this.selectedSnapshots, function(s) {
+ var name = s.get('name');
+
+ _this.shares.each(function(share, index) {
+ if (s.get('share') == share.get('id')) {
+ var shareName = share.get('name');
+ $.ajax({
+ url: '/api/shares/' + shareName + '/snapshots/' + name,
+ type: 'DELETE',
+ success: function() {
+ enableButton(button);
+ _this.$('[rel=tooltip]').tooltip('hide');
+ _this.selectedSnapshots = [];
+ _this.collection.fetch({
+ reset: true
+ });
+
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ _this.$('[rel=tooltip]').tooltip('hide');
+ }
+ });
+
+ }
+ });
+ });
+ }
+
+ }
},
selectedContains: function(name) {
- return _.find(this.selectedSnapshots, function(snap) {
- return snap.get('name') == name;
- });
+ return _.find(this.selectedSnapshots, function(snap) {
+ return snap.get('name') == name;
+ });
},
addToSelected: function(name) {
- this.selectedSnapshots.push(this.collection.find(function(snap) {
- return snap.get('name') == name;
- }));
+ this.selectedSnapshots.push(this.collection.find(function(snap) {
+ return snap.get('name') == name;
+ }));
},
removeFromSelected: function(name) {
- var i = _.indexOf(_.map(this.selectedSnapshots, function(snap) {
- return snap.get('name');
- }), name);
- this.selectedSnapshots.splice(i,1);
+ var i = _.indexOf(_.map(this.selectedSnapshots, function(snap) {
+ return snap.get('name');
+ }), name);
+ this.selectedSnapshots.splice(i, 1);
},
cancel: function(event) {
- event.preventDefault();
- this.render();
+ event.preventDefault();
+ this.render();
},
- initHandlebarHelpers: function(){
- var _this = this;
- Handlebars.registerHelper('checkboxValue', function(snapName){
- var html = '';
- if (RockstorUtil.listContains(_this.selectedSnapshots, 'name', snapName)) {
- html += 'checked="checked"';
- } else {
- html += '';
- }
- return new Handlebars.SafeString(html);
- });
-
- Handlebars.registerHelper('getToc', function(toc){
- return moment(toc).format(RS_DATE_FORMAT);
- });
-
- Handlebars.registerHelper('getSize', function(size){
- return humanize.filesize(size * 1024);
- });
-
- //Create Snapshot Template Helpers
- Handlebars.registerHelper('show_shares_dropdown', function() {
- var html = '';
- _this.shares.each( function(share, index) {
- var shareName = share.get('name');
- html += '' + shareName + ' ';
- });
- return new Handlebars.SafeString(html);
- });
-
- Handlebars.registerHelper('display_writeable_options', function() {
- var html = '';
- _.each(_this.modify_choices, function(c) {
- html += '';
- if(c.value == 'yes'){
- html += ' ' + c.name;
- }else{
- html += ' ' + c.name;
- }
- html += ' ';
- });
- return new Handlebars.SafeString(html);
- });
+ initHandlebarHelpers: function() {
+ var _this = this;
+ Handlebars.registerHelper('checkboxValue', function(snapName) {
+ var html = '';
+ if (RockstorUtil.listContains(_this.selectedSnapshots, 'name', snapName)) {
+ html += 'checked="checked"';
+ } else {
+ html += '';
+ }
+ return new Handlebars.SafeString(html);
+ });
+
+ Handlebars.registerHelper('getToc', function(toc) {
+ return moment(toc).format(RS_DATE_FORMAT);
+ });
+
+ Handlebars.registerHelper('getSize', function(size) {
+ return humanize.filesize(size * 1024);
+ });
+
+ //Create Snapshot Template Helpers
+ Handlebars.registerHelper('show_shares_dropdown', function() {
+ var html = '';
+ _this.shares.each(function(share, index) {
+ var shareName = share.get('name');
+ html += '' + shareName + ' ';
+ });
+ return new Handlebars.SafeString(html);
+ });
+
+ Handlebars.registerHelper('display_writeable_options', function() {
+ var html = '';
+ _.each(_this.modify_choices, function(c) {
+ html += '';
+ if (c.value == 'yes') {
+ html += ' ' + c.name;
+ } else {
+ html += ' ' + c.name;
+ }
+ html += ' ';
+ });
+ return new Handlebars.SafeString(html);
+ });
}
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/snapshots_table.js b/src/rockstor/storageadmin/static/storageadmin/js/views/snapshots_table.js
index f01f7d52a..574c6e3a2 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/snapshots_table.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/snapshots_table.js
@@ -26,13 +26,13 @@
SnapshotsTableModule = SnapshotsCommonView.extend({
events: {
- "click #js-snapshot-add": "add",
- "click #js-snapshot-cancel": "cancel",
- "click .js-snapshot-delete": "deleteSnapshot",
- "click .js-snapshot-clone": "cloneSnapshot",
- "click .js-snapshot-select": "selectSnapshot",
- "click .js-snapshot-select-all": "selectAllSnapshots",
- "click #js-snapshot-delete-multiple": "deleteMultipleSnapshots"
+ 'click #js-snapshot-add': 'add',
+ 'click #js-snapshot-cancel': 'cancel',
+ 'click .js-snapshot-delete': 'deleteSnapshot',
+ 'click .js-snapshot-clone': 'cloneSnapshot',
+ 'click .js-snapshot-select': 'selectSnapshot',
+ 'click .js-snapshot-select-all': 'selectAllSnapshots',
+ 'click #js-snapshot-delete-multiple': 'deleteMultipleSnapshots'
},
initialize: function() {
@@ -42,7 +42,7 @@ SnapshotsTableModule = SnapshotsCommonView.extend({
this.share = this.options.share;
this.snapshots = this.options.snapshots;
this.collection = this.options.snapshots;
- this.collection.on("reset", this.render, this);
+ this.collection.on('reset', this.render, this);
this.selectedSnapshots = [];
this.parentView = this.options.parentView;
this.initHandlebarHelpers();
@@ -87,7 +87,7 @@ SnapshotsTableModule = SnapshotsCommonView.extend({
var err_msg = '';
var name_err_msg = function() {
return err_msg;
- }
+ };
$.validator.addMethod('validateSnapshotName', function(value) {
var snapshot_name = $('#snapshot-name').val();
@@ -110,9 +110,9 @@ SnapshotsTableModule = SnapshotsCommonView.extend({
if (buttonDisabled(button)) return false;
disableButton(button);
$.ajax({
- url: "/api/shares/" + _this.share.get('name') + "/snapshots/" + _this.$('#snapshot-name').val(),
- type: "POST",
- dataType: "json",
+ url: '/api/shares/' + _this.share.get('name') + '/snapshots/' + _this.$('#snapshot-name').val(),
+ type: 'POST',
+ dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(_this.$('#add-snapshot-form').getJSON()),
success: function() {
@@ -139,16 +139,16 @@ SnapshotsTableModule = SnapshotsCommonView.extend({
var _this = this;
var name = $(event.currentTarget).attr('data-name');
var esize = $(event.currentTarget).attr('data-size');
- var share_name = this.share.get("name");
+ var share_name = this.share.get('name');
var button = $(event.currentTarget);
if (buttonDisabled(button)) return false;
- if (confirm("Deleting snapshot(" + name + ") deletes " + esize + " of data permanently. Do you really want to delete it?")) {
+ if (confirm('Deleting snapshot(' + name + ') deletes ' + esize + ' of data permanently. Do you really want to delete it?')) {
disableButton(button);
$.ajax({
- url: "/api/shares/" + share_name + "/snapshots/" + name,
- type: "DELETE",
+ url: '/api/shares/' + share_name + '/snapshots/' + name,
+ type: 'DELETE',
success: function() {
- enableButton(button)
+ enableButton(button);
_this.$('[rel=tooltip]').tooltip('hide');
_this.selectedSnapshots = [];
_this.collection.fetch({
@@ -158,7 +158,7 @@ SnapshotsTableModule = SnapshotsCommonView.extend({
});
},
error: function(xhr, status, error) {
- enableButton(button)
+ enableButton(button);
_this.$('[rel=tooltip]').tooltip('hide');
}
});
@@ -184,7 +184,7 @@ SnapshotsTableModule = SnapshotsCommonView.extend({
event.preventDefault();
var button = $(event.currentTarget);
if (buttonDisabled(button)) return false;
- var share_name = this.share.get("name");
+ var share_name = this.share.get('name');
if (this.selectedSnapshots.length == 0) {
alert('Select at least one snapshot to delete');
} else {
@@ -209,10 +209,10 @@ SnapshotsTableModule = SnapshotsCommonView.extend({
if (confirm(confirmMsg + snapNames + ' deletes ' + totalSizeStr + ' of data. Are you sure?')) {
disableButton(button);
$.ajax({
- url: "/api/shares/" + share_name + "/snapshots?id=" + snapIds,
- type: "DELETE",
+ url: '/api/shares/' + share_name + '/snapshots?id=' + snapIds,
+ type: 'DELETE',
success: function() {
- enableButton(button)
+ enableButton(button);
_this.$('[rel=tooltip]').tooltip('hide');
// reset selected snapshots
_this.selectedSnapshots = [];
@@ -229,7 +229,7 @@ SnapshotsTableModule = SnapshotsCommonView.extend({
}
},
error: function(xhr, status, error) {
- enableButton(button)
+ enableButton(button);
_this.$('[rel=tooltip]').tooltip('hide');
_this.selectedSnapshots = [];
_this.collection.fetch();
@@ -287,4 +287,4 @@ SnapshotsTableModule = SnapshotsCommonView.extend({
});
//Add pagination
-Cocktail.mixin(SnapshotsTableModule, PaginationMixin);
+Cocktail.mixin(SnapshotsTableModule, PaginationMixin);
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/spindown_disks.js b/src/rockstor/storageadmin/static/storageadmin/js/views/spindown_disks.js
index aa908a6ab..81ec21222 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/spindown_disks.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/spindown_disks.js
@@ -29,44 +29,44 @@ SpindownDiskView = RockstorLayoutView.extend({
'click #cancel': 'cancel'
},
- initialize: function () {
+ initialize: function() {
var _this = this;
this.constructor.__super__.initialize.apply(this, arguments);
this.template = window.JST.disk_spindown_disks;
this.disks = new DiskCollection();
this.diskName = this.options.diskName;
this.dependencies.push(this.disks);
- this.tickFormatter = function (d) {
- var formatter = d3.format(",.0f");
+ this.tickFormatter = function(d) {
+ var formatter = d3.format(',.0f');
if (d > 254.4) {
- return formatter(d) + " off";
+ return formatter(d) + ' off';
}
if (d < 0.5) {
- return "none"
+ return 'none';
}
return formatter(d);
- }
- this.tickFormatterText = function (d) {
- var formatter = d3.format(",.0f");
+ };
+ this.tickFormatterText = function(d) {
+ var formatter = d3.format(',.0f');
return formatter(d);
- }
+ };
this.slider = null;
// update the text box apm_value when ever the slider is moved.
- this.sliderCallback = function (slider) {
+ this.sliderCallback = function(slider) {
var value = slider.value();
_this.$('#apm_value').val(_this.tickFormatterText(value));
- }
+ };
this.initHandlebarHelpers();
},
- render: function () {
+ render: function() {
this.fetch(this.renderDisksForm, this);
return this;
},
- renderDisksForm: function () {
+ renderDisksForm: function() {
if (this.$('[rel=tooltip]')) {
- this.$("[rel=tooltip]").tooltip('hide');
+ this.$('[rel=tooltip]').tooltip('hide');
}
var _this = this;
var disk_name = this.diskName;
@@ -86,15 +86,15 @@ SpindownDiskView = RockstorLayoutView.extend({
};
_this.spindownTimes = spindownTimes;
// retrieve local copy of disk serial number
- var serialNumber = this.disks.find(function (d) {
+ var serialNumber = this.disks.find(function(d) {
return (d.get('name') == disk_name);
}).get('serial');
// retrieve local copy of current hdparm settings
- var hdparmSetting = this.disks.find(function (d) {
+ var hdparmSetting = this.disks.find(function(d) {
return (d.get('name') == disk_name);
}).get('hdparm_setting');
// retrieve local copy of current apm level
- var apmLevel = this.disks.find(function (d) {
+ var apmLevel = this.disks.find(function(d) {
return (d.get('name') == disk_name);
}).get('apm_level');
@@ -112,13 +112,13 @@ SpindownDiskView = RockstorLayoutView.extend({
});
var err_msg = '';
- var spindown_err_msg = function () {
+ var spindown_err_msg = function() {
return err_msg;
};
- $.validator.addMethod('validateApmValue', function (value) {
+ $.validator.addMethod('validateApmValue', function(value) {
var apm_value = $('#apm_value').val();
- if (apm_value == "") {
+ if (apm_value == '') {
err_msg = 'Please enter an APM value (1-255), or 0 to not apply an APM settings.';
return false;
}
@@ -133,7 +133,7 @@ SpindownDiskView = RockstorLayoutView.extend({
return true;
}, spindown_err_msg);
- this.$('#enable_apm').click(function () {
+ this.$('#enable_apm').click(function() {
// $('#apm_value').prop('disable', !this.checked); // disable apm text
//$('#slide_lower_half').prop('disable', !this.checked);
//$('#slide_upper_half').prop('disable', !this.checked);
@@ -171,7 +171,7 @@ SpindownDiskView = RockstorLayoutView.extend({
// apm_value = the text box and it's entered value
// update the slider when the apm_value text box is changed
//_this.$('#apm_value').focusout(function () {
- _this.$('#apm_value').change(function () {
+ _this.$('#apm_value').change(function() {
var our_value = this.value;
// avoid passing NaN value to slider, leaving them to be
// validated by our forms validateApmValue
@@ -198,7 +198,7 @@ SpindownDiskView = RockstorLayoutView.extend({
//},
},
- submitHandler: function () {
+ submitHandler: function() {
var button = $('#spindown-disk');
if (buttonDisabled(button)) return false;
disableButton(button);
@@ -206,7 +206,7 @@ SpindownDiskView = RockstorLayoutView.extend({
var posturl = '/api/disks/' + disk_name + '/spindown-drive';
var data = _this.$('#add-spindown-disk-form').getJSON();
var selected_time = data.spindown_time;
- var spindown_text = "no message";
+ var spindown_text = 'no message';
// look through spindownTimes to find the selected value
for (var time_string in _this.spindownTimes) {
if (_this.spindownTimes[time_string] == selected_time) {
@@ -227,13 +227,15 @@ SpindownDiskView = RockstorLayoutView.extend({
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(data),
- success: function () {
+ success: function() {
enableButton(button);
_this.$('#add-spindown-disk-form :input').tooltip('hide');
- app_router.navigate('disks', {trigger: true});
+ app_router.navigate('disks', {
+ trigger: true
+ });
},
- error: function (xhr, status, error) {
+ error: function(xhr, status, error) {
enableButton(button);
}
});
@@ -243,13 +245,13 @@ SpindownDiskView = RockstorLayoutView.extend({
});
},
- initHandlebarHelpers: function () {
+ initHandlebarHelpers: function() {
// helper to fill dropdown with drive spindown values
// eg by generating dynamicaly lines of the following
// 20 minutes
- Handlebars.registerHelper('display_spindown_time', function () {
+ Handlebars.registerHelper('display_spindown_time', function() {
var html = '';
- if (this.hdparmSetting == null){
+ if (this.hdparmSetting == null) {
// if there is no previous setting then default to 20 minutes
this.hdparmSetting = '20 minutes';
}
@@ -268,17 +270,19 @@ SpindownDiskView = RockstorLayoutView.extend({
});
},
- renderSlider: function () {
+ renderSlider: function() {
// Callback used to broadcast our changing value.
this.$('#slider').empty();
this.slider = d3.slider2().min(0).max(255).ticks(10).tickFormat(this.tickFormatter).value(0).reclaimable(127).used(0.5).callback(this.sliderCallback);
d3.select('#slider').call(this.slider);
},
- cancel: function (event) {
+ cancel: function(event) {
event.preventDefault();
this.$('#add-spindown-disk-form :input').tooltip('hide');
- app_router.navigate('disks', {trigger: true});
+ app_router.navigate('disks', {
+ trigger: true
+ });
}
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/tasks.js b/src/rockstor/storageadmin/static/storageadmin/js/views/tasks.js
index 5c560c40d..50b27cba6 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/tasks.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/tasks.js
@@ -1,4 +1,3 @@
-
/*
*
* @licstart The following is the entire license notice for the
@@ -26,74 +25,75 @@
*/
TasksView = RockstorLayoutView.extend({
- events: {
- },
+ events: {},
+
+ initialize: function() {
+ // call initialize of base
+ this.constructor.__super__.initialize.apply(this, arguments);
+ // set template
+ this.template = window.JST.scheduled_tasks_tasks;
+ // add dependencies
+ this.taskDefId = this.options.taskDefId;
+ this.taskDef = new TaskDef({
+ id: this.taskDefId
+ });
+ this.dependencies.push(this.taskDef);
+ this.collection = new TaskCollection(null, {
+ taskDefId: this.taskDefId
+ });
+ this.collection.pageSize = 10;
+ this.dependencies.push(this.collection);
+ this.collection.on('reset', this.renderTasks, this);
+ // has the replica been fetched? prevents renderReplicaTrails executing
+ // (because of collection reset) before replica has been fetched
+ this.taskDefFetched = false;
+ this.initHandlebarHelpers();
+ },
- initialize: function() {
- // call initialize of base
- this.constructor.__super__.initialize.apply(this, arguments);
- // set template
- this.template = window.JST.scheduled_tasks_tasks;
- // add dependencies
- this.taskDefId = this.options.taskDefId;
- this.taskDef = new TaskDef({id: this.taskDefId});
- this.dependencies.push(this.taskDef);
- this.collection = new TaskCollection(null, {
- taskDefId: this.taskDefId
- });
- this.collection.pageSize = 10;
- this.dependencies.push(this.collection);
- this.collection.on("reset", this.renderTasks, this);
- // has the replica been fetched? prevents renderReplicaTrails executing
- // (because of collection reset) before replica has been fetched
- this.taskDefFetched = false;
- this.initHandlebarHelpers();
- },
+ render: function() {
+ this.fetch(this.firstFetch, this);
+ return this;
+ },
- render: function() {
- this.fetch(this.firstFetch, this);
- return this;
- },
+ firstFetch: function() {
+ this.taskDefFetched = true;
+ this.renderTasks();
+ },
- firstFetch: function() {
- this.taskDefFetched = true;
- this.renderTasks();
- },
+ renderTasks: function() {
+ if (!this.taskDefFetched) return false;
+ var _this = this;
+ $(this.el).html(this.template({
+ taskDef: this.taskDef,
+ taskName: this.taskDef.get('name'),
+ taskColl: this.collection.toJSON(),
+ collection: this.collection,
+ collectionNotEmpty: !this.collection.isEmpty(),
+ }));
+ this.$('[rel=tooltip]').tooltip({
+ placement: 'bottom'
+ });
- renderTasks: function() {
- if (!this.taskDefFetched) return false;
- var _this = this;
- $(this.el).html(this.template({
- taskDef: this.taskDef,
- taskName: this.taskDef.get('name'),
- taskColl: this.collection.toJSON(),
- collection: this.collection,
- collectionNotEmpty: !this.collection.isEmpty(),
- }));
- this.$('[rel=tooltip]').tooltip({ placement: 'bottom'});
-
- this.renderDataTables();
- },
+ this.renderDataTables();
+ },
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_snapshot_scrub', function(){
- var html = '';
- if (this.taskDef.get('task_type') == 'snapshot') {
- html += 'Snapshot of Share[' + JSON.parse(this.taskDef.get('json_meta')).share + ']';
- } else {
- html += 'Scrub of Pool[' + JSON.parse(this.taskDef.get('json_meta')).pool + ']';
- }
- return new Handlebars.SafeString(html);
- });
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_snapshot_scrub', function() {
+ var html = '';
+ if (this.taskDef.get('task_type') == 'snapshot') {
+ html += 'Snapshot of Share[' + JSON.parse(this.taskDef.get('json_meta')).share + ']';
+ } else {
+ html += 'Scrub of Pool[' + JSON.parse(this.taskDef.get('json_meta')).pool + ']';
+ }
+ return new Handlebars.SafeString(html);
+ });
- Handlebars.registerHelper('dateFormat', function(taskTime){
- return moment(taskTime).format(RS_DATE_FORMAT);
- });
- }
+ Handlebars.registerHelper('dateFormat', function(taskTime) {
+ return moment(taskTime).format(RS_DATE_FORMAT);
+ });
+ }
});
//Add pagination
-Cocktail.mixin(TasksView, PaginationMixin);
-
-
+Cocktail.mixin(TasksView, PaginationMixin);
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/update_certificate.js b/src/rockstor/storageadmin/static/storageadmin/js/views/update_certificate.js
index 5820e5bb8..a1649d601 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/update_certificate.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/update_certificate.js
@@ -25,104 +25,115 @@
*/
UpdateCertificateView = RockstorLayoutView.extend({
- events: {
- "click #update-certificate" : "renderCertificateForm",
- "click #cancel": "cancel"
- },
+ events: {
+ 'click #update-certificate': 'renderCertificateForm',
+ 'click #cancel': 'cancel'
+ },
- initialize: function() {
- // call initialize of base
- this.constructor.__super__.initialize.apply(this, arguments);
- this.updatetemplate = window.JST.setup_update_certificate;
- this.template = window.JST.setup_certificate_desc;
- this.certificate = new Certificate();
- this.certificates = new Certificate();
- this.dependencies.push(this.certificates);
- this.initHandlebarHelpers();
- },
+ initialize: function() {
+ // call initialize of base
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.updatetemplate = window.JST.setup_update_certificate;
+ this.template = window.JST.setup_certificate_desc;
+ this.certificate = new Certificate();
+ this.certificates = new Certificate();
+ this.dependencies.push(this.certificates);
+ this.initHandlebarHelpers();
+ },
- render: function() {
- var _this = this;
- this.fetch(this.renderCertificate, this);
- return this;
- },
+ render: function() {
+ var _this = this;
+ this.fetch(this.renderCertificate, this);
+ return this;
+ },
- renderCertificate: function() {
- var cert = _.first(this.certificates.get("results"));
- this.certificate.set(cert);
- this.renderCertificateDescription();
- },
+ renderCertificate: function() {
+ var cert = _.first(this.certificates.get('results'));
+ this.certificate.set(cert);
+ this.renderCertificateDescription();
+ },
- renderCertificateDescription: function() {
- var cname = this.certificate.get("name");
- $(this.el).html(this.template({"name": cname}));
- },
+ renderCertificateDescription: function() {
+ var cname = this.certificate.get('name');
+ $(this.el).html(this.template({
+ 'name': cname
+ }));
+ },
- cancel: function(event) {
- $(this.el).empty();
- var cname = this.certificate.get("name");
- $(this.el).html(this.template({"name": cname}));
- },
+ cancel: function(event) {
+ $(this.el).empty();
+ var cname = this.certificate.get('name');
+ $(this.el).html(this.template({
+ 'name': cname
+ }));
+ },
- renderCertificateForm: function() {
- var _this = this;
- $(this.el).html(this.updatetemplate());
- this.$('#update-certificate-form :input').tooltip({placement: 'right'});
- this.$('#group').chosen();
+ renderCertificateForm: function() {
+ var _this = this;
+ $(this.el).html(this.updatetemplate());
+ this.$('#update-certificate-form :input').tooltip({
+ placement: 'right'
+ });
+ this.$('#group').chosen();
- this.validator = this.$("#update-certificate-form").validate({
- onfocusout: false,
- onkeyup: false,
- rules: {
- certificatename: 'required',
- certificate: 'required',
- privatekey: 'required'
- },
- submitHandler: function() {
- var button = $('#save-certificate');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- var certificateName = $('#certificatename').val();
- var certificate = $('#certificate').val();
- var privatekey = $('#privatekey').val();
- var certData = JSON.stringify({"name": certificateName,
- "cert": certificate, "key": privatekey});
- $.ajax({
- url: '/api/certificate',
- type: 'POST',
- dataType: 'json',
- contentType: 'application/json',
- data: certData,
- success: function() {
- enableButton(button);
- _this.$('#update-certificate-form :input').tooltip('hide');
- _this.certificate.set({"name": certificateName});
- alert('Certificate update successfully. It will take effect now.');
- location.reload();
- _this.renderCertificateDescription();
- },
- error: function(xhr, status, error) {
- enableButton(button);
- _this.$('#update-certificate-form :input').tooltip('hide');
- var msg = parseXhrError(xhr.responseText);
- _this.$(".messages").html(msg);
- },
- });
- }
- });
- return this;
- },
+ this.validator = this.$('#update-certificate-form').validate({
+ onfocusout: false,
+ onkeyup: false,
+ rules: {
+ certificatename: 'required',
+ certificate: 'required',
+ privatekey: 'required'
+ },
+ submitHandler: function() {
+ var button = $('#save-certificate');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ var certificateName = $('#certificatename').val();
+ var certificate = $('#certificate').val();
+ var privatekey = $('#privatekey').val();
+ var certData = JSON.stringify({
+ 'name': certificateName,
+ 'cert': certificate,
+ 'key': privatekey
+ });
+ $.ajax({
+ url: '/api/certificate',
+ type: 'POST',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: certData,
+ success: function() {
+ enableButton(button);
+ _this.$('#update-certificate-form :input').tooltip('hide');
+ _this.certificate.set({
+ 'name': certificateName
+ });
+ alert('Certificate update successfully. It will take effect now.');
+ location.reload();
+ _this.renderCertificateDescription();
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ _this.$('#update-certificate-form :input').tooltip('hide');
+ var msg = parseXhrError(xhr.responseText);
+ _this.$('.messages').html(msg);
+ },
+ });
+ }
+ });
+ return this;
+ },
- initHandlebarHelpers: function(){
- Handlebars.registerHelper('display_message', function(){
- var html = '';
- if (_.isEmpty(name)) {
- html += 'A self signed Certificate created during installation is in use by default.';
- } else {
- html += 'Admin provided Certificate(' + name + ') is currently in use.';
- }
- return new Handlebars.SafeString(html);
- });
- }
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_message', function() {
+ var html = '';
+ if (_.isEmpty(name)) {
+ html += 'A self signed Certificate created during installation is in use by default.';
+ } else {
+ html += 'Admin provided Certificate(' + name + ') is currently in use.';
+ }
+ return new Handlebars.SafeString(html);
+ });
+ }
-});
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/users.js b/src/rockstor/storageadmin/static/storageadmin/js/views/users.js
index 47e5ab9fb..e4b3dc305 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/users.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/users.js
@@ -25,228 +25,243 @@
*/
UsersView = RockstorLayoutView.extend({
- events: {
- "click .delete-user": "deleteUser",
- "click .edit-user": "editUser",
- "click .add-pincard": "addPincard",
- "hidden.bs.modal #pincard-modal": "PincardModalClose"
- },
-
- initialize: function() {
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.users_users;
- this.collection = new UserCollection();
- this.dependencies.push(this.collection);
- this.collection.on("reset", this.renderUsers, this);
- this.initHandlebarHelpers();
- },
-
- render: function() {
- this.collection.fetch();
- return this;
- },
-
- renderUsers: function() {
- if (this.$('[rel=tooltip]')) {
- this.$('[rel=tooltip]').tooltip('hide');
- }
-
- this.rockstorUsers = this.collection.filter(function(grp) {
- return (grp.get('admin'))
- });
- this.otherSystemUsers = this.collection.filter(function(grp) {
- return (!grp.get('admin'))
- });
-
- $(this.el).html(this.template({
- collection: this.collection,
- rockstorUsers: this.rockstorUsers,
- otherSystemUsers: this.otherSystemUsers,
- }));
-
- this.$('[rel=tooltip]').tooltip({
- placement: 'bottom'
- });
- this.renderDataTables();
- },
-
- deleteUser: function(event) {
- event.preventDefault();
- var _this = this;
- var username = $(event.currentTarget).attr('data-username');
- if (confirm("Delete user: " + username + ". Are you sure?")) {
- $.ajax({
- url: "/api/users/" + username,
- type: "DELETE",
- dataType: "json",
- success: function() {
- _this.collection.fetch();
- },
- error: function(xhr, status, error) {}
- });
- } else {
- return false;
- }
- },
-
- editUser: function(event) {
- if (event) event.preventDefault();
- if (this.$('[rel=tooltip]')) {
- this.$('[rel=tooltip]').tooltip('hide');
- }
- var username = $(event.currentTarget).attr('data-username');
- app_router.navigate('users/' + username + '/edit', {
- trigger: true
- });
- },
-
- addPincard: function(event) {
- event.preventDefault();
- var uid = $(event.currentTarget).attr('data-uid');
- var username = $(event.currentTarget).attr('data-username');
- RockStorSocket.pincardManager = io.connect('/pincardmanager', {
+ events: {
+ 'click .delete-user': 'deleteUser',
+ 'click .edit-user': 'editUser',
+ 'click .add-pincard': 'addPincard',
+ 'hidden.bs.modal #pincard-modal': 'PincardModalClose'
+ },
+
+ initialize: function() {
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.users_users;
+ this.collection = new UserCollection();
+ this.dependencies.push(this.collection);
+ this.collection.on('reset', this.renderUsers, this);
+ this.initHandlebarHelpers();
+ },
+
+ render: function() {
+ this.collection.fetch();
+ return this;
+ },
+
+ renderUsers: function() {
+ if (this.$('[rel=tooltip]')) {
+ this.$('[rel=tooltip]').tooltip('hide');
+ }
+
+ this.rockstorUsers = this.collection.filter(function(grp) {
+ return (grp.get('admin'));
+ });
+ this.otherSystemUsers = this.collection.filter(function(grp) {
+ return (!grp.get('admin'));
+ });
+
+ $(this.el).html(this.template({
+ collection: this.collection,
+ rockstorUsers: this.rockstorUsers,
+ otherSystemUsers: this.otherSystemUsers,
+ }));
+
+ this.$('[rel=tooltip]').tooltip({
+ placement: 'bottom'
+ });
+ this.renderDataTables();
+ },
+
+ deleteUser: function(event) {
+ event.preventDefault();
+ var _this = this;
+ var username = $(event.currentTarget).attr('data-username');
+ if (confirm('Delete user: ' + username + '. Are you sure?')) {
+ $.ajax({
+ url: '/api/users/' + username,
+ type: 'DELETE',
+ dataType: 'json',
+ success: function() {
+ _this.collection.fetch();
+ },
+ error: function(xhr, status, error) {}
+ });
+ } else {
+ return false;
+ }
+ },
+
+ editUser: function(event) {
+ if (event) event.preventDefault();
+ if (this.$('[rel=tooltip]')) {
+ this.$('[rel=tooltip]').tooltip('hide');
+ }
+ var username = $(event.currentTarget).attr('data-username');
+ app_router.navigate('users/' + username + '/edit', {
+ trigger: true
+ });
+ },
+
+ addPincard: function(event) {
+ event.preventDefault();
+ var uid = $(event.currentTarget).attr('data-uid');
+ var username = $(event.currentTarget).attr('data-username');
+ RockStorSocket.pincardManager = io.connect('/pincardmanager', {
'secure': true,
'force new connection': true
});
- $('#pincard_user').text(username);
- RockStorSocket.addListener(this.renderPincard, this, 'pincardManager:newpincard');
- RockStorSocket.pincardManager.emit('generatepincard', uid);
- },
-
- renderPincard: function(data) {
-
- //Define start and default values
- var pins_array = data;
- var pin_cells_start = {'x': 7, 'y': 18};
- var pin_cells_dimensions = {'x': 45, 'y': 30};
- var pin_indexes_start = {'x': 28, 'y': 15};
- var pin_texts_start = {'x': 30, 'y': 38};
- var pincard_objects_slide = {'x': 53, 'y': 46};
- var Pincard_canvas = $('#Pincard_canvas')[0];
- var ctx = Pincard_canvas.getContext("2d");
- //Clear Pincard canvas
- ctx.clearRect(0, 0, 324, 204);
- //Create canvas shape and fill will black background
- ctx.fillStyle = "black";
- ctx.strokeStyle = "black";
- ctx.moveTo(12, 0);
- ctx.lineTo(312, 0);
- ctx.arcTo(324, 0, 324, 12, 12);
- ctx.lineTo(324, 192);
- ctx.arcTo(324, 204, 312, 204, 12);
- ctx.lineTo(12, 204);
- ctx.arcTo(0, 204, 0, 192, 12);
- ctx.lineTo(0, 12);
- ctx.arcTo(0, 0, 12, 0, 12);
- ctx.fill();
- //Add Rockstor watermark image then render pins cells, indexes and pins values
- var background_image = $('#canvas_background')[0];
- //Reduce opacity for background image
- ctx.globalAlpha = 0.3
- ctx.drawImage(background_image, 32, 2, 260, 208);
- //Back to normal opacity for pin cells, indexes and values
- ctx.globalAlpha = 1
- ctx.strokeStyle = "white";
- ctx.lineWidth = "2";
- ctx.fillStyle = "white";
- ctx.textAlign = "center";
- var pin_index, x_delta, y_delta, pin_cell_x, pin_cell_y,
- pin_index_x, pin_index_y, pin_text_x, pin_text_y;
- var pins_string = '';
-
- for (var y=0;y<=3;y++){
- //Loop through Pincard rows and calculate y deltas for every object
- y_delta = y*pincard_objects_slide['y'];
- pin_cell_y = pin_cells_start['y'] + y_delta;
- pin_index_y = pin_indexes_start['y'] + y_delta;
- pin_text_y = pin_texts_start['y'] + y_delta;
- pins_string += '';
-
- for (var x=0;x<=5;x++){
- //Loop through Pincard columns and calculate
- //x deltas for every object and current pin index value
- pin_index = (x+1)+y*6;
- x_delta = x*pincard_objects_slide['x'];
- pin_cell_x = pin_cells_start['x'] + x_delta;
- pin_index_x = pin_indexes_start['x'] + x_delta;
- pin_text_x = pin_texts_start['x'] + x_delta;
- //Render Pin cell
- ctx.strokeRect(pin_cell_x, pin_cell_y, pin_cells_dimensions.x, pin_cells_dimensions.y);
- //Render Pin index
- ctx.font = "bold 13px Courier New";
- ctx.fillText(pin_index, pin_index_x, pin_index_y);
- //Render Pin value
- ctx.font = "bold 14px Courier New";
- ctx.fillText(pins_array[pin_index-1], pin_text_x, pin_text_y);
- pins_string += '' + $('
').text(pins_array[pin_index-1]).html() + ' ';
- }
- pins_string += ' ';
- }
- pins_string += '
';
- $('#pins_list').html('Selectable Pincard pins: ' + pins_string);
+ $('#pincard_user').text(username);
+ RockStorSocket.addListener(this.renderPincard, this, 'pincardManager:newpincard');
+ RockStorSocket.pincardManager.emit('generatepincard', uid);
+ },
+
+ renderPincard: function(data) {
+
+ //Define start and default values
+ var pins_array = data;
+ var pin_cells_start = {
+ 'x': 7,
+ 'y': 18
+ };
+ var pin_cells_dimensions = {
+ 'x': 45,
+ 'y': 30
+ };
+ var pin_indexes_start = {
+ 'x': 28,
+ 'y': 15
+ };
+ var pin_texts_start = {
+ 'x': 30,
+ 'y': 38
+ };
+ var pincard_objects_slide = {
+ 'x': 53,
+ 'y': 46
+ };
+ var Pincard_canvas = $('#Pincard_canvas')[0];
+ var ctx = Pincard_canvas.getContext('2d');
+ //Clear Pincard canvas
+ ctx.clearRect(0, 0, 324, 204);
+ //Create canvas shape and fill will black background
+ ctx.fillStyle = 'black';
+ ctx.strokeStyle = 'black';
+ ctx.moveTo(12, 0);
+ ctx.lineTo(312, 0);
+ ctx.arcTo(324, 0, 324, 12, 12);
+ ctx.lineTo(324, 192);
+ ctx.arcTo(324, 204, 312, 204, 12);
+ ctx.lineTo(12, 204);
+ ctx.arcTo(0, 204, 0, 192, 12);
+ ctx.lineTo(0, 12);
+ ctx.arcTo(0, 0, 12, 0, 12);
+ ctx.fill();
+ //Add Rockstor watermark image then render pins cells, indexes and pins values
+ var background_image = $('#canvas_background')[0];
+ //Reduce opacity for background image
+ ctx.globalAlpha = 0.3;
+ ctx.drawImage(background_image, 32, 2, 260, 208);
+ //Back to normal opacity for pin cells, indexes and values
+ ctx.globalAlpha = 1;
+ ctx.strokeStyle = 'white';
+ ctx.lineWidth = '2';
+ ctx.fillStyle = 'white';
+ ctx.textAlign = 'center';
+ var pin_index, x_delta, y_delta, pin_cell_x, pin_cell_y,
+ pin_index_x, pin_index_y, pin_text_x, pin_text_y;
+ var pins_string = '';
+
+ for (var y = 0; y <= 3; y++) {
+ //Loop through Pincard rows and calculate y deltas for every object
+ y_delta = y * pincard_objects_slide['y'];
+ pin_cell_y = pin_cells_start['y'] + y_delta;
+ pin_index_y = pin_indexes_start['y'] + y_delta;
+ pin_text_y = pin_texts_start['y'] + y_delta;
+ pins_string += '';
+
+ for (var x = 0; x <= 5; x++) {
+ //Loop through Pincard columns and calculate
+ //x deltas for every object and current pin index value
+ pin_index = (x + 1) + y * 6;
+ x_delta = x * pincard_objects_slide['x'];
+ pin_cell_x = pin_cells_start['x'] + x_delta;
+ pin_index_x = pin_indexes_start['x'] + x_delta;
+ pin_text_x = pin_texts_start['x'] + x_delta;
+ //Render Pin cell
+ ctx.strokeRect(pin_cell_x, pin_cell_y, pin_cells_dimensions.x, pin_cells_dimensions.y);
+ //Render Pin index
+ ctx.font = 'bold 13px Courier New';
+ ctx.fillText(pin_index, pin_index_x, pin_index_y);
+ //Render Pin value
+ ctx.font = 'bold 14px Courier New';
+ ctx.fillText(pins_array[pin_index - 1], pin_text_x, pin_text_y);
+ pins_string += '' + $('
').text(pins_array[pin_index - 1]).html() + ' ';
+ }
+ pins_string += ' ';
+ }
+ pins_string += '
';
+ $('#pins_list').html('Selectable Pincard pins: ' + pins_string);
$('#pincard-modal').modal({
keyboard: false,
show: false,
backdrop: 'static'
});
$('#pincard-modal').modal('show');
- },
-
- PincardModalClose: function(){
-
- RockStorSocket.removeOneListener('pincardManager');
- RockStorSocket.pincardManager.disconnect();
- },
-
- initHandlebarHelpers: function() {
- Handlebars.registerHelper('display_users_table', function(adminBool) {
- var html = '';
- var filteredCollection = null;
- if (adminBool) {
- filteredCollection = this.rockstorUsers;
- } else {
- filteredCollection = this.otherSystemUsers;
- }
- if (filteredCollection == null) {
- html += "No groups exist";
- } else {
- for (var i = 0; i < filteredCollection.length; i++) {
- var has_pincard = filteredCollection[i].get('has_pincard');
- var pincard_allowed = filteredCollection[i].get('pincard_allowed');
-
- html += '';
- html += ' ' + filteredCollection[i].get('username') + ' ';
- html += '' + filteredCollection[i].get('uid') + ' ';
- html += '' + filteredCollection[i].get('groupname') + ' ';
- html += '' + filteredCollection[i].get('gid') + ' ';
- html += '';
- if (filteredCollection[i].get('shell') != null) {
- html += filteredCollection[i].get('shell');
- }
- html += ' ';
- html += '';
- if (filteredCollection[i].get('managed_user')) {
- html += ' ';
- html += ' ';
- }
- if (has_pincard && pincard_allowed=='yes') {
- html += ' ';
- } else {
- switch (pincard_allowed) {
- case 'yes':
- html += ' ';
- break;
- case 'otp':
- html += ' ';
- break;
- }
- }
- html += ' ';
- html += ' ';
- }
- }
- return new Handlebars.SafeString(html);
- });
- }
-
-});
+ },
+
+ PincardModalClose: function() {
+
+ RockStorSocket.removeOneListener('pincardManager');
+ RockStorSocket.pincardManager.disconnect();
+ },
+
+ initHandlebarHelpers: function() {
+ Handlebars.registerHelper('display_users_table', function(adminBool) {
+ var html = '';
+ var filteredCollection = null;
+ if (adminBool) {
+ filteredCollection = this.rockstorUsers;
+ } else {
+ filteredCollection = this.otherSystemUsers;
+ }
+ if (filteredCollection == null) {
+ html += 'No groups exist';
+ } else {
+ for (var i = 0; i < filteredCollection.length; i++) {
+ var has_pincard = filteredCollection[i].get('has_pincard');
+ var pincard_allowed = filteredCollection[i].get('pincard_allowed');
+
+ html += '';
+ html += ' ' + filteredCollection[i].get('username') + ' ';
+ html += '' + filteredCollection[i].get('uid') + ' ';
+ html += '' + filteredCollection[i].get('groupname') + ' ';
+ html += '' + filteredCollection[i].get('gid') + ' ';
+ html += '';
+ if (filteredCollection[i].get('shell') != null) {
+ html += filteredCollection[i].get('shell');
+ }
+ html += ' ';
+ html += '';
+ if (filteredCollection[i].get('managed_user')) {
+ html += ' ';
+ html += ' ';
+ }
+ if (has_pincard && pincard_allowed == 'yes') {
+ html += ' ';
+ } else {
+ switch (pincard_allowed) {
+ case 'yes':
+ html += ' ';
+ break;
+ case 'otp':
+ html += ' ';
+ break;
+ }
+ }
+ html += ' ';
+ html += ' ';
+ }
+ }
+ return new Handlebars.SafeString(html);
+ });
+ }
+
+});
\ No newline at end of file
diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/version.js b/src/rockstor/storageadmin/static/storageadmin/js/views/version.js
index c0392d31f..b3ba94e7f 100644
--- a/src/rockstor/storageadmin/static/storageadmin/js/views/version.js
+++ b/src/rockstor/storageadmin/static/storageadmin/js/views/version.js
@@ -26,312 +26,312 @@
VersionView = RockstorLayoutView.extend({
events: {
- 'click #update': 'update',
- 'click #donateYes': 'donateYes',
- 'click #autoUpdateSwitch': 'autoUpdateSwitch',
- 'click #enableAuto': 'enableAutoUpdate',
- 'click #disableAuto': 'disableAutoUpdate',
- 'click #stable-modal': 'showStableModal',
- 'click #testing-modal': 'showTestingModal',
- 'click #activateStable': 'activateStable',
- 'click #activateTesting': 'activateTesting'
+ 'click #update': 'update',
+ 'click #donateYes': 'donateYes',
+ 'click #autoUpdateSwitch': 'autoUpdateSwitch',
+ 'click #enableAuto': 'enableAutoUpdate',
+ 'click #disableAuto': 'disableAutoUpdate',
+ 'click #stable-modal': 'showStableModal',
+ 'click #testing-modal': 'showTestingModal',
+ 'click #activateStable': 'activateStable',
+ 'click #activateTesting': 'activateTesting'
},
initialize: function() {
- // call initialize of base
- this.constructor.__super__.initialize.apply(this, arguments);
- this.template = window.JST.update_version_info;
- this.timeLeft = 300;
- this.subscriptions = new UpdateSubscriptionCollection();
- this.dependencies.push(this.subscriptions);
- this.appliances = new ApplianceCollection();
- this.dependencies.push(this.appliances);
- this.initHandlebarHelpers();
+ // call initialize of base
+ this.constructor.__super__.initialize.apply(this, arguments);
+ this.template = window.JST.update_version_info;
+ this.timeLeft = 300;
+ this.subscriptions = new UpdateSubscriptionCollection();
+ this.dependencies.push(this.subscriptions);
+ this.appliances = new ApplianceCollection();
+ this.dependencies.push(this.appliances);
+ this.initHandlebarHelpers();
},
render: function() {
- this.fetch(this.renderUpdates, this);
- return this;
+ this.fetch(this.renderUpdates, this);
+ return this;
},
renderUpdates: function() {
- var _this = this;
- $('.modal-backdrop').remove();
- $.ajax({
- url: "/api/commands/update-check",
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.currentVersion = data[0];
- _this.mostRecentVersion = data[1];
- _this.changeList = data[2];
- _this.checkAutoUpdateStatus();
- },
- error: function(xhr, status, error) {
- }
- });
- return this;
+ var _this = this;
+ $('.modal-backdrop').remove();
+ $.ajax({
+ url: '/api/commands/update-check',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.currentVersion = data[0];
+ _this.mostRecentVersion = data[1];
+ _this.changeList = data[2];
+ _this.checkAutoUpdateStatus();
+ },
+ error: function(xhr, status, error) {}
+ });
+ return this;
},
checkAutoUpdateStatus: function() {
- var _this = this;
- $.ajax({
- url: '/api/commands/auto-update-status',
- type: 'POST',
- dataType: 'json',
- success: function(data, status, xhr) {
- _this.autoUpdateEnabled = data.enabled;
- _this.renderVersionInfo();
- },
- error: function(xhr, status, error) {
- }
- });
- return this;
+ var _this = this;
+ $.ajax({
+ url: '/api/commands/auto-update-status',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.autoUpdateEnabled = data.enabled;
+ _this.renderVersionInfo();
+ },
+ error: function(xhr, status, error) {}
+ });
+ return this;
},
renderVersionInfo: function() {
- var stableSub = null;
- var defaultSub = null;
- this.subscriptions.each(function(s) {
- if (s.get('name') == 'Stable') {
- stableSub = s.toJSON();
- }
- if (s.get('name') == 'Testing') {
- defaultSub = s.toJSON();
- }
- });
- var currentAppliance = this.appliances.find(function(a) {
- return a.get('current_appliance') == true;
- });
+ var stableSub = null;
+ var defaultSub = null;
+ this.subscriptions.each(function(s) {
+ if (s.get('name') == 'Stable') {
+ stableSub = s.toJSON();
+ }
+ if (s.get('name') == 'Testing') {
+ defaultSub = s.toJSON();
+ }
+ });
+ var currentAppliance = this.appliances.find(function(a) {
+ return a.get('current_appliance') == true;
+ });
- $(this.el).html(this.template({
- currentVersion: this.currentVersion,
- mostRecentVersion: this.mostRecentVersion,
- changeList: this.changeList,
- changeMap: this.changeLog(this.changeList),
- autoUpdateEnabled: this.autoUpdateEnabled,
- stableSub: stableSub,
- defaultSub: defaultSub,
- applianceId: currentAppliance.get('uuid')
- }));
- this.$('#update-modal').modal({
- keyboard: false,
- backdrop: 'static',
- show: false
- });
+ $(this.el).html(this.template({
+ currentVersion: this.currentVersion,
+ mostRecentVersion: this.mostRecentVersion,
+ changeList: this.changeList,
+ changeMap: this.changeLog(this.changeList),
+ autoUpdateEnabled: this.autoUpdateEnabled,
+ stableSub: stableSub,
+ defaultSub: defaultSub,
+ applianceId: currentAppliance.get('uuid')
+ }));
+ this.$('#update-modal').modal({
+ keyboard: false,
+ backdrop: 'static',
+ show: false
+ });
},
donateYes: function() {
- var contrib = 0;
- this.$('input[name="amount"]').val(contrib);
- this.$('#contrib-form').submit();
+ var contrib = 0;
+ this.$('input[name="amount"]').val(contrib);
+ this.$('#contrib-form').submit();
},
update: function() {
- this.$('#update-modal').modal('show');
- this.startForceRefreshTimer();
- $.ajax({
- url: "/api/commands/update",
- type: "POST",
- dataType: "json",
- global: false, // dont show global loading indicator
- success: function(data, status, xhr) {
- _this.checkIfUp();
- },
- error: function(xhr, status, error) {
- _this.checkIfUp();
- }
- });
+ this.$('#update-modal').modal('show');
+ this.startForceRefreshTimer();
+ $.ajax({
+ url: '/api/commands/update',
+ type: 'POST',
+ dataType: 'json',
+ global: false, // dont show global loading indicator
+ success: function(data, status, xhr) {
+ _this.checkIfUp();
+ },
+ error: function(xhr, status, error) {
+ _this.checkIfUp();
+ }
+ });
},
checkIfUp: function() {
- var _this = this;
- this.isUpTimer = window.setInterval(function() {
- $.ajax({
- url: "/api/sm/sprobes/loadavg?limit=1&format=json",
- type: "GET",
- dataType: "json",
- global: false, // dont show global loading indicator
- success: function(data, status, xhr) {
- _this.reloadWindow();
- },
- error: function(xhr, status, error) {
- // server is not up, continue checking
- }
- });
- }, 5000);
+ var _this = this;
+ this.isUpTimer = window.setInterval(function() {
+ $.ajax({
+ url: '/api/sm/sprobes/loadavg?limit=1&format=json',
+ type: 'GET',
+ dataType: 'json',
+ global: false, // dont show global loading indicator
+ success: function(data, status, xhr) {
+ _this.reloadWindow();
+ },
+ error: function(xhr, status, error) {
+ // server is not up, continue checking
+ }
+ });
+ }, 5000);
},
// countdown timeLeft seconds and then force a window reload
startForceRefreshTimer: function() {
- var _this = this;
- this.forceRefreshTimer = window.setInterval(function() {
- _this.timeLeft = _this.timeLeft - 1;
- _this.showTimeRemaining();
- if (_this.timeLeft <= 0) {
- _this.reloadWindow();
- }
- }, 1000);
+ var _this = this;
+ this.forceRefreshTimer = window.setInterval(function() {
+ _this.timeLeft = _this.timeLeft - 1;
+ _this.showTimeRemaining();
+ if (_this.timeLeft <= 0) {
+ _this.reloadWindow();
+ }
+ }, 1000);
},
showTimeRemaining: function() {
- mins = Math.floor(this.timeLeft/60);
- sec = this.timeLeft - (mins*60);
- sec = sec >=10 ? '' + sec : '0' + sec;
- this.$('#time-left').html(mins + ':' + sec);
- if (mins <= 1 && !this.userMsgDisplayed) {
- this.displayUserMsg();
- this.userMsgDisplayed = true;
- }
+ mins = Math.floor(this.timeLeft / 60);
+ sec = this.timeLeft - (mins * 60);
+ sec = sec >= 10 ? '' + sec : '0' + sec;
+ this.$('#time-left').html(mins + ':' + sec);
+ if (mins <= 1 && !this.userMsgDisplayed) {
+ this.displayUserMsg();
+ this.userMsgDisplayed = true;
+ }
},
reloadWindow: function() {
- this.clearTimers();
- this.$('#update-modal').modal('hide');
- location.reload(true);
+ this.clearTimers();
+ this.$('#update-modal').modal('hide');
+ location.reload(true);
},
clearTimers: function() {
- window.clearInterval(this.isUpTimer);
- window.clearInterval(this.forceRefreshTimer);
+ window.clearInterval(this.isUpTimer);
+ window.clearInterval(this.forceRefreshTimer);
},
displayUserMsg: function() {
- this.$('#user-msg').show('highlight', null, 1000);
+ this.$('#user-msg').show('highlight', null, 1000);
},
autoUpdateSwitch: function() {
- $('#auto-update-modal').modal({
- keyboard: false,
- show: false,
- backdrop: 'static'
- });
- $('#auto-update-modal').modal('show');
+ $('#auto-update-modal').modal({
+ keyboard: false,
+ show: false,
+ backdrop: 'static'
+ });
+ $('#auto-update-modal').modal('show');
},
enableAutoUpdate: function() {
- return this.toggleAutoUpdate('enable-auto-update');
+ return this.toggleAutoUpdate('enable-auto-update');
},
disableAutoUpdate: function() {
- return this.toggleAutoUpdate('disable-auto-update');
+ return this.toggleAutoUpdate('disable-auto-update');
},
toggleAutoUpdate: function(updateFlag) {
- var _this = this;
- $.ajax({
- url: "/api/commands/" + updateFlag,
- type: "POST",
- dataType: "json",
- success: function(data, status, xhr) {
- _this.reloadWindow();
+ var _this = this;
+ $.ajax({
+ url: '/api/commands/' + updateFlag,
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.reloadWindow();
},
error: function(xhr, status, error) {
- // server is not up, continue checking
+ // server is not up, continue checking
}
- });
+ });
},
- changeLog: function(logArray){
- var changeLogArray = [];
- var issues = [];
- var nextString = [];
- var changeDescription = [];
- var contributors = [];
+ changeLog: function(logArray) {
+ var changeLogArray = [];
+ var issues = [];
+ var nextString = [];
+ var changeDescription = [];
+ var contributors = [];
- for(var i = 0; i < logArray.length; i++){
- var hashIndex = logArray[i].indexOf('#');
- var atRateIndex = logArray[i].indexOf('@');
- issues[i] = logArray[i].substring(hashIndex + 1,atRateIndex - 1);
- var namesNum = logArray[i].indexOf('@') + 1;
- changeDescription[i] = logArray[i].substring(0, hashIndex - 1);
- nextString[i] = logArray[i].substring(namesNum, logArray[i].length);
- contributors[i] = nextString[i].split(' @');
- }
- for (var i = 0; i < changeDescription.length; i++) {
- var cl = changeDescription[i];
- cl += ' #';
- cl += issues[i];
- cl += " ";
+ for (var i = 0; i < logArray.length; i++) {
+ var hashIndex = logArray[i].indexOf('#');
+ var atRateIndex = logArray[i].indexOf('@');
+ issues[i] = logArray[i].substring(hashIndex + 1, atRateIndex - 1);
+ var namesNum = logArray[i].indexOf('@') + 1;
+ changeDescription[i] = logArray[i].substring(0, hashIndex - 1);
+ nextString[i] = logArray[i].substring(namesNum, logArray[i].length);
+ contributors[i] = nextString[i].split(' @');
+ }
+ for (var k = 0; k < changeDescription.length; k++) {
+ var cl = changeDescription[k];
+ cl += ' #';
+ cl += issues[k];
+ cl += ' ';
- for (var j = 0; j < contributors[i].length; j++) {
- cl += ' @';
- cl += contributors[i][j];
- cl += " ";
- }
- changeLogArray.push(new Handlebars.SafeString(cl));
- }
- return changeLogArray;
+ for (var j = 0; j < contributors[k].length; j++) {
+ cl += ' @';
+ cl += contributors[k][j];
+ cl += ' ';
+ }
+ changeLogArray.push(new Handlebars.SafeString(cl));
+ }
+ return changeLogArray;
},
showStableModal: function() {
- this.$('#activate-stable').modal('show');
+ this.$('#activate-stable').modal('show');
},
showTestingModal: function() {
- this.$('#activate-testing').modal('show');
+ this.$('#activate-testing').modal('show');
},
activateStable: function() {
- var button = this.$('activateStable');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- var activationCode = this.$('#activation-code').val();
- var _this = this;
- $.ajax({
- url: '/api/update-subscriptions/activate-stable',
- type: 'POST',
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({'activation_code': activationCode }),
- success: function(data, status, xhr) {
- _this.reloadWindow();
- },
- error: function(xhr, status, error) {
- enableButton(button);
- }
- });
+ var button = this.$('activateStable');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ var activationCode = this.$('#activation-code').val();
+ var _this = this;
+ $.ajax({
+ url: '/api/update-subscriptions/activate-stable',
+ type: 'POST',
+ dataType: 'json',
+ contentType: 'application/json',
+ data: JSON.stringify({
+ 'activation_code': activationCode
+ }),
+ success: function(data, status, xhr) {
+ _this.reloadWindow();
+ },
+ error: function(xhr, status, error) {
+ enableButton(button);
+ }
+ });
},
activateTesting: function() {
- var _this = this;
- var button = this.$('activateTesting');
- if (buttonDisabled(button)) return false;
- disableButton(button);
- console.log("Inactive testing");
- $.ajax({
- url: '/api/update-subscriptions/activate-testing',
- type: 'POST',
- dataType: 'json',
- success: function(data, status, xhr) {
- _this.reloadWindow();
- }
- });
+ var _this = this;
+ var button = this.$('activateTesting');
+ if (buttonDisabled(button)) return false;
+ disableButton(button);
+ console.log('Inactive testing');
+ $.ajax({
+ url: '/api/update-subscriptions/activate-testing',
+ type: 'POST',
+ dataType: 'json',
+ success: function(data, status, xhr) {
+ _this.reloadWindow();
+ }
+ });
},
initHandlebarHelpers: function() {
- Handlebars.registerHelper('is_sub_active', function(sub, options) {
- if (sub && sub.status == 'active') {
- return options.fn(this);
- }
- return options.inverse(this);
- });
- Handlebars.registerHelper('no_sub_active', function(options) {
- if (!this.defaultSub && !this.stableSub) {
- return options.fn(this);
- }
- return options.inverse(this);
- });
- Handlebars.registerHelper('update_available', function(options) {
- if (this.currentVersion != this.mostRecentVersion) {
- return options.fn(this);
- }
- return options.inverse(this);
- });
+ Handlebars.registerHelper('is_sub_active', function(sub, options) {
+ if (sub && sub.status == 'active') {
+ return options.fn(this);
+ }
+ return options.inverse(this);
+ });
+ Handlebars.registerHelper('no_sub_active', function(options) {
+ if (!this.defaultSub && !this.stableSub) {
+ return options.fn(this);
+ }
+ return options.inverse(this);
+ });
+ Handlebars.registerHelper('update_available', function(options) {
+ if (this.currentVersion != this.mostRecentVersion) {
+ return options.fn(this);
+ }
+ return options.inverse(this);
+ });
}
-});
+});
\ No newline at end of file