From: Nicolas Boisselier Date: Tue, 2 Jan 2018 20:36:12 +0000 (+0000) Subject: etc/profile.d/nb.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=e8ae9f296cfb72a7ad97621607ae9c40c730c8d9;p=nb.git etc/profile.d/nb.sh --- diff --git a/bin/nb-update b/bin/nb-update index 1cf9aeb7..769dbf53 100755 --- a/bin/nb-update +++ b/bin/nb-update @@ -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 diff --git a/etc/profile.d/nb.sh b/etc/profile.d/nb.sh index 69931c9c..995700e3 100644 --- a/etc/profile.d/nb.sh +++ b/etc/profile.d/nb.sh @@ -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 } diff --git a/www/dbq/html/default.js b/www/dbq/html/default.js index 2c00e9b9..db8da16f 100644 --- a/www/dbq/html/default.js +++ b/www/dbq/html/default.js @@ -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); diff --git a/www/dbq/html/default.min.js b/www/dbq/html/default.min.js index 15551627..e6afad11 100644 --- a/www/dbq/html/default.min.js +++ b/www/dbq/html/default.min.js @@ -1 +1 @@ -function form_clean(e){var t;for(i=0;i'+document.querySelector(".nav.bottom").innerHTML+""),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.perm>=window._dbq.perms.write?' ':""))}),document.querySelector("DISABLE th.delete")){var e=document.createElement("a");e.setAttribute("href","#"),e.innerHTML=document.querySelector("th.delete").innerHTML+" All",document.querySelector("th.delete").innerHTML="",e.onclick=function(){var e=document.querySelectorAll("form.rm");for(i=0;i'+document.querySelector(".nav.bottom").innerHTML+""),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.perm>=window._dbq.perms.write?' ':""))}),document.querySelector("th.delete")){var e=document.createElement("a");e.setAttribute("href","#"),e.innerHTML=document.querySelector("th.delete").innerHTML+" All",document.querySelector("th.delete").innerHTML="",e.onclick=function(){var e=document.querySelectorAll("form.rm");for(j=0;j