Add mobile support for datasync restart

This commit is contained in:
Lance Edgar 2016-12-11 21:20:51 -06:00
parent 22c7fee0f6
commit 06dee96af6
4 changed files with 28 additions and 4 deletions

View file

@ -37,3 +37,10 @@ $(document).on('pageshow', function() {
el.focus(); el.focus();
} }
}); });
$(document).on('click', '#datasync-restart', function() {
// disable datasync restart button when clicked
$(this).button('disable');
});

View file

@ -72,6 +72,9 @@
% elif request.is_admin: % elif request.is_admin:
<li class="root-user" data-icon="forbidden">${h.link_to("Become root", url('become_root'), **{'data-ajax': 'false'})}</li> <li class="root-user" data-icon="forbidden">${h.link_to("Become root", url('become_root'), **{'data-ajax': 'false'})}</li>
% endif % endif
% if request.has_perm('datasync.restart'):
<li>${h.link_to("DataSync", url('datasync.mobile'))}</li>
% endif
<li data-icon="lock">${h.link_to("Logout", url('logout'), **{'data-ajax': 'false'})}</li> <li data-icon="lock">${h.link_to("Logout", url('logout'), **{'data-ajax': 'false'})}</li>
<li data-icon="info">${h.link_to("About {}".format(capture(self.app_title)), url('mobile.about'))}</li> <li data-icon="info">${h.link_to("About {}".format(capture(self.app_title)), url('mobile.about'))}</li>
</ul> </ul>

View file

@ -0,0 +1,8 @@
## -*- coding: utf-8 -*-
<%inherit file="/mobile/base.mako" />
<%def name="title()">DataSync</%def>
${h.form(url('datasync.restart'))}
${h.submit('restart', "Restart DataSync", id='datasync-restart')}
${h.end_form()}

View file

@ -43,7 +43,6 @@ class DataSyncChangesView(MasterView):
Master view for the DataSyncChange model. Master view for the DataSyncChange model.
""" """
model_class = model.DataSyncChange model_class = model.DataSyncChange
model_title = "DataSync Change"
url_prefix = '/datasync/changes' url_prefix = '/datasync/changes'
permission_prefix = 'datasync' permission_prefix = 'datasync'
@ -74,7 +73,10 @@ class DataSyncChangesView(MasterView):
self.request.session.flash("DataSync daemon has been restarted.") self.request.session.flash("DataSync daemon has been restarted.")
else: else:
self.request.session.flash("DataSync daemon could not be restarted; result was: {}".format(result), 'error') self.request.session.flash("DataSync daemon could not be restarted; result was: {}".format(result), 'error')
return self.redirect(self.request.route_url('datasyncchanges')) return self.redirect(self.request.get_referrer(default=self.request.route_url('datasyncchanges')))
def mobile_index(self):
return {}
@classmethod @classmethod
def defaults(cls, config): def defaults(cls, config):
@ -84,10 +86,14 @@ class DataSyncChangesView(MasterView):
# restart daemon # restart daemon
config.add_route('datasync.restart', '/datasync/restart') config.add_route('datasync.restart', '/datasync/restart')
config.add_view(cls, attr='restart', route_name='datasync.restart', config.add_view(cls, attr='restart', route_name='datasync.restart', permission='datasync.restart')
permission='datasync.restart')
config.add_tailbone_permission('datasync', 'datasync.restart', label="Restart DataSync Daemon") config.add_tailbone_permission('datasync', 'datasync.restart', label="Restart DataSync Daemon")
# mobile
config.add_route('datasync.mobile', '/mobile/datasync/')
config.add_view(cls, attr='mobile_index', route_name='datasync.mobile',
permission='datasync.restart', renderer='/mobile/datasync.mako')
cls._defaults(config) cls._defaults(config)