Skip to content
Closed
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
56 changes: 30 additions & 26 deletions zeppelin-web/src/components/noteName-create/notename.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,45 @@

'use strict';

angular.module('zeppelinWebApp').controller('NotenameCtrl', function($scope, $rootScope, $routeParams, websocketMsgSrv) {
angular.module('zeppelinWebApp').controller('NotenameCtrl', function($scope, $rootScope, $routeParams, websocketMsgSrv, $location) {
var vm = this;
vm.websocketMsgSrv = websocketMsgSrv;
$scope.note = {};
vm.createNote = function(){
if(!vm.clone){
vm.websocketMsgSrv.createNotebook($scope.note.notename);
}else{
var noteId = $routeParams.noteId;
vm.websocketMsgSrv.cloneNotebook(noteId, $scope.note.notename);
}

vm.createNote = function() {
if (!vm.clone) {
vm.websocketMsgSrv.createNotebook($scope.note.notename);
} else {
var noteId = $routeParams.noteId;
vm.websocketMsgSrv.cloneNotebook(noteId, $scope.note.notename);
}
};

$scope.$on('setNoteContent', function(event, note) {
if(note !== undefined) {
window.location = '#/notebook/' + note.id;
console.log(note);
//a hack, to make it run only after notebook creation
//it should not run i.e in case of linking to the paragraph
if (note && $location.path().indexOf(note.id) < 0) {
$location.path('notebook/' + note.id);
}
});

vm.preVisible = function(clone){
var generatedName = vm.generateName();
$scope.note.notename = 'Note ' + generatedName;
vm.clone = clone;
$scope.$apply();
vm.preVisible = function(clone) {
var generatedName = vm.generateName();
$scope.note.notename = 'Note ' + generatedName;
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;
};
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;
};

});