jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1576804 - in /jena/branches/jena-fuseki-new-ui/src/main/webapp: js/app/controllers/upload-controller.js upload.html
Date Wed, 12 Mar 2014 16:18:09 GMT
Author: andy
Date: Wed Mar 12 16:18:08 2014
New Revision: 1576804

URL: http://svn.apache.org/r1576804
Log:
Rework HTML and destination dropdownlist

Modified:
    jena/branches/jena-fuseki-new-ui/src/main/webapp/js/app/controllers/upload-controller.js
    jena/branches/jena-fuseki-new-ui/src/main/webapp/upload.html

Modified: jena/branches/jena-fuseki-new-ui/src/main/webapp/js/app/controllers/upload-controller.js
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/webapp/js/app/controllers/upload-controller.js?rev=1576804&r1=1576803&r2=1576804&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/webapp/js/app/controllers/upload-controller.js
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/webapp/js/app/controllers/upload-controller.js
Wed Mar 12 16:18:08 2014
@@ -2,81 +2,14 @@
 define(
   function( require ) {
     var Marionette = require( "marionette" ),
-        Backbone = require( "backbone" ),
-        _ = require( "underscore" ),
-        fui = require( "fui" ),
-        pageUtils = require( "util/page-utils" ),
-        DatasetsDropdownListView = require( "views/datasets-dropdown-list" );
+    Backbone = require( "backbone" ),
+    _ = require( "underscore" ),
+    fui = require( "fui" ),
+    pageUtils = require( "util/page-utils" ),
+    DatasetsDropdownListView = require( "views/datasets-dropdown-list" );
 
     var UploadController = function() {
       this.initEvents();
-	    bindEvents() ;
-    };
-
-    var _config = {} ;
-
-    var initEndpoints = function(endpoints) {
-      var ulEndpoints = $("ul.endpoints");
-      ulEndpoints.empty();
-
-      $.each( endpoints, function( key, url ) {
-        var html = sprintf( "<li role='presentation'><a role='menuitem' tabindex='-1'
href='#'>%s</a></li>", url );
-        ulEndpoints.append( html );
-      } );
-
-      setCurrentEndpoint( endpoints["default"] );
-    } ;
-
-    var bindEvents = function() {
-      $(".endpoints").on( "click", "a", function( e ) {
-        var elem = $(e.currentTarget);
-        setCurrentEndpoint( $.trim( elem.text() ) );
-      } );
-      $("ul.formats").on( "click", "a", function( e ) {
-        var elem = $(e.currentTarget);
-        setCurrentFormat( elem.data( "value" ), $.trim( elem.text() ) );
-      } );
-
-      $(".run-upload").on( "click", runUpload );
-    } ;
-
-     /** Return the current endpoint text */
-    var currentEndpoint = function( ) {
-      return $("[id=uploadEndpoint]").val();
-    };
-
-    /** Set the current endpoint text */
-    var setCurrentEndpoint = function( url ) {
-      $("[id=uploadEndpoint]").val( url );
-    };
-
-    var runUpload = function( e ) {
-      console.info("runUpload") ;
-      e.preventDefault();
-
-      var url = currentEndpoint();
-      console.info(sprintf("runUpload: %s", url)) ;
-
-      var options = {
-//        data: {query: query, output: format},
-//        success: function( data, xhr ) {
-//          onQuerySuccess( data, format );
-//        },
-        success: onUploadSuccess ,
-        error: onUploadFail
-      };
-
-      $.ajax( url, options );
-    } ;
-
-    var onUploadSuccess = function( data, format ) {    
-        console.info("Upload - onUploadSuccess") ;
-    } ;
-
-    /** Report query failure */
-    var onUploadFail = function( jqXHR, textStatus, errorThrown ) {
-      var text = jqXHR.valueOf().responseText || sprintf( "Sorry, that didn't work because:
'%s'", jqXHR.valueOf().statusText );
-      $("#results").html( sprintf( "<pre class='text-danger'>%s</pre>", _.escape(text)
) );
     };
 
     // add the behaviours defined on the controller
@@ -86,6 +19,22 @@ define(
         fui.vent.on( "models.fuseki-server.ready", this.onServerModelReady );
       },
 
+      /** Return a hashmap of datasets */
+      datasetsConfig: function( endpoints, datasets ) {
+        _.each( datasets, function( ds ) {
+          var uploadURL = ds.uploadURL();
+          if (uploadURL) {
+            endpoints[ds.name()] = uploadURL;
+
+            if (!endpoints["default"]) {
+              endpoints["default"] = uploadURL;
+            }
+          }
+        } );
+
+        return endpoints;
+      },
+
       /** Set the default endpoint, if it was passed in the URL */
       setDefaultEndpoint: function( fusekiServer, endpoints ) {
         var dsName = pageUtils.queryParam( "ds" );
@@ -93,17 +42,36 @@ define(
           var ds = fusekiServer.dataset( dsName );
           endpoints["default"] = ds.uploadURL();
         }
-      },	
+      },  
+
+      /** Return a hashmap in a form we can pass to initUploader (c.f. a qconsole config)
 */
+      datasetsConfig: function( endpoints, datasets ) {
+        _.each( datasets, function( ds ) {
+          var uploadURL = ds.uploadURL();
+          if (uploadURL) {
+            endpoints[ds.name()] = uploadURL;
+
+            if (!endpoints["default"]) {
+              endpoints["default"] = uploadURL;
+            }
+          }
+        } );
+
+        var x = {} ;
+        x.endpoints = endpoints ;
+        return x ;
+      },
 
       /** When the fuseki server is ready, we can list the initial datasets */
       onServerModelReady: function( event ) {
-	      var fusekiServer = fui.models.fusekiServer;
+        var fusekiServer = fui.models.fusekiServer;
         var endpoints = {};
         var datasets = fusekiServer.datasets();
 
         this.setDefaultEndpoint( fusekiServer, endpoints );  
 
-        initEndpoints(endpoints) ;
+        var config = this.datasetsConfig(endpoints, datasets) ;
+        initUploader(config) ; ;
 
         var ddlv = new DatasetsDropdownListView( {model: datasets} );
         ddlv.render();
@@ -112,6 +80,57 @@ define(
 
     } );
 
-      return UploadController;
+    // Like qconsole initialization.
+    var initUploader = function( config ) {
+      initEndpoints(config) ;
+      bindEvents();
+    };
+
+    /** Bind events that we want to manage */
+    var bindEvents = function() {
+      $(".endpoints").on( "click", "a", function( e ) {
+        var elem = $(e.currentTarget);
+        setCurrentEndpoint( $.trim( elem.text() ) );
+      } );
+
+      // TODO Conflicts with the JQuery uploader?
+      $(".run-upload").on( "click", runUpload );
+    };
+
+    /** Set up the drop-down list of end-points */
+    var initEndpoints = function( config ) {
+      var endpoints = $("ul.endpoints");
+      endpoints.empty();
+
+      $.each( config.endpoints, function( key, url ) {
+        var html = sprintf( "<li role='presentation'><a role='menuitem' tabindex='-1'
href='#'>%s</a></li>",
+          url );
+        endpoints.append( html );
+      } );
+
+      setCurrentEndpoint( config.endpoints["default"] );
+    };
+
+    /** Set the current endpoint text */
+    var setCurrentEndpoint = function( url ) {
+      $("[id=uploadEndpoint]").val( url );
+    };
+
+    /** Return the current endpoint text */
+    var currentEndpoint = function( url ) {
+      return $("[id=uploadEndpoint]").val();
+    };
+
+    var runUpload = function( e ) {
+      e.preventDefault();
+      resetResults() ;
+
+      console.info("runUpload") ;
+      var url = currentEndpoint();
+      console.info(sprintf("runUpload: %s", url)) ;
+
+      // ?????
+      } ;
+    return UploadController;
   }
 );

Modified: jena/branches/jena-fuseki-new-ui/src/main/webapp/upload.html
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/webapp/upload.html?rev=1576804&r1=1576803&r2=1576804&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/webapp/upload.html (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/webapp/upload.html Wed Mar 12 16:18:08 2014
@@ -113,47 +113,47 @@
 
           <div class="col-md-12 well">
             <div class="query-chrome">
+              <form class="form-inline" role="form">
 
-              <div class="form-group">
-                <label for="uploadEndpoint">Destination</label>
-                <input type="text" class="form-control" id="uploadEndpoint" />
-              </div>
-
-              <!-- UPLOAD -->
-              <!-- Form like settings -->
+                <div class="form-group">
+                  <label for="uploadEndpoint"></label>
+                  <div class="dropdown ">
+                    <a data-toggle="dropdown" class="btn btn-custom2" href="#">
+                      Select Destination <i class="icon-collapse"></i></a>
+                    <ul class="dropdown-menu endpoints" role="menu" aria-labelledby="dropdownMenu1"></ul>
+                  </div>
+                </div>
 
-              <div class="form-group">
-                <label for="uploadEndpoint"></label>
-                <div class="dropdown ">
-                  <a data-toggle="dropdown" class="btn btn-custom2" href="#">
-                    Select Destination <i class="icon-collapse"></i></a>
-                  <ul class="dropdown-menu endpoints" role="menu" aria-labelledby="dropdownMenu1"></ul>
+                <div class="form-group">
+                  <label for="uploadEndpoint">Destination</label>
+                  <input type="text" class="form-control" id="uploadEndpoint" />
                 </div>
-              </div>
 
+                <div class="form-group">
+                  <!-- The fileinput-button span is used to style the file input field
as button -->
+                  <span class="btn btn-success fileinput-button">
+                    <i class="glyphicon glyphicon-plus"></i>
+                    <span>Select files...</span>
+                    <!-- The file input field used as target for the file upload widget
-->
+                    <input id="fileupload" type="file" name="files[]" multiple>
+                  </span>
+                  <br>
+                  <br>
+                  <!-- The global progress bar -->
+                  <div id="progress" class="progress">
+                    <div class="progress-bar progress-bar-success"></div>
+                  </div>
+                  <!-- The container for the uploaded files -->
+                  <div id="files" class="files"></div>
+                </div>
 
-              <!-- The fileinput-button span is used to style the file input field as
button -->
-              <span class="btn btn-success fileinput-button">
-                <i class="glyphicon glyphicon-plus"></i>
-                <span>Select files...</span>
-                <!-- The file input field used as target for the file upload widget -->
-                <input id="fileupload" type="file" name="files[]" multiple>
-              </span>
-              <br>
-              <br>
-              <!-- The global progress bar -->
-              <div id="progress" class="progress">
-                <div class="progress-bar progress-bar-success"></div>
+                </form>
               </div>
-              <!-- The container for the uploaded files -->
-              <div id="files" class="files"></div>
-              <br>
-
-            </div>
           </div>
-        </div>
 
-      </div>
+        </div> <!-- row -->
+      </div> <!-- container -->
+
 <script>
 /*global window, $ */
 $(function () {



Mime
View raw message