Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions zeppelin-web/src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
templateUrl: 'app/notebook/notebook.html',
controller: 'NotebookCtrl'
})
.when('/notebook/:noteId/offlineView', {
templateUrl: 'app/notebook/notebook.html',
controller: 'NotebookCtrl'
})
.when('/jobmanager', {
templateUrl: 'app/jobmanager/jobmanager.html',
controller: 'JobmanagerCtrl'
Expand Down
42 changes: 27 additions & 15 deletions zeppelin-web/src/app/notebook/notebook-actionBar.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,41 @@
<h3>
<div style="float: left; width: auto; max-width: 40%">
<input type="text" pu-elastic-input class="form-control2" placeholder="{{noteName(note)}}" style="min-width: 0px; max-width: 95%;"
ng-show="showEditor" ng-model="note.name" ng-blur="sendNewName();showEditor = false;" ng-enter="sendNewName();showEditor = false;" ng-escape="note.name = oldName; showEditor = false" focus-if="showEditor" />
<p class="form-control-static2" ng-click="showEditor = true; oldName = note.name" ng-show="!showEditor">{{noteName(note)}}</p>
ng-show="showEditor" ng-model="note.name" ng-blur="sendNewName();showEditor = false;" ng-enter="sendNewName();showEditor = false;" ng-escape="note.name = oldName; showEditor = false" focus-if="showEditor" ng-disabled="{{offlineView}}"/>
<p class="form-control-static2" ng-click="showEditor = !offlineView; oldName = note.name" ng-show="!showEditor">{{noteName(note)}}</p>
</div>
<div style="float: left; padding-bottom: 10px">
<span class="labelBtn btn-group">
<button type="button"
class="btn btn-default btn-xs"
ng-click="runNote()"
ng-class="{'disabled':isNoteRunning()}"
tooltip-placement="bottom" tooltip="Run all paragraphs">
tooltip-placement="bottom" tooltip="Run all paragraphs"
ng-disabled="{{offlineView}}">
<i class="icon-control-play"></i>
</button>
<button type="button"
class="btn btn-default btn-xs"
ng-click="toggleAllEditor()"
ng-hide="viewOnly"
tooltip-placement="bottom" tooltip="Show/hide the code">
tooltip-placement="bottom" tooltip="Show/hide the code"
ng-disabled="{{offlineView}}">
<i ng-class="editorToggled ? 'fa icon-size-fullscreen' :'fa icon-size-actual'"></i></button>
<button type="button"
class="btn btn-default btn-xs"
ng-click="toggleAllTable()"
ng-hide="viewOnly"
tooltip-placement="bottom" tooltip="Show/hide the output">
tooltip-placement="bottom" tooltip="Show/hide the output"
ng-disabled="{{offlineView}}">
<i ng-class="tableToggled ? 'fa icon-notebook' : 'fa icon-book-open'"></i>
</button>
<button type="button"
class="btn btn-default btn-xs"
ng-click="clearAllParagraphOutput()"
ng-hide="viewOnly"
ng-class="{'disabled':isNoteRunning()}"
tooltip-placement="bottom" tooltip="Clear output">
tooltip-placement="bottom" tooltip="Clear output"
ng-disabled="{{offlineView}}">
<i class="fa fa-eraser"></i>
</button>

Expand All @@ -54,21 +58,23 @@ <h3>
ng-hide="viewOnly"
tooltip-placement="bottom" tooltip="Clone the notebook"
data-toggle="modal" data-target="#noteNameModal" data-clone="true"
>
ng-disabled="{{offlineView}}">
<i class="fa fa-copy"></i>
</button>
<button type="button"
class="btn btn-default btn-xs"
ng-hide="viewOnly"
ng-click="exportNotebook()"
tooltip-placement="bottom" tooltip="Export the notebook">
tooltip-placement="bottom" tooltip="Export the notebook"
ng-disabled="{{offlineView}}">
<i class="fa fa-download"></i>
</button>
<button type="button"
class="btn btn-default btn-xs dropdown-toggle"
ng-hide="viewOnly"
data-toggle="dropdown"
tooltip-placement="bottom" tooltip="Version control">
tooltip-placement="bottom" tooltip="Version control"
ng-disabled="{{offlineView}}">
<i class="fa fa-file-code-o"></i>
</button>
<ul class="dropdown-menu" role="menu" style="width:250px">
Expand Down Expand Up @@ -100,7 +106,8 @@ <h3>
class="btn btn-default btn-xs"
ng-click="removeNote(note.id)"
ng-hide="viewOnly"
tooltip-placement="bottom" tooltip="Remove the notebook">
tooltip-placement="bottom" tooltip="Remove the notebook"
ng-disabled="{{offlineView}}">
<i class="icon-trash"></i>
</button>
</span>
Expand All @@ -111,7 +118,8 @@ <h3>
type="button"
data-toggle="dropdown"
ng-class="{ 'btn-info' : note.config.cron, 'btn-danger' : note.info.cron, 'btn-default' : !note.config.cron}"
tooltip-placement="bottom" tooltip="Run scheduler">
tooltip-placement="bottom" tooltip="Run scheduler"
ng-disabled="{{offlineView}}">
<span class="fa fa-clock-o"></span> {{getCronOptionNameFromValue(note.config.cron)}}
</div>
<ul class="dropdown-menu" role="menu" style="width:300px">
Expand Down Expand Up @@ -157,20 +165,20 @@ <h3>
</div>

<div class="pull-right" style="margin-top:15px; margin-right:15px; margin-left: 15px; margin-bottom: 13px; font-size:15px;">
<span class="setting-btn"
<span class="setting-btn {{offlineView ? 'disable' : ''}}"
type="button"
data-toggle="modal"
data-target="#shortcutModal"
tooltip-placement="bottom" tooltip="List of shortcut">
<i class="fa fa-keyboard-o"></i>
</span>
<span class="setting-btn"
<span class="setting-btn {{offlineView ? 'disable' : ''}}"
type="button"
ng-click="toggleSetting()"
tooltip-placement="bottom" tooltip="Interpreter binding">
<i class="fa fa-cog" ng-style="{color: showSetting ? '#3071A9' : 'black' }"></i>
</span>
<span class="setting-btn"
<span class="setting-btn {{offlineView ? 'disable' : ''}}"
type="button"
ng-click="togglePermissions()"
tooltip-placement="bottom" tooltip="Note permissions">
Expand All @@ -179,13 +187,17 @@ <h3>

<span class="btn-group">
<button type="button" class="btn btn-default btn-xs dropdown-toggle"
data-toggle="dropdown">
data-toggle="dropdown" ng-disabled="{{offlineView}}">
{{note.config.looknfeel}} <span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right" role="menu">
<li ng-repeat="looknfeel in looknfeelOption">
<a style="cursor:pointer" ng-click="setLookAndFeel(looknfeel)">{{looknfeel}}</a>
</li>
<li class="divider"></li>
<li>
<a style="cursor:pointer" ng-href="{{offlineViewPath}}" target="_blank">offline view</a>
</li>
</ul>
</span>
</div>
Expand Down
19 changes: 18 additions & 1 deletion zeppelin-web/src/app/notebook/notebook.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,21 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
$scope.interpreterBindings = [];
$scope.isNoteDirty = null;
$scope.saveTimer = null;

var connectedOnce = false;


// offline view mode
var pattern = new RegExp('^.*\/notebook\/[a-zA-Z0-9_]*\/offlineView$');
$scope.offlineView = pattern.test($location.path());
var path = '';
if ($scope.offlineView) {
path = '/#' + $location.path();
} else {
path = '/#' + $location.path() + '/offlineView';
}
$scope.offlineViewPath = path;
$scope.offlineViewLoaded = false;

// user auto complete related
$scope.suggestions = [];
$scope.selectIndex = -1;
Expand Down Expand Up @@ -338,6 +350,9 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro

/** update the current note */
$scope.$on('setNoteContent', function(event, note) {
if ($scope.offlineView && $scope.offlineViewLoaded) {
return;
}
$scope.paragraphUrl = $routeParams.paragraphId;
$scope.asIframe = $routeParams.asIframe;
if ($scope.paragraphUrl) {
Expand All @@ -353,6 +368,8 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
initializeLookAndFeel();
//open interpreter binding setting when there're none selected
getInterpreterBindings(getInterpreterBindingsCallBack);
//note loaded for viewOnly mode
$scope.offlineViewLoaded = true;
});

var initializeLookAndFeel = function() {
Expand Down
2 changes: 1 addition & 1 deletion zeppelin-web/src/app/notebook/notebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h4>Note Permissions (Only note owners can change)</h4>
ng-init="init(currentParagraph, note)"
ng-class="columnWidthClass(currentParagraph.config.colWidth)"
class="paragraph-col">
<div class="new-paragraph" ng-click="insertNew('above')" ng-hide="viewOnly || asIframe">
<div class="new-paragraph" ng-click="insertNew('above')" ng-hide="viewOnly || asIframe || offlineView">
<h4 class="plus-sign">&#43;</h4>
</div>
<div id="{{currentParagraph.id}}_paragraphColumn"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<span class="{{paragraph.config.tableHide ? 'icon-notebook' : 'icon-book-open'}}" style="cursor:pointer;" tooltip-placement="top" tooltip="{{(paragraph.config.tableHide ? 'Show' : 'Hide') + ' output'}}"
ng-click="toggleOutput()"></span>
<span class="dropdown navbar-right">
<span ng-if="!offlineView">
<span class="icon-settings" style="cursor:pointer"
data-toggle="dropdown"
type="button">
Expand Down Expand Up @@ -91,4 +92,5 @@
</li>
</ul>
</span>
</span>
</div>
12 changes: 12 additions & 0 deletions zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ angular.module('zeppelinWebApp').controller('ParagraphCtrl', function($scope, $r

// TODO: this may have impact on performance when there are many paragraphs in a note.
$scope.$on('updateParagraph', function(event, data) {
if ($scope.offlineView) {
return;
}
if (data.paragraph.id === $scope.paragraph.id &&
(data.paragraph.dateCreated !== $scope.paragraph.dateCreated ||
data.paragraph.dateFinished !== $scope.paragraph.dateFinished ||
Expand Down Expand Up @@ -528,6 +531,9 @@ angular.module('zeppelinWebApp').controller('ParagraphCtrl', function($scope, $r
};

$scope.runParagraph = function(data) {
if ($scope.offlineView) {
return;
}
websocketMsgSrv.runParagraph($scope.paragraph.id, $scope.paragraph.title,
data, $scope.paragraph.config, $scope.paragraph.settings.params);
$scope.originalText = angular.copy(data);
Expand Down Expand Up @@ -599,6 +605,9 @@ angular.module('zeppelinWebApp').controller('ParagraphCtrl', function($scope, $r
};

$scope.toggleEditor = function() {
if ($scope.offlineView) {
return;
}
if ($scope.paragraph.config.editorHide) {
$scope.openEditor();
} else {
Expand Down Expand Up @@ -720,6 +729,9 @@ angular.module('zeppelinWebApp').controller('ParagraphCtrl', function($scope, $r
};

$scope.toggleOutput = function() {
if ($scope.offlineView) {
return;
}
var newConfig = angular.copy($scope.paragraph.config);
newConfig.tableHide = !newConfig.tableHide;
var newParams = angular.copy($scope.paragraph.settings.params);
Expand Down
4 changes: 2 additions & 2 deletions zeppelin-web/src/app/notebook/paragraph/paragraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
ng-blur="setTitle(); showTitleEditor = false"
ng-enter="setTitle(); showTitleEditor = false"
focus-if="showTitleEditor" />
<div ng-click="showTitleEditor = !asIframe && !viewOnly; oldTitle = paragraph.title;"
<div ng-click="showTitleEditor = !asIframe && !viewOnly && !offlineView; oldTitle = paragraph.title;"
ng-show="!showTitleEditor"
ng-bind-html="paragraph.title || 'Untitled'">
</div>
Expand All @@ -45,7 +45,7 @@
require : ['ace/ext/language_tools']
}"
ng-model="paragraph.text"
ng-class="{'disable': paragraph.status == 'RUNNING' || paragraph.status == 'PENDING',
ng-class="{'disable': {{offlineView}} || paragraph.status == 'RUNNING' || paragraph.status == 'PENDING',
'paragraph-text--dirty' : dirtyText !== originalText && dirtyText !== undefined}">
</div>
</div>
Expand Down