app/javascript/packs/notification.js in fluentd-ui-1.0.0.alpha.3 vs app/javascript/packs/notification.js in fluentd-ui-1.0.0.beta.1
- old
+ new
@@ -1,15 +1,24 @@
-const POLLING_INTERVAL = 3 * 1000
-const POLLING_URL = "/polling/alerts"
+const POLLING_INTERVAL = 3 * 1000;
+const POLLING_URL = "/polling/alerts";
$(document).ready(()=> {
- let alert = new Vue({
+ 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(){
@@ -28,26 +37,17 @@
if(xhr.status === 0) {
// server unreachable (maybe down)
}
});
};
- window.addEventListener('focus', function(ev){
+ window.addEventListener("focus", function(_event){
currentInterval = POLLING_INTERVAL;
timer = setTimeout(fetch, currentInterval);
}, false);
- window.addEventListener('blur', function(ev){
+ window.addEventListener("blur", function(_event){
clearTimeout(timer);
}, false);
fetch();
- },
-
- computed: {
- alertsCount: {
- get: function(){ return this.alerts.length; }
- },
- hasAlerts: {
- get: function(){ return this.alertsCount > 0; }
- }
},
methods: {
fetchAlertsData: function() {
return new Promise(function(resolve, reject) {