]> git.nbdom.net Git - nb.git/commitdiff
dbq
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 20 Dec 2016 16:31:10 +0000 (16:31 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 20 Dec 2016 16:31:10 +0000 (16:31 +0000)
lib/php/mime.php
lib/php/out.php
src/Docker/nginx/default.conf
www/dbq/dbq.php
www/dbq/etc/nginx/default.conf

index e13183b62d0da18d02375483d91de904db3723b4..d229e2b30d6664701f2f5dc28ef3eac800cea031 100644 (file)
@@ -412,6 +412,7 @@ class Mime {
 'image/x-portable-graymap' => 'pgm',
 'application/x-chess-pgn' => 'pgn',
 'application/pgp-signature' => 'pgp',
+'text/x-php' => 'php',
 'image/x-pict' => 'pic',
 'application/pkixcmp' => 'pki',
 'application/pkix-pkipath' => 'pkipath',
index ff81ce9d3ab56bede184e6c78e895b75859ac0ef..468c35002fa3c70ee173b1731d404f9660ed4e1c 100644 (file)
@@ -8,7 +8,7 @@ Class Out extends Nb {
   protected static $type;
   public static function init() {
 
-    self::$types = array(
+    self::$types = [
 
       'human' => [
         'sep' => self::p('sep'," | "),
@@ -192,8 +192,9 @@ Class Out extends Nb {
         'rec' => ',',
       ),
 
-    );
+    ];
 
+    #self::$types['html'] = self::$types['table'];
     self::type(self::client_type());
   }
 
index ac59a71a71c0f5c4d2b2d4ca868daa5db0abc02a..10aabf51471961499211e5eb58cc39e38be92913 100644 (file)
@@ -21,7 +21,8 @@ server {
 
     client_max_body_size 100m;
 
-    location ~ \.php$ {
+    location ~ /index\.php$ {
+    #location index.php {
         fastcgi_split_path_info ^(.+\.php)(/.+)$;
         fastcgi_pass php:9000;
         fastcgi_index index.php;
index d89615cd388de8e504ca415d03597aea3a2c7de8..ff17602713f27ba65f0e47a7696873235778add4 100644 (file)
@@ -143,6 +143,35 @@ table.rows th, table.rows td { border-color: '.$this->colors['body-border'].'; }
       // Write output
       $this->page_colors();
       $this->page->headers_no_cache();
+      $this->page->js_code = trim('
+function form_submit_clean(form) {
+  form_clean(form);
+  form.submit();
+}
+function form_clean(form) {
+    var e;
+    for(i=0;i<form.length;i++) {
+      e = form.elements[i];
+      if (e.style.display == "none") continue;
+      if (e.type != "text") continue;
+      e.value = ""
+    }
+}
+document.addEventListener("DOMContentLoaded", function() {
+  for (var e of document.querySelectorAll(".menu select.limit")) {
+    e.onchange = function() {
+      this.form.submit();
+      return false;
+    };
+  }
+  for (var e of document.querySelectorAll(".menu select.tables, .menu select.format")) {
+    e.onchange = function() {
+      window.location =  "./" + this.form.elements["table"].value + "." + this.form.elements["format"].value;
+      return false;
+    };
+  }
+});
+      ');
       $this->page->begin();
     }
 
@@ -233,14 +262,17 @@ table.rows th, table.rows td { border-color: '.$this->colors['body-border'].'; }
 
   public function table_rows($fct=null) {
 
+    if ($this->page->is('html')) {
+      #debug($this->page->content_type());
+    }
     $opt = ($this->page->is('html')
       and ($this->perm >= self::VIEW)
       and $this->table->type() != 'sql'
     ) ? [
       'buttons' => join('&nbsp;',[
         '<input type="submit" class="button button-small" value="GO"/>',
-        #'<input type="button" class="button button-small" onclick="f=this.parentElement.parentElement; f.elements[\'action\'].value=\'edit\'; f.setAttribute(\'method\',\'POST\'); f.submit();" value="Add"/>',
         '<input type="button" class="button button-small" onclick="window.location=\''.$this->table->base.'add/'.'\'" value="Add"/>',
+        '<input type="button" class="button button-small" onclick="form_clean(this.form)" value="X"/>',
       ]),
       'row_parse_pre' => function(&$r){
 
@@ -471,6 +503,13 @@ table.rows th, table.rows td { border-color: '.$this->colors['body-border'].'; }
 
     if ($format == 'html') $format = 'table';
     $this->params['format'] = $format;
+    $this->db->formats = [
+      'table',
+      'csv',
+      'json',
+      'yaml',
+      'sh',
+    ];
     $this->db->format = $format;
 
     // Then content type
index a30b86a62e676e56883ee5029dba5f2b972c4190..fc4db670655a812f58ec7047fdcd1e829dc827d8 100644 (file)
@@ -45,7 +45,8 @@ server {
 
                ###############################################################
                # FastCGI
-    location ~ \.php$ {
+    #location ~ \.php$ {
+    location ~ /index\.php$ {
         fastcgi_split_path_info ^(.+\.php)(/.+)$;
         #fastcgi_pass localhost:9000;
         fastcgi_pass unix:/var/run/php5-fpm.sock;