]> git.nbdom.net Git - nb.git/commitdiff
etc/profile.d/nb.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 2 Jan 2018 20:36:12 +0000 (20:36 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 2 Jan 2018 20:36:12 +0000 (20:36 +0000)
bin/nb-update
etc/profile.d/nb.sh
www/dbq/html/default.js
www/dbq/html/default.min.js

index 1cf9aeb770a1ec5aa8f402149683b5899d595555..769dbf53f3559265398518dc69a77ed44fd04d50 100755 (executable)
@@ -87,8 +87,8 @@ for repo in $(nb_repos); do
   fi
 
   echo
-  nb_api_post host_info key=repo.$name.exit_code val=$ex
-  nb_api_post host_info key=repo.$name.last_commit val=$(cd "$repo" && git log | head -1 | awk '/^commit/ { print $2; exit; }')
+  nb_api_post_host_info key=repo.$name.exit_code val=$ex
+  nb_api_post_host_info key=repo.$name.last_commit val=$(cd "$repo" && git log | head -1 | awk '/^commit/ { print $2; exit; }')
 
 done
 
index 69931c9c5f44c27551efdf64c61fef6df92b4619..995700e3cad514751ecf18d2e0c92adcd6284fcb 100644 (file)
@@ -84,15 +84,17 @@ nb_api() {
        curl -su "$NB_AUTH" "https://api.nbdom.net$uri" "$@"
 }
 
+nb_api_post_host_info() {
+       local host=$(hostname)
+       [ -z "$host" ] && host=$(hostname -f)
+       nb_api_post host_info "host=$host" "$@"
+}
+
 nb_api_post() {
        local usage="Usage: nb_api_post TABLE field1=val1 field2=val2 ..."
        local table="${1:?$usage}"; shift
 
-       local host=$(hostname)
-       [ -z "$host" ] && host=$(hostname -f)
-
-       local curl="nb_api /data/$table/replace.sh -d host=$host"
-       #local curl=""
+       local curl="nb_api /data/$table/replace.sh"
 
        local args="$*"
        while [ "$#" -gt "0" ]; do
@@ -107,6 +109,6 @@ nb_api_post() {
 nb_post_sys_infos() {
        # To be compatible with other sed that does not support \t
        sys_infos | tr '\t' '!' | sed -e 's/"/\\"/g' -e 's/^/key="sys./' -e 's/!/" val="/' -e 's/$/"/' | while read -r i; do
-               eval nb_api_post host_info $i
+               eval nb_api_post_host_info $i
        done
 }
index 2c00e9b94d9a5bc82e051db23670350fa849a029..db8da16fe8ce0942be1026a57c6fc4c58320865c 100644 (file)
@@ -137,39 +137,21 @@ document.addEventListener("DOMContentLoaded", function() {
       var forms = document.querySelectorAll("form.rm");
       for (j = 0; j < forms.length; ++j) {
         var f = forms[j];
-      //document.querySelectorAll("form.rm").forEach(function(f) {
         var url = f.getAttribute('action');
         var params = [];
-        /*
-        [].slice.call(f).forEach(function(e) {
-          params[e.name] = encodeURI(e.value);
-          //console.log(e.name+'='+e.value);
-        });
-        */
         var items = f.getElementsByTagName('input');
         for (i = 0; i < items.length; ++i) {
           var e = items[i];
           params.push(e.name+'='+encodeURI(e.value));
         }
-        //console.log(url+'?'+params.join('&')); continue;
         var xhttp = new XMLHttpRequest();
         xhttp.open("POST", url, false);
         xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
-        xhttp.onload = function (e) {
-          if (xhttp.readyState === 4) {
-          }
-        }
+        xhttp.onload = function (e) { if (xhttp.readyState === 4) { } }
         xhttp.send(params.join('&'));
         //console.log(params.join('&'));
       }//);
       location.reload();
-      /*
-      var items = document.querySelectorAll("form.rm");
-      for (i = 0; i < items.length; ++i) {
-        var e = items[i];
-        e.submit();
-      }
-      */
       return false;
     };
     document.querySelector("th.delete").appendChild(a);
index 15551627c3b9af5d3f6f3dea8da58611220b15e6..e6afad117e2437fbaabff37244a90c28e1e2ea79 100644 (file)
@@ -1 +1 @@
-function form_clean(e){var t;for(i=0;i<e.length;i++)"none"!=(t=e.elements[i]).style.display&&("text"==t.type?t.value="":!t.type.match(/^select/)||"limit"!=t.name&&"format"!=t.name||(t.selectedIndex=0))}function form_submit_clean(e){var t=0,n="",o=e.getAttribute("action");if("get"!=e.getAttribute("method"))return!0;for(t=0;t<e.length;t++){var r=e[t];r.name&&(""!=r.value&&"undefined"!=r.value&&(n+=(n?"&":"?")+encodeURI(r.name)+"="+encodeURI(r.value)))}return n=("?"==o?"":o)+n,e.reset(),window.location=n,!1}document.addEventListener("DOMContentLoaded",function(){if(NodeList.prototype.forEach=Array.prototype.forEach,document.querySelectorAll("form").forEach(function(e){e.onsubmit=function(){if(this.elements.limit){var e=this.elements.limit;"undefined"!=window._dbq.default_limit&&e.value==window._dbq.default_limit&&e.removeAttribute("value")}return form_submit_clean(this)}}),document.querySelectorAll("form.menu").forEach(function(e){e.setAttribute("action",window.location.toString().replace(/\?.*$/,"")),e.querySelectorAll("form.menu select.format").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["table.base"]+"."+this.value),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.tables").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["db.base"]+"/"+this.value+".html"),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.limit").forEach(function(e){e.onchange=function(){return this.form.onsubmit()}})}),document.querySelector(".nav.bottom")&&document.querySelector("table.rows")&&document.querySelector("table.rows").insertAdjacentHTML("beforebegin",'<div class="nav top">'+document.querySelector(".nav.bottom").innerHTML+"</div>"),document.querySelectorAll("table").forEach(function(e){parseInt(e.offsetWidth)>parseInt(window.innerWidth)&&(e.className=e.className.replace(/(^| +)fixed($| )/,"")+" fixed",e.className=e.className.trim())}),window._dbq.perm<window._dbq.perms.write&&(document.querySelectorAll("form.edit").forEach(function(e){e.setAttribute("onsubmit","return false")}),document.querySelectorAll("form.edit input[type=submit],form.edit input[type=reset]").forEach(function(e){e.setAttribute("style","display:none")})),document.querySelectorAll("form.menu input[type=submit]").forEach(function(e){e.insertAdjacentHTML("afterend",'&nbsp;<input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)" value="'+window._dbq["text.clear"]+'" />'+(window._dbq.perm>=window._dbq.perms.write?'&nbsp;<input type="button" class="add '+e.className+'" onclick="window.location=\''+window._dbq["table.base"]+'/add/\'" value="'+window._dbq["text.add"]+'"/>':""))}),document.querySelector("DISABLE th.delete")){var e=document.createElement("a");e.setAttribute("href","#"),e.innerHTML=document.querySelector("th.delete").innerHTML+"&nbsp;All",document.querySelector("th.delete").innerHTML="",e.onclick=function(){var e=document.querySelectorAll("form.rm");for(i=0;i<e.length;++i)e[i].submit();return!1},document.querySelector("th.delete").appendChild(e)}});
+function form_clean(e){var t;for(i=0;i<e.length;i++)"none"!=(t=e.elements[i]).style.display&&("text"==t.type?t.value="":!t.type.match(/^select/)||"limit"!=t.name&&"format"!=t.name||(t.selectedIndex=0))}function form_submit_clean(e){var t=0,n="",o=e.getAttribute("action");if("get"!=e.getAttribute("method"))return!0;for(t=0;t<e.length;t++){var r=e[t];r.name&&(""!=r.value&&"undefined"!=r.value&&(n+=(n?"&":"?")+encodeURI(r.name)+"="+encodeURI(r.value)))}return n=("?"==o?"":o)+n,e.reset(),window.location=n,!1}document.addEventListener("DOMContentLoaded",function(){if(NodeList.prototype.forEach=Array.prototype.forEach,document.querySelectorAll("form").forEach(function(e){e.onsubmit=function(){if(this.elements.limit){var e=this.elements.limit;"undefined"!=window._dbq.default_limit&&e.value==window._dbq.default_limit&&e.removeAttribute("value")}return form_submit_clean(this)}}),document.querySelectorAll("form.menu").forEach(function(e){e.setAttribute("action",window.location.toString().replace(/\?.*$/,"")),e.querySelectorAll("form.menu select.format").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["table.base"]+"."+this.value),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.tables").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["db.base"]+"/"+this.value+".html"),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.limit").forEach(function(e){e.onchange=function(){return this.form.onsubmit()}})}),document.querySelector(".nav.bottom")&&document.querySelector("table.rows")&&document.querySelector("table.rows").insertAdjacentHTML("beforebegin",'<div class="nav top">'+document.querySelector(".nav.bottom").innerHTML+"</div>"),document.querySelectorAll("table").forEach(function(e){parseInt(e.offsetWidth)>parseInt(window.innerWidth)&&(e.className=e.className.replace(/(^| +)fixed($| )/,"")+" fixed",e.className=e.className.trim())}),window._dbq.perm<window._dbq.perms.write&&(document.querySelectorAll("form.edit").forEach(function(e){e.setAttribute("onsubmit","return false")}),document.querySelectorAll("form.edit input[type=submit],form.edit input[type=reset]").forEach(function(e){e.setAttribute("style","display:none")})),document.querySelectorAll("form.menu input[type=submit]").forEach(function(e){e.insertAdjacentHTML("afterend",'&nbsp;<input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)" value="'+window._dbq["text.clear"]+'" />'+(window._dbq.perm>=window._dbq.perms.write?'&nbsp;<input type="button" class="add '+e.className+'" onclick="window.location=\''+window._dbq["table.base"]+'/add/\'" value="'+window._dbq["text.add"]+'"/>':""))}),document.querySelector("th.delete")){var e=document.createElement("a");e.setAttribute("href","#"),e.innerHTML=document.querySelector("th.delete").innerHTML+"&nbsp;All",document.querySelector("th.delete").innerHTML="",e.onclick=function(){var e=document.querySelectorAll("form.rm");for(j=0;j<e.length;++j){var t=e[j],n=t.getAttribute("action"),o=[],r=t.getElementsByTagName("input");for(i=0;i<r.length;++i){var l=r[i];o.push(l.name+"="+encodeURI(l.value))}var a=new XMLHttpRequest;a.open("POST",n,!1),a.setRequestHeader("Content-type","application/x-www-form-urlencoded"),a.onload=function(e){a.readyState},a.send(o.join("&"))}return location.reload(),!1},document.querySelector("th.delete").appendChild(e)}});