You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by pr...@apache.org on 2018/02/23 04:54:52 UTC
[12/12] zeppelin git commit: [ZEPPELIN-3245] checkstyle/eslintrc for
zeppelin-web (JavaScript)
[ZEPPELIN-3245] checkstyle/eslintrc for zeppelin-web (JavaScript)
Have added this PR to add a rule in eslinerc to have semicolons in javascript source
[Improvement | Refactoring]
* [ZEPPELIN-3245](https://issues.apache.org/jira/browse/ZEPPELIN-3245)
```
cd zeppelin-web
npm install (or yarn install if you have yarn)
npm run lint:once
```
Author: Prabhjyot Singh <pr...@gmail.com>
Closes #2804 from prabhjyotsingh/discuss/eslint_semi_rule and squashes the following commits:
4506f243e [Prabhjyot Singh] eslint rule for space
bc43d68a6 [Prabhjyot Singh] merge `[ZEPPELIN-3177]Resize charts on paragaph resize` changes
2d57ba30b [Prabhjyot Singh] fix failing WEB_E2E="true"
f23cb61d4 [Prabhjyot Singh] remove `"linebreak-style": 0,` and `"no-use-before-define": 0,`
39f37fb88 [Prabhjyot Singh] remove "standard" from eslint
6edac44f6 [Prabhjyot Singh] add `"semi": [2, "always"]` rule in eslinerc
Change-Id: I91546ea973c2c9e7540da1586d6329fc93088eb0
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/ea2c9447
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/ea2c9447
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/ea2c9447
Branch: refs/heads/master
Commit: ea2c944742cea6e8e37e225d1acc67cdb195056e
Parents: f6ef64f
Author: Prabhjyot Singh <pr...@gmail.com>
Authored: Fri Feb 23 09:35:30 2018 +0530
Committer: Prabhjyot Singh <pr...@gmail.com>
Committed: Fri Feb 23 10:24:33 2018 +0530
----------------------------------------------------------------------
.../org/apache/zeppelin/AbstractZeppelinIT.java | 2 +-
zeppelin-web/.eslintrc | 24 +-
zeppelin-web/src/app/app.controller.js | 52 +-
zeppelin-web/src/app/app.controller.test.js | 44 +-
zeppelin-web/src/app/app.js | 162 +-
.../configuration/configuration.controller.js | 42 +-
.../src/app/configuration/configuration.test.js | 92 +-
.../src/app/credential/credential.controller.js | 236 +-
.../src/app/credential/credential.test.js | 132 +-
zeppelin-web/src/app/helium/helium-conf.js | 96 +-
zeppelin-web/src/app/helium/helium-package.js | 32 +-
zeppelin-web/src/app/helium/helium-type.js | 2 +-
.../src/app/helium/helium.controller.js | 424 ++--
zeppelin-web/src/app/helium/helium.service.js | 334 +--
zeppelin-web/src/app/helium/index.js | 4 +-
zeppelin-web/src/app/home/home.controller.js | 188 +-
.../interpreter/interpreter-item.directive.js | 20 +-
.../app/interpreter/interpreter.controller.js | 838 +++----
.../src/app/interpreter/interpreter.filter.js | 12 +-
.../widget/number-widget.directive.js | 20 +-
zeppelin-web/src/app/jobmanager/job-status.js | 26 +-
.../src/app/jobmanager/job/job.component.js | 118 +-
.../app/jobmanager/job/job.component.test.js | 70 +-
.../src/app/jobmanager/jobmanager.component.js | 177 +-
.../app/jobmanager/jobmanager.component.test.js | 34 +-
.../src/app/jobmanager/jobmanager.filter.js | 38 +-
.../src/app/jobmanager/jobmanager.service.js | 46 +-
.../app/jobmanager/jobmanager.service.test.js | 66 +-
.../notebook-repository.controller.js | 78 +-
.../dropdown-input/dropdown-input.directive.js | 14 +-
.../dynamic-forms/dynamic-forms.directive.js | 42 +-
.../elastic-input/elastic-input.controller.js | 10 +-
.../src/app/notebook/note-var-share.service.js | 36 +-
.../src/app/notebook/notebook.controller.js | 1590 ++++++------
.../app/notebook/notebook.controller.test.js | 240 +-
.../notebook/paragraph/clipboard.controller.js | 36 +-
.../code-editor/code-editor.directive.js | 24 +-
.../notebook/paragraph/paragraph.controller.js | 1824 +++++++-------
.../paragraph/paragraph.controller.test.js | 68 +-
.../app/notebook/paragraph/paragraph.status.js | 16 +-
.../notebook/paragraph/resizable.directive.js | 66 +-
.../paragraph/result/result.controller.js | 1118 ++++-----
.../revisions-comparator.component.js | 162 +-
.../notebook/save-as/browser-detect.service.js | 26 +-
.../src/app/notebook/save-as/save-as.service.js | 60 +-
.../src/app/search/result-list.controller.js | 134 +-
zeppelin-web/src/app/search/search.service.js | 24 +-
zeppelin-web/src/app/spell/index.js | 4 +-
zeppelin-web/src/app/spell/spell-base.js | 14 +-
zeppelin-web/src/app/spell/spell-result.js | 182 +-
.../tabledata/advanced-transformation-util.js | 1010 ++++----
.../advanced-transformation-util.test.js | 2288 +++++++++---------
.../app/tabledata/advanced-transformation.js | 202 +-
.../src/app/tabledata/columnselector.js | 54 +-
zeppelin-web/src/app/tabledata/dataset.js | 6 +-
.../src/app/tabledata/datasetfactory.js | 12 +-
.../src/app/tabledata/datasetfactory.test.js | 46 +-
zeppelin-web/src/app/tabledata/network.js | 22 +-
zeppelin-web/src/app/tabledata/networkdata.js | 76 +-
.../src/app/tabledata/networkdata.test.js | 72 +-
zeppelin-web/src/app/tabledata/passthrough.js | 10 +-
zeppelin-web/src/app/tabledata/pivot.js | 240 +-
zeppelin-web/src/app/tabledata/tabledata.js | 64 +-
.../src/app/tabledata/tabledata.test.js | 132 +-
.../src/app/tabledata/transformation.js | 68 +-
.../builtins/visualization-areachart.js | 144 +-
.../builtins/visualization-barchart.js | 122 +-
.../builtins/visualization-d3network.js | 256 +-
.../builtins/visualization-linechart.js | 162 +-
.../builtins/visualization-nvd3chart.js | 242 +-
.../builtins/visualization-piechart.js | 66 +-
.../builtins/visualization-scatterchart.js | 326 +--
.../builtins/visualization-table.js | 318 +--
.../builtins/visualization-util.js | 146 +-
.../src/app/visualization/visualization.js | 108 +-
.../array-ordering/array-ordering.service.js | 44 +-
.../src/components/base-url/base-url.service.js | 40 +-
.../src/components/login/login.controller.js | 88 +-
.../expand-collapse.directive.js | 30 +-
.../src/components/navbar/navbar.controller.js | 258 +-
.../components/navbar/navbar.controller.test.js | 28 +-
.../components/ng-enter/ng-enter.directive.js | 18 +-
.../ng-enter/ng-enter.directive.test.js | 26 +-
.../components/ng-escape/ng-escape.directive.js | 18 +-
.../note-action/note-action.service.js | 144 +-
.../note-create/note-create.controller.js | 120 +-
.../note-create/note-create.controller.test.js | 54 +-
.../components/note-create/visible.directive.js | 40 +-
.../note-import/note-import.controller.js | 176 +-
.../components/note-list/note-list.factory.js | 62 +-
.../note-list/note-list.factory.test.js | 122 +-
.../note-rename/note-rename.controller.js | 44 +-
.../note-rename/note-rename.service.js | 12 +-
.../websocket/websocket-event.factory.js | 204 +-
.../websocket/websocket-message.service.js | 292 +--
zeppelin-web/src/index.js | 118 +-
96 files changed, 8777 insertions(+), 8452 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-integration/src/test/java/org/apache/zeppelin/AbstractZeppelinIT.java
----------------------------------------------------------------------
diff --git a/zeppelin-integration/src/test/java/org/apache/zeppelin/AbstractZeppelinIT.java b/zeppelin-integration/src/test/java/org/apache/zeppelin/AbstractZeppelinIT.java
index b4ebfe9..e1992fb 100644
--- a/zeppelin-integration/src/test/java/org/apache/zeppelin/AbstractZeppelinIT.java
+++ b/zeppelin-integration/src/test/java/org/apache/zeppelin/AbstractZeppelinIT.java
@@ -110,7 +110,7 @@ abstract public class AbstractZeppelinIT {
WebDriverWait block = new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC);
block.until(ExpectedConditions.visibilityOfElementLocated(By.id("noteCreateModal")));
clickAndWait(By.id("createNoteButton"));
- block.until(ExpectedConditions.invisibilityOfElementLocated(By.className("pull-right")));
+ block.until(ExpectedConditions.invisibilityOfElementLocated(By.id("createNoteButton")));
}
protected void deleteTestNotebook(final WebDriver driver) {
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/.eslintrc
----------------------------------------------------------------------
diff --git a/zeppelin-web/.eslintrc b/zeppelin-web/.eslintrc
index 6dca5c8..6207bb9 100644
--- a/zeppelin-web/.eslintrc
+++ b/zeppelin-web/.eslintrc
@@ -1,5 +1,5 @@
{
- "extends": ["eslint:recommended", "google", "standard"],
+ "extends": ["eslint:recommended", "google"],
"env": {
"browser": true,
"jasmine": true,
@@ -31,26 +31,11 @@
"process": false
},
"rules": {
- "array-bracket-spacing": 0,
- "space-before-function-paren": 0,
- "no-unneeded-ternary": 0,
- "comma-dangle": 0,
- "object-curly-spacing": 0,
- "standard/object-curly-even-spacing": 0,
- "arrow-parens": 0,
- "require-jsdoc": 0,
- "valid-jsdoc": 0,
- "no-invalid-this": 0,
- "no-console": 0,
- "guard-for-in": 0,
- "no-mixed-operators": 1,
- "no-useless-escape": 1,
"no-bitwise": 2,
"camelcase": 2,
"curly": 2,
"eqeqeq": 2,
"wrap-iife": [2, "any"],
- "no-use-before-define": 0,
"new-cap": 2,
"no-caller": 2,
"quotes": [2, "single"],
@@ -59,6 +44,11 @@
"no-unused-vars": [2, { "vars": "local", "args": "none" }],
"strict": [2, "global"],
"max-len": [2, {"code": 120, "ignoreComments": true, "ignoreRegExpLiterals": true}],
- "linebreak-style": 0
+ "require-jsdoc": "off",
+ "no-console": ["off"],
+ "valid-jsdoc": "off",
+ "semi": [2, "always"],
+ "no-invalid-this": 1,
+ "indent": ["error", 2, { "SwitchCase": 1 }]
}
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/app.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/app.controller.js b/zeppelin-web/src/app/app.controller.js
index 6c64a33..904fbd7 100644
--- a/zeppelin-web/src/app/app.controller.js
+++ b/zeppelin-web/src/app/app.controller.js
@@ -12,48 +12,48 @@
* limitations under the License.
*/
-angular.module('zeppelinWebApp').controller('MainCtrl', MainCtrl)
+angular.module('zeppelinWebApp').controller('MainCtrl', MainCtrl);
-function MainCtrl ($scope, $rootScope, $window, arrayOrderingSrv) {
- 'ngInject'
+function MainCtrl($scope, $rootScope, $window, arrayOrderingSrv) {
+ 'ngInject';
- $scope.looknfeel = 'default'
+ $scope.looknfeel = 'default';
- let init = function () {
- $scope.asIframe = (($window.location.href.indexOf('asIframe') > -1) ? true : false)
- }
+ let init = function() {
+ $scope.asIframe = (($window.location.href.indexOf('asIframe') > -1) ? true : false);
+ };
- init()
+ init();
- $rootScope.$on('setIframe', function (event, data) {
+ $rootScope.$on('setIframe', function(event, data) {
if (!event.defaultPrevented) {
- $scope.asIframe = data
- event.preventDefault()
+ $scope.asIframe = data;
+ event.preventDefault();
}
- })
+ });
- $rootScope.$on('setLookAndFeel', function (event, data) {
+ $rootScope.$on('setLookAndFeel', function(event, data) {
if (!event.defaultPrevented && data && data !== '' && data !== $scope.looknfeel) {
- $scope.looknfeel = data
- event.preventDefault()
+ $scope.looknfeel = data;
+ event.preventDefault();
}
- })
+ });
// Set The lookAndFeel to default on every page
- $rootScope.$on('$routeChangeStart', function (event, next, current) {
- $rootScope.$broadcast('setLookAndFeel', 'default')
- })
+ $rootScope.$on('$routeChangeStart', function(event, next, current) {
+ $rootScope.$broadcast('setLookAndFeel', 'default');
+ });
- $rootScope.noteName = function (note) {
+ $rootScope.noteName = function(note) {
if (!_.isEmpty(note)) {
- return arrayOrderingSrv.getNoteName(note)
+ return arrayOrderingSrv.getNoteName(note);
}
- }
+ };
- BootstrapDialog.defaultOptions.onshown = function () {
- angular.element('#' + this.id).find('.btn:last').focus()
- }
+ BootstrapDialog.defaultOptions.onshown = function() {
+ angular.element('#' + this.id).find('.btn:last').focus();
+ };
// Remove BootstrapDialog animation
- BootstrapDialog.configDefaultOptions({animate: false})
+ BootstrapDialog.configDefaultOptions({animate: false});
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/app.controller.test.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/app.controller.test.js b/zeppelin-web/src/app/app.controller.test.js
index 67d5034..b6c6261 100644
--- a/zeppelin-web/src/app/app.controller.test.js
+++ b/zeppelin-web/src/app/app.controller.test.js
@@ -1,28 +1,28 @@
-describe('Controller: MainCtrl', function () {
- beforeEach(angular.mock.module('zeppelinWebApp'))
+describe('Controller: MainCtrl', function() {
+ beforeEach(angular.mock.module('zeppelinWebApp'));
- let scope
- let rootScope
+ let scope;
+ let rootScope;
- beforeEach(inject(function ($controller, $rootScope) {
- rootScope = $rootScope
- scope = $rootScope.$new()
+ beforeEach(inject(function($controller, $rootScope) {
+ rootScope = $rootScope;
+ scope = $rootScope.$new();
$controller('MainCtrl', {
- $scope: scope
- })
- }))
+ $scope: scope,
+ });
+ }));
- it('should attach "asIframe" to the scope and the default value should be false', function () {
- expect(scope.asIframe).toBeDefined()
- expect(scope.asIframe).toEqual(false)
- })
+ it('should attach "asIframe" to the scope and the default value should be false', function() {
+ expect(scope.asIframe).toBeDefined();
+ expect(scope.asIframe).toEqual(false);
+ });
- it('should set the default value of "looknfeel to "default"', function () {
- expect(scope.looknfeel).toEqual('default')
- })
+ it('should set the default value of "looknfeel to "default"', function() {
+ expect(scope.looknfeel).toEqual('default');
+ });
- it('should set "asIframe" flag to true when a controller broadcasts setIframe event', function () {
- rootScope.$broadcast('setIframe', true)
- expect(scope.asIframe).toEqual(true)
- })
-})
+ it('should set "asIframe" flag to true when a controller broadcasts setIframe event', function() {
+ rootScope.$broadcast('setIframe', true);
+ expect(scope.asIframe).toEqual(true);
+ });
+});
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/app.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/app.js b/zeppelin-web/src/app/app.js
index ed89dd8..64ceff0 100644
--- a/zeppelin-web/src/app/app.js
+++ b/zeppelin-web/src/app/app.js
@@ -15,14 +15,14 @@
* limitations under the License.
*/
-import 'headroom.js'
-import 'headroom.js/dist/angular.headroom'
+import 'headroom.js';
+import 'headroom.js/dist/angular.headroom';
-import 'scrollmonitor/scrollMonitor.js'
-import 'angular-viewport-watch/angular-viewport-watch.js'
+import 'scrollmonitor/scrollMonitor.js';
+import 'angular-viewport-watch/angular-viewport-watch.js';
-import 'angular-ui-grid/ui-grid.css'
-import 'angular-ui-grid'
+import 'angular-ui-grid/ui-grid.css';
+import 'angular-ui-grid';
const requiredModules = [
'ngCookies',
@@ -56,167 +56,169 @@ const requiredModules = [
'ui.grid.moveColumns',
'ui.grid.pagination',
'ui.grid.saveState',
-]
+];
// headroom should not be used for CI, since we have to execute some integration tests.
// otherwise, they will fail.
-if (!process.env.BUILD_CI) { requiredModules.push('headroom') }
+if (!process.env.BUILD_CI) {
+ requiredModules.push('headroom');
+}
let zeppelinWebApp = angular.module('zeppelinWebApp', requiredModules)
- .filter('breakFilter', function () {
- return function (text) {
+ .filter('breakFilter', function() {
+ return function(text) {
// eslint-disable-next-line no-extra-boolean-cast
if (!!text) {
- return text.replace(/\n/g, '<br />')
+ return text.replace(/\n/g, '<br />');
}
- }
+ };
})
- .config(function ($httpProvider, $routeProvider, ngToastProvider) {
+ .config(function($httpProvider, $routeProvider, ngToastProvider) {
// withCredentials when running locally via grunt
- $httpProvider.defaults.withCredentials = true
+ $httpProvider.defaults.withCredentials = true;
let visBundleLoad = {
- load: ['heliumService', function (heliumService) {
- return heliumService.load
- }]
- }
+ load: ['heliumService', function(heliumService) {
+ return heliumService.load;
+ }],
+ };
$routeProvider
.when('/', {
- templateUrl: 'app/home/home.html'
+ templateUrl: 'app/home/home.html',
})
.when('/notebook/:noteId', {
templateUrl: 'app/notebook/notebook.html',
controller: 'NotebookCtrl',
- resolve: visBundleLoad
+ resolve: visBundleLoad,
})
.when('/notebook/:noteId/paragraph?=:paragraphId', {
templateUrl: 'app/notebook/notebook.html',
controller: 'NotebookCtrl',
- resolve: visBundleLoad
+ resolve: visBundleLoad,
})
.when('/notebook/:noteId/paragraph/:paragraphId?', {
templateUrl: 'app/notebook/notebook.html',
controller: 'NotebookCtrl',
- resolve: visBundleLoad
+ resolve: visBundleLoad,
})
.when('/notebook/:noteId/revision/:revisionId', {
templateUrl: 'app/notebook/notebook.html',
controller: 'NotebookCtrl',
- resolve: visBundleLoad
+ resolve: visBundleLoad,
})
.when('/jobmanager', {
templateUrl: 'app/jobmanager/jobmanager.html',
- controller: 'JobManagerCtrl'
+ controller: 'JobManagerCtrl',
})
.when('/interpreter', {
templateUrl: 'app/interpreter/interpreter.html',
- controller: 'InterpreterCtrl'
+ controller: 'InterpreterCtrl',
})
.when('/notebookRepos', {
templateUrl: 'app/notebook-repository/notebook-repository.html',
controller: 'NotebookRepositoryCtrl',
- controllerAs: 'noterepo'
+ controllerAs: 'noterepo',
})
.when('/credential', {
templateUrl: 'app/credential/credential.html',
- controller: 'CredentialCtrl'
+ controller: 'CredentialCtrl',
})
.when('/helium', {
templateUrl: 'app/helium/helium.html',
- controller: 'HeliumCtrl'
+ controller: 'HeliumCtrl',
})
.when('/configuration', {
templateUrl: 'app/configuration/configuration.html',
- controller: 'ConfigurationCtrl'
+ controller: 'ConfigurationCtrl',
})
.when('/search/:searchTerm', {
templateUrl: 'app/search/result-list.html',
- controller: 'SearchResultCtrl'
+ controller: 'SearchResultCtrl',
})
.otherwise({
- redirectTo: '/'
- })
+ redirectTo: '/',
+ });
ngToastProvider.configure({
dismissButton: true,
dismissOnClick: false,
combineDuplications: true,
- timeout: 6000
- })
+ timeout: 6000,
+ });
})
// handel logout on API failure
- .config(function ($httpProvider, $provide) {
+ .config(function($httpProvider, $provide) {
if (process.env.PROD) {
- $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
+ $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
}
- $provide.factory('httpInterceptor', function ($q, $rootScope) {
+ $provide.factory('httpInterceptor', function($q, $rootScope) {
return {
- 'responseError': function (rejection) {
+ 'responseError': function(rejection) {
if (rejection.status === 405) {
- let data = {}
- data.info = ''
- $rootScope.$broadcast('session_logout', data)
+ let data = {};
+ data.info = '';
+ $rootScope.$broadcast('session_logout', data);
}
- $rootScope.$broadcast('httpResponseError', rejection)
- return $q.reject(rejection)
- }
- }
- })
- $httpProvider.interceptors.push('httpInterceptor')
+ $rootScope.$broadcast('httpResponseError', rejection);
+ return $q.reject(rejection);
+ },
+ };
+ });
+ $httpProvider.interceptors.push('httpInterceptor');
})
- .constant('TRASH_FOLDER_ID', '~Trash')
+ .constant('TRASH_FOLDER_ID', '~Trash');
-function auth () {
- let $http = angular.injector(['ng']).get('$http')
- let baseUrlSrv = angular.injector(['zeppelinWebApp']).get('baseUrlSrv')
+function auth() {
+ let $http = angular.injector(['ng']).get('$http');
+ let baseUrlSrv = angular.injector(['zeppelinWebApp']).get('baseUrlSrv');
// withCredentials when running locally via grunt
- $http.defaults.withCredentials = true
+ $http.defaults.withCredentials = true;
jQuery.ajaxSetup({
dataType: 'json',
xhrFields: {
- withCredentials: true
+ withCredentials: true,
},
- crossDomain: true
- })
- let config = (process.env.PROD) ? {headers: { 'X-Requested-With': 'XMLHttpRequest' }} : {}
- return $http.get(baseUrlSrv.getRestApiBase() + '/security/ticket', config).then(function (response) {
- zeppelinWebApp.run(function ($rootScope) {
- let res = angular.fromJson(response.data).body
+ crossDomain: true,
+ });
+ let config = (process.env.PROD) ? {headers: {'X-Requested-With': 'XMLHttpRequest'}} : {};
+ return $http.get(baseUrlSrv.getRestApiBase() + '/security/ticket', config).then(function(response) {
+ zeppelinWebApp.run(function($rootScope) {
+ let res = angular.fromJson(response.data).body;
if (res['redirectURL']) {
- window.location.href = res['redirectURL'] + window.location.href
+ window.location.href = res['redirectURL'] + window.location.href;
} else {
- $rootScope.ticket = res
- $rootScope.ticket.screenUsername = $rootScope.ticket.principal
+ $rootScope.ticket = res;
+ $rootScope.ticket.screenUsername = $rootScope.ticket.principal;
if ($rootScope.ticket.principal.indexOf('#Pac4j') === 0) {
- let re = ', name=(.*?),'
- $rootScope.ticket.screenUsername = $rootScope.ticket.principal.match(re)[1]
+ let re = ', name=(.*?),';
+ $rootScope.ticket.screenUsername = $rootScope.ticket.principal.match(re)[1];
}
}
- })
- }, function (errorResponse) {
+ });
+ }, function(errorResponse) {
// Handle error case
- let redirect = errorResponse.headers('Location')
+ let redirect = errorResponse.headers('Location');
if (errorResponse.status === 401 && redirect !== undefined) {
// Handle page redirect
- window.location.href = redirect
+ window.location.href = redirect;
}
- })
+ });
}
-function bootstrapApplication () {
- zeppelinWebApp.run(function ($rootScope, $location) {
- $rootScope.$on('$routeChangeStart', function (event, next, current) {
- $rootScope.pageTitle = 'Zeppelin'
+function bootstrapApplication() {
+ zeppelinWebApp.run(function($rootScope, $location) {
+ $rootScope.$on('$routeChangeStart', function(event, next, current) {
+ $rootScope.pageTitle = 'Zeppelin';
if (!$rootScope.ticket && next.$$route && !next.$$route.publicAccess) {
- $location.path('/')
+ $location.path('/');
}
- })
- })
- angular.bootstrap(document, ['zeppelinWebApp'])
+ });
+ });
+ angular.bootstrap(document, ['zeppelinWebApp']);
}
-angular.element(document).ready(function () {
- auth().then(bootstrapApplication)
-})
+angular.element(document).ready(function() {
+ auth().then(bootstrapApplication);
+});
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/configuration/configuration.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/configuration/configuration.controller.js b/zeppelin-web/src/app/configuration/configuration.controller.js
index 0d845de..0f5eba3 100644
--- a/zeppelin-web/src/app/configuration/configuration.controller.js
+++ b/zeppelin-web/src/app/configuration/configuration.controller.js
@@ -12,37 +12,37 @@
* limitations under the License.
*/
-angular.module('zeppelinWebApp').controller('ConfigurationCtrl', ConfigurationCtrl)
+angular.module('zeppelinWebApp').controller('ConfigurationCtrl', ConfigurationCtrl);
-function ConfigurationCtrl ($scope, $http, baseUrlSrv, ngToast) {
- 'ngInject'
+function ConfigurationCtrl($scope, $http, baseUrlSrv, ngToast) {
+ 'ngInject';
- $scope.configrations = []
- ngToast.dismiss()
+ $scope.configrations = [];
+ ngToast.dismiss();
- let getConfigurations = function () {
+ let getConfigurations = function() {
$http.get(baseUrlSrv.getRestApiBase() + '/configurations/all')
- .success(function (data, status, headers, config) {
- $scope.configurations = data.body
+ .success(function(data, status, headers, config) {
+ $scope.configurations = data.body;
})
- .error(function (data, status, headers, config) {
+ .error(function(data, status, headers, config) {
if (status === 401) {
ngToast.danger({
content: 'You don\'t have permission on this page',
verticalPosition: 'bottom',
- timeout: '3000'
- })
- setTimeout(function () {
- window.location = baseUrlSrv.getBase()
- }, 3000)
+ timeout: '3000',
+ });
+ setTimeout(function() {
+ window.location = baseUrlSrv.getBase();
+ }, 3000);
}
- console.log('Error %o %o', status, data.message)
- })
- }
+ console.log('Error %o %o', status, data.message);
+ });
+ };
- let init = function () {
- getConfigurations()
- }
+ let init = function() {
+ getConfigurations();
+ };
- init()
+ init();
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/configuration/configuration.test.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/configuration/configuration.test.js b/zeppelin-web/src/app/configuration/configuration.test.js
index 8add102..4d98a08 100644
--- a/zeppelin-web/src/app/configuration/configuration.test.js
+++ b/zeppelin-web/src/app/configuration/configuration.test.js
@@ -1,69 +1,69 @@
-import template from './configuration.html'
+import template from './configuration.html';
-describe('Controller: Configuration', function () {
- beforeEach(angular.mock.module('zeppelinWebApp'))
+describe('Controller: Configuration', function() {
+ beforeEach(angular.mock.module('zeppelinWebApp'));
- let baseUrlSrvMock = { getRestApiBase: () => '' }
+ let baseUrlSrvMock = {getRestApiBase: () => ''};
- let ctrl // controller instance
- let $scope
- let $compile
- let $controller // controller generator
- let $httpBackend
- let ngToast
+ let ctrl; // controller instance
+ let $scope;
+ let $compile;
+ let $controller; // controller generator
+ let $httpBackend;
+ let ngToast;
beforeEach(inject((_$controller_, _$rootScope_, _$compile_, _$httpBackend_, _ngToast_) => {
- $scope = _$rootScope_.$new()
- $compile = _$compile_
- $controller = _$controller_
- $httpBackend = _$httpBackend_
- ngToast = _ngToast_
- }))
+ $scope = _$rootScope_.$new();
+ $compile = _$compile_;
+ $controller = _$controller_;
+ $httpBackend = _$httpBackend_;
+ ngToast = _ngToast_;
+ }));
- afterEach(function () {
- $httpBackend.verifyNoOutstandingExpectation()
- $httpBackend.verifyNoOutstandingRequest()
- })
+ afterEach(function() {
+ $httpBackend.verifyNoOutstandingExpectation();
+ $httpBackend.verifyNoOutstandingRequest();
+ });
it('should get configuration initially', () => {
- const conf = { 'conf1': 'value1' }
- ctrl = $controller('ConfigurationCtrl', { $scope: $scope, baseUrlSrv: baseUrlSrvMock, })
- expect(ctrl).toBeDefined()
+ const conf = {'conf1': 'value1'};
+ ctrl = $controller('ConfigurationCtrl', {$scope: $scope, baseUrlSrv: baseUrlSrvMock});
+ expect(ctrl).toBeDefined();
$httpBackend
.when('GET', '/configurations/all')
- .respond(200, { body: conf, })
- $httpBackend.expectGET('/configurations/all')
- $httpBackend.flush()
+ .respond(200, {body: conf});
+ $httpBackend.expectGET('/configurations/all');
+ $httpBackend.flush();
- expect($scope.configurations).toEqual(conf) // scope is updated after $httpBackend.flush()
- })
+ expect($scope.configurations).toEqual(conf); // scope is updated after $httpBackend.flush()
+ });
it('should display ngToast when failed to get configuration properly', () => {
- ctrl = $controller('ConfigurationCtrl', { $scope: $scope, baseUrlSrv: baseUrlSrvMock, })
- spyOn(ngToast, 'danger')
+ ctrl = $controller('ConfigurationCtrl', {$scope: $scope, baseUrlSrv: baseUrlSrvMock});
+ spyOn(ngToast, 'danger');
- $httpBackend.when('GET', '/configurations/all').respond(401, {})
- $httpBackend.expectGET('/configurations/all')
- $httpBackend.flush()
+ $httpBackend.when('GET', '/configurations/all').respond(401, {});
+ $httpBackend.expectGET('/configurations/all');
+ $httpBackend.flush();
- expect(ngToast.danger).toHaveBeenCalled()
- })
+ expect(ngToast.danger).toHaveBeenCalled();
+ });
it('should render list of configurations as the sorted order', () => {
$scope.configurations = {
'zeppelin.server.port': '8080',
'zeppelin.server.addr': '0.0.0.0',
- }
- const elem = $compile(template)($scope)
- $scope.$digest()
- const tbody = elem.find('tbody')
- const tds = tbody.find('td')
+ };
+ const elem = $compile(template)($scope);
+ $scope.$digest();
+ const tbody = elem.find('tbody');
+ const tds = tbody.find('td');
// should be sorted
- expect(tds[0].innerText.trim()).toBe('zeppelin.server.addr')
- expect(tds[1].innerText.trim()).toBe('0.0.0.0')
- expect(tds[2].innerText.trim()).toBe('zeppelin.server.port')
- expect(tds[3].innerText.trim()).toBe('8080')
- })
-})
+ expect(tds[0].innerText.trim()).toBe('zeppelin.server.addr');
+ expect(tds[1].innerText.trim()).toBe('0.0.0.0');
+ expect(tds[2].innerText.trim()).toBe('zeppelin.server.port');
+ expect(tds[3].innerText.trim()).toBe('8080');
+ });
+});
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/credential/credential.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/credential/credential.controller.js b/zeppelin-web/src/app/credential/credential.controller.js
index 102876e..cf6c340 100644
--- a/zeppelin-web/src/app/credential/credential.controller.js
+++ b/zeppelin-web/src/app/credential/credential.controller.js
@@ -12,194 +12,196 @@
* limitations under the License.
*/
-angular.module('zeppelinWebApp').controller('CredentialCtrl', CredentialController)
+angular.module('zeppelinWebApp').controller('CredentialCtrl', CredentialController);
function CredentialController($scope, $http, baseUrlSrv, ngToast) {
- 'ngInject'
+ 'ngInject';
- ngToast.dismiss()
+ ngToast.dismiss();
- $scope.credentialInfo = []
- $scope.showAddNewCredentialInfo = false
- $scope.availableInterpreters = []
+ $scope.credentialInfo = [];
+ $scope.showAddNewCredentialInfo = false;
+ $scope.availableInterpreters = [];
- $scope.entity = ''
- $scope.password = ''
- $scope.username = ''
+ $scope.entity = '';
+ $scope.password = '';
+ $scope.username = '';
$scope.hasCredential = () => {
- return Array.isArray($scope.credentialInfo) && $scope.credentialInfo.length
- }
+ return Array.isArray($scope.credentialInfo) && $scope.credentialInfo.length;
+ };
- let getCredentialInfo = function () {
+ let getCredentialInfo = function() {
$http.get(baseUrlSrv.getRestApiBase() + '/credential')
- .success(function (data, status, headers, config) {
- $scope.credentialInfo.length = 0 // keep the ref while cleaning
- const returnedCredentials = data.body.userCredentials
+ .success(function(data, status, headers, config) {
+ $scope.credentialInfo.length = 0; // keep the ref while cleaning
+ const returnedCredentials = data.body.userCredentials;
for (let key in returnedCredentials) {
- const value = returnedCredentials[key]
- $scope.credentialInfo.push({
- entity: key,
- password: value.password,
- username: value.username,
- })
+ if (returnedCredentials.hasOwnProperty(key)) {
+ const value = returnedCredentials[key];
+ $scope.credentialInfo.push({
+ entity: key,
+ password: value.password,
+ username: value.username,
+ });
+ }
}
- console.log('Success %o %o', status, $scope.credentialInfo)
+ console.log('Success %o %o', status, $scope.credentialInfo);
})
- .error(function (data, status, headers, config) {
+ .error(function(data, status, headers, config) {
if (status === 401) {
- showToast('You do not have permission on this page', 'danger')
- setTimeout(function () {
- window.location = baseUrlSrv.getBase()
- }, 3000)
+ showToast('You do not have permission on this page', 'danger');
+ setTimeout(function() {
+ window.location = baseUrlSrv.getBase();
+ }, 3000);
}
- console.log('Error %o %o', status, data.message)
- })
- }
+ console.log('Error %o %o', status, data.message);
+ });
+ };
$scope.isValidCredential = function() {
- return $scope.entity.trim() !== '' && $scope.username.trim() !== ''
- }
+ return $scope.entity.trim() !== '' && $scope.username.trim() !== '';
+ };
- $scope.addNewCredentialInfo = function () {
+ $scope.addNewCredentialInfo = function() {
if (!$scope.isValidCredential()) {
- showToast('Username \\ Entity can not be empty.', 'danger')
- return
+ showToast('Username \\ Entity can not be empty.', 'danger');
+ return;
}
let newCredential = {
'entity': $scope.entity,
'username': $scope.username,
- 'password': $scope.password
- }
+ 'password': $scope.password,
+ };
$http.put(baseUrlSrv.getRestApiBase() + '/credential', newCredential)
- .success(function (data, status, headers, config) {
- showToast('Successfully saved credentials.', 'success')
- $scope.credentialInfo.push(newCredential)
- resetCredentialInfo()
- $scope.showAddNewCredentialInfo = false
- console.log('Success %o %o', status, data.message)
+ .success(function(data, status, headers, config) {
+ showToast('Successfully saved credentials.', 'success');
+ $scope.credentialInfo.push(newCredential);
+ resetCredentialInfo();
+ $scope.showAddNewCredentialInfo = false;
+ console.log('Success %o %o', status, data.message);
})
- .error(function (data, status, headers, config) {
- showToast('Error saving credentials', 'danger')
- console.log('Error %o %o', status, data.message)
- })
- }
+ .error(function(data, status, headers, config) {
+ showToast('Error saving credentials', 'danger');
+ console.log('Error %o %o', status, data.message);
+ });
+ };
- let getAvailableInterpreters = function () {
+ let getAvailableInterpreters = function() {
$http.get(baseUrlSrv.getRestApiBase() + '/interpreter/setting')
- .success(function (data, status, headers, config) {
+ .success(function(data, status, headers, config) {
for (let setting = 0; setting < data.body.length; setting++) {
$scope.availableInterpreters.push(
- data.body[setting].group + '.' + data.body[setting].name)
+ data.body[setting].group + '.' + data.body[setting].name);
}
angular.element('#entityname').autocomplete({
source: $scope.availableInterpreters,
- select: function (event, selected) {
- $scope.entity = selected.item.value
- return false
- }
- })
+ select: function(event, selected) {
+ $scope.entity = selected.item.value;
+ return false;
+ },
+ });
})
- .error(function (data, status, headers, config) {
- showToast(data.message, 'danger')
- console.log('Error %o %o', status, data.message)
- })
- }
+ .error(function(data, status, headers, config) {
+ showToast(data.message, 'danger');
+ console.log('Error %o %o', status, data.message);
+ });
+ };
- $scope.toggleAddNewCredentialInfo = function () {
+ $scope.toggleAddNewCredentialInfo = function() {
if ($scope.showAddNewCredentialInfo) {
- $scope.showAddNewCredentialInfo = false
+ $scope.showAddNewCredentialInfo = false;
} else {
- $scope.showAddNewCredentialInfo = true
+ $scope.showAddNewCredentialInfo = true;
}
- }
+ };
- $scope.cancelCredentialInfo = function () {
- $scope.showAddNewCredentialInfo = false
- resetCredentialInfo()
- }
+ $scope.cancelCredentialInfo = function() {
+ $scope.showAddNewCredentialInfo = false;
+ resetCredentialInfo();
+ };
- const resetCredentialInfo = function () {
- $scope.entity = ''
- $scope.username = ''
- $scope.password = ''
- }
+ const resetCredentialInfo = function() {
+ $scope.entity = '';
+ $scope.username = '';
+ $scope.password = '';
+ };
- $scope.copyOriginCredentialsInfo = function () {
- showToast('Since entity is a unique key, you can edit only username & password', 'info')
- }
+ $scope.copyOriginCredentialsInfo = function() {
+ showToast('Since entity is a unique key, you can edit only username & password', 'info');
+ };
- $scope.updateCredentialInfo = function (form, data, entity) {
+ $scope.updateCredentialInfo = function(form, data, entity) {
if (!$scope.isValidCredential()) {
- showToast('Username \\ Entity can not be empty.', 'danger')
- return
+ showToast('Username \\ Entity can not be empty.', 'danger');
+ return;
}
let credential = {
entity: entity,
username: data.username,
- password: data.password
- }
+ password: data.password,
+ };
$http.put(baseUrlSrv.getRestApiBase() + '/credential/', credential)
- .success(function (data, status, headers, config) {
- const index = $scope.credentialInfo.findIndex(elem => elem.entity === entity)
- $scope.credentialInfo[index] = credential
- return true
- })
- .error(function (data, status, headers, config) {
- showToast('We could not save the credential', 'danger')
- console.log('Error %o %o', status, data.message)
- form.$show()
+ .success(function(data, status, headers, config) {
+ const index = $scope.credentialInfo.findIndex((elem) => elem.entity === entity);
+ $scope.credentialInfo[index] = credential;
+ return true;
})
- return false
- }
-
- $scope.removeCredentialInfo = function (entity) {
+ .error(function(data, status, headers, config) {
+ showToast('We could not save the credential', 'danger');
+ console.log('Error %o %o', status, data.message);
+ form.$show();
+ });
+ return false;
+ };
+
+ $scope.removeCredentialInfo = function(entity) {
BootstrapDialog.confirm({
closable: false,
closeByBackdrop: false,
closeByKeyboard: false,
title: '',
message: 'Do you want to delete this credential information?',
- callback: function (result) {
+ callback: function(result) {
if (result) {
$http.delete(baseUrlSrv.getRestApiBase() + '/credential/' + entity)
- .success(function (data, status, headers, config) {
- const index = $scope.credentialInfo.findIndex(elem => elem.entity === entity)
- $scope.credentialInfo.splice(index, 1)
- console.log('Success %o %o', status, data.message)
- })
- .error(function (data, status, headers, config) {
- showToast(data.message, 'danger')
- console.log('Error %o %o', status, data.message)
+ .success(function(data, status, headers, config) {
+ const index = $scope.credentialInfo.findIndex((elem) => elem.entity === entity);
+ $scope.credentialInfo.splice(index, 1);
+ console.log('Success %o %o', status, data.message);
})
+ .error(function(data, status, headers, config) {
+ showToast(data.message, 'danger');
+ console.log('Error %o %o', status, data.message);
+ });
}
- }
- })
- }
+ },
+ });
+ };
function showToast(message, type) {
- const verticalPosition = 'bottom'
- const timeout = '3000'
+ const verticalPosition = 'bottom';
+ const timeout = '3000';
if (type === 'success') {
- ngToast.success({ content: message, verticalPosition: verticalPosition, timeout: timeout, })
+ ngToast.success({content: message, verticalPosition: verticalPosition, timeout: timeout});
} else if (type === 'info') {
- ngToast.info({ content: message, verticalPosition: verticalPosition, timeout: timeout, })
+ ngToast.info({content: message, verticalPosition: verticalPosition, timeout: timeout});
} else {
- ngToast.danger({ content: message, verticalPosition: verticalPosition, timeout: timeout, })
+ ngToast.danger({content: message, verticalPosition: verticalPosition, timeout: timeout});
}
}
- let init = function () {
- getAvailableInterpreters()
- getCredentialInfo()
- }
+ let init = function() {
+ getAvailableInterpreters();
+ getCredentialInfo();
+ };
- init()
+ init();
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/credential/credential.test.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/credential/credential.test.js b/zeppelin-web/src/app/credential/credential.test.js
index d90567b..2b3c17a 100644
--- a/zeppelin-web/src/app/credential/credential.test.js
+++ b/zeppelin-web/src/app/credential/credential.test.js
@@ -1,114 +1,114 @@
-describe('Controller: Credential', function () {
- beforeEach(angular.mock.module('zeppelinWebApp'))
+describe('Controller: Credential', function() {
+ beforeEach(angular.mock.module('zeppelinWebApp'));
- let baseUrlSrvMock = { getRestApiBase: () => '' }
+ let baseUrlSrvMock = {getRestApiBase: () => ''};
- let $scope
- let $controller // controller generator
- let $httpBackend
+ let $scope;
+ let $controller; // controller generator
+ let $httpBackend;
beforeEach(inject((_$controller_, _$rootScope_, _$compile_, _$httpBackend_, _ngToast_) => {
- $scope = _$rootScope_.$new()
- $controller = _$controller_
- $httpBackend = _$httpBackend_
- }))
+ $scope = _$rootScope_.$new();
+ $controller = _$controller_;
+ $httpBackend = _$httpBackend_;
+ }));
- const credentialResponse = { 'spark.testCredential': { username: 'user1', password: 'password1' }, }
+ const credentialResponse = {'spark.testCredential': {username: 'user1', password: 'password1'}};
const interpreterResponse = [
- { 'name': 'spark', 'group': 'spark', },
- { 'name': 'md', 'group': 'md', },
- ] // simplified
+ {'name': 'spark', 'group': 'spark'},
+ {'name': 'md', 'group': 'md'},
+ ]; // simplified
function setupInitialization(credentialRes, interpreterRes) {
// requests should follow the exact order
$httpBackend
.when('GET', '/interpreter/setting')
- .respond(200, { body: interpreterRes, })
- $httpBackend.expectGET('/interpreter/setting')
+ .respond(200, {body: interpreterRes});
+ $httpBackend.expectGET('/interpreter/setting');
$httpBackend
.when('GET', '/credential')
- .respond(200, { body: { userCredentials: credentialRes, } })
- $httpBackend.expectGET('/credential')
+ .respond(200, {body: {userCredentials: credentialRes}});
+ $httpBackend.expectGET('/credential');
// should flush after calling this function
}
it('should get available interpreters and credentials initially', () => {
- const ctrl = createController()
- expect(ctrl).toBeDefined()
+ const ctrl = createController();
+ expect(ctrl).toBeDefined();
- setupInitialization(credentialResponse, interpreterResponse)
- $httpBackend.flush()
+ setupInitialization(credentialResponse, interpreterResponse);
+ $httpBackend.flush();
expect($scope.credentialInfo).toEqual(
- [{ entity: 'spark.testCredential', username: 'user1', password: 'password1'}]
- )
+ [{entity: 'spark.testCredential', username: 'user1', password: 'password1'}]
+ );
expect($scope.availableInterpreters).toEqual(
['spark.spark', 'md.md']
- )
+ );
- $httpBackend.verifyNoOutstandingExpectation()
- $httpBackend.verifyNoOutstandingRequest()
- })
+ $httpBackend.verifyNoOutstandingExpectation();
+ $httpBackend.verifyNoOutstandingRequest();
+ });
it('should toggle using toggleAddNewCredentialInfo', () => {
- createController()
+ createController();
- expect($scope.showAddNewCredentialInfo).toBe(false)
- $scope.toggleAddNewCredentialInfo()
- expect($scope.showAddNewCredentialInfo).toBe(true)
- $scope.toggleAddNewCredentialInfo()
- expect($scope.showAddNewCredentialInfo).toBe(false)
- })
+ expect($scope.showAddNewCredentialInfo).toBe(false);
+ $scope.toggleAddNewCredentialInfo();
+ expect($scope.showAddNewCredentialInfo).toBe(true);
+ $scope.toggleAddNewCredentialInfo();
+ expect($scope.showAddNewCredentialInfo).toBe(false);
+ });
it('should check empty credentials using isInvalidCredential', () => {
- createController()
+ createController();
- $scope.entity = ''
- $scope.username = ''
- expect($scope.isValidCredential()).toBe(false)
+ $scope.entity = '';
+ $scope.username = '';
+ expect($scope.isValidCredential()).toBe(false);
- $scope.entity = 'spark1'
- $scope.username = ''
- expect($scope.isValidCredential()).toBe(false)
+ $scope.entity = 'spark1';
+ $scope.username = '';
+ expect($scope.isValidCredential()).toBe(false);
- $scope.entity = ''
- $scope.username = 'user1'
- expect($scope.isValidCredential()).toBe(false)
+ $scope.entity = '';
+ $scope.username = 'user1';
+ expect($scope.isValidCredential()).toBe(false);
- $scope.entity = 'spark'
- $scope.username = 'user1'
- expect($scope.isValidCredential()).toBe(true)
- })
+ $scope.entity = 'spark';
+ $scope.username = 'user1';
+ expect($scope.isValidCredential()).toBe(true);
+ });
it('should be able to add credential via addNewCredentialInfo', () => {
- const ctrl = createController()
- expect(ctrl).toBeDefined()
- setupInitialization(credentialResponse, interpreterResponse)
+ const ctrl = createController();
+ expect(ctrl).toBeDefined();
+ setupInitialization(credentialResponse, interpreterResponse);
// when
- const newCredential = { entity: 'spark.sql', username: 'user2', password: 'password2'}
+ const newCredential = {entity: 'spark.sql', username: 'user2', password: 'password2'};
$httpBackend
.when('PUT', '/credential', newCredential)
- .respond(200, { })
- $httpBackend.expectPUT('/credential', newCredential)
+ .respond(200, { });
+ $httpBackend.expectPUT('/credential', newCredential);
- $scope.entity = newCredential.entity
- $scope.username = newCredential.username
- $scope.password = newCredential.password
- $scope.addNewCredentialInfo()
+ $scope.entity = newCredential.entity;
+ $scope.username = newCredential.username;
+ $scope.password = newCredential.password;
+ $scope.addNewCredentialInfo();
- $httpBackend.flush()
+ $httpBackend.flush();
- expect($scope.credentialInfo[1]).toEqual(newCredential)
+ expect($scope.credentialInfo[1]).toEqual(newCredential);
- $httpBackend.verifyNoOutstandingExpectation()
- $httpBackend.verifyNoOutstandingRequest()
- })
+ $httpBackend.verifyNoOutstandingExpectation();
+ $httpBackend.verifyNoOutstandingRequest();
+ });
function createController() {
- return $controller('CredentialCtrl', { $scope: $scope, baseUrlSrv: baseUrlSrvMock, })
+ return $controller('CredentialCtrl', {$scope: $scope, baseUrlSrv: baseUrlSrvMock});
}
-})
+});
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/helium/helium-conf.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/helium/helium-conf.js b/zeppelin-web/src/app/helium/helium-conf.js
index 10ca18a..05a58cf 100644
--- a/zeppelin-web/src/app/helium/helium-conf.js
+++ b/zeppelin-web/src/app/helium/helium-conf.js
@@ -16,84 +16,92 @@ export const HeliumConfFieldType = {
NUMBER: 'number',
JSON: 'json',
STRING: 'string',
-}
+};
/**
* @param persisted <Object> including `type`, `description`, `defaultValue` for each conf key
* @param spec <Object> including `value` for each conf key
*/
-export function mergePersistedConfWithSpec (persisted, spec) {
- const confs = []
+export function mergePersistedConfWithSpec(persisted, spec) {
+ const confs = [];
for (let name in spec) {
- const specField = spec[name]
- const persistedValue = persisted[name]
-
- const value = (persistedValue) ? persistedValue : specField.defaultValue
- const merged = {
- name: name,
- type: specField.type,
- description: specField.description,
- value: value,
- defaultValue: specField.defaultValue,
+ if (spec.hasOwnProperty(name)) {
+ const specField = spec[name];
+ const persistedValue = persisted[name];
+
+ const value = (persistedValue) ? persistedValue : specField.defaultValue;
+ const merged = {
+ name: name,
+ type: specField.type,
+ description: specField.description,
+ value: value,
+ defaultValue: specField.defaultValue,
+ };
+
+ confs.push(merged);
}
-
- confs.push(merged)
}
- return confs
+ return confs;
}
-export function createAllPackageConfigs (defaultPackages, persistedConfs) {
- let packageConfs = {}
+export function createAllPackageConfigs(defaultPackages, persistedConfs) {
+ let packageConfs = {};
for (let name in defaultPackages) {
- const pkgSearchResult = defaultPackages[name]
-
- const spec = pkgSearchResult.pkg.config
- if (!spec) { continue }
-
- const artifact = pkgSearchResult.pkg.artifact
- if (!artifact) { continue }
-
- let persistedConf = {}
- if (persistedConfs[artifact]) {
- persistedConf = persistedConfs[artifact]
+ if (defaultPackages.hasOwnProperty(name)) {
+ const pkgSearchResult = defaultPackages[name];
+
+ const spec = pkgSearchResult.pkg.config;
+ if (!spec) {
+ continue;
+ }
+
+ const artifact = pkgSearchResult.pkg.artifact;
+ if (!artifact) {
+ continue;
+ }
+
+ let persistedConf = {};
+ if (persistedConfs[artifact]) {
+ persistedConf = persistedConfs[artifact];
+ }
+
+ const confs = mergePersistedConfWithSpec(persistedConf, spec);
+ packageConfs[name] = confs;
}
-
- const confs = mergePersistedConfWithSpec(persistedConf, spec)
- packageConfs[name] = confs
}
- return packageConfs
+ return packageConfs;
}
-export function parseConfigValue (type, stringified) {
- let value = stringified
+export function parseConfigValue(type, stringified) {
+ let value = stringified;
try {
if (HeliumConfFieldType.NUMBER === type) {
- value = parseFloat(stringified)
+ value = parseFloat(stringified);
} else if (HeliumConfFieldType.JSON === type) {
- value = JSON.parse(stringified)
+ value = JSON.parse(stringified);
}
} catch (error) {
// return just the stringified one
- console.error(`Failed to parse conf type ${type}, value ${value}`)
+ console.error(`Failed to parse conf type ${type}, value ${value}`);
}
- return value
+ return value;
}
/**
* persist key-value only
* since other info (e.g type, desc) can be provided by default config
*/
-export function createPersistableConfig (currentConfs) {
+export function createPersistableConfig(currentConfs) {
const filtered = currentConfs.reduce((acc, c) => {
- acc[c.name] = parseConfigValue(c.type, c.value)
- return acc
- }, {})
+ acc[c.name] = parseConfigValue(c.type, c.value);
+ return acc;
+ }, {});
- return filtered
+ return filtered;
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/helium/helium-package.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/helium/helium-package.js b/zeppelin-web/src/app/helium/helium-package.js
index 88d191a..2fe9bf5 100644
--- a/zeppelin-web/src/app/helium/helium-package.js
+++ b/zeppelin-web/src/app/helium/helium-package.js
@@ -12,20 +12,22 @@
* limitations under the License.
*/
-export function createDefaultPackage (pkgSearchResult, sce) {
+export function createDefaultPackage(pkgSearchResult, sce) {
for (let pkgIdx in pkgSearchResult) {
- const pkg = pkgSearchResult[pkgIdx]
- pkg.pkg.icon = sce.trustAsHtml(pkg.pkg.icon)
- if (pkg.enabled) {
- pkgSearchResult.splice(pkgIdx, 1)
- return pkg
+ if (pkgSearchResult.hasOwnProperty(pkgIdx)) {
+ const pkg = pkgSearchResult[pkgIdx];
+ pkg.pkg.icon = sce.trustAsHtml(pkg.pkg.icon);
+ if (pkg.enabled) {
+ pkgSearchResult.splice(pkgIdx, 1);
+ return pkg;
+ }
}
}
// show first available version if package is not enabled
- const result = pkgSearchResult[0]
- pkgSearchResult.splice(0, 1)
- return result
+ const result = pkgSearchResult[0];
+ pkgSearchResult.splice(0, 1);
+ return result;
}
/**
@@ -35,13 +37,15 @@ export function createDefaultPackage (pkgSearchResult, sce) {
* @param sce angular `$sce` object
* @returns {Object} including {name, pkgInfo}
*/
-export function createDefaultPackages (pkgSearchResults, sce) {
- const defaultPackages = {}
+export function createDefaultPackages(pkgSearchResults, sce) {
+ const defaultPackages = {};
// show enabled version if any version of package is enabled
for (let name in pkgSearchResults) {
- const pkgSearchResult = pkgSearchResults[name]
- defaultPackages[name] = createDefaultPackage(pkgSearchResult, sce)
+ if (pkgSearchResults.hasOwnProperty(name)) {
+ const pkgSearchResult = pkgSearchResults[name];
+ defaultPackages[name] = createDefaultPackage(pkgSearchResult, sce);
+ }
}
- return defaultPackages
+ return defaultPackages;
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/helium/helium-type.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/helium/helium-type.js b/zeppelin-web/src/app/helium/helium-type.js
index 27b34fa..0b37a41 100644
--- a/zeppelin-web/src/app/helium/helium-type.js
+++ b/zeppelin-web/src/app/helium/helium-type.js
@@ -17,4 +17,4 @@ export const HeliumType = {
SPELL: 'SPELL',
INTERPRETER: 'INTERPRETER',
APPLICATION: 'APPLICATION',
-}
+};
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/ea2c9447/zeppelin-web/src/app/helium/helium.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/helium/helium.controller.js b/zeppelin-web/src/app/helium/helium.controller.js
index a397ace..4728e08 100644
--- a/zeppelin-web/src/app/helium/helium.controller.js
+++ b/zeppelin-web/src/app/helium/helium.controller.js
@@ -12,92 +12,94 @@
* limitations under the License.
*/
-import { HeliumType, } from './helium-type'
+import {HeliumType} from './helium-type';
-export default function HeliumCtrl ($scope, $rootScope, $sce,
+export default function HeliumCtrl($scope, $rootScope, $sce,
baseUrlSrv, ngToast, heliumService) {
- 'ngInject'
-
- $scope.pkgSearchResults = {}
- $scope.defaultPackages = {}
- $scope.showVersions = {}
- $scope.bundleOrder = []
- $scope.bundleOrderChanged = false
- $scope.vizTypePkg = {}
- $scope.spellTypePkg = {}
- $scope.intpTypePkg = {}
- $scope.appTypePkg = {}
- $scope.numberOfEachPackageByType = {}
- $scope.allPackageTypes = [HeliumType][0]
- $scope.pkgListByType = 'VISUALIZATION'
- $scope.defaultPackageConfigs = {} // { pkgName, [{name, type, desc, value, defaultValue}] }
- $scope.intpDefaultIcon = $sce.trustAsHtml('<img src="../assets/images/maven_default_icon.png" style="width: 12px"/>')
-
- function init () {
+ 'ngInject';
+
+ $scope.pkgSearchResults = {};
+ $scope.defaultPackages = {};
+ $scope.showVersions = {};
+ $scope.bundleOrder = [];
+ $scope.bundleOrderChanged = false;
+ $scope.vizTypePkg = {};
+ $scope.spellTypePkg = {};
+ $scope.intpTypePkg = {};
+ $scope.appTypePkg = {};
+ $scope.numberOfEachPackageByType = {};
+ $scope.allPackageTypes = [HeliumType][0];
+ $scope.pkgListByType = 'VISUALIZATION';
+ $scope.defaultPackageConfigs = {}; // { pkgName, [{name, type, desc, value, defaultValue}] }
+ $scope.intpDefaultIcon = $sce.trustAsHtml('<img src="../assets/images/maven_default_icon.png" style="width: 12px"/>');
+
+ function init() {
// get all package info and set config
heliumService.getAllPackageInfoAndDefaultPackages()
- .then(({ pkgSearchResults, defaultPackages }) => {
+ .then(({pkgSearchResults, defaultPackages}) => {
// pagination
- $scope.itemsPerPage = 10
- $scope.currentPage = 1
- $scope.maxSize = 5
+ $scope.itemsPerPage = 10;
+ $scope.currentPage = 1;
+ $scope.maxSize = 5;
- $scope.pkgSearchResults = pkgSearchResults
- $scope.defaultPackages = defaultPackages
- classifyPkgType($scope.defaultPackages)
+ $scope.pkgSearchResults = pkgSearchResults;
+ $scope.defaultPackages = defaultPackages;
+ classifyPkgType($scope.defaultPackages);
- return heliumService.getAllPackageConfigs()
+ return heliumService.getAllPackageConfigs();
})
- .then(defaultPackageConfigs => {
- $scope.defaultPackageConfigs = defaultPackageConfigs
- return heliumService.getVisualizationPackageOrder()
- })
- .then(visPackageOrder => {
- setVisPackageOrder(visPackageOrder)
+ .then((defaultPackageConfigs) => {
+ $scope.defaultPackageConfigs = defaultPackageConfigs;
+ return heliumService.getVisualizationPackageOrder();
})
+ .then((visPackageOrder) => {
+ setVisPackageOrder(visPackageOrder);
+ });
}
const setVisPackageOrder = function(visPackageOrder) {
- $scope.bundleOrder = visPackageOrder
- $scope.bundleOrderChanged = false
- }
+ $scope.bundleOrder = visPackageOrder;
+ $scope.bundleOrderChanged = false;
+ };
- let orderPackageByPubDate = function (a, b) {
+ let orderPackageByPubDate = function(a, b) {
if (!a.pkg.published) {
// Because local registry pkgs don't have 'published' field, put current time instead to show them first
- a.pkg.published = new Date().getTime()
+ a.pkg.published = new Date().getTime();
}
- return new Date(a.pkg.published).getTime() - new Date(b.pkg.published).getTime()
- }
+ return new Date(a.pkg.published).getTime() - new Date(b.pkg.published).getTime();
+ };
- const classifyPkgType = function (packageInfo) {
- let allTypesOfPkg = {}
- let vizTypePkg = []
- let spellTypePkg = []
- let intpTypePkg = []
- let appTypePkg = []
+ const classifyPkgType = function(packageInfo) {
+ let allTypesOfPkg = {};
+ let vizTypePkg = [];
+ let spellTypePkg = [];
+ let intpTypePkg = [];
+ let appTypePkg = [];
- let packageInfoArr = Object.keys(packageInfo).map(key => packageInfo[key])
- packageInfoArr = packageInfoArr.sort(orderPackageByPubDate).reverse()
+ let packageInfoArr = Object.keys(packageInfo).map((key) => packageInfo[key]);
+ packageInfoArr = packageInfoArr.sort(orderPackageByPubDate).reverse();
for (let name in packageInfoArr) {
- let pkgs = packageInfoArr[name]
- let pkgType = pkgs.pkg.type
-
- switch (pkgType) {
- case HeliumType.VISUALIZATION:
- vizTypePkg.push(pkgs)
- break
- case HeliumType.SPELL:
- spellTypePkg.push(pkgs)
- break
- case HeliumType.INTERPRETER:
- intpTypePkg.push(pkgs)
- break
- case HeliumType.APPLICATION:
- appTypePkg.push(pkgs)
- break
+ if (packageInfoArr.hasOwnProperty(name)) {
+ let pkgs = packageInfoArr[name];
+ let pkgType = pkgs.pkg.type;
+
+ switch (pkgType) {
+ case HeliumType.VISUALIZATION:
+ vizTypePkg.push(pkgs);
+ break;
+ case HeliumType.SPELL:
+ spellTypePkg.push(pkgs);
+ break;
+ case HeliumType.INTERPRETER:
+ intpTypePkg.push(pkgs);
+ break;
+ case HeliumType.APPLICATION:
+ appTypePkg.push(pkgs);
+ break;
+ }
}
}
@@ -105,95 +107,99 @@ export default function HeliumCtrl ($scope, $rootScope, $sce,
vizTypePkg,
spellTypePkg,
intpTypePkg,
- appTypePkg
- ]
+ appTypePkg,
+ ];
for (let idx in _.keys(HeliumType)) {
- allTypesOfPkg[_.keys(HeliumType)[idx]] = pkgsArr[idx]
+ if (_.keys(HeliumType).hasOwnProperty(idx)) {
+ allTypesOfPkg[_.keys(HeliumType)[idx]] = pkgsArr[idx];
+ }
}
- $scope.allTypesOfPkg = allTypesOfPkg
- }
+ $scope.allTypesOfPkg = allTypesOfPkg;
+ };
$scope.bundleOrderListeners = {
- accept: function (sourceItemHandleScope, destSortableScope) { return true },
- itemMoved: function (event) {},
- orderChanged: function (event) {
- $scope.bundleOrderChanged = true
- }
- }
-
- $scope.saveBundleOrder = function () {
+ accept: function(sourceItemHandleScope, destSortableScope) {
+ return true;
+ },
+ itemMoved: function(event) {},
+ orderChanged: function(event) {
+ $scope.bundleOrderChanged = true;
+ },
+ };
+
+ $scope.saveBundleOrder = function() {
const confirm = BootstrapDialog.confirm({
closable: false,
closeByBackdrop: false,
closeByKeyboard: false,
title: '',
message: 'Save changes?',
- callback: function (result) {
+ callback: function(result) {
if (result) {
- confirm.$modalFooter.find('button').addClass('disabled')
+ confirm.$modalFooter.find('button').addClass('disabled');
confirm.$modalFooter.find('button:contains("OK")')
- .html('<i class="fa fa-circle-o-notch fa-spin"></i> Enabling')
+ .html('<i class="fa fa-circle-o-notch fa-spin"></i> Enabling');
heliumService.setVisualizationPackageOrder($scope.bundleOrder)
- .success(function (data, status) {
- setVisPackageOrder($scope.bundleOrder)
- confirm.close()
+ .success(function(data, status) {
+ setVisPackageOrder($scope.bundleOrder);
+ confirm.close();
})
- .error(function (data, status) {
- confirm.close()
- console.log('Failed to save order')
+ .error(function(data, status) {
+ confirm.close();
+ console.log('Failed to save order');
BootstrapDialog.show({
title: 'Error on saving order ',
- message: data.message
- })
- })
- return false
+ message: data.message,
+ });
+ });
+ return false;
}
- }
- })
- }
+ },
+ });
+ };
- let getLicense = function (name, artifact) {
- let filteredPkgSearchResults = _.filter($scope.defaultPackages[name], function (p) {
- return p.artifact === artifact
- })
+ let getLicense = function(name, artifact) {
+ let filteredPkgSearchResults = _.filter($scope.defaultPackages[name], function(p) {
+ return p.artifact === artifact;
+ });
- let license
+ let license;
if (filteredPkgSearchResults.length === 0) {
- filteredPkgSearchResults = _.filter($scope.pkgSearchResults[name], function (p) {
- return p.pkg.artifact === artifact
- })
+ filteredPkgSearchResults = _.filter($scope.pkgSearchResults[name], function(p) {
+ return p.pkg.artifact === artifact;
+ });
if (filteredPkgSearchResults.length > 0) {
- license = filteredPkgSearchResults[0].pkg.license
+ license = filteredPkgSearchResults[0].pkg.license;
}
} else {
- license = filteredPkgSearchResults[0].license
+ license = filteredPkgSearchResults[0].license;
}
if (!license) {
- license = 'Unknown'
+ license = 'Unknown';
}
- return license
- }
+ return license;
+ };
- const getHeliumTypeText = function (type) {
+ const getHeliumTypeText = function(type) {
if (type === HeliumType.VISUALIZATION) {
- return `<a target="_blank" href="https://zeppelin.apache.org/docs/${$rootScope.zeppelinVersion}/development/helium/writing_visualization.html">${type}</a>` // eslint-disable-line max-len
+ return `<a target="_blank" href="https://zeppelin.apache.org/docs/${$rootScope.zeppelinVersion}/development/helium/writing_visualization.html">${type}</a>`; // eslint-disable-line max-len
} else if (type === HeliumType.SPELL) {
- return `<a target="_blank" href="https://zeppelin.apache.org/docs/${$rootScope.zeppelinVersion}/development/helium/writing_spell.html">${type}</a>` // eslint-disable-line max-len
+ return `<a target="_blank" href="https://zeppelin.apache.org/docs/${$rootScope.zeppelinVersion}/development/helium/writing_spell.html">${type}</a>`; // eslint-disable-line max-len
} else {
- return type
+ return type;
}
- }
+ };
- $scope.enable = function (name, artifact, type, groupId, description) {
- let license = getLicense(name, artifact)
- let mavenArtifactInfoToHTML = groupId + ':' + artifact.split('@')[0] + ':' + artifact.split('@')[1]
- let zeppelinVersion = $rootScope.zeppelinVersion
- let url = 'https://zeppelin.apache.org/docs/' + zeppelinVersion + '/manual/interpreterinstallation.html'
+ $scope.enable = function(name, artifact, type, groupId, description) {
+ let license = getLicense(name, artifact);
+ let mavenArtifactInfoToHTML = groupId + ':' + artifact.split('@')[0] + ':' + artifact.split('@')[1];
+ let zeppelinVersion = $rootScope.zeppelinVersion;
+ let url = 'https://zeppelin.apache.org/docs/' + zeppelinVersion + '/manual/interpreterinstallation.html';
- let confirm = ''
+ let confirm = '';
if (type === HeliumType.INTERPRETER) {
confirm = BootstrapDialog.show({
title: '',
@@ -206,8 +212,8 @@ export default function HeliumCtrl ($scope, $rootScope, $sce,
mavenArtifactInfoToHTML + ' </code></pre>' +
'<p>After restart Zeppelin, create interpreter setting and bind it with your note. ' +
'For more detailed information, see <a target="_blank" href=' +
- url + '>Interpreter Installation.</a></p>'
- })
+ url + '>Interpreter Installation.</a></p>',
+ });
} else {
confirm = BootstrapDialog.confirm({
closable: false,
@@ -226,138 +232,138 @@ export default function HeliumCtrl ($scope, $rootScope, $sce,
'<hr style="margin-top: 10px; margin-bottom: 10px;" />' +
'<div style="font-size: 14px;">License</div>' +
`<div style="color:gray">${license}</div>`,
- callback: function (result) {
+ callback: function(result) {
if (result) {
- confirm.$modalFooter.find('button').addClass('disabled')
+ confirm.$modalFooter.find('button').addClass('disabled');
confirm.$modalFooter.find('button:contains("OK")')
- .html('<i class="fa fa-circle-o-notch fa-spin"></i> Enabling')
- heliumService.enable(name, artifact, type).success(function (data, status) {
- init()
- confirm.close()
- }).error(function (data, status) {
- confirm.close()
- console.log('Failed to enable package %o %o. %o', name, artifact, data)
+ .html('<i class="fa fa-circle-o-notch fa-spin"></i> Enabling');
+ heliumService.enable(name, artifact, type).success(function(data, status) {
+ init();
+ confirm.close();
+ }).error(function(data, status) {
+ confirm.close();
+ console.log('Failed to enable package %o %o. %o', name, artifact, data);
BootstrapDialog.show({
title: 'Error on enabling ' + name,
- message: data.message
- })
- })
- return false
+ message: data.message,
+ });
+ });
+ return false;
}
- }
- })
+ },
+ });
}
- }
+ };
- $scope.disable = function (name, artifact) {
+ $scope.disable = function(name, artifact) {
const confirm = BootstrapDialog.confirm({
closable: false,
closeByBackdrop: false,
closeByKeyboard: false,
title: '<div style="font-weight: 300;">Do you want to disable Helium Package?</div>',
message: artifact,
- callback: function (result) {
+ callback: function(result) {
if (result) {
- confirm.$modalFooter.find('button').addClass('disabled')
+ confirm.$modalFooter.find('button').addClass('disabled');
confirm.$modalFooter.find('button:contains("OK")')
- .html('<i class="fa fa-circle-o-notch fa-spin"></i> Disabling')
+ .html('<i class="fa fa-circle-o-notch fa-spin"></i> Disabling');
heliumService.disable(name)
- .success(function (data, status) {
- init()
- confirm.close()
+ .success(function(data, status) {
+ init();
+ confirm.close();
})
- .error(function (data, status) {
- confirm.close()
- console.log('Failed to disable package %o. %o', name, data)
+ .error(function(data, status) {
+ confirm.close();
+ console.log('Failed to disable package %o. %o', name, data);
BootstrapDialog.show({
title: 'Error on disabling ' + name,
- message: data.message
- })
- })
- return false
+ message: data.message,
+ });
+ });
+ return false;
}
- }
- })
- }
+ },
+ });
+ };
- $scope.toggleVersions = function (pkgName) {
+ $scope.toggleVersions = function(pkgName) {
if ($scope.showVersions[pkgName]) {
- $scope.showVersions[pkgName] = false
+ $scope.showVersions[pkgName] = false;
} else {
- $scope.showVersions[pkgName] = true
+ $scope.showVersions[pkgName] = true;
}
- }
+ };
- $scope.isLocalPackage = function (pkgSearchResult) {
- const pkg = pkgSearchResult.pkg
- return pkg.artifact && !pkg.artifact.includes('@')
- }
+ $scope.isLocalPackage = function(pkgSearchResult) {
+ const pkg = pkgSearchResult.pkg;
+ return pkg.artifact && !pkg.artifact.includes('@');
+ };
- $scope.hasNpmLink = function (pkgSearchResult) {
- const pkg = pkgSearchResult.pkg
+ $scope.hasNpmLink = function(pkgSearchResult) {
+ const pkg = pkgSearchResult.pkg;
return (pkg.type === HeliumType.SPELL || pkg.type === HeliumType.VISUALIZATION) &&
- !$scope.isLocalPackage(pkgSearchResult)
- }
+ !$scope.isLocalPackage(pkgSearchResult);
+ };
- $scope.hasMavenLink = function (pkgSearchResult) {
- const pkg = pkgSearchResult.pkg
+ $scope.hasMavenLink = function(pkgSearchResult) {
+ const pkg = pkgSearchResult.pkg;
return (pkg.type === HeliumType.APPLICATION || pkg.type === HeliumType.INTERPRETER) &&
- !$scope.isLocalPackage(pkgSearchResult)
- }
-
- $scope.getPackageSize = function (pkgSearchResult, targetPkgType) {
- let result = []
- _.map(pkgSearchResult, function (pkg) {
- result.push(_.find(pkg, {type: targetPkgType}))
- })
- return _.compact(result).length
- }
-
- $scope.configExists = function (pkgSearchResult) {
+ !$scope.isLocalPackage(pkgSearchResult);
+ };
+
+ $scope.getPackageSize = function(pkgSearchResult, targetPkgType) {
+ let result = [];
+ _.map(pkgSearchResult, function(pkg) {
+ result.push(_.find(pkg, {type: targetPkgType}));
+ });
+ return _.compact(result).length;
+ };
+
+ $scope.configExists = function(pkgSearchResult) {
// helium package config is persisted per version
- return pkgSearchResult.pkg.config && pkgSearchResult.pkg.artifact
- }
+ return pkgSearchResult.pkg.config && pkgSearchResult.pkg.artifact;
+ };
- $scope.configOpened = function (pkgSearchResult) {
- return pkgSearchResult.configOpened && !pkgSearchResult.configFetching
- }
+ $scope.configOpened = function(pkgSearchResult) {
+ return pkgSearchResult.configOpened && !pkgSearchResult.configFetching;
+ };
- $scope.getConfigButtonClass = function (pkgSearchResult) {
+ $scope.getConfigButtonClass = function(pkgSearchResult) {
return (pkgSearchResult.configOpened && pkgSearchResult.configFetching)
- ? 'disabled' : ''
- }
+ ? 'disabled' : '';
+ };
- $scope.toggleConfigButton = function (pkgSearchResult) {
+ $scope.toggleConfigButton = function(pkgSearchResult) {
if (pkgSearchResult.configOpened) {
- pkgSearchResult.configOpened = false
- return
+ pkgSearchResult.configOpened = false;
+ return;
}
- const pkg = pkgSearchResult.pkg
- const pkgName = pkg.name
- pkgSearchResult.configFetching = true
- pkgSearchResult.configOpened = true
+ const pkg = pkgSearchResult.pkg;
+ const pkgName = pkg.name;
+ pkgSearchResult.configFetching = true;
+ pkgSearchResult.configOpened = true;
heliumService.getSinglePackageConfigs(pkg)
- .then(confs => {
- $scope.defaultPackageConfigs[pkgName] = confs
- pkgSearchResult.configFetching = false
- })
- }
+ .then((confs) => {
+ $scope.defaultPackageConfigs[pkgName] = confs;
+ pkgSearchResult.configFetching = false;
+ });
+ };
- $scope.saveConfig = function (pkgSearchResult) {
- const pkgName = pkgSearchResult.pkg.name
- const currentConf = $scope.defaultPackageConfigs[pkgName]
+ $scope.saveConfig = function(pkgSearchResult) {
+ const pkgName = pkgSearchResult.pkg.name;
+ const currentConf = $scope.defaultPackageConfigs[pkgName];
heliumService.saveConfig(pkgSearchResult.pkg, currentConf, () => {
// close after config is saved
- pkgSearchResult.configOpened = false
- })
- }
+ pkgSearchResult.configOpened = false;
+ });
+ };
- $scope.getDescriptionText = function (pkgSearchResult) {
- return $sce.trustAsHtml(pkgSearchResult.pkg.description)
- }
+ $scope.getDescriptionText = function(pkgSearchResult) {
+ return $sce.trustAsHtml(pkgSearchResult.pkg.description);
+ };
- init()
+ init();
}