Skip to content

Commit

Permalink
Merge pull request #1114 from schakrava/858_part4
Browse files Browse the repository at this point in the history
858 part4
  • Loading branch information
schakrava committed Jan 21, 2016
2 parents 35f7e78 + aae16fb commit 67241ff
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ DockerServiceView = Backbone.View.extend({
},

initialize: function() {
this.dashboardconfig = this.options.dashboardconfig;
this.template = window.JST.rockons_docker_service;
this.serviceName = 'docker';
this.service = new Service({name: this.serviceName});
Expand Down
71 changes: 27 additions & 44 deletions src/rockstor/storageadmin/static/storageadmin/js/views/rockons.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,14 @@ RockonsView = RockstorLayoutView.extend({
});

$(this.el).html(this.template({
rockons: this.rockons,
status: this.service.get('status'),
rockons: _this.rockons,
status: _this.service.get('status'),
ui_map: ui_map
}));

if (!this.dockerServiceView) {
this.dockerServiceView = new DockerServiceView({
parentView: this,
dockerService: this.dockerService
parentView: _this
});
}
// Render the Rockons template with a status describing whether
Expand Down Expand Up @@ -341,9 +340,9 @@ RockonsView = RockstorLayoutView.extend({
html += '<br><br>';
if (_this.ui_map[rockon.get('id')]) {
if (rockon.get('status') == 'started') {
html += '<a href="' + _this.ui_map[rockon.get('id')] + '" target="_blank" class="btn btn-primary">' + rockon.get('name') + ' UI</a>';
html += '<a href="' + _this.ui_map[rockon.get('id')] + '" target="_blank" class="btn btn-primary">' + rockon.get('name') + ' UI</a> ';
} else {
html += '<a href="#" class="btn btn-primary disabled" title="Switch on to access the UI">' + rockon.get('name') + ' UI</a>';
html += '<a href="#" class="btn btn-primary disabled" title="Switch on to access the UI">' + rockon.get('name') + ' UI</a> ';
}
}
if (rockon.get('status') != 'started') {
Expand Down Expand Up @@ -404,6 +403,28 @@ RockonsView = RockstorLayoutView.extend({
}
return new Handlebars.SafeString(html);
});

Handlebars.registerHelper('display_ccForm', function(){
var html = '';
this.cc.each(function(cci, index) {
html += '<div class="form-group">';
html += '<label class="control-label col-sm-3" for="cc">' + cci.get('label') + '<span class="required">*</span></label>';
html += '<div class="controls">';
html += '<div class="col-sm-6">';
html += '<input class="form-control" ';
if (cci.get('label').match(/password/i)) {
html += 'type="password" ';
} else {
html += 'type="text" ';
}
html += 'id="' + cci.id + '" name="' + cci.id + '" value="' + (cci.get('val') || '') + '">';
html += '</div>&nbsp;&nbsp';
html += '<i class="fa fa-info-circle fa-lg" title="' + cci.get('description') + '" rel="tooltop"></i>';
html += '</div>';
html += '</div>';
});
return new Handlebars.SafeString(html);
});
}

});
Expand Down Expand Up @@ -662,7 +683,6 @@ RockonCustomChoice = RockstorWizardPage.extend({
this.cc_template = window.JST.rockons_cc_form;
this.custom_config = this.model.get('custom_config');
RockstorWizardPage.prototype.initialize.apply(this, arguments);
this.initHandlebarHelpers();
},

render: function() {
Expand Down Expand Up @@ -694,24 +714,6 @@ RockonCustomChoice = RockstorWizardPage.extend({
}, this);
this.model.set('cc_map', cc_map);
return $.Deferred().resolve();
},

initHandlebarHelpers: function(){
Handlebars.registerHelper('display_ccForm', function(){
var html = '';
this.cc.each(function(cci, index) {
html += '<div class="form-group">';
html += '<label class="control-label col-sm-3" for="cc">' + cci.get('label') + '<span class="required">*</span></label>';
html += '<div class="controls">';
html += '<div class="col-sm-6">';
html += '<input class="form-control" type="text" id="' + cci.id + '" name="' + cci.id + '" value="' + (cci.get('val') || '') + '">';
html += '</div>&nbsp;&nbsp';
html += '<i class="fa fa-info-circle fa-lg" title="' + cci.get('description') + '" rel="tooltop"></i>';
html += '</div>';
html += '</div>';
});
return new Handlebars.SafeString(html);
});
}
});

Expand All @@ -721,7 +723,6 @@ RockonEnvironment = RockstorWizardPage.extend({
this.cc_template = window.JST.rockons_cc_form;
this.custom_config = this.model.get('environment');
RockstorWizardPage.prototype.initialize.apply(this, arguments);
this.initHandlebarHelpers();
},

render: function() {
Expand All @@ -741,24 +742,6 @@ RockonEnvironment = RockstorWizardPage.extend({
return this;
},

initHandlebarHelpers: function(){
Handlebars.registerHelper('display_ccForm', function(){
var html = '';
this.cc.each(function(cci, index) {
html += '<div class="form-group">';
html += '<label class="control-label col-sm-3" for="cc">' + cci.get('label') + '<span class="required">*</span></label>';
html += '<div class="controls">';
html += '<div class="col-sm-6">';
html += '<input class="form-control" type="text" id="' + cci.id + '" name="' + cci.id + '" value="' + (cci.get('val') || '') + '">';
html += '</div>&nbsp;&nbsp';
html += '<i class="fa fa-info-circle fa-lg" title="' + cci.get('description') + '" rel="tooltop"></i>';
html += '</div>';
html += '</div>';
});
return new Handlebars.SafeString(html);
});
},

save: function() {
if (!this.cc_form.valid()) {
this.validator.showErrors();
Expand Down
8 changes: 4 additions & 4 deletions src/rockstor/storageadmin/views/rockon.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def put(self, request):
def post(self, request, command=None):
with self._handle_exception(request):
if (command == 'update'):
rockons = self._get_available(request)
rockons = self._get_available()
for r in rockons:
try:
self._create_update_meta(r, rockons[r])
Expand Down Expand Up @@ -146,7 +146,7 @@ def _create_update_meta(self, name, r_d):
e_msg = ('Container(%s) belongs to another '
'Rock-On(%s). Update rolled back.' %
(c, co.rockon.name))
handle_exception(Exception(e_msg), request)
handle_exception(Exception(e_msg), self.request)
if (not created):
co.dimage = io
co.launch_order = co_defaults['launch_order']
Expand Down Expand Up @@ -284,12 +284,12 @@ def _update_env(self, co, c_d):
for eo in DContainerEnv.objects.filter(container=co):
if (eo.key not in cc_d): eo.delete()

def _get_available(self, request):
def _get_available(self):
msg = ('Network error while checking for updates. '
'Please try again later.')
url_root = settings.ROCKONS.get('remote_metastore')
remote_root = ('%s/%s' % (url_root, settings.ROCKONS.get('remote_root')))
with self._handle_exception(request, msg=msg):
with self._handle_exception(self.request, msg=msg):
response = requests.get(remote_root, timeout=10)
root = response.json()
meta_cfg = {}
Expand Down
5 changes: 3 additions & 2 deletions src/rockstor/storageadmin/views/rockon_discourse.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ def discourse_repo(rockon):

def discourse_install(rockon):
#1. install git
if (not os.path.isfile('/usr/bin/git')):
git = '/usr/bin/git'
if (not os.path.isfile(git)):
install_pkg('git')

#2. prep Discourse.yml
repo = discourse_repo(rockon)
if (not os.path.isdir(repo)):
run_command(['git', 'clone',
run_command([git, 'clone',
'https://github.com/discourse/discourse_docker.git',
repo])

Expand Down
2 changes: 1 addition & 1 deletion src/rockstor/storageadmin/views/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def get_queryset(self, *args, **kwargs):
#It is a transient subvolume that gets rolled into a proper Share after
#5 incremental-sends. Until then, keep such transient shares hidden from the UI,
#mostly for costmetic and UX reasons.
return Share.objects.exclude(name__regex=r'^\.snapshots/.*/.*_replication_')
return Share.objects.exclude(name__regex=r'^\.snapshots/.*/.*_replication_').order_by('-id')

@transaction.atomic
def post(self, request):
Expand Down

0 comments on commit 67241ff

Please sign in to comment.