From bfc38919020643cb143a19aed70bcbe1cde7dc50 Mon Sep 17 00:00:00 2001 From: tinkoff-dwh Date: Mon, 27 Nov 2017 13:33:01 +0300 Subject: [PATCH 1/7] [ZEPPELIN-2517]&[ZEPPELIN-465] Run paragraphs from 1st to this. From this to last --- .../src/app/notebook/notebook.controller.js | 75 +++++++++++++++++++ .../notebook/paragraph/paragraph-control.html | 18 +++++ .../paragraph/paragraph.controller.js | 41 +++++++++- 3 files changed, 133 insertions(+), 1 deletion(-) diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js index d09a0b23b64..81a37d140bc 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.js @@ -1180,6 +1180,81 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, ** $scope.$on functions below */ + $scope.$on('runAllFromFirstToThis', function (event, paragraph, isNeedConfirm) { + let allParagraphs = $scope.note.paragraphs + let toRunParagraphs = [] + + for (let i = 0; allParagraphs[i] !== paragraph; i++) { + if (i === allParagraphs.length - 1) { return } // if paragraph not in array of all paragraphs + toRunParagraphs.push(allParagraphs[i]) + } + + toRunParagraphs.push(paragraph) + + const paragraphs = toRunParagraphs.map(p => { + return { + id: p.id, + title: p.title, + paragraph: p.text, + config: p.config, + params: p.settings.params + } + }) + + if (!isNeedConfirm) { + websocketMsgSrv.runAllParagraphs($scope.note.id, paragraphs) + } else { + BootstrapDialog.confirm({ + closable: true, + title: '', + message: 'Run all paragraphs from first to this?', + callback: function (result) { + if (result) { + websocketMsgSrv.runAllParagraphs($scope.note.id, paragraphs) + } + } + }) + } + }) + + $scope.$on('runAllFromThisToLast', function (event, paragraph, isNeedConfirm) { + let allParagraphs = $scope.note.paragraphs + let toRunParagraphs = [] + + for (let i = allParagraphs.length - 1; allParagraphs[i] !== paragraph; i--) { + if (i < 0) { return } // if paragraph not in array of all paragraphs + toRunParagraphs.push(allParagraphs[i]) + } + + toRunParagraphs.push(paragraph) + toRunParagraphs.reverse() + + const paragraphs = toRunParagraphs.map(p => { + return { + id: p.id, + title: p.title, + paragraph: p.text, + config: p.config, + params: p.settings.params + } + }) + + if (!isNeedConfirm) { + websocketMsgSrv.runAllParagraphs($scope.note.id, paragraphs) + } else { + BootstrapDialog.confirm({ + closable: true, + title: '', + message: 'Run all paragraphs from this to this?', + callback: function (result) { + if (result) { + websocketMsgSrv.runAllParagraphs($scope.note.id, paragraphs) + } + } + }) + } + }) + $scope.$on('setConnectedStatus', function (event, param) { if (connectedOnce && param) { initNotebook() diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html b/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html index d6599725cc0..1f148c29f92 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html @@ -140,6 +140,24 @@ Insert new +
  • + + + + Ctrl+{{ isMac ? 'Option' : 'Shift'}}+Enter + Run: from first to this + +
  • +
  • + + + + Ctrl+{{ isMac ? 'Option' : 'Shift'}}+Enter + Run: from this to last + +
  • Ctrl+Shift+C diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js index c5788416adf..e8a71492422 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js @@ -471,6 +471,43 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca $scope.runParagraph($scope.getEditorValue(), false, false) } + $scope.runAllToThis = function(paragraph) { + $scope.$emit('runAllFromFirstToThis', paragraph, true) + } + + $scope.runAllFromThis = function(paragraph) { + $scope.$emit('runAllFromThisToLast', paragraph, true) + } + + $scope.runAllToOrFromThis = function (paragraph) { + BootstrapDialog.show({ + message: 'Run paragraphs:', + title: '', + buttons: [{ + label: 'Close', + action: function(dialog) { + dialog.close() + } + }, + { + label: 'From first to this', + cssClass: 'btn-primary', + action: function(dialog) { + $scope.$emit('runAllFromFirstToThis', paragraph, false) + dialog.close() + } + }, + { + label: 'From this to the last', + cssClass: 'btn-primary', + action: function(dialog) { + $scope.$emit('runAllFromThisToLast', paragraph, false) + dialog.close() + } + }] + }) + } + $scope.turnOnAutoRun = function (paragraph) { paragraph.config.runOnSelectionChange = !paragraph.config.runOnSelectionChange commitParagraph(paragraph) @@ -1446,8 +1483,10 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca // move focus to next paragraph // $timeout stops chaining effect of focus propogation $timeout(() => $scope.$emit('moveFocusToNextParagraph', paragraphId)) - } else if (keyEvent.shiftKey && keyCode === 13) { // Shift + Enter + } else if (!keyEvent.ctrlKey && keyEvent.shiftKey && keyCode === 13) { // Shift + Enter $scope.runParagraphFromShortcut($scope.getEditorValue()) + } else if (keyEvent.ctrlKey && keyEvent.shiftKey && keyCode === 13) { // Ctrl + Shift + Enter + $scope.runAllToOrFromThis($scope.paragraph) } else if (keyEvent.ctrlKey && keyEvent.altKey && keyCode === 67) { // Ctrl + Alt + c $scope.cancelParagraph($scope.paragraph) } else if (keyEvent.ctrlKey && keyEvent.altKey && keyCode === 68) { // Ctrl + Alt + d From 9fbcdb6d24f9a72b000a06d5e8020ee121309060 Mon Sep 17 00:00:00 2001 From: tinkoff-dwh Date: Mon, 27 Nov 2017 14:38:15 +0300 Subject: [PATCH 2/7] [ZEPPELIN-2517]&[ZEPPELIN-465] add keyboard shortcut --- zeppelin-web/src/app/notebook/shortcut.html | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zeppelin-web/src/app/notebook/shortcut.html b/zeppelin-web/src/app/notebook/shortcut.html index c4b4009ee11..261e3960f95 100644 --- a/zeppelin-web/src/app/notebook/shortcut.html +++ b/zeppelin-web/src/app/notebook/shortcut.html @@ -37,6 +37,17 @@

    Keyboard shortcuts

    + + +
    Run: from first/this to this/last
    + + +
    + Ctrl + Shift + Enter +
    + + +
    Cancel
    From a7a415847158efad03bac57cc31d418a2c0115ee Mon Sep 17 00:00:00 2001 From: tinkoff-dwh Date: Tue, 28 Nov 2017 13:29:34 +0300 Subject: [PATCH 3/7] [ZEPPELIN-2517]&[ZEPPELIN-465] logic change --- zeppelin-web/src/app/notebook/notebook.controller.js | 10 ++++------ .../src/app/notebook/paragraph/paragraph-control.html | 4 ++-- .../src/app/notebook/paragraph/paragraph.controller.js | 8 ++++---- zeppelin-web/src/app/notebook/shortcut.html | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js index 81a37d140bc..40a21afc8b2 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.js @@ -1180,7 +1180,7 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, ** $scope.$on functions below */ - $scope.$on('runAllFromFirstToThis', function (event, paragraph, isNeedConfirm) { + $scope.$on('runAllAbove', function (event, paragraph, isNeedConfirm) { let allParagraphs = $scope.note.paragraphs let toRunParagraphs = [] @@ -1189,8 +1189,6 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, toRunParagraphs.push(allParagraphs[i]) } - toRunParagraphs.push(paragraph) - const paragraphs = toRunParagraphs.map(p => { return { id: p.id, @@ -1207,7 +1205,7 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, BootstrapDialog.confirm({ closable: true, title: '', - message: 'Run all paragraphs from first to this?', + message: 'Run all above?', callback: function (result) { if (result) { websocketMsgSrv.runAllParagraphs($scope.note.id, paragraphs) @@ -1217,7 +1215,7 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, } }) - $scope.$on('runAllFromThisToLast', function (event, paragraph, isNeedConfirm) { + $scope.$on('runAllBelowAndCurrent', function (event, paragraph, isNeedConfirm) { let allParagraphs = $scope.note.paragraphs let toRunParagraphs = [] @@ -1245,7 +1243,7 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, BootstrapDialog.confirm({ closable: true, title: '', - message: 'Run all paragraphs from this to this?', + message: 'Run current and all below?', callback: function (result) { if (result) { websocketMsgSrv.runAllParagraphs($scope.note.id, paragraphs) diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html b/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html index 1f148c29f92..8b244446036 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html @@ -146,7 +146,7 @@ style="position: relative; transform: rotate(-90deg); left: -4px;"> Ctrl+{{ isMac ? 'Option' : 'Shift'}}+Enter - Run: from first to this + Run all above
  • @@ -155,7 +155,7 @@ style="position: relative; transform: rotate(-90deg); left: -4px;"> Ctrl+{{ isMac ? 'Option' : 'Shift'}}+Enter - Run: from this to last + Run current and all below
  • diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js index e8a71492422..d1eb86bf31a 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js @@ -472,11 +472,11 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca } $scope.runAllToThis = function(paragraph) { - $scope.$emit('runAllFromFirstToThis', paragraph, true) + $scope.$emit('runAllAbove', paragraph, true) } $scope.runAllFromThis = function(paragraph) { - $scope.$emit('runAllFromThisToLast', paragraph, true) + $scope.$emit('runAllBelowAndCurrent', paragraph, true) } $scope.runAllToOrFromThis = function (paragraph) { @@ -493,7 +493,7 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca label: 'From first to this', cssClass: 'btn-primary', action: function(dialog) { - $scope.$emit('runAllFromFirstToThis', paragraph, false) + $scope.$emit('runAllAbove', paragraph, false) dialog.close() } }, @@ -501,7 +501,7 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca label: 'From this to the last', cssClass: 'btn-primary', action: function(dialog) { - $scope.$emit('runAllFromThisToLast', paragraph, false) + $scope.$emit('runAllBelowAndCurrent', paragraph, false) dialog.close() } }] diff --git a/zeppelin-web/src/app/notebook/shortcut.html b/zeppelin-web/src/app/notebook/shortcut.html index 261e3960f95..5d1dd745afa 100644 --- a/zeppelin-web/src/app/notebook/shortcut.html +++ b/zeppelin-web/src/app/notebook/shortcut.html @@ -39,7 +39,7 @@

    Keyboard shortcuts

    -
    Run: from first/this to this/last
    +
    Run all above/below
    From 8ca1df207ad7cb5157bd4e314e34bf56568ca116 Mon Sep 17 00:00:00 2001 From: tinkoff-dwh Date: Tue, 28 Nov 2017 15:19:00 +0300 Subject: [PATCH 4/7] [Zeppelin-2517]&[Zeppelin-465] line reduction --- zeppelin-web/src/app/notebook/paragraph/paragraph-control.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html b/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html index 8b244446036..5ea3b455779 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html @@ -155,7 +155,7 @@ style="position: relative; transform: rotate(-90deg); left: -4px;"> Ctrl+{{ isMac ? 'Option' : 'Shift'}}+Enter - Run current and all below + Run all below
  • From 70f130cea38d34e304302451bec4ab916fff481c Mon Sep 17 00:00:00 2001 From: tinkoff-dwh Date: Tue, 28 Nov 2017 17:33:36 +0300 Subject: [PATCH 5/7] [Zeppelin-2517]&[Zeppelin-465] some text change --- zeppelin-web/src/app/notebook/shortcut.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zeppelin-web/src/app/notebook/shortcut.html b/zeppelin-web/src/app/notebook/shortcut.html index 5d1dd745afa..9bc55973a53 100644 --- a/zeppelin-web/src/app/notebook/shortcut.html +++ b/zeppelin-web/src/app/notebook/shortcut.html @@ -39,7 +39,7 @@

    Keyboard shortcuts

    -
    Run all above/below
    +
    Run all above/below paragraphs
    From 3d57b3038a6791c7038ed72ddaa57d6da6dc9c98 Mon Sep 17 00:00:00 2001 From: tinkoff-dwh Date: Wed, 29 Nov 2017 15:18:38 +0300 Subject: [PATCH 6/7] [ZEPPELIN-2517]&[ZEPPELIN-465] save paragraph's focus --- .../src/app/notebook/notebook.controller.js | 17 +++++++++++++++-- .../paragraph/paragraph.controller.js | 19 +++++++++++-------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js index 40a21afc8b2..111d1c49feb 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.js @@ -164,7 +164,7 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, for (let i = 0; i < $scope.note.paragraphs.length; i++) { let paragraphId = $scope.note.paragraphs[i].id if (jQuery.contains(angular.element('#' + paragraphId + '_container')[0], clickEvent.target)) { - $scope.$broadcast('focusParagraph', paragraphId, 0, true) + $scope.$broadcast('focusParagraph', paragraphId, 0, null, true) break } } @@ -504,7 +504,7 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, para.focus = true // we need `$timeout` since angular DOM might not be initialized - $timeout(() => { $scope.$broadcast('focusParagraph', para.id, 0, false) }) + $timeout(() => { $scope.$broadcast('focusParagraph', para.id, 0, null, false) }) } }) } @@ -1213,6 +1213,8 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, } }) } + + $scope.saveCursorPosition(paragraph) }) $scope.$on('runAllBelowAndCurrent', function (event, paragraph, isNeedConfirm) { @@ -1251,8 +1253,19 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope, } }) } + + $scope.saveCursorPosition(paragraph) }) + $scope.saveCursorPosition = function (paragraph) { + let angParagEditor = angular + .element('#' + paragraph.id + '_paragraphColumn_main') + .scope().editor + let col = angParagEditor.selection.lead.column + let row = angParagEditor.selection.lead.row + $scope.$broadcast('focusParagraph', paragraph.id, row + 1, col) + } + $scope.$on('setConnectedStatus', function (event, param) { if (connectedOnce && param) { initNotebook() diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js index d1eb86bf31a..d3ed3466e76 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js @@ -490,7 +490,7 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca } }, { - label: 'From first to this', + label: 'Run all above', cssClass: 'btn-primary', action: function(dialog) { $scope.$emit('runAllAbove', paragraph, false) @@ -498,7 +498,7 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca } }, { - label: 'From this to the last', + label: 'Run current and all below', cssClass: 'btn-primary', action: function(dialog) { $scope.$emit('runAllBelowAndCurrent', paragraph, false) @@ -1539,7 +1539,10 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca } }) - $scope.$on('focusParagraph', function (event, paragraphId, cursorPos, mouseEvent) { + $scope.$on('focusParagraph', function (event, paragraphId, cursorPosRow, cursorPosCol, mouseEvent) { + if (cursorPosCol === null || cursorPosCol === undefined) { + cursorPosCol = 0 + } if ($scope.paragraph.id === paragraphId) { // focus editor if (!$scope.paragraph.config.editorHide) { @@ -1547,14 +1550,14 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca $scope.editor.focus() // move cursor to the first row (or the last row) let row - if (cursorPos >= 0) { - row = cursorPos - $scope.editor.gotoLine(row, 0) + if (cursorPosRow >= 0) { + row = cursorPosRow + $scope.editor.gotoLine(row, cursorPosCol) } else { row = $scope.editor.session.getLength() - $scope.editor.gotoLine(row, 0) + $scope.editor.gotoLine(row, cursorPosCol) } - $scope.scrollToCursor($scope.paragraph.id, 0) + $scope.scrollToCursor($scope.paragraph.id, cursorPosCol) } } handleFocus(true) From 304c196098442836901e54634f464ec5762df200 Mon Sep 17 00:00:00 2001 From: tinkoff-dwh Date: Thu, 30 Nov 2017 10:55:14 +0300 Subject: [PATCH 7/7] [ZEPPELIN-2517]&[ZEPPELIN-465] fix shortcut description --- .../src/app/notebook/paragraph/paragraph-control.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html b/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html index 5ea3b455779..0b4ca1e4d67 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html @@ -145,7 +145,7 @@ - Ctrl+{{ isMac ? 'Option' : 'Shift'}}+Enter + Ctrl+Shift+Enter Run all above
  • @@ -154,7 +154,7 @@ - Ctrl+{{ isMac ? 'Option' : 'Shift'}}+Enter + Ctrl+Shift+Enter Run all below