diff --git a/tailbone/static/js/tailbone.js b/tailbone/static/js/tailbone.js
index 075b90ab..bedd4ee4 100644
--- a/tailbone/static/js/tailbone.js
+++ b/tailbone/static/js/tailbone.js
@@ -32,9 +32,12 @@ function disable_filter_options() {
function disable_button(button, label) {
$(button).button('disable');
if (label === undefined) {
- label = "Working, please wait...";
+ label = $(button).data('working-label') || "Working, please wait...";
}
if (label) {
+ if (label.slice(-3) != '...') {
+ label += '...';
+ }
$(button).button('option', 'label', label);
}
}
diff --git a/tailbone/templates/datasync/changes/index.mako b/tailbone/templates/datasync/changes/index.mako
index 43fdfcc0..1a746144 100644
--- a/tailbone/templates/datasync/changes/index.mako
+++ b/tailbone/templates/datasync/changes/index.mako
@@ -1,27 +1,23 @@
## -*- coding: utf-8; -*-
<%inherit file="/master/index.mako" />
-<%def name="extra_javascript()">
- ${parent.extra_javascript()}
-
-%def>
-
<%def name="grid_tools()">
${parent.grid_tools()}
- ${h.form(url('datasync.restart'), name='restart-datasync')}
- ${h.csrf_token(request)}
-
- ${h.end_form()}
+
+ % if request.has_perm('datasync.restart'):
+ ${h.form(url('datasync.restart'), name='restart-datasync', class_='autodisable')}
+ ${h.csrf_token(request)}
+ ${h.submit('submit', "Restart DataSync", data_working_label="Restarting DataSync")}
+ ${h.end_form()}
+ % endif
+
+ % if request.has_perm('filemon.restart'):
+ ${h.form(url('filemon.restart'), name='restart-filemon', class_='autodisable')}
+ ${h.csrf_token(request)}
+ ${h.submit('submit', "Restart FileMon", data_working_label="Restarting FileMon")}
+ ${h.end_form()}
+ % endif
+
%def>
${parent.body()}
diff --git a/tailbone/views/datasync.py b/tailbone/views/datasync.py
index def5ee5f..11a98599 100644
--- a/tailbone/views/datasync.py
+++ b/tailbone/views/datasync.py
@@ -84,11 +84,11 @@ class DataSyncChangesView(MasterView):
# fix permission group title
config.add_tailbone_permission_group('datasync', label="DataSync")
- # restart daemon
+ # restart datasync
+ config.add_tailbone_permission('datasync', 'datasync.restart', label="Restart DataSync Daemon")
+ # desktop
config.add_route('datasync.restart', '/datasync/restart')
config.add_view(cls, attr='restart', route_name='datasync.restart', permission='datasync.restart')
- 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',
diff --git a/tailbone/views/filemon.py b/tailbone/views/filemon.py
new file mode 100644
index 00000000..1d164c83
--- /dev/null
+++ b/tailbone/views/filemon.py
@@ -0,0 +1,67 @@
+# -*- coding: utf-8; -*-
+################################################################################
+#
+# Rattail -- Retail Software Framework
+# Copyright © 2010-2018 Lance Edgar
+#
+# This file is part of Rattail.
+#
+# Rattail is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+#
+# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Rattail. If not, see .
+#
+################################################################################
+"""
+FileMon Views
+"""
+
+from __future__ import unicode_literals, absolute_import
+
+import subprocess
+import logging
+
+from tailbone.views import View
+
+
+log = logging.getLogger(__name__)
+
+
+class FilemonView(View):
+ """
+ Misc. views for Filemon...(for now)
+ """
+
+ def restart(self):
+ cmd = self.rattail_config.getlist('tailbone', 'filemon.restart', default='/bin/sleep 3') # simulate by default
+ log.debug("attempting filemon restart with command: %s", cmd)
+ try:
+ subprocess.check_call(cmd)
+ except Except as error:
+ self.request.session.flash("FileMon daemon could not be restarted: {}".format(error), 'error')
+ else:
+ self.request.session.flash("FileMon daemon has been restarted.")
+ return self.redirect(self.request.get_referrer(default=self.request.route_url('datasyncchanges')))
+
+ @classmethod
+ def defaults(cls, config):
+
+ # fix permission group title
+ config.add_tailbone_permission_group('filemon', label="FileMon")
+
+ # restart filemon
+ config.add_tailbone_permission('filemon', 'filemon.restart', label="Restart FileMon Daemon")
+ config.add_route('filemon.restart', '/filemon/restart', request_method='POST')
+ config.add_view(cls, attr='restart', route_name='filemon.restart', permission='filemon.restart')
+
+
+def includeme(config):
+ FilemonView.defaults(config)