diff --git a/data/interfaces/default/logs.html b/data/interfaces/default/logs.html
index 571257ec..9bafbaab 100644
--- a/data/interfaces/default/logs.html
+++ b/data/interfaces/default/logs.html
@@ -22,6 +22,7 @@ from plexpy import helpers
+
@@ -156,24 +157,28 @@ from plexpy import helpers
$("#plexpy-logs-btn").click(function () {
$("#clear-logs").show();
+ $("#clear-notify-logs").hide();
LoadPlexPyLogs();
clearSearchButton('log_table', log_table);
});
$("#plex-logs-btn").click(function () {
$("#clear-logs").hide();
+ $("#clear-notify-logs").hide();
LoadPlexLogs();
clearSearchButton('plex_log_table', plex_log_table);
});
$("#plex-scanner-logs-btn").click(function () {
$("#clear-logs").hide();
+ $("#clear-notify-logs").hide();
LoadPlexScannerLogs();
clearSearchButton('plex_scanner_log_table', plex_scanner_log_table);
});
$("#notification-logs-btn").click(function () {
$("#clear-logs").hide();
+ $("#clear-notify-logs").show();
LoadNotificationLogs();
clearSearchButton('notification_log_table', notification_log_table);
});
@@ -185,6 +190,19 @@ from plexpy import helpers
}
});
+ $("#clear-notify-logs").click(function () {
+ var r = confirm("Are you sure you want to clear the PlexPy notification log?");
+ if (r == true) {
+ $.ajax({
+ url: 'clearNotifyLogs',
+ type: 'POST',
+ success: function (data) {
+ notification_log_table.draw();
+ }
+ });
+ }
+ });
+
var timer;
function setRefresh()
{
diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py
index 8b6d151d..2900e8f8 100644
--- a/plexpy/datafactory.py
+++ b/plexpy/datafactory.py
@@ -1206,4 +1206,16 @@ class DataFactory(object):
'draw': query['draw']
}
- return dict
\ No newline at end of file
+ return dict
+
+ def delete_notification_log(self):
+ monitor_db = database.MonitorDatabase()
+
+ try:
+ logger.info(u"PlexPy DataFactory :: Clearing notification logs from database.")
+ monitor_db.action('DELETE FROM notify_log')
+ monitor_db.action('VACUUM')
+ return 'Cleared notification logs.'
+ except Exception as e:
+ logger.warn(u"PlexPy DataFactory :: Unable to execute database query for delete_notification_log: %s." % e)
+ return 'Unable to clear notification logs.'
\ No newline at end of file
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index 6e2142cf..e2afdcf1 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -1096,6 +1096,19 @@ class WebInterface(object):
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps(notifications)
+ @cherrypy.expose
+ @addtoapi()
+ def clearNotifyLogs(self, **kwargs):
+ data_factory = datafactory.DataFactory()
+ result = data_factory.delete_notification_log()
+
+ if result:
+ cherrypy.response.headers['Content-type'] = 'application/json'
+ return json.dumps({'message': result})
+ else:
+ cherrypy.response.headers['Content-type'] = 'application/json'
+ return json.dumps({'message': 'no data received'})
+
@cherrypy.expose
def clearLogs(self):
plexpy.LOG_LIST = []