فهرست منبع

HUE-6298 [frontend] Create a star application component

Enrico Berti 8 سال پیش
والد
کامیت
e1e10c3d64

+ 9 - 0
apps/oozie/src/oozie/templates/navigation-bar.mako

@@ -32,6 +32,14 @@
           <div class="nav-collapse">
             <ul class="nav">
               <li class="app-header">
+                <%def name="getApp(section)"><%
+                  if section == 'coordinators':
+                    return 'oozie-coordinator'
+                  elif section == 'bundles':
+                    return 'oozie-bundle'
+                  else:
+                    return 'oozie-workflow'
+                %></%def>
                 <%def name="getURL(section, dashboard, is_v2)">
                 <%
                   if dashboard:
@@ -66,6 +74,7 @@
                 % else:
                 <a title="${ _('Switch to the dashboard') }" href="${ is_embeddable and '/hue/jobbrowser/#!workflows' or getURL(section, dashboard, ENABLE_V2.get())}">
                   <svg class="svg-app-icon"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#hi-oozie"></use></svg> ${ _('Oozie Editor') }
+                  <!-- ko component: { name: 'hue-favorite-app', params: { hue4: IS_HUE_4, app: '${ getApp(section) }' }} --><!-- /ko -->
                 </a>
                 % endif
                </li>

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue.css


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue3-extra.css


+ 9 - 0
desktop/core/src/desktop/static/desktop/less/hue-cross-version.less

@@ -49,6 +49,15 @@ input[type='password']::-ms-reveal {
   padding-left: 0;
   color: @hue-primary-color-dark;
   cursor: pointer;
+  .favorite-app {
+    opacity: 0;
+    .hue-linear-transition(opacity);
+  }
+  &:hover {
+    .favorite-app {
+      opacity: 1;
+    }
+  }
 }
 
 .svg-app-icon {

+ 67 - 0
desktop/core/src/desktop/templates/ko_components.mako

@@ -471,4 +471,71 @@ from desktop.views import _ko
       });
     })();
   </script>
+
+  <script type="text/html" id="hue-favorite-app-template">
+    <!-- ko if: isHue4 -->
+    <div title="${ _('Toggle as the default Hue 4 action') }" class="inline pointer favorite-app" data-bind="click: setAsFavoriteApp">
+      <i class="fa" data-bind="css: {'fa-star-o muted': !isFavorite(), 'fa-star': isFavorite }"></i>
+    </div>
+    <!-- /ko -->
+  </script>
+
+  <script type="text/javascript">
+    (function () {
+
+      var FavoriteApp = function (params) {
+        var self = this;
+        self.isHue4 = ko.observable(params.hue4);
+        self.isFavorite = ko.observable(false);
+        self.app = params.app;
+        self.interpreter = params.interpreter;
+
+        self.parseCurrentFavorite = function (data) {
+          self.isFavorite(false);
+          if (data.status === 0 && data.data && data.data.default_app) {
+            try {
+              var defaultApp = JSON.parse(data.data.default_app);
+              self.isFavorite(defaultApp.app === self.app && ((self.app === 'editor' && defaultApp.interpreter === self.interpreter) || self.app !== 'editor'));
+            }
+            catch (e) {
+              console.error('${ _ko("There was a problem decoding the default app setting.") }');
+            }
+          }
+        }
+
+        self.setAsFavoriteApp = function (vm, e) {
+          e.originalEvent.stopPropagation();
+          e.originalEvent.stopImmediatePropagation();
+          var postParams = {
+            app: self.app
+          }
+          if (self.app === 'editor' && self.interpreter !== '') {
+            postParams['interpreter'] = self.interpreter;
+          }
+          var post = {};
+          if (self.isFavorite()) {
+            post['delete'] = true;
+          }
+          else {
+            post['set'] = ko.mapping.toJSON(postParams);
+          }
+          $.post('/desktop/api2/user_preferences/default_app', post, function (data) {
+            self.parseCurrentFavorite(data);
+          });
+        }
+
+        if (self.isHue4()) {
+          // load the fav app status
+          $.get('/desktop/api2/user_preferences/default_app', function (data) {
+            self.parseCurrentFavorite(data);
+          });
+        }
+      };
+
+      ko.components.register('hue-favorite-app', {
+        viewModel: FavoriteApp,
+        template: {element: 'hue-favorite-app-template'}
+      });
+    })();
+  </script>
 </%def>

+ 1 - 0
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -54,6 +54,7 @@ from desktop.views import commonheader, commonfooter, _ko
     <div class="app-header">
       <a href="#" data-bind="hueLink: '${ url('search:new_search') }'">
         <!-- ko template: { name: 'app-icon-template', data: { icon: 'dashboard' } } --><!-- /ko --> ${ _('Dashboard') }
+        <!-- ko component: { name: 'hue-favorite-app', params: { hue4: IS_HUE_4, app: 'dashboard' }} --><!-- /ko -->
       </a>
     </div>
   </div>

+ 2 - 0
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -324,11 +324,13 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
               <!-- ko if: ['impala', 'pig', 'hive', 'beeswax', 'rdbms', 'java', 'spark2', 'sqoop1', 'distcp', 'shell', 'mapreduce'].indexOf(editorType()) == -1 -->
                 SQL
               <!-- /ko -->
+              <!-- ko component: { name: 'hue-favorite-app', params: { hue4: IS_HUE_4, app: 'editor', interpreter: editorType() }} --><!-- /ko -->
               </a>
             <!-- /ko -->
             <!-- ko ifnot: editorMode -->
               <i class="fa fa-file-text-o app-icon" style="vertical-align: middle"></i>
                 Notebook
+              <!-- ko component: { name: 'hue-favorite-app', params: { hue4: IS_HUE_4, app: 'notebook' }} --><!-- /ko -->
             <!-- /ko -->
           </li>
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است