zeppelin/zeppelin-web/src/app/notebookRepos/notebookRepos.controller.js
1ambda 19b0f30f8d [ZEPPELIN-1940] lint rule set is NOT applied at all.
### What is this PR for?

eslint ruleset is NOT applied at all due to invalid `.eslintrc`.

This PR includes

- fixes which are automatically done by eslint (`eslint --fix src`)
- modification in `.eslintrc`, `package.json`
- while removing eslint conf in `gruntfile.js`

As a result of this PR, we can have more strict and modernized rulesets which can help us to prevent bugs.

### What type of PR is it?
[Improvement]

### Todos
* [x] - Setup rules
* [x] - Remove grunt eslint config
* [x] - Ignore useless rules
* [x] - Fix code for applied rules

### What is the Jira issue?

[ZEPPELIN-1940](https://issues.apache.org/jira/browse/ZEPPELIN-1940)

### How should this be tested?

- `cd zeppelin-web`
- `npm install` (or `yarn install` if you have yarn)
- `npm run lint:once`

### Screenshots (if appropriate)

### Questions:
* Does the licenses files need update? - NO
* Is there breaking changes for older versions? - NO
* Does this needs documentation? - NO

Author: 1ambda <[email protected]>

Closes #2252 from 1ambda/ZEPPELIN-1940/apply-lint-rule-set and squashes the following commits:

d3e6c0a [1ambda] fix: eslint errors for #2245
013d7ca [1ambda] fix: eslint errors for #2244
6feb158 [1ambda] fix: eslint errors for #2133
02545c7 [1ambda] fix: eslint for #2203, #2248
4ab8a39 [1ambda] fix: eslint errors for #2228
cc874d2 [1ambda] fix: semi
d4a8082 [1ambda] fix: lint for src/app/tabledata/advanced-
4d991a2 [1ambda] fix: ignore array-bracket-spacing
d69113a [1ambda] fix: ignore space-before-function-paren
526dbeb [1ambda] fix: no-var
3fd91fe [1ambda] fix: no-redeclare
a5947da [1ambda] fix: prefer-spread
a20d20e [1ambda] fix: prefer-rest-params
e3f9641 [1ambda] fix: no-unused-expressions
bd981d7 [1ambda] fix: ignore no-unneeded-ternary
c52b095 [1ambda] fix: no-useless-constructor
83d6789 [1ambda] fix: no-eval
7a740b5 [1ambda] fix: ignore comma-dangle
7d3b393 [1ambda] fix: ignore standard/object-curly-even-spacing
a3f1264 [1ambda] fix: padded-blocks
5d19c6f [1ambda] fix: space-infix-ops
eac6b43 [1ambda] fix: no-extra-semi
bfd7984 [1ambda] fix: ignore arrow-parens
3c91566 [1ambda] fix: ignore object-curly-spacing
6e44e96 [1ambda] fix: space-before-function-paren
59c3996 [1ambda] fix: indent
40125e9 [1ambda] fix: no-multiple-empty-lines
3a6626f [1ambda] fix: no-trailing-spaces
ca94341 [1ambda] fix: spaced-comment
d65c47b [1ambda] fix: comma-spacing
9150539 [1ambda] fix: operator-linebreak
925dc7b [1ambda] fix: block-spacing
021f9e7 [1ambda] fix: space-before-blocks
a896442 [1ambda] fix: keyword-spacing
5948d97 [1ambda] fix: space-in-parens
b094fff [1ambda] fix: no-empty
131c901 [1ambda] fix: no-multi-spaces
1de9a8d [1ambda] fix: one-var
7aa4b1a [1ambda] fix: brace-style
cde8a2d [1ambda] fix: dot-location
d62af8d [1ambda] fix: object-property-newline
70cb63b [1ambda] fix: no-extra-boolean-cast
a5c7842 [1ambda] fix: semi-spacing
3abfc7c [1ambda] fix: no-mixed-spaces-and-tabs
8d5a3d9 [1ambda] fix: yoda
4b36afb [1ambda] fix: ignore all rules
7840ca5 [1ambda] fix: Set ignored, warn lint rules
5566911 [1ambda] fix: Remove invalid visdev
4baadbb [1ambda] fix: Use eslint instead of grunt-eslint
2017-04-20 13:52:34 +09:00

87 lines
2.6 KiB
JavaScript

/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
angular.module('zeppelinWebApp').controller('NotebookReposCtrl', NotebookReposCtrl)
function NotebookReposCtrl ($http, baseUrlSrv, ngToast) {
'ngInject'
let vm = this
vm.notebookRepos = []
vm.showDropdownSelected = showDropdownSelected
vm.saveNotebookRepo = saveNotebookRepo
_init()
// Public functions
function saveNotebookRepo (valueform, repo, data) {
console.log('data %o', data)
$http.put(baseUrlSrv.getRestApiBase() + '/notebook-repositories', {
'name': repo.className,
'settings': data
}).success(function (data) {
let index = _.findIndex(vm.notebookRepos, {'className': repo.className})
if (index >= 0) {
vm.notebookRepos[index] = data.body
console.log('repos %o, data %o', vm.notebookRepos, data.body)
}
valueform.$show()
}).error(function () {
ngToast.danger({
content: 'We couldn\'t save that NotebookRepo\'s settings',
verticalPosition: 'bottom',
timeout: '3000'
})
valueform.$show()
})
return 'manual'
}
function showDropdownSelected (setting) {
let index = _.findIndex(setting.value, {'value': setting.selected})
if (index < 0) {
return 'No value'
} else {
return setting.value[index].name
}
}
// Private functions
function _getInterpreterSettings () {
$http.get(baseUrlSrv.getRestApiBase() + '/notebook-repositories')
.success(function (data, status, headers, config) {
vm.notebookRepos = data.body
console.log('ya notebookRepos %o', vm.notebookRepos)
}).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.replace('/')
}, 3000)
}
console.log('Error %o %o', status, data.message)
})
}
function _init () {
_getInterpreterSettings()
}
}