Skip to content

Commit

Permalink
[apache#1778] improvement(dashboard): Dashboard adds the ability to a…
Browse files Browse the repository at this point in the history
…utomatically format code. (apache#1779)

### What changes were proposed in this pull request?

Introducing the front-end eslint code validation tool and formatting the front-end code.

### Why are the changes needed?

Fix: apache#1778 

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Existential test.
  • Loading branch information
yl09099 authored Jun 15, 2024
1 parent 5ba2df8 commit 8eff38e
Show file tree
Hide file tree
Showing 39 changed files with 659 additions and 608 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
* limitations under the License.
*/

package org.apache.uniffle.coordinator.web.resource;
package org.apache.uniffle.common.web.resource;

import java.util.concurrent.Callable;

import org.apache.uniffle.coordinator.web.Response;

public abstract class BaseResource {
protected <T> Response<T> execute(Callable<T> callable) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.uniffle.coordinator.web;
package org.apache.uniffle.common.web.resource;

public class Response<T> {
private static final int SUCCESS_CODE = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.uniffle.common.web.resource.BaseResource;
import org.apache.uniffle.common.web.resource.Response;
import org.apache.uniffle.coordinator.AccessManager;
import org.apache.uniffle.coordinator.ServerNode;
import org.apache.uniffle.coordinator.access.checker.AccessChecker;
import org.apache.uniffle.coordinator.web.Response;

@Produces({MediaType.APPLICATION_JSON})
public class AdminResource extends BaseResource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
import org.apache.hbase.thirdparty.javax.ws.rs.core.Context;
import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType;

import org.apache.uniffle.common.web.resource.BaseResource;
import org.apache.uniffle.common.web.resource.Response;
import org.apache.uniffle.coordinator.ApplicationManager;
import org.apache.uniffle.coordinator.web.Response;
import org.apache.uniffle.coordinator.web.vo.AppInfoVO;
import org.apache.uniffle.coordinator.web.vo.UserAppNumVO;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType;

import org.apache.uniffle.common.util.RssUtils;
import org.apache.uniffle.common.web.resource.BaseResource;
import org.apache.uniffle.common.web.resource.Response;
import org.apache.uniffle.coordinator.CoordinatorConf;
import org.apache.uniffle.coordinator.CoordinatorServer;
import org.apache.uniffle.coordinator.util.CoordinatorUtils;
import org.apache.uniffle.coordinator.web.Response;
import org.apache.uniffle.coordinator.web.vo.CoordinatorConfVO;

import static org.apache.uniffle.common.config.RssBaseConf.JETTY_HTTP_PORT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@

import org.apache.uniffle.common.Application;
import org.apache.uniffle.common.ServerStatus;
import org.apache.uniffle.common.web.resource.BaseResource;
import org.apache.uniffle.common.web.resource.Response;
import org.apache.uniffle.coordinator.ApplicationManager;
import org.apache.uniffle.coordinator.ClusterManager;
import org.apache.uniffle.coordinator.ServerNode;
import org.apache.uniffle.coordinator.web.Response;
import org.apache.uniffle.coordinator.web.request.ApplicationRequest;
import org.apache.uniffle.coordinator.web.request.CancelDecommissionRequest;
import org.apache.uniffle.coordinator.web.request.DecommissionRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.apache.uniffle.coordinator.GenericTestUtils;
import org.apache.uniffle.coordinator.web.request.ApplicationRequest;

import static org.apache.uniffle.coordinator.web.Response.fail;
import static org.apache.uniffle.common.web.resource.Response.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import org.apache.hbase.thirdparty.javax.ws.rs.core.Context;
import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType;

import org.apache.uniffle.common.web.resource.BaseResource;
import org.apache.uniffle.common.web.resource.Response;

@Produces({MediaType.APPLICATION_JSON})
public class CoordinatorResource extends BaseResource {

Expand Down

This file was deleted.

21 changes: 21 additions & 0 deletions dashboard/src/main/webapp/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#

/node_modules
/package-lock.json
/dist
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@
* limitations under the License.
*/

package org.apache.uniffle.dashboard.web.resource;

import java.util.concurrent.Callable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class BaseResource {
private static final Logger LOG = LoggerFactory.getLogger(BaseResource.class);

protected <T> Response<T> execute(Callable<T> callable) {
try {
return Response.success(callable.call());
} catch (Throwable e) {
LOG.error("Call failure:", e);
return Response.fail(e.getMessage());
}
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
node: true
},
extends: ['plugin:vue/essential', 'standard', '@vue/prettier'],
parserOptions: {
ecmaVersion: 13
},
plugins: ['vue'],
rules: {
quotes: [2, 'single']
}
}
25 changes: 25 additions & 0 deletions dashboard/src/main/webapp/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"___asflicense__": [
"",
"Licensed to the Apache Software Foundation (ASF) under one",
"or more contributor license agreements. See the NOTICE file",
"distributed with this work for additional information",
"regarding copyright ownership. The ASF licenses this file",
"to you 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."
],
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}
4 changes: 1 addition & 3 deletions dashboard/src/main/webapp/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@
*/

module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
presets: ['@vue/cli-plugin-babel/preset']
}
11 changes: 2 additions & 9 deletions dashboard/src/main/webapp/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,8 @@
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
"@/*": ["src/*"]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
}
}
33 changes: 10 additions & 23 deletions dashboard/src/main/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,18 @@
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "^5.0.8",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"@vue/eslint-config-prettier": "^9.0.0",
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.2.0",
"eslint-plugin-vue": "^9.26.0",
"node-sass": "^9.0.0",
"prettier": "^3.3.2",
"sass-loader": "^13.3.1",
"vue-loader": "^17.2.2",
"vue-template-compiler": "^2.7.14"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
}
12 changes: 6 additions & 6 deletions dashboard/src/main/webapp/packagescript/cleanfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const nodeModulesPath = p.join(__dirname, '../node_modules')
const lockJsonPath = p.join(__dirname, '../package-lock.json')

if (fs.existsSync(nodeModulesPath)) {
const fileUtil = require('./fileutils')
const fileUtil = require('./fileutils')

//fileUtil.deleteFolderByRimraf(nodeModulesPath)
fileUtil.deleteFolder(nodeModulesPath)
console.log('Deleted node_modules successfully!')
// fileUtil.deleteFolderByRimraf(nodeModulesPath)
fileUtil.deleteFolder(nodeModulesPath)
console.log('Deleted node_modules successfully!')

fileUtil.deleteFile(lockJsonPath)
console.log('Delete package-lock.json successfully!')
fileUtil.deleteFile(lockJsonPath)
console.log('Delete package-lock.json successfully!')
}
Loading

0 comments on commit 8eff38e

Please sign in to comment.