Repository: incubator-zeppelin Updated Branches: refs/heads/master 9a3e55533 -> 3bc145f04
The user will be able to provide a name to note at creation time Ability to name a note while creating from UI. By default a name is shown. User can change that name. If user does not provide any name then we randomly name it at backend like the way its happening right now. Author: Karuppayya <[email protected]> Author: Karuppayya <[email protected]> Author: Karuppayya <[email protected]> Closes #156 from Karuppayya/notename and squashes the following commits: 02e6073 [Karuppayya] Fix js error eb6ff07 [Karuppayya] merge os/master d6f30dd [Karuppayya] Allow configuring the id of the input , whose text should be selected. If not id is passed, text will not be selected ca4357c [Karuppayya] Fix build time js warnings 98d6cfa [Karuppayya] Fixing a bad merge 4aba316 [Karuppayya] Removing duplicate entry 58b1c43 [Karuppayya] Removing duplicate entry 1972e12 [Karuppayya] Merge branch 'notename' of github.com:Karuppayya/incubator-zeppelin into notename 606282a [Karuppayya] Browse seems to recognize "javascript:void(0)" as cross origin request. Removed it. We just need a pointer when we hover over "create new note". Fixed it. 9ae1431 [Karuppayya] *Remove DOM maniupaltion from controller 6d61425 [Karuppayya] *change directive name to be more specific. *Make directive generic by provisioning callbacks. *Make "note" to "Note"(in the generated name) d8403f1 [Karuppayya] Removing a flag that is not required 9b8db92 [Karuppayya] Selenium test fix 4c8f422 [Karuppayya] test fix 03c382b [Karuppayya] Fix selenium test. 5a980c7 [Karuppayya] Fixing Test 7206579 [Karuppayya] Fixing tests 80e4995 [Karuppayya] Add License header to new file that was added. eb63ac4 [Karuppayya] When no name is given, note is created with default name 3aa4eb5 [Karuppayya] The user will be able to provide a name to note at creation time 1199ac3 [Karuppayya] Browse seems to recognize "javascript:void(0)" as cross origin request. Removed it. We just need a pointer when we hover over "create new note". Fixed it. 9816cd7 [Karuppayya] resolving conflicts ed35811 [Karuppayya] *Remove DOM maniupaltion from controller b9059db [Karuppayya] *change directive name to be more specific. *Make directive generic by provisioning callbacks. *Make "note" to "Note"(in the generated name) f7499cf [Karuppayya] Merge branch 'notename' of github.com:Karuppayya/incubator-zeppelin into notename a05096b [Karuppayya] Removing a flag that is not required 307db03 [Karuppayya] Selenium test fix ea99cb0 [Karuppayya] test fix 8eefcc0 [Karuppayya] Fix selenium test. caae8d2 [Karuppayya] Fixing Test d9416de [Karuppayya] Fixing tests f2cf950 [Karuppayya] Add License header to new file that was added. 05d3af0 [Karuppayya] When no name is given, note is created with default name 0a7db2b [Karuppayya] The user will be able to provide a name to note at creation time Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/3bc145f0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/3bc145f0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/3bc145f0 Branch: refs/heads/master Commit: 3bc145f043a61d7ba0c07299fcb001c424afe8d9 Parents: 9a3e555 Author: Karuppayya <[email protected]> Authored: Sun Aug 9 11:38:47 2015 +0530 Committer: Lee moon soo <[email protected]> Committed: Sun Aug 9 12:48:30 2015 -0700 ---------------------------------------------------------------------- .../apache/zeppelin/socket/NotebookServer.java | 9 ++++- .../java/org/apache/zeppelin/ZeppelinIT.java | 10 ++++- zeppelin-web/src/app/home/home.html | 2 +- zeppelin-web/src/components/navbar/navbar.html | 2 +- .../noteName-create/note-name-dialog.html | 41 ++++++++++++++++++++ .../noteName-create/notename.controller.js | 40 +++++++++++++++++++ .../noteName-create/visible.directive.js | 38 ++++++++++++++++++ .../websocketEvents/websocketMsg.service.js | 4 +- zeppelin-web/src/index.html | 3 ++ 9 files changed, 141 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/3bc145f0/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java index ed35ea1..fe0d391 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java @@ -98,7 +98,7 @@ public class NotebookServer extends WebSocketServlet implements sendNote(conn, notebook, messagereceived); break; case NEW_NOTE: - createNote(conn, notebook); + createNote(conn, notebook, messagereceived); break; case DEL_NOTE: removeNote(conn, notebook, messagereceived); @@ -334,9 +334,14 @@ public class NotebookServer extends WebSocketServlet implements return cronUpdated; } - private void createNote(WebSocket conn, Notebook notebook) throws IOException { + private void createNote(WebSocket conn, Notebook notebook, Message message) throws IOException { Note note = notebook.createNote(); note.addParagraph(); // it's an empty note. so add one paragraph + if (message != null) { + String noteName = (String) message.get("name"); + if (noteName != null && !noteName.isEmpty()) + note.setName(noteName); + } note.persist(); broadcastNote(note); broadcastNoteList(); http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/3bc145f0/zeppelin-server/src/test/java/org/apache/zeppelin/ZeppelinIT.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/ZeppelinIT.java b/zeppelin-server/src/test/java/org/apache/zeppelin/ZeppelinIT.java index b170a95..215d3de 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/ZeppelinIT.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/ZeppelinIT.java @@ -37,6 +37,7 @@ import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxProfile; import org.openqa.selenium.safari.SafariDriver; import org.openqa.selenium.support.ui.ExpectedCondition; +import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; /** @@ -300,8 +301,13 @@ public class ZeppelinIT { notebookTitles.add(el.getText()); } - WebElement createNoteLink = driver.findElement(By.partialLinkText("Create new note")); - createNoteLink.click(); + WebElement createNoteLink = driver.findElement(By.xpath("//div[contains(@class, \"col-md-4\")]/div/h5/a")); + createNoteLink.click(); + + WebDriverWait block = new WebDriverWait(driver, 10); + WebElement modal = block.until(ExpectedConditions.visibilityOfElementLocated(By.id("noteNameModal"))); + WebElement createNoteButton = modal.findElement(By.id("createNoteButton")); + createNoteButton.click(); try { Thread.sleep(500); // wait for notebook list updated http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/3bc145f0/zeppelin-web/src/app/home/home.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/home/home.html b/zeppelin-web/src/app/home/home.html index 9e7963c..b3991ae 100644 --- a/zeppelin-web/src/app/home/home.html +++ b/zeppelin-web/src/app/home/home.html @@ -27,7 +27,7 @@ limitations under the License. <h4>Notebook</h4> <div> - <h5><a href="javascript:void(0);" ng-click="home.websocketMsgSrv.createNotebook()" style="text-decoration: none;"> + <h5><a href="" data-toggle="modal" data-target="#noteNameModal" style="text-decoration: none;"> <i style="font-size: 15px;" class="icon-notebook"></i> Create new note</a></h5> <ul style="list-style-type: none;"> <li ng-repeat="note in home.notes.list track by $index"><i style="font-size: 10px;" class="icon-doc"></i> http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/3bc145f0/zeppelin-web/src/components/navbar/navbar.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/navbar/navbar.html b/zeppelin-web/src/components/navbar/navbar.html index e583098..995ba76 100644 --- a/zeppelin-web/src/components/navbar/navbar.html +++ b/zeppelin-web/src/components/navbar/navbar.html @@ -29,7 +29,7 @@ limitations under the License. <li class="dropdown" dropdown> <a href="#" class="dropdown-toggle" dropdown-toggle>Notebook <span class="caret"></span></a> <ul class="dropdown-menu" role="menu"> - <li><a href="javascript:void(0);" ng-click="navbar.websocketMsgSrv.createNotebook()"><i class="fa fa-plus"></i> Create new note</a></li> + <li><a href="" data-toggle="modal" data-target="#noteNameModal"><i class="fa fa-plus"></i> Create new note</a></li> <li class="divider"></li> <div id="notebook-list" class="scrollbar-container"> <li ng-repeat="note in navbar.notes.list track by $index" ng-class="{'active' : navbar.isActive(note.id)}"> http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/3bc145f0/zeppelin-web/src/components/noteName-create/note-name-dialog.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/noteName-create/note-name-dialog.html b/zeppelin-web/src/components/noteName-create/note-name-dialog.html new file mode 100644 index 0000000..e7670f9 --- /dev/null +++ b/zeppelin-web/src/components/noteName-create/note-name-dialog.html @@ -0,0 +1,41 @@ +<!-- +Licensed 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. +--> +<div ng-controller="NotenameCtrl as notenamectrl"> + <div id="noteNameModal" class="modal fade" role="dialog" modalvisible previsiblecallback="notenamectrl.preVisible()" + targetinput="noteName" tabindex='-1'> + <div class="modal-dialog"> + + <!-- Modal content--> + <div class="modal-content" id="NotenameCtrl"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal">×</button> + <h4 class="modal-title">Create new note</h4> + </div> + <div class="modal-body"> + <div class="form-group"> + <label for="noteName">Note Name</label> <input + placeholder="Note name" type="text" class="form-control" + id="noteName" ng-model="notename"> + </div> + </div> + <div class="modal-footer"> + <button type="button" id="createNoteButton" + class="btn btn-default" + data-dismiss="modal" ng-click="notenamectrl.createNote()">Create + Note</button> + </div> + </div> + </div> + </div> +</div> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/3bc145f0/zeppelin-web/src/components/noteName-create/notename.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/noteName-create/notename.controller.js b/zeppelin-web/src/components/noteName-create/notename.controller.js new file mode 100644 index 0000000..3f0e82d --- /dev/null +++ b/zeppelin-web/src/components/noteName-create/notename.controller.js @@ -0,0 +1,40 @@ +/* + * Licensed 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. + */ + +'use strict'; + +angular.module('zeppelinWebApp').controller('NotenameCtrl', function($scope, $rootScope, websocketMsgSrv) { + var vm = this; + vm.websocketMsgSrv = websocketMsgSrv; + + vm.createNote = function(){ + vm.websocketMsgSrv.createNotebook($scope.notename); + }; + vm.preVisible = function(){ + var generatedName = vm.generateName(); + $scope.notename = 'Note ' + generatedName; + $scope.$apply(); + }; + vm.generateName = function () { + var DICTIONARY = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', + 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', + 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ]; + var randIndex, name = ''; + for (var i = 0; i < 9; i++) { + randIndex = Math.floor(Math.random() * 32); + name += DICTIONARY[randIndex]; + } + return name; + }; +}); http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/3bc145f0/zeppelin-web/src/components/noteName-create/visible.directive.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/noteName-create/visible.directive.js b/zeppelin-web/src/components/noteName-create/visible.directive.js new file mode 100644 index 0000000..8d3e9a1 --- /dev/null +++ b/zeppelin-web/src/components/noteName-create/visible.directive.js @@ -0,0 +1,38 @@ +/* + * Licensed 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. + */ +'use strict'; + +angular.module('zeppelinWebApp').directive('modalvisible', function () { + return { + restrict: 'A', + scope: { + preVisibleCallback: '&previsiblecallback', + postVisibleCallback: '&postvisiblecallback', + targetinput: '@targetinput' + }, + link: function(scope, elem, attrs) { + // Add some listeners + var previsibleMethod = scope.preVisibleCallback; + var postVisibleMethod = scope.postVisibleCallback; + elem.on('show.bs.modal',function(e) { + previsibleMethod(); + }); + elem.on('shown.bs.modal', function(e) { + if(scope.targetinput) + $(e.target).find('input#' + scope.targetinput ).select(); + postVisibleMethod(); + }); + } + }; +}); http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/3bc145f0/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js index 2c4f132..fcdc51f 100644 --- a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js +++ b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js @@ -17,8 +17,8 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope, return { - createNotebook: function() { - websocketEvents.sendNewEvent({op: 'NEW_NOTE'}); + createNotebook: function(noteName) { + websocketEvents.sendNewEvent({op: 'NEW_NOTE',data: {name: noteName}}); }, deleteNotebook: function(noteId) { http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/3bc145f0/zeppelin-web/src/index.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/index.html b/zeppelin-web/src/index.html index 36aa933..a65c944 100644 --- a/zeppelin-web/src/index.html +++ b/zeppelin-web/src/index.html @@ -61,6 +61,7 @@ limitations under the License. </div> <!-- Modal :: Keyboard shortcuts --> <div ng-include src="'components/modal-shortcut/modal-shortcut.html'"></div> + <div id="note-modal-container" ng-include src="'components/noteName-create/note-name-dialog.html'"></div> <!-- build:js(.) scripts/oldieshim.js --> <!--[if lt IE 9]> <script src="bower_components/es5-shim/es5-shim.js"></script> @@ -113,10 +114,12 @@ limitations under the License. <script src="app/notebook/paragraph/paragraph.controller.js"></script> <script src="components/navbar/navbar.controller.js"></script> <script src="components/ngescape/ngescape.directive.js"></script> + <script src="components/noteName-create/notename.controller.js"></script> <script src="components/popover-html-unsafe/popover-html-unsafe.directive.js"></script> <script src="components/ngenter/ngenter.directive.js"></script> <script src="components/dropdowninput/dropdowninput.directive.js"></script> <script src="components/resizable/resizable.directive.js"></script> + <script src="components/noteName-create/visible.directive.js"></script> <script src="components/websocketEvents/websocketMsg.service.js"></script> <script src="components/websocketEvents/websocketEvents.factory.js"></script> <script src="components/notebookListDataFactory/notebookList.datafactory.js"></script>
