]> git.immae.eu Git - github/bastienwirtz/homer.git/commitdiff
Merge branch 'master' into dynamic-message 7/head
authorBastien Wirtz <bastien.wirtz@gmail.com>
Fri, 27 Dec 2019 18:39:44 +0000 (10:39 -0800)
committerGitHub <noreply@github.com>
Fri, 27 Dec 2019 18:39:44 +0000 (10:39 -0800)
1  2 
app.js
config.yml

diff --combined app.js
index 93902d803cbef8e1c4e72e9f2997b645198fae55,40830da1a457f3053b4ff230b54e0814c0add6a2..6c2ba9078ef73da8214034e360530a33e7a3a55c
--- 1/app.js
--- 2/app.js
+++ b/app.js
@@@ -7,34 -7,22 +7,34 @@@ const app = new Vue(
          vlayout: true,
          isDark: null
      },
 -    created: function () {
 +    created: async function () {
          let that = this;
  
-         this.isDark = 'overrideDark' in localStorage ? 
+         this.isDark = 'overrideDark' in localStorage ?
              JSON.parse(localStorage.overrideDark) : matchMedia("(prefers-color-scheme: dark)").matches;
  
          if ('vlayout' in localStorage) {
              this.vlayout = JSON.parse(localStorage.vlayout)
          }
-         
          this.checkOffline();
 -        that.getConfig().then(function (config) {
 -            that.config = config;
 -        }).catch(function () {
 -            that.offline = true;
 -        });
 +        try {
 +            this.config =  await this.getConfig();
 +        } catch (error) {
 +            this.offline = true;
 +        }
 +
 +        // Look for a new message if an endpoint is provided.
 +        if (this.config.message.url) {
 +            this.getMessage(this.config.message.url).then(function(message){
 +                // keep the original config value if no value is provided by the endpoint
 +                for (const prop of ['title','style','content']) {
 +                    if (prop in message && message[prop] !== null) {
 +                        that.config.message[prop] = message[prop];
 +                    }    
 +                }
 +            });
 +        }
  
          document.addEventListener('visibilitychange', function () {
              if (document.visibilityState == "visible") {
                  });
              });
          },
 +        getMessage: function (url) {
 +            return fetch(url).then(function (response) {
 +                if (response.status != 200) {
 +                    return;
 +                }
 +                return response.json();
 +            });
 +        },
          toggleTheme: function() {
              this.isDark = !this.isDark;
              localStorage.overrideDark = this.isDark; 
          }, 
          toggleLayout: function() {
              this.vlayout = !this.vlayout;
-             localStorage.vlayout = this.vlayout; 
-         }, 
+             localStorage.vlayout = this.vlayout;
+         },
      }
  });
  
@@@ -115,6 -95,6 +115,6 @@@ Vue.component('service', 
  
  if ('serviceWorker' in navigator) {
      window.addEventListener('load', function () {
-         navigator.serviceWorker.register('/worker.js');
+         navigator.serviceWorker.register('worker.js');
      });
  }
diff --combined config.yml
index 80833f5c562a1afe8562979c42078f9f0a77c344,2adddb181ea9478ce7a63cb20bc0e93c209c29df..7288da6dd2c857221bc4450f50dd7b0e447cdb5f
@@@ -10,7 -10,6 +10,7 @@@ icon: "fas fa-skull-crossbones
  # Optional message
  # See https://bulma.io/documentation/components/message/#colors for styling options.
  message:
 +  # url: https://....
    style: "is-warning"
    title: "Optional message!"
    content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque risus mi, tempus quis placerat ut, porta nec nulla. Vestibulum rhoncus ac ex sit amet fringilla. Nullam gravida purus diam, et dictum felis venenatis efficitur. Aenean ac eleifend lacus, in mollis lectus. Donec sodales, arcu et sollicitudin porttitor, tortor urna tempor ligula."
@@@ -32,12 -31,12 +32,12 @@@ services
      icon: "fas fa-code-branch"
      items:
        - name: "Jenkins"
-         logo: "/assets/tools/jenkins.png"
+         logo: "assets/tools/jenkins.png"
          subtitle: "Continuous integration server"
          tag: "CI"
          url: "#"
        - name: "RabbitMQ Management"
-         logo: "/assets/tools/rabbitmq.png"
+         logo: "assets/tools/rabbitmq.png"
          subtitle: "Manage & monitor RabbitMQ server"
          tag: "haproxy"
          # Optional tagstyle
      icon: "fas fa-heartbeat"
      items:
        - name: "M/Monit"
-         logo: "/assets/tools/monit.png"
+         logo: "assets/tools/monit.png"
          subtitle: "Monitor & manage all monit enabled hosts"
          tag: "monit"
          url: "#"
        - name: "Grafana"
-         logo: "/assets/tools/grafana.png"
+         logo: "assets/tools/grafana.png"
          subtitle: "Metric analytics & dashboards"
          url: "#"
        - name: "Kibana"
-         logo: "/assets/tools/elastic.png"
+         logo: "assets/tools/elastic.png"
          subtitle: "Explore & visualize logs"
          tag: "elk"
          url: "#"
        - name: "Website monitoring"
-         logo: "/assets/tools/pingdom.png"
+         logo: "assets/tools/pingdom.png"
          subtitle: "Pingdom public reports overview"
          tag: "CI"
          url: "#"