Browse Source

HUE-7876 [presentation] Allow to publish presentation mode turned on

Romain Rigaux 7 years ago
parent
commit
a74fe29

+ 13 - 11
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -2069,18 +2069,20 @@ var EditorViewModel = (function() {
     self.canWrite = ko.observable(typeof notebook.can_write != "undefined" && notebook.can_write != null ? notebook.can_write : true);
     self.onSuccessUrl = ko.observable(typeof notebook.onSuccessUrl != "undefined" && notebook.onSuccessUrl != null ? notebook.onSuccessUrl : null);
     self.pubSubUrl = ko.observable(typeof notebook.pubSubUrl != "undefined" && notebook.pubSubUrl != null ? notebook.pubSubUrl : null);
-    self.isPresentationMode = ko.observable(typeof notebook.isPresentationMode != "undefined" && notebook.isPresentationMode != null ? notebook.isPresentationMode : false);
+    self.isPresentationModeDefault = ko.observable(typeof notebook.isPresentationModeDefault != "undefined" && notebook.isPresentationModeDefault != null ? notebook.isPresentationModeDefault : false);
+    self.isPresentationMode = ko.observable(false);
     self.isPresentationMode.subscribe(function(newValue) {
-        wasResultFullScreenMode = false;
-        if (! newValue) {
-          self.cancelExecutingAll();
-        }
-        huePubSub.publish('editor.presentation.operate.toggle', newValue); // Problem with headers / row numbers redraw on full screen results
-        vm.togglePresentationMode();
-        if (newValue) {
-          hueAnalytics.convert('editor', 'presentation');
-        }
-      });
+      wasResultFullScreenMode = false;
+      if (! newValue) {
+        self.cancelExecutingAll();
+      }
+      huePubSub.publish('editor.presentation.operate.toggle', newValue); // Problem with headers / row numbers redraw on full screen results
+      vm.togglePresentationMode();
+      if (newValue) {
+        hueAnalytics.convert('editor', 'presentation');
+      }
+    });
+//    self.isPresentationMode(self.isPresentationModeDefault());
     self.presentationSnippets = ko.observable({});
 
     self.snippets = ko.observableArray();

+ 7 - 5
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -249,17 +249,19 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
 <script type="text/html" id="notebook-menu-buttons-${ suffix }">
   <div class="pull-right margin-right-10">
   % if ENABLE_PRESENTATION.get():
-    <div class="btn-group" data-bind="visible: $root.isPresentationMode()">
-      <a class="btn" title="${ _ko('Open document as presentation by default') }" data-bind="click: function() { $root.selectedNotebook().isPresentationMode(true); }">
-        <i class="fa" data-bind="css: {'fa-toggle-off': $root.isPresentationMode()}"></i>
+    <!-- ko with: selectedNotebook() -->
+    <div class="btn-group" data-bind="visible: $root.isPresentationMode() && $root.canSave()">
+      <a class="btn" title="${ _ko('Wether to open the document in presentation mode by default') }" data-bind="click: function() { isPresentationModeDefault(!isPresentationModeDefault()); }">
+        <i class="fa" data-bind="css: {'fa-toggle-on': isPresentationModeDefault(), 'fa-toggle-off': !isPresentationModeDefault()}"></i>
       </a>
     </div>
     <div class="btn-group">
-      <a class="btn" title="${ _ko('View as a presentation') }" data-bind="click: function() { $root.selectedNotebook().isPresentationMode(true); },
+      <a class="btn" title="${ _ko('View as a presentation') }" data-bind="click: function() { isPresentationMode(!isPresentationMode()); },
         css: {'btn-inverse': $root.isPresentationMode()}">
         <i class="fa fa-line-chart"></i>
       </a>
     </div>
+    <!-- /ko -->
   % endif
 
     % if IS_EMBEDDED.get():
@@ -291,7 +293,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
         <!-- /ko -->
       </div>
 
-      <!-- ko template: { ifnot: editorMode, name: 'notebook-actions' }--><!-- /ko -->
+      <!-- ko template: { ifnot: editorMode() || isPresentationMode(), name: 'notebook-actions' }--><!-- /ko -->
 
       <div class="dropdown pull-right margin-left-10">
         <a class="btn" data-toggle="dropdown" href="javascript: void(0)">