From 5eb3190bd23483f0170d29552480c5e3e88a72aa Mon Sep 17 00:00:00 2001 From: zhaochongyu Date: Thu, 13 May 2021 16:33:34 +0800 Subject: [PATCH 1/8] features updating --- index.html | 2 +- src/api/homeTable.js | 3 +- src/components/Dialogs/Dialogs.vue | 198 ++++++++++++------ src/components/HomeTable/HomeTable.vue | 33 ++- .../Layout/Operations/Operations.vue | 44 ++-- 5 files changed, 188 insertions(+), 92 deletions(-) diff --git a/index.html b/index.html index c954583..5fbbb9d 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - HA-VUE + openUnicorn HA
diff --git a/src/api/homeTable.js b/src/api/homeTable.js index 15b7976..c162755 100644 --- a/src/api/homeTable.js +++ b/src/api/homeTable.js @@ -141,11 +141,10 @@ export function standbyAction(url) { } -export function runAction(url, data) { +export function runAction(url) { return request({ url, method: 'put', - data }) diff --git a/src/components/Dialogs/Dialogs.vue b/src/components/Dialogs/Dialogs.vue index ffc22d1..b5e0259 100644 --- a/src/components/Dialogs/Dialogs.vue +++ b/src/components/Dialogs/Dialogs.vue @@ -5,12 +5,17 @@ :visible.sync="isVisible" width="700px" :before-close="closeDialog" + v-if="isRouterShow" >
{{ title }}
- + - - + 刷新 - + { - if(_this.chosenItem.running_node.indexOf(item.id) == -1) { - _this.migrateNodes.push(item.id) + _this.nodeLists.forEach((item) => { + if (_this.chosenItem.running_node.indexOf(item.id) == -1) { + _this.migrateNodes.push(item.id); } - }) + }); _this.disableMigrateDialog = true; - } else { let req = "/resources/" + this.chosenItem.id + "/" + action; easyRequest(req).then(() => { @@ -583,14 +587,13 @@ export default { for (const key in _this.rscLocation) { location[key] = _this.rscLocation[key]; if (_this.rscLocation[key].length == 0) { - continue - } else if(_this.rscLocation[key].length >= 1) { + continue; + } else if (_this.rscLocation[key].length >= 1) { location.node_level.push({ level: key, node: _this.rscLocation[key], }); } else { - } } @@ -647,7 +650,10 @@ export default { period: "", to_node: "", }; - this.disableMigrateDialog = false + this.disableMigrateDialog = false; + }, + cleanSelets() { + this.$emit("clear"); }, }, }; -- Gitee From 6ed00e5b58a1ed7592588ca5085104c0e383af1c Mon Sep 17 00:00:00 2001 From: Feelsgoodagain Date: Fri, 14 May 2021 14:52:51 +0800 Subject: [PATCH 2/8] update README.md. --- README.md | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 175 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 06e9a29..ba2b791 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,183 @@ -# HA-WEB +## HA-web介绍 -> HA-WEB-VUE +HA-web:Linux 高可用集群Web提供一套基于BS架构对集群资源统一配置和管理的界面。 该管理界面直观易用,可以实时监控所有集群节点的运行状态,能对集群资源进行规则设置、添加、启动、停止、修改、删除等常规操作。 跨平台支持Chrome、IE、Firefox常用浏览器。 -## Build Setup +## 一、安装HA-web开发环境 -``` bash -# install dependencies -npm install +### 1、安装node.js环境: -# serve with hot reload at localhost:8080 -npm run dev +#### Windows环境: -# build for production with minification -npm run build +#### 方法一:使用Windows安装包(.msi) + +下载地址:[https://nodejs.org/en/download/](http://nodejs.org/en/download/) + +安装步骤: + +步骤 1 : 双击下载后的安装包 + +步骤 2 : 点击Run(运行) + +步骤 3 : 勾选接受协议选项,点击 next + +步骤 4 : Node.js默认安装目录为 "C:\Program Files\nodejs\" , 你可以修改目录,并点击 next + +步骤 5 : 点击树形图标来选择你需要的安装模式 , 然后点击下一步 next + +步骤 6 :点击 Install(安装) 开始安装Node.js。 + +检测PATH环境变量是否配置了Node.js,点击开始=》运行=》输入"cmd" => 输入命令"path",输出如下结果: + +```bash +PATH=C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\Windows\system32; +C:\Program Files\nodejs\;C:\Users\rg\AppData\Roaming\npm +``` +检查Node.js版本 + +```bash +C:\> node --version +v14.16.0 +$ npm -v +6.14.11 +``` +#### 方法二:使用Windows二进制文件安装(.exe) + +下载地址:[https://nodejs.org/en/download/](http://nodejs.org/en/download/) + +32 位安装包下载地址 : [http://nodejs.org/dist/v0.10.26/node.exe](http://nodejs.org/dist/v0.10.26/node.exe) + +64 位安装包下载地址 : [http://nodejs.org/dist/v0.10.26/x64/node.exe](http://nodejs.org/dist/v0.10.26/x64/node.exe) + +安装步骤: + +步骤 1 : 双击下载后的安装包Node.exe + +步骤 2 : 点击Run(运行) + +检查Node.js版本 + +```bash +C:\> cd download +C:\download> node --version +v14.16.0 +$ npm -v +6.14.11 + + +``` +#### Linux环境: + +#### 方法一:直接使用已编译好的包(.msi)** + +下载地址:[https://nodejs.org/en/download/](http://nodejs.org/en/download/) + +``` + +$ wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz // 下载 +$ tar xf node-v10.9.0-linux-x64.tar.xz // 解压 +$ cd node-v10.9.0-linux-x64/ // 进入解压目录 +$ ./bin/node -v // 执行node命令 查看版本 +v14.16.0 +$ npm -v +6.14.11 +``` + + +解压文件的 bin 目录下包含了 node、npm 等命令,可以使用 ln 命令来设置软连接: + + +``` + +$ ln -s /usr/software/nodejs/bin/npm /usr/local/bin/ +$ ln -s /usr/software/nodejs/bin/node /usr/local/bin/ -# build for production and view the bundle analyzer report -npm run build --report ``` -For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). +#### 方法二: 源码安装 Node.js(以CentOS为例)** + +下载地址:[https://nodejs.org/en/download/](http://nodejs.org/en/download/) + +下载Binaries包(以x86为例) + +安装步骤: + +步骤 1 : 解压安装包 + + +``` +$ tar -xvf node-v10.16.0-linux-x64.tar.xz +$ cd /usr/local/ +$ mv /var/ftp/pub/node-v10.16.0-linux-64 ./ +$ mv node-v10.16.0.0-linux-64/ nodejs + +``` + + +步骤 2 : 添加node.js至全局命令 + +``` +$ ln -s /usr/local/nodejs/bin/npm /usr/local/bin/ +$ ln -s /usr/local/nodejs/bin/node /usr/local/bin/ +``` + + +查看nodejs是否安装成功 + +``` +$ node -v +v14.16.0 +$ npm -v +6.14.11 +``` + + +### 2、下载源码: + + +```bash + +$ git clone https://gitee.com/openeuler/A-Tune.git + +``` +### 3、安装node_modules依赖: + + +```bash +$ cd ha-web/ +$ npm install +``` +如果依赖下载安装缓慢可以尝试更换国内源: + +```bash +$ npm install --registry https://registry.npm.taobao.org +``` +## 二、部署HA-web开发环境 + +### 1.热更新方式在本地部署开发环境 + +```bash +$ npm run dev +``` +### 2.打包依赖生成生产环境 +```bash +$ npm run build +``` + + +### 3.将打包后的资源放入ha-api的静态资源文件夹 +```bash + +$ cd ha-web +$ mv dist/index.html dist/static/ +$ scp -r dist/* root@:/root/ha-api/views/static/ +``` + +注:打包后的资源文件在dist目录下,请将index.html文件放入static文件夹并将资源复制到目标ha-api服务器的静态资源文件夹后重启ha-api服务 +ha-api部署方法等详细信息请参考ha-api项目的[README](https://gitee.com/openeuler/ha-api/blob/master/README.md)文件 + + +三、如何贡献 +---------- +如果您有意愿参与到项目开发贡献中,需要先签署[CLA](https://openeuler.org/en/cla.html),我们期待着您的加入与贡献。 + +如果您有任何疑问、意见或建议,请通过[HA-web issues](https://gitee.com/openeuler/ha-web/issues) 提交issues,我们会尽快回复。 \ No newline at end of file -- Gitee From 29ded706f0716cbbbbba03fed1df5d542184ba7f Mon Sep 17 00:00:00 2001 From: zhaochongyu Date: Fri, 14 May 2021 15:51:19 +0800 Subject: [PATCH 3/8] log download updata --- src/components/Logs/Logs.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Logs/Logs.vue b/src/components/Logs/Logs.vue index dc2d3db..270948a 100644 --- a/src/components/Logs/Logs.vue +++ b/src/components/Logs/Logs.vue @@ -27,7 +27,7 @@ export default { let aLink = document.createElement("a"); let evt = document.createEvent("MouseEvents"); evt.initEvent("click", false, true); - aLink.href = "kylinha-log-ha1-20210506111701.tar"; + aLink.href = res.data.data.filepath; aLink.dispatchEvent(evt); return Promise.resolve(); }); -- Gitee From a5aa2fe1e55d68f019e356c58ec5998fcfeb66ad Mon Sep 17 00:00:00 2001 From: zhaochongyu Date: Tue, 18 May 2021 14:34:12 +0800 Subject: [PATCH 4/8] merge and fix status refreshing --- src/components/HomeTable/HomeTable.vue | 8 +++++ .../Layout/Operations/Operations.vue | 35 +++++++++---------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/components/HomeTable/HomeTable.vue b/src/components/HomeTable/HomeTable.vue index 83954a6..97d32ce 100644 --- a/src/components/HomeTable/HomeTable.vue +++ b/src/components/HomeTable/HomeTable.vue @@ -232,6 +232,14 @@ export default { } }); _this.$store.commit("mutationsIds", ids); + if (_this.radio) { + for (let i of _this.tableData) { + if (i.id == _this.radio) { + let chosenItem = JSON.parse(JSON.stringify(i)); + _this.showRow(chosenItem); + } + } + } }) .catch((err) => { if (err.response.status == 403) { diff --git a/src/components/Layout/Operations/Operations.vue b/src/components/Layout/Operations/Operations.vue index 6f3900b..3149c60 100644 --- a/src/components/Layout/Operations/Operations.vue +++ b/src/components/Layout/Operations/Operations.vue @@ -84,7 +84,10 @@ - + 关系 @@ -487,14 +490,19 @@ export default { operate(action) { let _this = this; if (action == "migrate") { - _this.migrateNodes = [] //清空上次存储的值,以免造成数据重复 + this.migrate = { + is_force: false, + period: "", + to_node: "", + }; + _this.migrateNodes = []; //清空上次存储的值,以免造成数据重复 - //因为不点击当前行chosenItem不会更新最新数据,所以该方法更新choseItem - _this.$store.state.rscs.forEach(item => { - if(item.id == _this.chosenItem.id) { - _this.chosenItem = item + //因为不点击当前行chosenItem不会更新最新数据,所以该方法更新choseItem + _this.$store.state.rscs.forEach((item) => { + if (item.id == _this.chosenItem.id) { + _this.chosenItem = item; } - }) + }); //选中的数据的running_node有值,则该值不可作为迁移的节点 _this.nodeLists.forEach((item) => { if (_this.chosenItem.running_node.indexOf(item.id) == -1) { @@ -505,6 +513,7 @@ export default { } else { let req = "/resources/" + this.chosenItem.id + "/" + action; easyRequest(req).then(() => { + _this.getResources(); this.$message({ type: "success", message: "resource " + action + " success", @@ -524,18 +533,6 @@ export default { }); }); }, - updateUnmigrate() { - let _this = this; - let url = "/resources/" + _this.chosenItem.id + "/unmigrate"; - updateUnmigrates(url).then(() => { - _this.disableMigrateDialog = false; - _this.getResources(); - this.$message({ - type: "success", - message: "resource unmigrate success", - }); - }); - }, deleteItem() { let _this = this; let url = "/resources/" + _this.chosenItem.id + "/delete"; -- Gitee From bb1628dbe8bde9174cd62936e2e85a472ee804ec Mon Sep 17 00:00:00 2001 From: zhaochongyu Date: Tue, 18 May 2021 16:04:32 +0800 Subject: [PATCH 5/8] update username display --- src/components/Layout/Login/Login.vue | 1 + src/components/Layout/TopBar/TopBar.vue | 7 ++++++- src/components/VueX/store.js | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/Layout/Login/Login.vue b/src/components/Layout/Login/Login.vue index 12b4252..6dc0f30 100644 --- a/src/components/Layout/Login/Login.vue +++ b/src/components/Layout/Login/Login.vue @@ -61,6 +61,7 @@ export default { .post("/api/v1/login", _this.loginForm) .then(() => { localStorage.setItem("userLogin", _this.loginForm.username); + this.$store.commit("mutationsUsername", _this.loginForm.username); this.$router.push({ path: "/" }); }) .catch((err) => { diff --git a/src/components/Layout/TopBar/TopBar.vue b/src/components/Layout/TopBar/TopBar.vue index 524b2ff..c998c06 100644 --- a/src/components/Layout/TopBar/TopBar.vue +++ b/src/components/Layout/TopBar/TopBar.vue @@ -3,7 +3,7 @@ - user + {{username}} Date: Wed, 19 May 2021 15:28:32 +0800 Subject: [PATCH 6/8] i18n update --- package-lock.json | 6 + package.json | 1 + src/assets/i18n/en.json | 99 ++++++++ src/assets/i18n/zh.json | 99 ++++++++ .../ClusterOperation/ClusterOperation.vue | 10 +- src/components/Dialogs/Dialogs.vue | 71 ++++-- src/components/HeartBeat/HeartBeat.vue | 223 ++++++++++-------- src/components/HomeTable/HomeTable.vue | 20 +- src/components/Homepage.vue | 37 +-- src/components/Layout/Login/Login.vue | 8 +- .../Layout/Operations/Operations.vue | 103 ++++---- src/components/Layout/TopBar/TopBar.vue | 50 ++-- src/components/Logs/Logs.vue | 21 +- src/components/Priority/Priority.vue | 8 +- src/main.js | 18 ++ 15 files changed, 525 insertions(+), 249 deletions(-) create mode 100644 src/assets/i18n/en.json create mode 100644 src/assets/i18n/zh.json diff --git a/package-lock.json b/package-lock.json index 660136c..4d01a04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12474,6 +12474,12 @@ "integrity": "sha1-UylVzB6yCKPZkLOp+acFdGV+CPI=", "dev": true }, + "vue-i18n": { + "version": "8.24.4", + "resolved": "https://registry.nlark.com/vue-i18n/download/vue-i18n-8.24.4.tgz?cache=0&sync_timestamp=1619621701227&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fvue-i18n%2Fdownload%2Fvue-i18n-8.24.4.tgz", + "integrity": "sha1-sVhhTB332xg9nK3du3Ph1UAmlJI=", + "dev": true + }, "vue-loader": { "version": "13.7.3", "resolved": "https://registry.npm.taobao.org/vue-loader/download/vue-loader-13.7.3.tgz", diff --git a/package.json b/package.json index 1191292..412f03c 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "shelljs": "^0.7.6", "uglifyjs-webpack-plugin": "^1.1.1", "url-loader": "^0.5.8", + "vue-i18n": "^8.24.4", "vue-loader": "^13.3.0", "vue-sidebar-menu": "^4.7.4", "vue-style-loader": "^3.0.1", diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json new file mode 100644 index 0000000..eb8108c --- /dev/null +++ b/src/assets/i18n/en.json @@ -0,0 +1,99 @@ +{ + "common": { + "confirm": "confirm", + "cancel": "cancel", + "pleaseSelect": "please select" + }, + "login": { + "welcome": "welcome", + "username": "username", + "password": "password", + "login": "login" + }, + "sidebar": { + "system": "system", + "cluster": "cluster settings", + "priority": "priority settings", + "heartbeat": "heartbeat settings", + "tool": "tools", + "log": "log download", + "warning": "The status of cluster nodes is 'Not Running' or 'Not Running/Standby', heartbeat functionality is disabled.", + "ip": "node heartbeat IP-", + "main": "main heartbeat", + "backup": "backup heartbeat", + "switch": "active backup heartbeat", + "shortcut": "cluster operation shortcut", + "tips": "tips", + "wait": "Downloading, please wait for a moment.", + "cancel": "Download cancelled", + "logTips": "It would take some time to download the logs, are you sure about starting immediately?", + "action": "cluster operation", + "select": "please select operation scripts", + "result": "operation result", + "close": "close" + }, + "topbar": { + "refresh": "refresh setting", + "logout": "logout", + "disableRefresh": "disable auto-refresh", + "fivesec": "refresh every 5 seconds", + "tensec": "refresh every 10 seconds" + }, + "operations": { + "add": "add", + "edit": "edit", + "start": "start", + "stop": "stop", + "cleanup": "cleanup", + "migrate": "migrate", + "unmigrate": "unmigrate", + "delete": "delete", + "relation": "relation", + "refresh": "refresh", + "primitive": "add primitive resource", + "clone": "add clone resource", + "group": "add group resource", + "location": "resource location", + "coop": "resource cooperation", + "order": "resource order", + "confirmDelete": "Are you sure about deleting?", + "migrateRsc": "migrate", + "rscName": "resource name:", + "toNode": "migrate to node:", + "force": "force to migrate:", + "validity": "period of validity:", + "noRes": "no result", + "hour": "hour(s)", + "samenode": "same-node resource:", + "diffnode": "diff-node resource:", + "front": "pre-resource:", + "back": "post-resource:" + }, + "dialog": { + "add": "add resource", + "edit": "edit resource", + "basic": "basic", + "rscName": "resource name:", + "rscType": "resource type:", + "groupRsc": "resource in group:", + "target": "clone target:", + "instance": "instance attribute", + "instanceChange": "instance attributes to modify:", + "actions": "action attribute", + "actionsChange": "action attributes to be modified:", + "metas": "meta attribute", + "metasChange": "meta attribute to be modified:" + }, + "table": { + "select": "select", + "rscName": "resource name", + "status": "status", + "rscType": "resource type", + "service": "service", + "nodeId": "node ID:", + "disable": "disable", + "enable": "enable", + "unstandby": "unstandby", + "standby": "standby" + } +} \ No newline at end of file diff --git a/src/assets/i18n/zh.json b/src/assets/i18n/zh.json new file mode 100644 index 0000000..34663c0 --- /dev/null +++ b/src/assets/i18n/zh.json @@ -0,0 +1,99 @@ +{ + "common": { + "confirm": "确定", + "cancel": "取消", + "pleaseSelect": "请选择" + }, + "login": { + "welcome": "欢迎登录", + "username": "输入用户名", + "password": "输入密码", + "login": "登录" + }, + "sidebar": { + "system": "系统", + "cluster": "集群配置", + "priority": "首选项配置", + "heartbeat": "心跳配置", + "tool": "工具", + "log": "日志下载", + "warning": "集群nodes状态为 Not Running 或 Not Running/Standby, 心跳配置功能不能使用", + "ip": "节点心跳IP-", + "backup": "备用心跳", + "switch": "启用备用心跳", + "shortcut": "集群快捷操作", + "tips": "提示", + "wait": "正在下载,请稍候", + "cancel": "下载取消", + "logTips": "日志下载需要一段时间,你确定要立即下载集群日志吗?", + "action": "集群操作", + "select": "请选择操作命令", + "result": "操作结果", + "close": "关闭" + + }, + "topbar": { + "refresh": "刷新设置", + "logout": "退出登录", + "disableRefresh": "不自动刷新", + "fivesec": "每5秒自动刷新", + "tensec": "每10秒自动刷新" + }, + "operations": { + "add": "添加", + "edit": "编辑", + "start": "启动", + "stop": "停止", + "cleanup": "清理", + "migrate": "迁移", + "unmigrate": "回迁", + "delete": "删除", + "relation": "关系", + "refresh": "刷新", + "primitive": "添加普通资源", + "clone": "添加克隆资源", + "group": "添加组资源", + "location": "资源位置", + "coop": "资源协同", + "order": "资源顺序", + "confirmDelete": "确定删除资源吗?", + "migrateRsc": "迁移资源", + "rscName": "资源名称:", + "toNode": "迁移至节点:", + "force": "强制迁移:", + "validity": "有效期:", + "noRes": "无返回结果", + "hour": "小时", + "samenode": "同节点资源:", + "diffnode": "互斥节点资源:", + "front": "前置资源:", + "back": "后置资源:" + }, + "dialog": { + "add": "创建资源", + "edit": "编辑资源", + "basic": "基本", + "rscName": "资源名称:", + "rscType": "资源类型:", + "groupRsc": "组内资源:", + "target": "克隆对象:", + "instance": "实例属性", + "instanceChange": "需要修改的实例属性:", + "actions": "操作属性", + "actionsChange": "需要修改的操作属性:", + "metas": "元属性", + "metasChange": "需要修改的元属性:" + }, + "table": { + "select": "选择", + "rscName": "资源名", + "status": "状态", + "rscType": "资源类型", + "service": "服务", + "nodeId": "节点id:", + "disable": "停用", + "enable": "启动", + "unstandby": "启用", + "standby": "备用" + } +} \ No newline at end of file diff --git a/src/components/ClusterOperation/ClusterOperation.vue b/src/components/ClusterOperation/ClusterOperation.vue index 4ff201c..c311d97 100644 --- a/src/components/ClusterOperation/ClusterOperation.vue +++ b/src/components/ClusterOperation/ClusterOperation.vue @@ -1,7 +1,7 @@