Преглед изворни кода

[home2] Create skeleton file browser ko component

Johan Ahlen пре 10 година
родитељ
комит
228a4a5

+ 58 - 0
desktop/core/src/desktop/templates/file_browser.mako

@@ -0,0 +1,58 @@
+## Licensed to Cloudera, Inc. under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  Cloudera, Inc. licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##     http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+
+<%!
+from desktop import conf
+from desktop.lib.i18n import smart_unicode
+from django.utils.translation import ugettext as _
+from desktop.views import _ko
+%>
+
+<%def name="fileBrowser()">
+  <style>
+
+  </style>
+
+  <script type="text/html" id="file-browser-template">
+    Hello
+  </script>
+
+  <script type="text/javascript" charset="utf-8">
+    (function (factory) {
+      if(typeof require === "function") {
+        define('fileBrowser', [
+          'knockout'
+        ], factory);
+      } else {
+        factory(ko);
+      }
+    }(function (ko) {
+
+      /**
+       * @param {Object} options
+       * @constructor
+       */
+      function FileBrowser (options) {
+        var self = this;
+      }
+
+      ko.components.register('file-browser', {
+        viewModel: FileBrowser,
+        template: { element: 'file-browser-template' }
+      });
+    }));
+  </script>
+</%def>

+ 9 - 3
desktop/core/src/desktop/templates/home2.mako

@@ -19,6 +19,7 @@
 %>
 
 <%namespace name="assist" file="/assist.mako" />
+<%namespace name="fileBrowser" file="/file_browser.mako" />
 <%namespace name="tableStats" file="/table_stats.mako" />
 <%namespace name="require" file="/require.mako" />
 
@@ -28,6 +29,7 @@ ${ require.config() }
 
 ${ tableStats.tableStats() }
 ${ assist.assistPanel() }
+${ fileBrowser.fileBrowser() }
 
 <style type="text/css">
 
@@ -238,9 +240,12 @@ ${ assist.assistPanel() }
           <i class="fa fa-upload"></i> ${ _('Import') }
         </a>
 
-        <!-- ko with: currentDirectory -->
-        <div></div>
-        <!-- /ko -->
+        <div class="file-browser" data-bind="component: {
+          name: 'file-browser',
+          params: {
+            currentDirectory: currentDirectory
+          }
+        }"></div>
       </div>
     </div>
   </div>
@@ -264,6 +269,7 @@ ${ commonimportexport(request) | n,unicode }
     'desktop/js/share2.vm',
     'assistPanel',
     'tableStats',
+    'fileBrowser',
     'knockout-mapping',
     'knockout-sortable',
     'ko.hue-bindings'