You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2016/02/06 07:22:17 UTC
incubator-zeppelin git commit: Update default notebook generateName
function for create note dialog
Repository: incubator-zeppelin
Updated Branches:
refs/heads/master 08b20e16a -> 6e3512085
Update default notebook generateName function for create note dialog
### What is this PR for?
The current default name for a notebook in create dialog is random, which is difficult to remember.
Instead of randomly generating names it's useful to have a prefix "Untitled Note " + seq number.
eg: Untitled Note 1, Untitled Note 2 etc.
### What type of PR is it?
Improvement
### How should this be tested?
Create note with default names populated in the field and check if the naming sequence is correct.
When there are no notes with "Untitled Note <num>" the default name should be "Untitled Note 1", otherwise it should be max num + 1.
### Screenshots
Before
<img width="659" alt="before" src="https://cloud.githubusercontent.com/assets/2031306/12294473/c63d823a-ba20-11e5-8e7d-6d9df098ab05.png">
<hr>
<img width="632" alt="after1" src="https://cloud.githubusercontent.com/assets/2031306/12294476/cff636dc-ba20-11e5-82a1-dab7ade0fc7c.png">
<img width="637" alt="after2" src="https://cloud.githubusercontent.com/assets/2031306/12294478/d3c5232c-ba20-11e5-8265-69ce41a1370b.png">
Author: Renjith Kamath <re...@gmail.com>
Closes #633 from r-kamath/noteNameUpdate and squashes the following commits:
06be629 [Renjith Kamath] Merge branch 'master' of https://github.com/apache/incubator-zeppelin into noteNameUpdate
b6c1f31 [Renjith Kamath] review updates
5408f2b [Renjith Kamath] review update regex
18ea083 [Renjith Kamath] Merge branch 'master' of https://github.com/apache/incubator-zeppelin into noteNameUpdate
39fe8b6 [Renjith Kamath] Update the logic to generate default notebook name
Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/6e351208
Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/6e351208
Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/6e351208
Branch: refs/heads/master
Commit: 6e351208518aa75247190d7e09e2cf8d835b4911
Parents: 08b20e1
Author: Renjith Kamath <re...@gmail.com>
Authored: Wed Jan 20 16:27:14 2016 +0530
Committer: Lee moon soo <mo...@apache.org>
Committed: Sat Feb 6 15:25:18 2016 +0900
----------------------------------------------------------------------
.../noteName-create/note-name-dialog.html | 14 ++++-----
.../noteName-create/notename.controller.js | 31 +++++++++++---------
2 files changed, 22 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/6e351208/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
index 74149bc..8c0cf91 100644
--- a/zeppelin-web/src/components/noteName-create/note-name-dialog.html
+++ b/zeppelin-web/src/components/noteName-create/note-name-dialog.html
@@ -31,15 +31,11 @@ limitations under the License.
</div>
<div class="modal-footer">
<button type="button" id="createNoteButton"
- class="btn btn-default"
- ng-show="!notenamectrl.clone"
- data-dismiss="modal" ng-click="notenamectrl.createNote()">Create
- Note</button>
- <button type="button" id="createNoteButton"
- class="btn btn-default"
- ng-show="notenamectrl.clone"
- data-dismiss="modal" ng-click="notenamectrl.createNote()">Clone
- Note</button>
+ class="btn btn-default"
+ data-dismiss="modal" ng-click="notenamectrl.createNote()">
+ <span ng-show="!notenamectrl.clone">Create Note</span>
+ <span ng-show="notenamectrl.clone">Clone Note</span>
+ </button>
</div>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/6e351208/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
index 4982e12..5c93053 100644
--- a/zeppelin-web/src/components/noteName-create/notename.controller.js
+++ b/zeppelin-web/src/components/noteName-create/notename.controller.js
@@ -14,9 +14,11 @@
'use strict';
-angular.module('zeppelinWebApp').controller('NotenameCtrl', function($scope, $rootScope, $routeParams, websocketMsgSrv,
- $location) {
+angular.module('zeppelinWebApp').controller('NotenameCtrl', function($scope, notebookListDataFactory,
+ $rootScope, $routeParams, websocketMsgSrv) {
var vm = this;
+ vm.clone = false;
+ vm.notes = notebookListDataFactory;
vm.websocketMsgSrv = websocketMsgSrv;
$scope.note = {};
@@ -35,22 +37,23 @@ angular.module('zeppelinWebApp').controller('NotenameCtrl', function($scope, $ro
};
vm.preVisible = function(clone) {
- var generatedName = vm.generateName();
- $scope.note.notename = 'Note ' + generatedName;
+ $scope.note.notename = vm.newNoteName();
vm.clone = clone;
$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;
+ vm.newNoteName = function () {
+ var newCount = 1;
+ angular.forEach(vm.notes.list, function (noteName) {
+ noteName = noteName.name;
+ if (noteName.match(/^Untitled Note [0-9]*$/)) {
+ var lastCount = noteName.substr(14) * 1;
+ if (newCount <= lastCount) {
+ newCount = lastCount + 1;
+ }
+ }
+ });
+ return 'Untitled Note ' + newCount;
};
});