diff --git a/app/javascript/packs/notification.js b/app/javascript/packs/notification.js deleted file mode 100644 index c01a829..0000000 --- a/app/javascript/packs/notification.js +++ /dev/null @@ -1,60 +0,0 @@ -const POLLING_INTERVAL = 3 * 1000; -const POLLING_URL = "/polling/alerts"; - -window.addEventListener("load", ()=> { - new Vue({ - el: "#vue-notification", - data: { - "alerts": [] - }, - - computed: { - alertsCount: { - get: function(){ return this.alerts.length; } - }, - hasAlerts: { - get: function(){ return this.alertsCount > 0; } - } - }, - - created: function(){ - let timer; - let self = this; - let currentInterval = POLLING_INTERVAL; - let fetch = function(){ - self.fetchAlertsData().then(function(alerts){ - if(self.alerts.toString() == alerts.toString()) { - currentInterval *= 1.1; - } else { - currentInterval = POLLING_INTERVAL; - } - self.alerts = alerts; - timer = setTimeout(fetch, currentInterval); - })["catch"](function(xhr){ - if(xhr.status === 401) { - // signed out - } - if(xhr.status === 0) { - // server unreachable (maybe down) - } - }); - }; - window.addEventListener("focus", function(_event){ - currentInterval = POLLING_INTERVAL; - timer = setTimeout(fetch, currentInterval); - }, false); - window.addEventListener("blur", function(_event){ - clearTimeout(timer); - }, false); - fetch(); - }, - - methods: { - fetchAlertsData: function() { - return new Promise(function(resolve, reject) { - $.getJSON(POLLING_URL, resolve).fail(reject); - }); - } - } - }); -}); diff --git a/app/views/shared/_modal.html.erb b/app/views/shared/_modal.html.erb deleted file mode 100644 index 1842857..0000000 --- a/app/views/shared/_modal.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -<% primary_button ||= "Save changes" %> - - - -