From 2c492654d890a4f9db87fd46125aeb87de11497a Mon Sep 17 00:00:00 2001 From: yl09099 Date: Thu, 13 Jun 2024 10:29:43 +0800 Subject: [PATCH] [#1778][Improvement] Dashboard adds the ability to automatically format code. --- dashboard/src/main/webapp/.eslintignore | 4 + dashboard/src/main/webapp/.eslintrc.js | 14 +-- dashboard/src/main/webapp/.prettierrc.json | 26 +++++ dashboard/src/main/webapp/babel.config.js | 4 +- dashboard/src/main/webapp/jsconfig.json | 11 +-- .../main/webapp/packagescript/cleanfile.js | 18 ++-- .../src/main/webapp/packagescript/filecopy.js | 10 +- .../main/webapp/packagescript/fileutils.js | 52 +++++----- dashboard/src/main/webapp/public/index.html | 15 +-- dashboard/src/main/webapp/src/App.vue | 2 +- dashboard/src/main/webapp/src/api/api.js | 28 +++--- .../main/webapp/src/components/LayoutPage.vue | 44 +++++---- dashboard/src/main/webapp/src/main.js | 24 ++--- .../main/webapp/src/pages/ApplicationPage.vue | 48 +++++----- .../src/pages/CoordinatorServerPage.vue | 55 +++++------ .../webapp/src/pages/ShuffleServerPage.vue | 40 ++++---- .../pages/serverstatus/ActiveNodeListPage.vue | 67 ++++++++----- .../DecommissionednodeListPage.vue | 69 +++++++------ .../DecommissioningNodeListPage.vue | 71 ++++++++------ .../pages/serverstatus/ExcludeNodeList.vue | 22 ++--- .../src/pages/serverstatus/LostNodeList.vue | 71 ++++++++------ .../serverstatus/UnhealthyNodeListPage.vue | 70 ++++++++------ dashboard/src/main/webapp/src/router/index.js | 96 +++++++++---------- .../webapp/src/store/useCurrentServerStore.js | 12 +-- dashboard/src/main/webapp/src/utils/common.js | 26 ++--- dashboard/src/main/webapp/src/utils/http.js | 38 ++++---- .../src/main/webapp/src/utils/request.js | 56 +++++------ dashboard/src/main/webapp/vue.config.js | 16 ++-- 28 files changed, 552 insertions(+), 457 deletions(-) create mode 100644 dashboard/src/main/webapp/.eslintignore create mode 100644 dashboard/src/main/webapp/.prettierrc.json diff --git a/dashboard/src/main/webapp/.eslintignore b/dashboard/src/main/webapp/.eslintignore new file mode 100644 index 0000000000..952e9f633e --- /dev/null +++ b/dashboard/src/main/webapp/.eslintignore @@ -0,0 +1,4 @@ +/node_modules +/package-lock.json +/dist +.DS_Store \ No newline at end of file diff --git a/dashboard/src/main/webapp/.eslintrc.js b/dashboard/src/main/webapp/.eslintrc.js index e05fa6948d..71e913eecd 100644 --- a/dashboard/src/main/webapp/.eslintrc.js +++ b/dashboard/src/main/webapp/.eslintrc.js @@ -20,12 +20,14 @@ module.exports = { browser: true, commonjs: true, es2021: true, - node: true, + node: true }, - extends: ["plugin:vue/essential", "standard", "@vue/prettier"], + extends: ['plugin:vue/essential', 'standard', '@vue/prettier'], parserOptions: { - ecmaVersion: 12, + ecmaVersion: 13 }, - plugins: ["vue"], - rules: {}, -}; + plugins: ['vue'], + rules: { + quotes: [2, 'single'] + } +} diff --git a/dashboard/src/main/webapp/.prettierrc.json b/dashboard/src/main/webapp/.prettierrc.json new file mode 100644 index 0000000000..933d6fbea2 --- /dev/null +++ b/dashboard/src/main/webapp/.prettierrc.json @@ -0,0 +1,26 @@ +{ + "___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" +} diff --git a/dashboard/src/main/webapp/babel.config.js b/dashboard/src/main/webapp/babel.config.js index 5e4045d0e3..8f440e2115 100644 --- a/dashboard/src/main/webapp/babel.config.js +++ b/dashboard/src/main/webapp/babel.config.js @@ -16,5 +16,5 @@ */ module.exports = { - presets: ["@vue/cli-plugin-babel/preset"], -}; + presets: ['@vue/cli-plugin-babel/preset'] +} diff --git a/dashboard/src/main/webapp/jsconfig.json b/dashboard/src/main/webapp/jsconfig.json index bb01e412c4..ee50273037 100644 --- a/dashboard/src/main/webapp/jsconfig.json +++ b/dashboard/src/main/webapp/jsconfig.json @@ -23,15 +23,8 @@ "baseUrl": "./", "moduleResolution": "node", "paths": { - "@/*": [ - "src/*" - ] + "@/*": ["src/*"] }, - "lib": [ - "esnext", - "dom", - "dom.iterable", - "scripthost" - ] + "lib": ["esnext", "dom", "dom.iterable", "scripthost"] } } diff --git a/dashboard/src/main/webapp/packagescript/cleanfile.js b/dashboard/src/main/webapp/packagescript/cleanfile.js index ed5d24efde..bd4af60cfd 100644 --- a/dashboard/src/main/webapp/packagescript/cleanfile.js +++ b/dashboard/src/main/webapp/packagescript/cleanfile.js @@ -15,19 +15,19 @@ * limitations under the License. */ -const fs = require("fs"); -const p = require("path"); +const fs = require('fs') +const p = require('path') -const nodeModulesPath = p.join(__dirname, "../node_modules"); -const lockJsonPath = p.join(__dirname, "../package-lock.json"); +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.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!') } diff --git a/dashboard/src/main/webapp/packagescript/filecopy.js b/dashboard/src/main/webapp/packagescript/filecopy.js index a4519fedee..9966d0a86d 100644 --- a/dashboard/src/main/webapp/packagescript/filecopy.js +++ b/dashboard/src/main/webapp/packagescript/filecopy.js @@ -15,12 +15,12 @@ * limitations under the License. */ -const fileUtil = require("./fileutils"); +const fileUtil = require('./fileutils') // Destination folder -const staticDirectory = "../resources/static"; +const staticDirectory = '../resources/static' // Delete -fileUtil.deleteFolder(staticDirectory); +fileUtil.deleteFolder(staticDirectory) // Copy -fileUtil.copyFolder("./dist", staticDirectory); -console.log("File copy successful!"); +fileUtil.copyFolder('./dist', staticDirectory) +console.log('File copy successful!') diff --git a/dashboard/src/main/webapp/packagescript/fileutils.js b/dashboard/src/main/webapp/packagescript/fileutils.js index bea83f9c51..7021b3d4fe 100644 --- a/dashboard/src/main/webapp/packagescript/fileutils.js +++ b/dashboard/src/main/webapp/packagescript/fileutils.js @@ -15,29 +15,29 @@ * limitations under the License. */ -const fs = require("fs"); -const pathName = require("path"); +const fs = require('fs') +const pathName = require('path') /** * Delete folder * @param path Path of the folder to be deleted */ function deleteFolder(path) { - let files = []; + let files = [] if (fs.existsSync(path)) { if (fs.statSync(path).isDirectory()) { - files = fs.readdirSync(path); + files = fs.readdirSync(path) files.forEach((file) => { - const curPath = path + "/" + file; + const curPath = path + '/' + file if (fs.statSync(curPath).isDirectory()) { - deleteFolder(curPath); + deleteFolder(curPath) } else { - fs.unlinkSync(curPath); + fs.unlinkSync(curPath) } - }); - fs.rmdirSync(path); + }) + fs.rmdirSync(path) } else { - fs.unlinkSync(path); + fs.unlinkSync(path) } } } @@ -49,9 +49,9 @@ function deleteFolder(path) { function deleteFile(path) { if (fs.existsSync(path)) { if (fs.statSync(path).isDirectory()) { - deleteFolder(path); + deleteFolder(path) } else { - fs.unlinkSync(path); + fs.unlinkSync(path) } } } @@ -62,36 +62,36 @@ function deleteFile(path) { * @param to Target directory */ function copyFolder(from, to) { - let files = []; + let files = [] // Whether the file exists If it does not exist, it is created if (fs.existsSync(to)) { - files = fs.readdirSync(from); + files = fs.readdirSync(from) files.forEach((file) => { - const targetPath = from + "/" + file; - const toPath = to + "/" + file; + const targetPath = from + '/' + file + const toPath = to + '/' + file // Copy folder if (fs.statSync(targetPath).isDirectory()) { - copyFolder(targetPath, toPath); + copyFolder(targetPath, toPath) } else { // Copy file - fs.copyFileSync(targetPath, toPath); + fs.copyFileSync(targetPath, toPath) } - }); + }) } else { - mkdirsSync(to); - copyFolder(from, to); + mkdirsSync(to) + copyFolder(from, to) } } // Create a directory synchronization method recursively function mkdirsSync(dirname) { if (fs.existsSync(dirname)) { - return true; + return true } else { if (mkdirsSync(pathName.dirname(dirname))) { - fs.mkdirSync(dirname); - return true; + fs.mkdirSync(dirname) + return true } } } @@ -99,5 +99,5 @@ function mkdirsSync(dirname) { module.exports = { deleteFolder, deleteFile, - copyFolder, -}; + copyFolder +} diff --git a/dashboard/src/main/webapp/public/index.html b/dashboard/src/main/webapp/public/index.html index d703f0fe3a..6d36f664eb 100644 --- a/dashboard/src/main/webapp/public/index.html +++ b/dashboard/src/main/webapp/public/index.html @@ -15,18 +15,21 @@ ~ limitations under the License. --> - + - - - - + + + + <%= htmlWebpackPlugin.options.title %>
diff --git a/dashboard/src/main/webapp/src/App.vue b/dashboard/src/main/webapp/src/App.vue index deaa982ad1..1eb251396e 100644 --- a/dashboard/src/main/webapp/src/App.vue +++ b/dashboard/src/main/webapp/src/App.vue @@ -20,7 +20,7 @@