Repository: zeppelin Updated Branches: refs/heads/master b84ae60f1 -> 5556f8152
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js index 7ed029d..1febeb1 100644 --- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js +++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js @@ -14,9 +14,10 @@ */ 'use strict'; -angular.module('zeppelinWebApp') - .controller('ParagraphCtrl', function($scope,$rootScope, $route, $window, $element, $routeParams, $location, - $timeout, $compile, $http, websocketMsgSrv, baseUrlSrv, ngToast, SaveAsService) { +angular.module('zeppelinWebApp').controller('ParagraphCtrl', function($scope, $rootScope, $route, $window, $element, + $routeParams, $location, $timeout, $compile, + $http, websocketMsgSrv, baseUrlSrv, ngToast, + SaveAsService) { var ANGULAR_FUNCTION_OBJECT_NAME_PREFIX = '_Z_ANGULAR_FUNC_'; $scope.parentNote = null; $scope.paragraph = null; @@ -93,7 +94,7 @@ angular.module('zeppelinWebApp') $scope.parentNote = note; $scope.originalText = angular.copy(newParagraph.text); $scope.chart = {}; - $scope.colWidthOption = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]; + $scope.colWidthOption = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; $scope.showTitleEditor = false; $scope.paragraphFocused = false; if (newParagraph.focus) { @@ -127,8 +128,6 @@ angular.module('zeppelinWebApp') } }; - - $scope.renderHtml = function() { var retryRenderer = function() { if (angular.element('#p' + $scope.paragraph.id + '_html').length) { @@ -150,12 +149,12 @@ angular.module('zeppelinWebApp') $scope.renderAngular = function() { var retryRenderer = function() { - if (angular.element('#p'+$scope.paragraph.id+'_angular').length) { + if (angular.element('#p' + $scope.paragraph.id + '_angular').length) { try { - angular.element('#p'+$scope.paragraph.id+'_angular').html($scope.paragraph.result.msg); + angular.element('#p' + $scope.paragraph.id + '_angular').html($scope.paragraph.result.msg); - $compile(angular.element('#p'+$scope.paragraph.id+'_angular').contents())(paragraphScope); - } catch(err) { + $compile(angular.element('#p' + $scope.paragraph.id + '_angular').contents())(paragraphScope); + } catch (err) { console.log('ANGULAR rendering error %o', err); } } else { @@ -199,7 +198,7 @@ angular.module('zeppelinWebApp') var textEl = angular.element('#p' + $scope.paragraph.id + '_text'); if (textEl.length) { var lines = msg.split('\n'); - for (var i=0; i < lines.length; i++) { + for (var i = 0; i < lines.length; i++) { textEl.append(angular.element('<div></div>').text(lines[i])); } } @@ -209,8 +208,6 @@ angular.module('zeppelinWebApp') } }; - - $scope.$on('angularObjectUpdate', function(event, data) { var noteId = $route.current.pathParams.noteId; if (!data.noteId || data.noteId === noteId) { @@ -221,7 +218,7 @@ angular.module('zeppelinWebApp') scope = paragraphScope; registry = angularObjectRegistry; } else { - var app = _.find($scope.apps, { id: data.paragraphId}); + var app = _.find($scope.apps, {id: data.paragraphId}); if (app) { scope = getAppScope(app); registry = getAppRegistry(app); @@ -239,9 +236,9 @@ angular.module('zeppelinWebApp') if (!registry[varName]) { registry[varName] = { - interpreterGroupId : data.interpreterGroupId, - noteId : data.noteId, - paragraphId : data.paragraphId + interpreterGroupId: data.interpreterGroupId, + noteId: data.noteId, + paragraphId: data.paragraphId }; } else { registry[varName].noteId = registry[varName].noteId || data.noteId; @@ -281,7 +278,6 @@ angular.module('zeppelinWebApp') } }); - $scope.$on('angularObjectRemove', function(event, data) { var noteId = $route.current.pathParams.noteId; if (!data.noteId || data.noteId === noteId) { @@ -292,7 +288,7 @@ angular.module('zeppelinWebApp') scope = paragraphScope; registry = angularObjectRegistry; } else { - var app = _.find($scope.apps, { id: data.paragraphId}); + var app = _.find($scope.apps, {id: data.paragraphId}); if (app) { scope = getAppScope(app); registry = getAppRegistry(app); @@ -365,7 +361,7 @@ angular.module('zeppelinWebApp') } }; - $scope.getIframeDimensions = function () { + $scope.getIframeDimensions = function() { if ($scope.asIframe) { var paragraphid = '#' + $routeParams.paragraphId + '_container'; var height = angular.element(paragraphid).height(); @@ -374,7 +370,7 @@ angular.module('zeppelinWebApp') return 0; }; - $scope.$watch($scope.getIframeDimensions, function (newValue, oldValue) { + $scope.$watch($scope.getIframeDimensions, function(newValue, oldValue) { if ($scope.asIframe && newValue) { var message = {}; message.height = newValue; @@ -383,7 +379,7 @@ angular.module('zeppelinWebApp') } }); - var isEmpty = function (object) { + var isEmpty = function(object) { return !object; }; @@ -417,12 +413,11 @@ angular.module('zeppelinWebApp') var statusChanged = (data.paragraph.status !== $scope.paragraph.status); - //console.log("updateParagraph oldData %o, newData %o. type %o -> %o, mode %o -> %o", $scope.paragraph, data, oldType, newType, oldGraphMode, newGraphMode); if ($scope.paragraph.text !== data.paragraph.text) { if ($scope.dirtyText) { // check if editor has local update - if ($scope.dirtyText === data.paragraph.text ) { // when local update is the same from remote, clear local update + if ($scope.dirtyText === data.paragraph.text) { // when local update is the same from remote, clear local update $scope.paragraph.text = data.paragraph.text; $scope.dirtyText = undefined; $scope.originalText = angular.copy(data.paragraph.text); @@ -483,7 +478,7 @@ angular.module('zeppelinWebApp') getSuggestions(); if (newActiveApp && newActiveApp !== oldActiveApp) { - var app = _.find($scope.apps, { id : newActiveApp }); + var app = _.find($scope.apps, {id: newActiveApp}); renderApp(app); } @@ -491,7 +486,7 @@ angular.module('zeppelinWebApp') // when last paragraph runs, zeppelin automatically appends new paragraph. // this broadcast will focus to the newly inserted paragraph var paragraphs = angular.element('div[id$="_paragraphColumn_main"]'); - if (paragraphs.length >= 2 && paragraphs[paragraphs.length-2].id.startsWith($scope.paragraph.id)) { + if (paragraphs.length >= 2 && paragraphs[paragraphs.length - 2].id.startsWith($scope.paragraph.id)) { // rendering output can took some time. So delay scrolling event firing for sometime. setTimeout(function() { $rootScope.$broadcast('scrollToCursor'); @@ -539,16 +534,17 @@ angular.module('zeppelinWebApp') $scope.dirtyText = undefined; }; - $scope.saveParagraph = function(){ - if($scope.dirtyText === undefined || $scope.dirtyText === $scope.originalText){ + $scope.saveParagraph = function() { + if ($scope.dirtyText === undefined || $scope.dirtyText === $scope.originalText) { return; } - commitParagraph($scope.paragraph.title, $scope.dirtyText, $scope.paragraph.config, $scope.paragraph.settings.params); + commitParagraph($scope.paragraph.title, $scope.dirtyText, $scope.paragraph.config, + $scope.paragraph.settings.params); $scope.originalText = angular.copy($scope.dirtyText); $scope.dirtyText = undefined; }; - $scope.toggleEnableDisable = function () { + $scope.toggleEnableDisable = function() { $scope.paragraph.config.enabled = $scope.paragraph.config.enabled ? false : true; var newParams = angular.copy($scope.paragraph.settings.params); var newConfig = angular.copy($scope.paragraph.config); @@ -578,7 +574,7 @@ angular.module('zeppelinWebApp') $scope.removeParagraph = function() { var paragraphs = angular.element('div[id$="_paragraphColumn_main"]'); - if (paragraphs[paragraphs.length-1].id.startsWith($scope.paragraph.id)) { + if (paragraphs[paragraphs.length - 1].id.startsWith($scope.paragraph.id)) { BootstrapDialog.alert({ closable: true, message: 'The last paragraph can\'t be deleted.' @@ -672,7 +668,7 @@ angular.module('zeppelinWebApp') commitParagraph($scope.paragraph.title, $scope.paragraph.text, newConfig, newParams); }; - $scope.showLineNumbers = function () { + $scope.showLineNumbers = function() { var newParams = angular.copy($scope.paragraph.settings.params); var newConfig = angular.copy($scope.paragraph.config); newConfig.lineNumbers = true; @@ -681,7 +677,7 @@ angular.module('zeppelinWebApp') commitParagraph($scope.paragraph.title, $scope.paragraph.text, newConfig, newParams); }; - $scope.hideLineNumbers = function () { + $scope.hideLineNumbers = function() { var newParams = angular.copy($scope.paragraph.settings.params); var newConfig = angular.copy($scope.paragraph.config); newConfig.lineNumbers = false; @@ -731,7 +727,7 @@ angular.module('zeppelinWebApp') commitParagraph($scope.paragraph.title, $scope.paragraph.text, newConfig, newParams); }; - $scope.toggleLineWithFocus = function () { + $scope.toggleLineWithFocus = function() { var mode = $scope.getGraphMode(); if (mode === 'lineWithFocusChart') { @@ -747,8 +743,6 @@ angular.module('zeppelinWebApp') return false; }; - - $scope.loadForm = function(formulaire, params) { var value = formulaire.defaultValue; if (params[formulaire.name]) { @@ -799,7 +793,7 @@ angular.module('zeppelinWebApp') autoAdjustEditorHeight(_editor.container.id); }); - if (navigator.appVersion.indexOf('Mac') !== -1 ) { + if (navigator.appVersion.indexOf('Mac') !== -1) { $scope.editor.setKeyboardHandler('ace/keyboard/emacs'); $rootScope.isMac = true; } else if (navigator.appVersion.indexOf('Win') !== -1 || @@ -811,7 +805,7 @@ angular.module('zeppelinWebApp') $scope.setParagraphMode = function(session, paragraphText, pos) { // Evaluate the mode only if the first 30 characters of the paragraph have been modified or the the position is undefined. - if ( (typeof pos === 'undefined') || (pos.row === 0 && pos.column < 30)) { + if ((typeof pos === 'undefined') || (pos.row === 0 && pos.column < 30)) { // If paragraph loading, use config value if exists if ((typeof pos === 'undefined') && $scope.paragraph.config.editorMode) { session.setMode($scope.paragraph.config.editorMode); @@ -823,7 +817,7 @@ angular.module('zeppelinWebApp') if (!editorModes[oldMode] || !editorModes[oldMode].test(paragraphText)) { for (var key in editorModes) { if (key !== oldMode) { - if (editorModes[key].test(paragraphText)){ + if (editorModes[key].test(paragraphText)) { $scope.paragraph.config.editorMode = key; session.setMode(key); return true; @@ -838,8 +832,8 @@ angular.module('zeppelinWebApp') }; var remoteCompleter = { - getCompletions : function(editor, session, pos, prefix, callback) { - if (!$scope.editor.isFocused() ){ return;} + getCompletions: function(editor, session, pos, prefix, callback) { + if (!$scope.editor.isFocused()) { return;} pos = session.getTextRange(new Range(0, 0, pos.row, pos.column)).length; var buf = session.getValue(); @@ -863,12 +857,13 @@ angular.module('zeppelinWebApp') } }; - langTools.setCompleters([remoteCompleter, langTools.keyWordCompleter, langTools.snippetCompleter, langTools.textCompleter]); + langTools.setCompleters([remoteCompleter, langTools.keyWordCompleter, langTools.snippetCompleter, + langTools.textCompleter]); $scope.editor.setOptions({ enableBasicAutocompletion: true, enableSnippets: false, - enableLiveAutocompletion:false + enableLiveAutocompletion: false }); $scope.handleFocus = function(value) { @@ -894,7 +889,6 @@ angular.module('zeppelinWebApp') $scope.setParagraphMode($scope.editor.getSession(), $scope.editor.getSession().getValue()); - // autocomplete on '.' /* $scope.editor.commands.on("afterExec", function(e, t) { @@ -910,7 +904,6 @@ angular.module('zeppelinWebApp') // remove binding $scope.editor.commands.bindKey('ctrl-alt-n.', null); - // autocomplete on 'ctrl+.' $scope.editor.commands.bindKey('ctrl-.', 'startAutocomplete'); $scope.editor.commands.bindKey('ctrl-space', null); @@ -921,7 +914,8 @@ angular.module('zeppelinWebApp') if ($scope.editor.completer && $scope.editor.completer.activated) { // if autocompleter is active } else { // fix ace editor focus issue in chrome (textarea element goes to top: -1000px after focused by cursor move) - if (parseInt(angular.element('#' + $scope.paragraph.id + '_editor > textarea').css('top').replace('px', '')) < 0) { + if (parseInt(angular.element('#' + $scope.paragraph.id + '_editor > textarea') + .css('top').replace('px', '')) < 0) { var position = $scope.editor.getCursorPosition(); var cursorPos = $scope.editor.renderer.$cursorLayer.getPixelPosition(position, true); angular.element('#' + $scope.paragraph.id + '_editor > textarea').css('top', cursorPos.top); @@ -942,7 +936,7 @@ angular.module('zeppelinWebApp') } else if (keyCode === 40 || (keyCode === 78 && e.ctrlKey && !e.altKey)) { // DOWN numRows = $scope.editor.getSession().getLength(); currentRow = $scope.editor.getCursorPosition().row; - if (currentRow === numRows-1) { + if (currentRow === numRows - 1) { // move focus to next paragraph $scope.$emit('moveFocusToNextParagraph', $scope.paragraph.id); } else { @@ -957,7 +951,8 @@ angular.module('zeppelinWebApp') var autoAdjustEditorHeight = function(id) { var editor = $scope.editor; - var height = editor.getSession().getScreenLength() * editor.renderer.lineHeight + editor.renderer.scrollBar.getWidth(); + var height = editor.getSession().getScreenLength() * editor.renderer.lineHeight + + editor.renderer.scrollBar.getWidth(); angular.element('#' + id).height(height.toString() + 'px'); editor.resize(); @@ -966,7 +961,7 @@ angular.module('zeppelinWebApp') $rootScope.$on('scrollToCursor', function(event) { // scroll on 'scrollToCursor' event only when cursor is in the last paragraph var paragraphs = angular.element('div[id$="_paragraphColumn_main"]'); - if (paragraphs[paragraphs.length-1].id.startsWith($scope.paragraph.id)) { + if (paragraphs[paragraphs.length - 1].id.startsWith($scope.paragraph.id)) { $scope.scrollToCursor($scope.paragraph.id, 0); } }); @@ -978,8 +973,8 @@ angular.module('zeppelinWebApp') **/ $scope.scrollToCursor = function(paragraphId, lastCursorMove) { if (!$scope.editor.isFocused()) { - // only make sense when editor is focused - return; + // only make sense when editor is focused + return; } var lineHeight = $scope.editor.renderer.lineHeight; var headerHeight = 103; // menubar, notebook titlebar @@ -989,20 +984,20 @@ angular.module('zeppelinWebApp') var windowHeight = angular.element(window).height(); // actual viewport height var scrollPosition = angular.element(document).scrollTop(); - var editorPosition = angular.element('#'+paragraphId+'_editor').offset(); + var editorPosition = angular.element('#' + paragraphId + '_editor').offset(); var position = $scope.editor.getCursorPosition(); var lastCursorPosition = $scope.editor.renderer.$cursorLayer.getPixelPosition(position, true); - var calculatedCursorPosition = editorPosition.top + lastCursorPosition.top + lineHeight*lastCursorMove; + var calculatedCursorPosition = editorPosition.top + lastCursorPosition.top + lineHeight * lastCursorMove; var scrollTargetPos; if (calculatedCursorPosition < scrollPosition + headerHeight + scrollTriggerEdgeMargin) { - scrollTargetPos = calculatedCursorPosition - headerHeight - ((windowHeight-headerHeight)/3); + scrollTargetPos = calculatedCursorPosition - headerHeight - ((windowHeight - headerHeight) / 3); if (scrollTargetPos < 0) { scrollTargetPos = 0; } - } else if(calculatedCursorPosition > scrollPosition + scrollTriggerEdgeMargin + windowHeight - headerHeight) { - scrollTargetPos = calculatedCursorPosition - headerHeight - ((windowHeight-headerHeight)*2/3); + } else if (calculatedCursorPosition > scrollPosition + scrollTriggerEdgeMargin + windowHeight - headerHeight) { + scrollTargetPos = calculatedCursorPosition - headerHeight - ((windowHeight - headerHeight) * 2 / 3); if (scrollTargetPos > documentHeight) { scrollTargetPos = documentHeight; @@ -1015,7 +1010,7 @@ angular.module('zeppelinWebApp') bodyEl.finish(); // scroll to scrollTargetPos - bodyEl.scrollTo(scrollTargetPos, {axis: 'y', interrupt: true, duration:100}); + bodyEl.scrollTo(scrollTargetPos, {axis: 'y', interrupt: true, duration: 100}); }; var setEditorHeight = function(id, height) { @@ -1034,7 +1029,7 @@ angular.module('zeppelinWebApp') var pdata = $scope.paragraph; var timeMs = Date.parse(pdata.dateFinished) - Date.parse(pdata.dateStarted); if (isNaN(timeMs) || timeMs < 0) { - if ($scope.isResultOutdated()){ + if ($scope.isResultOutdated()) { return 'outdated'; } return ''; @@ -1043,7 +1038,7 @@ angular.module('zeppelinWebApp') var desc = 'Took ' + moment.duration(moment(pdata.dateFinished).diff(moment(pdata.dateStarted))).humanize() + '. Last updated by ' + user + ' at ' + moment(pdata.dateUpdated).format('MMMM DD YYYY, h:mm:ss A') + '.'; - if ($scope.isResultOutdated()){ + if ($scope.isResultOutdated()) { desc += ' (outdated)'; } return desc; @@ -1055,13 +1050,13 @@ angular.module('zeppelinWebApp') $scope.isResultOutdated = function() { var pdata = $scope.paragraph; - if (pdata.dateUpdated !==undefined && Date.parse(pdata.dateUpdated) > Date.parse(pdata.dateStarted)){ + if (pdata.dateUpdated !== undefined && Date.parse(pdata.dateUpdated) > Date.parse(pdata.dateStarted)) { return true; } return false; }; - $scope.goToLineEnd = function () { + $scope.goToLineEnd = function() { $scope.editor.navigateLineEnd(); }; @@ -1176,7 +1171,6 @@ angular.module('zeppelinWebApp') $scope.closeTable(); }); - $scope.getResultType = function(paragraph) { var pdata = (paragraph) ? paragraph : $scope.paragraph; if (pdata.result && pdata.result.type) { @@ -1187,7 +1181,7 @@ angular.module('zeppelinWebApp') }; $scope.getBase64ImageSrc = function(base64Data) { - return 'data:image/png;base64,'+base64Data; + return 'data:image/png;base64,' + base64Data; }; $scope.getGraphMode = function(paragraph) { @@ -1219,7 +1213,7 @@ angular.module('zeppelinWebApp') } if (textRow === '') { - if (rows.length>0) { + if (rows.length > 0) { comment = true; } continue; @@ -1230,10 +1224,10 @@ angular.module('zeppelinWebApp') for (var j = 0; j < textCols.length; j++) { var col = textCols[j]; if (i === 0) { - columnNames.push({name:col, index:j, aggr:'sum'}); + columnNames.push({name: col, index: j, aggr: 'sum'}); } else { cols.push(col); - cols2.push({key: (columnNames[i]) ? columnNames[i].name: undefined, value: col}); + cols2.push({key: (columnNames[i]) ? columnNames[i].name : undefined, value: col}); } } if (i !== 0) { @@ -1258,8 +1252,7 @@ angular.module('zeppelinWebApp') if (!type || type === 'table') { setTable($scope.paragraph.result, refresh); - } - else { + } else { setD3Chart(type, $scope.paragraph.result, refresh); } } @@ -1310,7 +1303,7 @@ angular.module('zeppelinWebApp') fillHandle: false, fragmentSelection: true, disableVisualSelection: true, - cells: function (row, col, prop) { + cells: function(row, col, prop) { var cellProperties = {}; cellProperties.renderer = function(instance, td, row, col, prop, value, cellProperties) { if (!isNaN(value)) { @@ -1339,7 +1332,7 @@ angular.module('zeppelinWebApp') if (angular.element('#p' + $scope.paragraph.id + '_table').length) { try { renderTable(); - } catch(err) { + } catch (err) { console.log('Chart drawing error %o', err); } } else { @@ -1350,7 +1343,7 @@ angular.module('zeppelinWebApp') }; - var groupedThousandsWith3DigitsFormatter = function(x){ + var groupedThousandsWith3DigitsFormatter = function(x) { return d3.format(',')(d3.round(x, 3)); }; @@ -1371,7 +1364,7 @@ angular.module('zeppelinWebApp') }; var yAxisTickFormat = function(d) { - if(d >= Math.pow(10,6)){ + if (d >= Math.pow(10,6)) { return customAbbrevFormatter(d); } return groupedThousandsWith3DigitsFormatter(d); @@ -1419,12 +1412,12 @@ angular.module('zeppelinWebApp') $scope.chart[type].x(function(d) { return d.label;}) .y(function(d) { return d.value;}); - if ( d.length > 0 ) { - for ( var i=0; i<d[0].values.length ; i++) { + if (d.length > 0) { + for (var i = 0; i < d[0].values.length ; i++) { var e = d[0].values[i]; d3g.push({ - label : e.x, - value : e.y + label: e.x, + value: e.y }); } } @@ -1442,7 +1435,7 @@ angular.module('zeppelinWebApp') if ($scope.chart[type].useInteractiveGuideline) { // lineWithFocusChart hasn't got useInteractiveGuideline $scope.chart[type].useInteractiveGuideline(true); // for better UX and performance issue. (https://github.com/novus/nvd3/issues/691) } - if($scope.paragraph.config.graph.forceY) { + if ($scope.paragraph.config.graph.forceY) { $scope.chart[type].forceY([0]); // force y-axis minimum to 0 for line chart. } else { $scope.chart[type].forceY([]); @@ -1465,16 +1458,16 @@ angular.module('zeppelinWebApp') if (d3g[0].values.length > numberOfDataThreshold) { animationDuration = 0; } - } catch(ignoreErr) { + } catch (ignoreErr) { } - var chartEl = d3.select('#p'+$scope.paragraph.id+'_'+type+' svg') + var chartEl = d3.select('#p' + $scope.paragraph.id + '_' + type + ' svg') .attr('height', $scope.paragraph.config.graph.height) .datum(d3g) .transition() .duration(animationDuration) .call($scope.chart[type]); - d3.select('#p'+$scope.paragraph.id+'_'+type+' svg').style.height = height+'px'; + d3.select('#p' + $scope.paragraph.id + '_' + type + ' svg').style.height = height + 'px'; nv.utils.windowResize($scope.chart[type].update); }; @@ -1482,7 +1475,7 @@ angular.module('zeppelinWebApp') if (angular.element('#p' + $scope.paragraph.id + '_' + type + ' svg').length !== 0) { try { renderChart(); - } catch(err) { + } catch (err) { console.log('Chart drawing error %o', err); } } else { @@ -1494,14 +1487,13 @@ angular.module('zeppelinWebApp') $scope.isGraphMode = function(graphName) { var activeAppId = _.get($scope.paragraph.config, 'helium.activeApp'); - if ($scope.getResultType() === 'TABLE' && $scope.getGraphMode()===graphName && !activeAppId) { + if ($scope.getResultType() === 'TABLE' && $scope.getGraphMode() === graphName && !activeAppId) { return true; } else { return false; } }; - $scope.onGraphOptionChange = function() { clearUnknownColsFromGraphOption(); $scope.setGraphMode($scope.paragraph.config.graph.mode, true, false); @@ -1558,8 +1550,8 @@ angular.module('zeppelinWebApp') /* Clear unknown columns from graph option */ var clearUnknownColsFromGraphOption = function() { var unique = function(list) { - for (var i = 0; i<list.length; i++) { - for (var j=i+1; j<list.length; j++) { + for (var i = 0; i < list.length; i++) { + for (var j = i + 1; j < list.length; j++) { if (angular.equals(list[i], list[j])) { list.splice(j, 1); } @@ -1568,10 +1560,10 @@ angular.module('zeppelinWebApp') }; var removeUnknown = function(list) { - for (var i = 0; i<list.length; i++) { + for (var i = 0; i < list.length; i++) { // remove non existing column var found = false; - for (var j=0; j<$scope.paragraph.result.columnNames.length; j++) { + for (var j = 0; j < $scope.paragraph.result.columnNames.length; j++) { var a = list[i]; var b = $scope.paragraph.result.columnNames[j]; if (a.index === b.index && a.name === b.name) { @@ -1641,60 +1633,60 @@ angular.module('zeppelinWebApp') var values = $scope.paragraph.config.graph.values; var aggrFunc = { - sum : function(a,b) { + sum: function(a, b) { var varA = (a !== undefined) ? (isNaN(a) ? 1 : parseFloat(a)) : 0; var varB = (b !== undefined) ? (isNaN(b) ? 1 : parseFloat(b)) : 0; - return varA+varB; + return varA + varB; }, - count : function(a,b) { + count: function(a, b) { var varA = (a !== undefined) ? parseInt(a) : 0; var varB = (b !== undefined) ? 1 : 0; - return varA+varB; + return varA + varB; }, - min : function(a,b) { + min: function(a, b) { var varA = (a !== undefined) ? (isNaN(a) ? 1 : parseFloat(a)) : 0; var varB = (b !== undefined) ? (isNaN(b) ? 1 : parseFloat(b)) : 0; return Math.min(varA,varB); }, - max : function(a,b) { + max: function(a, b) { var varA = (a !== undefined) ? (isNaN(a) ? 1 : parseFloat(a)) : 0; var varB = (b !== undefined) ? (isNaN(b) ? 1 : parseFloat(b)) : 0; return Math.max(varA,varB); }, - avg : function(a,b,c) { + avg: function(a, b, c) { var varA = (a !== undefined) ? (isNaN(a) ? 1 : parseFloat(a)) : 0; var varB = (b !== undefined) ? (isNaN(b) ? 1 : parseFloat(b)) : 0; - return varA+varB; + return varA + varB; } }; var aggrFuncDiv = { - sum : false, - count : false, - min : false, - max : false, - avg : true + sum: false, + count: false, + min: false, + max: false, + avg: true }; var schema = {}; var rows = {}; - for (var i=0; i < data.rows.length; i++) { + for (var i = 0; i < data.rows.length; i++) { var row = data.rows[i]; var newRow = {}; var s = schema; var p = rows; - for (var k=0; k < keys.length; k++) { + for (var k = 0; k < keys.length; k++) { var key = keys[k]; // add key to schema if (!s[key.name]) { s[key.name] = { - order : k, - index : key.index, - type : 'key', - children : {} + order: k, + index: key.index, + type: 'key', + children: {} }; } s = s[key.name].children; @@ -1707,17 +1699,17 @@ angular.module('zeppelinWebApp') p = p[keyKey]; } - for (var g=0; g < groups.length; g++) { + for (var g = 0; g < groups.length; g++) { var group = groups[g]; var groupKey = row[group.index]; // add group to schema if (!s[groupKey]) { s[groupKey] = { - order : g, - index : group.index, - type : 'group', - children : {} + order: g, + index: group.index, + type: 'group', + children: {} }; } s = s[groupKey].children; @@ -1729,29 +1721,29 @@ angular.module('zeppelinWebApp') p = p[groupKey]; } - for (var v=0; v < values.length; v++) { + for (var v = 0; v < values.length; v++) { var value = values[v]; - var valueKey = value.name+'('+value.aggr+')'; + var valueKey = value.name + '(' + value.aggr + ')'; // add value to schema if (!s[valueKey]) { s[valueKey] = { - type : 'value', - order : v, - index : value.index + type: 'value', + order: v, + index: value.index }; } // add value to row if (!p[valueKey]) { p[valueKey] = { - value : (value.aggr !== 'count') ? row[value.index] : 1, + value: (value.aggr !== 'count') ? row[value.index] : 1, count: 1 }; } else { p[valueKey] = { - value : aggrFunc[value.aggr](p[valueKey].value, row[value.index], p[valueKey].count+1), - count : (aggrFuncDiv[value.aggr]) ? p[valueKey].count+1 : p[valueKey].count + value: aggrFunc[value.aggr](p[valueKey].value, row[value.index], p[valueKey].count + 1), + count: (aggrFuncDiv[value.aggr]) ? p[valueKey].count + 1 : p[valueKey].count }; } } @@ -1760,8 +1752,8 @@ angular.module('zeppelinWebApp') //console.log("schema=%o, rows=%o", schema, rows); return { - schema : schema, - rows : rows + schema: schema, + rows: rows }; }; @@ -1777,7 +1769,7 @@ angular.module('zeppelinWebApp') if (!o) { return n; } else { - return o+'.'+n; + return o + '.' + n; } }; @@ -1791,12 +1783,12 @@ angular.module('zeppelinWebApp') var traverse = function(sKey, s, rKey, r, func, rowName, rowValue, colName) { //console.log("TRAVERSE sKey=%o, s=%o, rKey=%o, r=%o, rowName=%o, rowValue=%o, colName=%o", sKey, s, rKey, r, rowName, rowValue, colName); - if (s.type==='key') { + if (s.type === 'key') { rowName = concat(rowName, sKey); rowValue = concat(rowValue, rKey); - } else if (s.type==='group') { + } else if (s.type === 'group') { colName = concat(colName, rKey); - } else if (s.type==='value' && sKey===rKey || valueOnly) { + } else if (s.type === 'value' && sKey === rKey || valueOnly) { colName = concat(colName, rKey); func(rowName, rowValue, colName, r); } @@ -1850,8 +1842,8 @@ angular.module('zeppelinWebApp') if (!d3g[i]) { d3g[i] = { - values : [], - key : (noKey && isMultiBarChart) ? 'values' : colName + values: [], + key: (noKey && isMultiBarChart) ? 'values' : colName }; } @@ -1862,8 +1854,8 @@ angular.module('zeppelinWebApp') yVar = isNaN(value.value) ? 0 : parseFloat(value.value) / parseFloat(value.count); } d3g[i].values.push({ - x : xVar, - y : yVar + x: xVar, + y: yVar }); }); } @@ -1890,7 +1882,7 @@ angular.module('zeppelinWebApp') } withoutAggr = colName.substring(0, colName.lastIndexOf('(')); - if (namesWithoutAggr[withoutAggr] <= 1 ) { + if (namesWithoutAggr[withoutAggr] <= 1) { d3g[0].values[valueIndex].x = withoutAggr; } } @@ -1898,7 +1890,7 @@ angular.module('zeppelinWebApp') for (var d3gIndex = 0; d3gIndex < d3g.length; d3gIndex++) { colName = d3g[d3gIndex].key; withoutAggr = colName.substring(0, colName.lastIndexOf('(')); - if (namesWithoutAggr[withoutAggr] <= 1 ) { + if (namesWithoutAggr[withoutAggr] <= 1) { d3g[d3gIndex].key = withoutAggr; } } @@ -1915,12 +1907,11 @@ angular.module('zeppelinWebApp') } return { - xLabels : rowIndexValue, - d3g : d3g + xLabels: rowIndexValue, + d3g: d3g }; }; - var setDiscreteScatterData = function(data) { var xAxis = $scope.paragraph.config.graph.scatter.xAxis; var yAxis = $scope.paragraph.config.graph.scatter.yAxis; @@ -1946,12 +1937,12 @@ angular.module('zeppelinWebApp') var key = xValue + ',' + yValue + ',' + grp; - if(!rows[key]) { + if (!rows[key]) { rows[key] = { - x : xValue, - y : yValue, - group : grp, - size : 1 + x: xValue, + y: yValue, + group: grp, + size: 1 }; } else { rows[key].size++; @@ -1960,7 +1951,7 @@ angular.module('zeppelinWebApp') // change object into array var newRows = []; - for(var r in rows){ + for (var r in rows) { var newRow = []; if (xAxis) { newRow[xAxis.index] = rows[r].x; } if (yAxis) { newRow[yAxis.index] = rows[r].y; } @@ -1999,7 +1990,7 @@ angular.module('zeppelinWebApp') if (!xAxis && !yAxis) { return { - d3g : [] + d3g: [] }; } @@ -2050,7 +2041,7 @@ angular.module('zeppelinWebApp') if (group) { grpName = row[group.index]; } - var sz = (isAllDiscrete) ? row[row.length-1] : ((size) ? row[size.index] : 1); + var sz = (isAllDiscrete) ? row[row.length - 1] : ((size) ? row[size.index] : 1); if (grpNameIndex[grpName] === undefined) { grpIndexValue[grpIdx] = grpName; @@ -2069,22 +2060,22 @@ angular.module('zeppelinWebApp') if (!d3g[grpNameIndex[grpName]]) { d3g[grpNameIndex[grpName]] = { - key : grpName, - values : [] + key: grpName, + values: [] }; } d3g[grpNameIndex[grpName]].values.push({ - x : xAxis ? (isNaN(xValue) ? rowNameIndex[xValue] : parseFloat(xValue)) : 0, - y : yAxis ? (isNaN(yValue) ? colNameIndex[yValue] : parseFloat(yValue)) : 0, - size : isNaN(parseFloat(sz))? 1 : parseFloat(sz) + x: xAxis ? (isNaN(xValue) ? rowNameIndex[xValue] : parseFloat(xValue)) : 0, + y: yAxis ? (isNaN(yValue) ? colNameIndex[yValue] : parseFloat(yValue)) : 0, + size: isNaN(parseFloat(sz)) ? 1 : parseFloat(sz) }); } return { - xLabels : rowIndexValue, - yLabels : colIndexValue, - d3g : d3g + xLabels: rowIndexValue, + yLabels: colIndexValue, + d3g: d3g }; }; @@ -2095,7 +2086,7 @@ angular.module('zeppelinWebApp') var j = 0; for (var i = 0; i < f.length; i++) { var item = f[i]; - if(uniqObj[item] !== 1) { + if (uniqObj[item] !== 1) { uniqObj[item] = 1; uniqArr[j++] = item; } @@ -2104,7 +2095,7 @@ angular.module('zeppelinWebApp') }; for (var i = 0; i < field.length; i++) { - if(isNaN(parseFloat(field[i])) && + if (isNaN(parseFloat(field[i])) && (typeof field[i] === 'string' || field[i] instanceof String)) { return true; } @@ -2112,14 +2103,14 @@ angular.module('zeppelinWebApp') var threshold = 0.05; var unique = getUnique(field); - if (unique.length/field.length < threshold) { + if (unique.length / field.length < threshold) { return true; } else { return false; } }; - $scope.isValidSizeOption = function (options, rows) { + $scope.isValidSizeOption = function(options, rows) { var xValues = []; var yValues = []; @@ -2178,15 +2169,16 @@ angular.module('zeppelinWebApp') }; } - $scope.goToSingleParagraph = function () { + $scope.goToSingleParagraph = function() { var noteId = $route.current.pathParams.noteId; - var redirectToUrl = location.protocol + '//' + location.host + location.pathname + '#/notebook/' + noteId + '/paragraph/' + $scope.paragraph.id+'?asIframe'; + var redirectToUrl = location.protocol + '//' + location.host + location.pathname + '#/notebook/' + noteId + + '/paragraph/' + $scope.paragraph.id + '?asIframe'; $window.open(redirectToUrl); }; - $scope.showScrollDownIcon = function(){ + $scope.showScrollDownIcon = function() { var doc = angular.element('#p' + $scope.paragraph.id + '_text'); - if(doc[0]){ + if (doc[0]) { return doc[0].scrollHeight > doc.innerHeight(); } return false; @@ -2198,8 +2190,8 @@ angular.module('zeppelinWebApp') $scope.keepScrollDown = true; }; - $scope.showScrollUpIcon = function(){ - if(angular.element('#p' + $scope.paragraph.id + '_text')[0]){ + $scope.showScrollUpIcon = function() { + if (angular.element('#p' + $scope.paragraph.id + '_text')[0]) { return angular.element('#p' + $scope.paragraph.id + '_text')[0].scrollTop !== 0; } return false; @@ -2212,7 +2204,7 @@ angular.module('zeppelinWebApp') $scope.keepScrollDown = false; }; - $scope.exportToDSV = function (delimiter) { + $scope.exportToDSV = function(delimiter) { var data = $scope.paragraph.result; var dsv = ''; for (var titleIndex in $scope.paragraph.result.columnNames) { @@ -2245,7 +2237,7 @@ angular.module('zeppelinWebApp') $scope.suggestion = {}; $scope.switchApp = function(appId) { - var app = _.find($scope.apps, { id : appId }); + var app = _.find($scope.apps, {id: appId}); var config = $scope.paragraph.config; var settings = $scope.paragraph.settings; @@ -2281,7 +2273,7 @@ angular.module('zeppelinWebApp') // Display ApplicationState if (paragraph.apps) { - _.forEach(paragraph.apps, function (app) { + _.forEach(paragraph.apps, function(app) { appStates.push({ id: app.id, pkg: app.pkg, @@ -2293,7 +2285,7 @@ angular.module('zeppelinWebApp') // update or remove app states no longer exists _.forEach($scope.apps, function(currentAppState, idx) { - var newAppState = _.find(appStates, { id : currentAppState.id }); + var newAppState = _.find(appStates, {id: currentAppState.id}); if (newAppState) { angular.extend($scope.apps[idx], newAppState); } else { @@ -2347,7 +2339,7 @@ angular.module('zeppelinWebApp') console.log('renderApp %o', appState); targetEl.html(appState.output); $compile(targetEl.contents())(getAppScope(appState)); - } catch(err) { + } catch (err) { console.log('App rendering error %o', err); } } else { @@ -2359,11 +2351,11 @@ angular.module('zeppelinWebApp') $scope.$on('appendAppOutput', function(event, data) { if ($scope.paragraph.id === data.paragraphId) { - var app = _.find($scope.apps, { id : data.appId }); + var app = _.find($scope.apps, {id: data.appId}); if (app) { app.output += data.data; - var paragraphAppState = _.find($scope.paragraph.apps, { id : data.appId }); + var paragraphAppState = _.find($scope.paragraph.apps, {id: data.appId}); paragraphAppState.output = app.output; var targetEl = angular.element(document.getElementById('p' + app.id)); @@ -2376,11 +2368,11 @@ angular.module('zeppelinWebApp') $scope.$on('updateAppOutput', function(event, data) { if ($scope.paragraph.id === data.paragraphId) { - var app = _.find($scope.apps, { id : data.appId }); + var app = _.find($scope.apps, {id: data.appId}); if (app) { app.output = data.data; - var paragraphAppState = _.find($scope.paragraph.apps, { id : data.appId }); + var paragraphAppState = _.find($scope.paragraph.apps, {id: data.appId}); paragraphAppState.output = app.output; var targetEl = angular.element(document.getElementById('p' + app.id)); @@ -2414,9 +2406,10 @@ angular.module('zeppelinWebApp') var app = _.find($scope.apps, {id: data.appId}); if (app) { app.status = data.status; - var paragraphAppState = _.find($scope.paragraph.apps, { id : data.appId }); + var paragraphAppState = _.find($scope.paragraph.apps, {id: data.appId}); paragraphAppState.status = app.status; } } }); }); + http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/app/search/result-list.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/search/result-list.controller.js b/zeppelin-web/src/app/search/result-list.controller.js index 2edf9f5..1cda335 100644 --- a/zeppelin-web/src/app/search/result-list.controller.js +++ b/zeppelin-web/src/app/search/result-list.controller.js @@ -18,11 +18,11 @@ angular .module('zeppelinWebApp') .controller('SearchResultCtrl', function($scope, $routeParams, searchService) { - $scope.isResult = true ; - $scope.searchTerm = $routeParams.searchTerm; - var results = searchService.search({'q': $routeParams.searchTerm}).query(); + $scope.isResult = true ; + $scope.searchTerm = $routeParams.searchTerm; + var results = searchService.search({'q': $routeParams.searchTerm}).query(); - results.$promise.then(function(result) { + results.$promise.then(function(result) { $scope.notes = result.body.map(function(note) { // redirect to notebook when search result is a notebook itself, // not a paragraph @@ -42,17 +42,17 @@ angular $scope.isResult = true; } - $scope.$on('$routeChangeStart', function (event, next, current) { + $scope.$on('$routeChangeStart', function(event, next, current) { if (next.originalPath !== '/search/:searchTerm') { searchService.searchTerm = ''; } }); }); - $scope.page = 0; - $scope.allResults = false; + $scope.page = 0; + $scope.allResults = false; - $scope.highlightSearchResults = function(note) { + $scope.highlightSearchResults = function(note) { return function(_editor) { function getEditorMode(text) { var editorModes = { @@ -65,7 +65,7 @@ angular }; return Object.keys(editorModes).reduce(function(res, mode) { - return editorModes[mode].test(text)? mode : res; + return editorModes[mode].test(text) ? mode : res; }, 'ace/mode/scala'); } @@ -82,7 +82,7 @@ angular return function(str) { var indeces = []; var i = -1; - while((i = str.indexOf(term, i + 1)) >= 0) { + while ((i = str.indexOf(term, i + 1)) >= 0) { indeces.push(i); } return indeces; @@ -155,4 +155,4 @@ angular }; }; -}); + }); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js b/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js index da9da18..00f827b 100644 --- a/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js +++ b/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js @@ -22,8 +22,8 @@ angular.module('zeppelinWebApp').service('arrayOrderingSrv', function() { }; this.getNoteName = function(note) { - if(note.name === undefined || note.name.trim() === '') { - return'Note ' + note.id; + if (note.name === undefined || note.name.trim() === '') { + return 'Note ' + note.id; } else { return note.name; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/components/baseUrl/baseUrl.service.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/baseUrl/baseUrl.service.js b/zeppelin-web/src/components/baseUrl/baseUrl.service.js index f06eef3..656df63 100644 --- a/zeppelin-web/src/components/baseUrl/baseUrl.service.js +++ b/zeppelin-web/src/components/baseUrl/baseUrl.service.js @@ -36,7 +36,8 @@ angular.module('zeppelinWebApp').service('baseUrlSrv', function() { }; this.getRestApiBase = function() { - return location.protocol + '//' + location.hostname + ':' + this.getPort() + skipTrailingSlash(location.pathname) + '/api'; + return location.protocol + '//' + location.hostname + ':' + this.getPort() + skipTrailingSlash(location.pathname) + + '/api'; }; var skipTrailingSlash = function(path) { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/components/dropdowninput/dropdowninput.directive.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/dropdowninput/dropdowninput.directive.js b/zeppelin-web/src/components/dropdowninput/dropdowninput.directive.js index 65dd5d3..6095da6 100644 --- a/zeppelin-web/src/components/dropdowninput/dropdowninput.directive.js +++ b/zeppelin-web/src/components/dropdowninput/dropdowninput.directive.js @@ -13,13 +13,13 @@ */ 'use strict'; -angular.module('zeppelinWebApp').directive('dropdownInput', function () { - return { - restrict: 'A', - link: function (scope, element) { - element.bind('click', function (event) { - event.stopPropagation(); - }); - } - }; +angular.module('zeppelinWebApp').directive('dropdownInput', function() { + return { + restrict: 'A', + link: function(scope, element) { + element.bind('click', function(event) { + event.stopPropagation(); + }); + } + }; }); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/components/expandCollapse/expandCollapse.directive.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/expandCollapse/expandCollapse.directive.js b/zeppelin-web/src/components/expandCollapse/expandCollapse.directive.js index ec40175..1c83188 100644 --- a/zeppelin-web/src/components/expandCollapse/expandCollapse.directive.js +++ b/zeppelin-web/src/components/expandCollapse/expandCollapse.directive.js @@ -16,18 +16,18 @@ angular.module('zeppelinWebApp').directive('expandCollapse', function() { return { restrict: 'EA', - link: function(scope, element, attrs){ - angular.element(element).click( function(event) { - if(angular.element(element).find('.expandable:visible').length > 1) { + link: function(scope, element, attrs) { + angular.element(element).click(function(event) { + if (angular.element(element).find('.expandable:visible').length > 1) { angular.element(element).find('.expandable:visible').slideUp('slow'); angular.element(element).find('i.icon-folder-alt').toggleClass('icon-folder icon-folder-alt'); - } else { + } else { angular.element(element).find('.expandable').first().slideToggle('200',function() { angular.element(element).find('i').first().toggleClass('icon-folder icon-folder-alt'); }); } event.stopPropagation(); - }); + }); } }; }); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/components/navbar/navbar.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/navbar/navbar.controller.js b/zeppelin-web/src/components/navbar/navbar.controller.js index 702a257..89faada 100644 --- a/zeppelin-web/src/components/navbar/navbar.controller.js +++ b/zeppelin-web/src/components/navbar/navbar.controller.js @@ -18,7 +18,7 @@ angular.module('zeppelinWebApp') .controller('NavCtrl', function($scope, $rootScope, $http, $routeParams, $location, notebookListDataFactory, baseUrlSrv, websocketMsgSrv, arrayOrderingSrv, searchService) { - $scope.query = {q : '' }; + $scope.query = {q: ''}; /** Current list of notes (ids) */ $scope.showLoginWindow = function() { @@ -36,7 +36,7 @@ angular.module('zeppelinWebApp') angular.element('#notebook-list').perfectScrollbar({suppressScrollX: true}); - angular.element(document).click(function(){ + angular.element(document).click(function() { $scope.query.q = ''; }); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/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 6965134..9a01cfd 100644 --- a/zeppelin-web/src/components/noteName-create/notename.controller.js +++ b/zeppelin-web/src/components/noteName-create/notename.controller.js @@ -23,15 +23,15 @@ angular.module('zeppelinWebApp').controller('NotenameCtrl', function($scope, not $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); - } + if (!vm.clone) { + vm.websocketMsgSrv.createNotebook($scope.note.notename); + } else { + var noteId = $routeParams.noteId; + vm.websocketMsgSrv.cloneNotebook(noteId, $scope.note.notename); + } }; - vm.handleNameEnter = function(){ + vm.handleNameEnter = function() { angular.element('#noteNameModal').modal('toggle'); vm.createNote(); }; @@ -42,9 +42,9 @@ angular.module('zeppelinWebApp').controller('NotenameCtrl', function($scope, not $scope.$apply(); }; - vm.newNoteName = function () { + vm.newNoteName = function() { var newCount = 1; - angular.forEach(vm.notes.flatList, function (noteName) { + angular.forEach(vm.notes.flatList, function(noteName) { noteName = noteName.name; if (noteName.match(/^Untitled Note [0-9]*$/)) { var lastCount = noteName.substr(14) * 1; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/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 index 3c15dcb..d0fe977 100644 --- a/zeppelin-web/src/components/noteName-create/visible.directive.js +++ b/zeppelin-web/src/components/noteName-create/visible.directive.js @@ -13,30 +13,30 @@ */ '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) { - var relatedTgt = angular.element(e.relatedTarget); - var clone = relatedTgt.data('clone'); - var cloneNote = clone ? true : false; - previsibleMethod()(cloneNote); - }); - elem.on('shown.bs.modal', function(e) { - if(scope.targetinput) { - angular.element(e.target).find('input#' + scope.targetinput ).select(); - } - postVisibleMethod(); - }); +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) { + var relatedTgt = angular.element(e.relatedTarget); + var clone = relatedTgt.data('clone'); + var cloneNote = clone ? true : false; + previsibleMethod()(cloneNote); + }); + elem.on('shown.bs.modal', function(e) { + if (scope.targetinput) { + angular.element(e.target).find('input#' + scope.targetinput).select(); } - }; + postVisibleMethod(); + }); + } + }; }); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/components/noteName-import/notenameImport.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/noteName-import/notenameImport.controller.js b/zeppelin-web/src/components/noteName-import/notenameImport.controller.js index d48179d..766064f 100644 --- a/zeppelin-web/src/components/noteName-import/notenameImport.controller.js +++ b/zeppelin-web/src/components/noteName-import/notenameImport.controller.js @@ -71,8 +71,7 @@ angular.module('zeppelinWebApp').controller('NoteImportCtrl', function($scope, $ $scope.note.errorText = 'Unable to Fetch URL'; $scope.$apply(); }); - } - else { + } else { $scope.note.errorText = 'Enter URL'; $scope.$apply(); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js b/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js index 91aa7be..730ea09 100644 --- a/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js +++ b/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js @@ -40,8 +40,8 @@ angular.module('zeppelinWebApp').factory('notebookListDataFactory', function() { var addNode = function(curDir, nodes, noteId) { if (nodes.length === 1) { // the leaf curDir.children.push({ - name : nodes[0], - id : noteId + name: nodes[0], + id: noteId }); } else { // a folder node var node = nodes.shift(); @@ -51,9 +51,9 @@ angular.module('zeppelinWebApp').factory('notebookListDataFactory', function() { addNode(dir, nodes, noteId); } else { var newDir = { - name : node, - hidden : true, - children : [] + name: node, + hidden: true, + children: [] }; curDir.children.push(newDir); addNode(newDir, nodes, noteId); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe.directive.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe.directive.js b/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe.directive.js index 3e405dc..274e011 100644 --- a/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe.directive.js +++ b/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe.directive.js @@ -18,7 +18,7 @@ angular.module('zeppelinWebApp') return { restrict: 'EA', replace: true, - scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' }, + scope: {title: '@', content: '@', placement: '@', animation: '&', isOpen: '&'}, templateUrl: 'components/popover-html-unsafe/popover-html-unsafe-popup.html' }; }) http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/components/searchService/search.service.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/searchService/search.service.js b/zeppelin-web/src/components/searchService/search.service.js index d026404..a2bc7cf 100644 --- a/zeppelin-web/src/components/searchService/search.service.js +++ b/zeppelin-web/src/components/searchService/search.service.js @@ -17,13 +17,13 @@ angular.module('zeppelinWebApp').service('searchService', function($resource, ba this.search = function(term) { this.searchTerm = term.q; - console.log('Searching for: %o', term.q); + console.log('Searching for: %o', term.q); if (!term.q) { //TODO(bzz): empty string check return; } var encQuery = window.encodeURIComponent(term.q); - return $resource(baseUrlSrv.getRestApiBase()+'/notebook/search?q='+encQuery, {}, { - query: {method:'GET'} + return $resource(baseUrlSrv.getRestApiBase() + '/notebook/search?q=' + encQuery, {}, { + query: {method: 'GET'} }); }; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js b/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js index 47bc854..4175818 100644 --- a/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js +++ b/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js @@ -13,7 +13,8 @@ */ 'use strict'; -angular.module('zeppelinWebApp').factory('websocketEvents', function($rootScope, $websocket, $location, $window, baseUrlSrv) { +angular.module('zeppelinWebApp').factory('websocketEvents', + function($rootScope, $websocket, $location, $window, baseUrlSrv) { var websocketCalls = {}; websocketCalls.ws = $websocket(baseUrlSrv.getWebsocketUrl()); @@ -22,7 +23,7 @@ angular.module('zeppelinWebApp').factory('websocketEvents', function($rootScope, websocketCalls.ws.onOpen(function() { console.log('Websocket created'); $rootScope.$broadcast('setConnectedStatus', true); - setInterval(function(){ + setInterval(function() { websocketCalls.sendNewEvent({op: 'PING'}); }, 10000); }); @@ -65,26 +66,26 @@ angular.module('zeppelinWebApp').factory('websocketEvents', function($rootScope, $rootScope.$broadcast('setUpdateNotebookJobs', data.notebookRunningJobs); } else if (op === 'AUTH_INFO') { BootstrapDialog.show({ - closable: false, - closeByBackdrop: false, - closeByKeyboard: false, - title: 'Insufficient privileges', - message: data.info.toString(), - buttons: [{ - label: 'Login', - action: function(dialog) { - dialog.close(); - angular.element('#loginModal').modal({ + closable: false, + closeByBackdrop: false, + closeByKeyboard: false, + title: 'Insufficient privileges', + message: data.info.toString(), + buttons: [{ + label: 'Login', + action: function(dialog) { + dialog.close(); + angular.element('#loginModal').modal({ show: 'true' }); - } - }, { - label: 'Cancel', - action: function(dialog) { - dialog.close(); - $window.location.replace('/'); - } - }] + } + }, { + label: 'Cancel', + action: function(dialog) { + dialog.close(); + $window.location.replace('/'); + } + }] }); } else if (op === 'PARAGRAPH') { $rootScope.$broadcast('updateParagraph', data); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/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 b636f0f..698b8ff 100644 --- a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js +++ b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js @@ -29,7 +29,7 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope, websocketEvents.sendNewEvent({op: 'DEL_NOTE', data: {id: noteId}}); }, - cloneNotebook: function(noteIdToClone, newNoteName ) { + cloneNotebook: function(noteIdToClone, newNoteName) { websocketEvents.sendNewEvent({op: 'CLONE_NOTE', data: {id: noteIdToClone, name: newNoteName}}); }, @@ -46,15 +46,15 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope, }, updateNotebook: function(noteId, noteName, noteConfig) { - websocketEvents.sendNewEvent({op: 'NOTE_UPDATE', data: {id: noteId, name: noteName, config : noteConfig}}); + websocketEvents.sendNewEvent({op: 'NOTE_UPDATE', data: {id: noteId, name: noteName, config: noteConfig}}); }, moveParagraph: function(paragraphId, newIndex) { - websocketEvents.sendNewEvent({ op: 'MOVE_PARAGRAPH', data : {id: paragraphId, index: newIndex}}); + websocketEvents.sendNewEvent({op: 'MOVE_PARAGRAPH', data: {id: paragraphId, index: newIndex}}); }, insertParagraph: function(newIndex) { - websocketEvents.sendNewEvent({ op: 'INSERT_PARAGRAPH', data : {index: newIndex}}); + websocketEvents.sendNewEvent({op: 'INSERT_PARAGRAPH', data: {index: newIndex}}); }, updateAngularObject: function(noteId, paragraphId, name, value, interpreterGroupId) { @@ -120,11 +120,11 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope, completion: function(paragraphId, buf, cursor) { websocketEvents.sendNewEvent({ - op : 'COMPLETION', - data : { - id : paragraphId, - buf : buf, - cursor : cursor + op: 'COMPLETION', + data: { + id: paragraphId, + buf: buf, + cursor: cursor } }); }, @@ -134,7 +134,7 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope, op: 'COMMIT_PARAGRAPH', data: { id: paragraphId, - title : paragraphTitle, + title: paragraphTitle, paragraph: paragraphData, config: paragraphConfig, params: paragraphParams @@ -161,7 +161,7 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope, }); }, - isConnected: function(){ + isConnected: function() { return websocketEvents.isConnected(); }, @@ -171,7 +171,7 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope, getUpdateNotebookJobsList: function(lastUpdateServerUnixTime) { websocketEvents.sendNewEvent( - {op: 'LIST_UPDATE_NOTEBOOK_JOBS', data : {lastUpdateUnixTime : lastUpdateServerUnixTime*1}} + {op: 'LIST_UPDATE_NOTEBOOK_JOBS', data: {lastUpdateUnixTime: lastUpdateServerUnixTime * 1}} ); }, http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/test/spec/controllers/nav.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/test/spec/controllers/nav.js b/zeppelin-web/test/spec/controllers/nav.js index 9bbfbe3..8b5e0a4 100644 --- a/zeppelin-web/test/spec/controllers/nav.js +++ b/zeppelin-web/test/spec/controllers/nav.js @@ -2,7 +2,8 @@ describe('Controller: NavCtrl', function() { // load the controller's module beforeEach(module('zeppelinWebApp')); - var NavCtrl, scope; + var NavCtrl; + var scope; // Initialize the controller and a mock scope beforeEach(inject(function($controller, $rootScope) { scope = $rootScope.$new(); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/test/spec/controllers/notebook.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/test/spec/controllers/notebook.js b/zeppelin-web/test/spec/controllers/notebook.js index 5afa628..317a905 100644 --- a/zeppelin-web/test/spec/controllers/notebook.js +++ b/zeppelin-web/test/spec/controllers/notebook.js @@ -103,4 +103,4 @@ describe('Controller: NotebookCtrl', function() { expect(scope.saveTimer).toEqual(null); }); -}); \ No newline at end of file +}); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/test/spec/controllers/paragraph.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/test/spec/controllers/paragraph.js b/zeppelin-web/test/spec/controllers/paragraph.js index 77fc495..31f8dc7 100644 --- a/zeppelin-web/test/spec/controllers/paragraph.js +++ b/zeppelin-web/test/spec/controllers/paragraph.js @@ -11,9 +11,9 @@ describe('Controller: ParagraphCtrl', function() { config: {} }; var route = { - current : { - pathParams : { - noteId : 'noteId' + current: { + pathParams: { + noteId: 'noteId' } } }; @@ -60,17 +60,18 @@ describe('Controller: ParagraphCtrl', function() { expect(scope.paragraphFocused).toEqual(false); }); - it('should call loadTableData() and getGraphMode() should return "table" when the result type is "TABLE"', function() { - scope.getResultType = jasmine.createSpy('getResultType spy').andCallFake(function() { - return 'TABLE'; + it('should call loadTableData() and getGraphMode() should return "table" when the result type is "TABLE"', + function() { + scope.getResultType = jasmine.createSpy('getResultType spy').andCallFake(function() { + return 'TABLE'; + }); + spyOn(scope, 'loadTableData'); + spyOn(scope, 'setGraphMode'); + scope.init(paragraphMock); + expect(scope.loadTableData).toHaveBeenCalled(); + expect(scope.setGraphMode).toHaveBeenCalled(); + expect(scope.getGraphMode()).toEqual('table'); }); - spyOn(scope, 'loadTableData'); - spyOn(scope, 'setGraphMode'); - scope.init(paragraphMock); - expect(scope.loadTableData).toHaveBeenCalled(); - expect(scope.setGraphMode).toHaveBeenCalled(); - expect(scope.getGraphMode()).toEqual('table'); - }); it('should call renderHtml() when the result type is "HTML"', function() { scope.getResultType = jasmine.createSpy('getResultType spy').andCallFake(function() { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/test/spec/directives/ngenter.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/test/spec/directives/ngenter.js b/zeppelin-web/test/spec/directives/ngenter.js index dc2136d..56f75cb 100644 --- a/zeppelin-web/test/spec/directives/ngenter.js +++ b/zeppelin-web/test/spec/directives/ngenter.js @@ -1,28 +1,28 @@ 'use strict'; -describe('Directive: ngEnter', function () { +describe('Directive: ngEnter', function() { // load the directive's module beforeEach(module('zeppelinWebApp')); - var element, - scope; + var element; + var scope; - beforeEach(inject(function ($rootScope) { + beforeEach(inject(function($rootScope) { scope = $rootScope.$new(); })); - it('should be define', inject(function ($compile) { + it('should be define', inject(function($compile) { element = angular.element('<ng-enter></ng-enter>'); element = $compile(element)(scope); expect(element.text()).toBeDefined(); })); //Test the rest of function in ngEnter -/* it('should make hidden element visible', inject(function ($compile) { - element = angular.element('<ng-enter></ng-enter>'); - element = $compile(element)(scope); - expect(element.text()).toBe('this is the ngEnter directive'); - }));*/ + /* it('should make hidden element visible', inject(function ($compile) { + element = angular.element('<ng-enter></ng-enter>'); + element = $compile(element)(scope); + expect(element.text()).toBe('this is the ngEnter directive'); + }));*/ }); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5556f815/zeppelin-web/test/spec/factory/notebookList.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/test/spec/factory/notebookList.js b/zeppelin-web/test/spec/factory/notebookList.js index 10c6981..e411f28 100644 --- a/zeppelin-web/test/spec/factory/notebookList.js +++ b/zeppelin-web/test/spec/factory/notebookList.js @@ -4,10 +4,10 @@ describe('Factory: NotebookList', function() { var notebookList; - beforeEach(function () { + beforeEach(function() { module('zeppelinWebApp'); - inject(function ($injector) { + inject(function($injector) { notebookList = $injector.get('notebookListDataFactory'); }); }); @@ -22,7 +22,7 @@ describe('Factory: NotebookList', function() { {name: '/C/CB/CBA', id: '000006'}, // same name with a dir {name: '/C/CB/CBA', id: '000007'}, // same name with another note {name: 'C///CB//CBB', id: '000008'}, - {name: 'D/D[A/DA]B', id:'000009'} // check if '[' and ']' considered as folder seperator + {name: 'D/D[A/DA]B', id: '000009'} // check if '[' and ']' considered as folder seperator ]; notebookList.setNotes(notesList);
