diff --git a/itbaima-monitor-server/src/main/java/com/example/controller/MonitorController.java b/itbaima-monitor-server/src/main/java/com/example/controller/MonitorController.java index 4ba7f8b..8ecb667 100644 --- a/itbaima-monitor-server/src/main/java/com/example/controller/MonitorController.java +++ b/itbaima-monitor-server/src/main/java/com/example/controller/MonitorController.java @@ -2,6 +2,8 @@ package com.example.controller; import com.example.entity.RestBean; import com.example.entity.vo.request.RenameClientVO; +import com.example.entity.vo.request.RenameNodeVO; +import com.example.entity.vo.response.ClientDetailsVO; import com.example.entity.vo.response.ClientPreviewVO; import com.example.service.ClientService; import jakarta.annotation.Resource; @@ -27,4 +29,15 @@ public class MonitorController { service.renameClient(vo); return RestBean.success(); } + + @PostMapping("/node") + public RestBean renameNode(@RequestBody @Valid RenameNodeVO vo) { + service.renameNode(vo); + return RestBean.success(); + } + + @GetMapping("/details") + public RestBean details(int clientId) { + return RestBean.success(service.clientDetails(clientId)); + } } diff --git a/itbaima-monitor-server/src/main/java/com/example/entity/vo/request/RenameNodeVO.java b/itbaima-monitor-server/src/main/java/com/example/entity/vo/request/RenameNodeVO.java new file mode 100644 index 0000000..7350571 --- /dev/null +++ b/itbaima-monitor-server/src/main/java/com/example/entity/vo/request/RenameNodeVO.java @@ -0,0 +1,14 @@ +package com.example.entity.vo.request; + +import jakarta.validation.constraints.Pattern; +import lombok.Data; +import org.hibernate.validator.constraints.Length; + +@Data +public class RenameNodeVO { + int id; + @Length(min = 1, max = 10) + String node; + @Pattern(regexp = "(cn|hk|jp|us|sg|kr|de)") + String location; +} diff --git a/itbaima-monitor-server/src/main/java/com/example/entity/vo/response/ClientDetailsVO.java b/itbaima-monitor-server/src/main/java/com/example/entity/vo/response/ClientDetailsVO.java new file mode 100644 index 0000000..8d01714 --- /dev/null +++ b/itbaima-monitor-server/src/main/java/com/example/entity/vo/response/ClientDetailsVO.java @@ -0,0 +1,19 @@ +package com.example.entity.vo.response; + +import lombok.Data; + +@Data +public class ClientDetailsVO { + int id; + String name; + boolean online; + String node; + String location; + String ip; + String cpuName; + String osName; + String osVersion; + double memory; + int cpuCore; + double disk; +} diff --git a/itbaima-monitor-server/src/main/java/com/example/service/ClientService.java b/itbaima-monitor-server/src/main/java/com/example/service/ClientService.java index 089a6fd..4346e08 100644 --- a/itbaima-monitor-server/src/main/java/com/example/service/ClientService.java +++ b/itbaima-monitor-server/src/main/java/com/example/service/ClientService.java @@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.example.entity.dto.Client; import com.example.entity.vo.request.ClientDetailVO; import com.example.entity.vo.request.RenameClientVO; +import com.example.entity.vo.request.RenameNodeVO; import com.example.entity.vo.request.RuntimeDetailVO; +import com.example.entity.vo.response.ClientDetailsVO; import com.example.entity.vo.response.ClientPreviewVO; import java.util.List; @@ -18,4 +20,6 @@ public interface ClientService extends IService { void updateRuntimeDetail(RuntimeDetailVO vo, Client client); List listClients(); void renameClient(RenameClientVO vo); + void renameNode(RenameNodeVO vo); + ClientDetailsVO clientDetails(int clientId); } diff --git a/itbaima-monitor-server/src/main/java/com/example/service/impl/ClientServiceImpl.java b/itbaima-monitor-server/src/main/java/com/example/service/impl/ClientServiceImpl.java index a38bc07..0e49858 100644 --- a/itbaima-monitor-server/src/main/java/com/example/service/impl/ClientServiceImpl.java +++ b/itbaima-monitor-server/src/main/java/com/example/service/impl/ClientServiceImpl.java @@ -6,7 +6,9 @@ import com.example.entity.dto.Client; import com.example.entity.dto.ClientDetail; import com.example.entity.vo.request.ClientDetailVO; import com.example.entity.vo.request.RenameClientVO; +import com.example.entity.vo.request.RenameNodeVO; import com.example.entity.vo.request.RuntimeDetailVO; +import com.example.entity.vo.response.ClientDetailsVO; import com.example.entity.vo.response.ClientPreviewVO; import com.example.mapper.ClientDetailMapper; import com.example.mapper.ClientMapper; @@ -95,7 +97,7 @@ public class ClientServiceImpl extends ServiceImpl impleme ClientPreviewVO vo = client.asViewObject(ClientPreviewVO.class); BeanUtils.copyProperties(detailMapper.selectById(vo.getId()), vo); RuntimeDetailVO runtime = currentRuntime.get(client.getId()); - if(runtime != null && System.currentTimeMillis() - runtime.getTimestamp() < 60 * 1000) { + if(this.isOnline(runtime)) { BeanUtils.copyProperties(runtime, vo); vo.setOnline(true); } @@ -109,6 +111,25 @@ public class ClientServiceImpl extends ServiceImpl impleme this.initClientCache(); } + @Override + public void renameNode(RenameNodeVO vo) { + this.update(Wrappers.update().eq("id", vo.getId()) + .set("node", vo.getNode()).set("location", vo.getLocation())); + this.initClientCache(); + } + + @Override + public ClientDetailsVO clientDetails(int clientId) { + ClientDetailsVO vo = this.clientIdCache.get(clientId).asViewObject(ClientDetailsVO.class); + BeanUtils.copyProperties(detailMapper.selectById(clientId), vo); + vo.setOnline(this.isOnline(currentRuntime.get(clientId))); + return vo; + } + + private boolean isOnline(RuntimeDetailVO runtime) { + return runtime != null && System.currentTimeMillis() - runtime.getTimestamp() < 60 * 1000; + } + private void addClientCache(Client client) { clientIdCache.put(client.getId(), client); clientTokenCache.put(client.getToken(), client); diff --git a/itbaima-monitor-web/package-lock.json b/itbaima-monitor-web/package-lock.json index 3fff73e..d4982e8 100644 --- a/itbaima-monitor-web/package-lock.json +++ b/itbaima-monitor-web/package-lock.json @@ -18,6 +18,7 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^4.2.3", + "less": "^4.2.0", "unplugin-auto-import": "^0.15.2", "unplugin-vue-components": "^0.24.1", "vite": "^4.4.6" @@ -823,6 +824,15 @@ "node": ">= 0.8" } }, + "node_modules/copy-anything": { + "version": "2.0.6", + "resolved": "https://registry.npmmirror.com/copy-anything/-/copy-anything-2.0.6.tgz", + "integrity": "sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==", + "dev": true, + "dependencies": { + "is-what": "^3.14.1" + } + }, "node_modules/csstype": { "version": "3.1.2", "resolved": "https://registry.npmmirror.com/csstype/-/csstype-3.1.2.tgz", @@ -956,6 +966,19 @@ } } }, + "node_modules/errno": { + "version": "0.1.8", + "resolved": "https://registry.npmmirror.com/errno/-/errno-0.1.8.tgz", + "integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==", + "dev": true, + "optional": true, + "dependencies": { + "prr": "~1.0.1" + }, + "bin": { + "errno": "cli.js" + } + }, "node_modules/esbuild": { "version": "0.18.17", "resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.18.17.tgz", @@ -1113,6 +1136,13 @@ "node": ">= 6" } }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmmirror.com/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "optional": true + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmmirror.com/has/-/has-1.0.3.tgz", @@ -1125,6 +1155,32 @@ "node": ">= 0.4.0" } }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "optional": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/image-size": { + "version": "0.5.5", + "resolved": "https://registry.npmmirror.com/image-size/-/image-size-0.5.5.tgz", + "integrity": "sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==", + "dev": true, + "optional": true, + "bin": { + "image-size": "bin/image-size.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmmirror.com/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -1176,12 +1232,44 @@ "node": ">=0.12.0" } }, + "node_modules/is-what": { + "version": "3.14.1", + "resolved": "https://registry.npmmirror.com/is-what/-/is-what-3.14.1.tgz", + "integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==", + "dev": true + }, "node_modules/jsonc-parser": { "version": "3.2.0", "resolved": "https://registry.npmmirror.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz", "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", "dev": true }, + "node_modules/less": { + "version": "4.2.0", + "resolved": "https://registry.npmmirror.com/less/-/less-4.2.0.tgz", + "integrity": "sha512-P3b3HJDBtSzsXUl0im2L7gTO5Ubg8mEN6G8qoTS77iXxXX4Hvu4Qj540PZDvQ8V6DmX6iXo98k7Md0Cm1PrLaA==", + "dev": true, + "dependencies": { + "copy-anything": "^2.0.1", + "parse-node-version": "^1.0.1", + "tslib": "^2.3.0" + }, + "bin": { + "lessc": "bin/lessc" + }, + "engines": { + "node": ">=6" + }, + "optionalDependencies": { + "errno": "^0.1.1", + "graceful-fs": "^4.1.2", + "image-size": "~0.5.0", + "make-dir": "^2.1.0", + "mime": "^1.4.1", + "needle": "^3.1.0", + "source-map": "~0.6.0" + } + }, "node_modules/local-pkg": { "version": "0.4.3", "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.3.tgz", @@ -1222,6 +1310,20 @@ "node": ">=12" } }, + "node_modules/make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "optional": true, + "dependencies": { + "pify": "^4.0.1", + "semver": "^5.6.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/memoize-one": { "version": "6.0.0", "resolved": "https://registry.npmmirror.com/memoize-one/-/memoize-one-6.0.0.tgz", @@ -1249,6 +1351,19 @@ "node": ">=8.6" } }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true, + "optional": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz", @@ -1309,6 +1424,23 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/needle": { + "version": "3.3.1", + "resolved": "https://registry.npmmirror.com/needle/-/needle-3.3.1.tgz", + "integrity": "sha512-6k0YULvhpw+RoLNiQCRKOl09Rv1dPLr8hHnVjHqdolKwDrdNyk+Hmrthi4lIGPPz3r39dLx0hsF5s40sZ3Us4Q==", + "dev": true, + "optional": true, + "dependencies": { + "iconv-lite": "^0.6.3", + "sax": "^1.2.4" + }, + "bin": { + "needle": "bin/needle" + }, + "engines": { + "node": ">= 4.4.x" + } + }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmmirror.com/normalize-path/-/normalize-path-3.0.0.tgz", @@ -1323,6 +1455,15 @@ "resolved": "https://registry.npmmirror.com/normalize-wheel-es/-/normalize-wheel-es-1.2.0.tgz", "integrity": "sha512-Wj7+EJQ8mSuXr2iWfnujrimU35R2W4FAErEyTmJoJ7ucwTn2hOUSsRehMb5RSYkxXGTM7Y9QpvPmp++w5ftoJw==" }, + "node_modules/parse-node-version": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/parse-node-version/-/parse-node-version-1.0.1.tgz", + "integrity": "sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==", + "dev": true, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmmirror.com/path-parse/-/path-parse-1.0.7.tgz", @@ -1349,6 +1490,16 @@ "node": ">=8.6" } }, + "node_modules/pify": { + "version": "4.0.1", + "resolved": "https://registry.npmmirror.com/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true, + "optional": true, + "engines": { + "node": ">=6" + } + }, "node_modules/pkg-types": { "version": "1.0.3", "resolved": "https://registry.npmmirror.com/pkg-types/-/pkg-types-1.0.3.tgz", @@ -1378,6 +1529,13 @@ "resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, + "node_modules/prr": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/prr/-/prr-1.0.1.tgz", + "integrity": "sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==", + "dev": true, + "optional": true + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmmirror.com/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -1445,12 +1603,46 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmmirror.com/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "optional": true + }, + "node_modules/sax": { + "version": "1.3.0", + "resolved": "https://registry.npmmirror.com/sax/-/sax-1.3.0.tgz", + "integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==", + "dev": true, + "optional": true + }, "node_modules/scule": { "version": "1.0.0", "resolved": "https://registry.npmmirror.com/scule/-/scule-1.0.0.tgz", "integrity": "sha512-4AsO/FrViE/iDNEPaAQlb77tf0csuq27EsVpy6ett584EcRTp6pTDLoGWVxCD77y5iU5FauOvhsI4o1APwPoSQ==", "dev": true }, + "node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmmirror.com/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "optional": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/source-map-js": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.0.2.tgz", @@ -1489,6 +1681,12 @@ "node": ">=8.0" } }, + "node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "dev": true + }, "node_modules/ufo": { "version": "1.2.0", "resolved": "https://registry.npmmirror.com/ufo/-/ufo-1.2.0.tgz", diff --git a/itbaima-monitor-web/package.json b/itbaima-monitor-web/package.json index 958668a..7e83c71 100644 --- a/itbaima-monitor-web/package.json +++ b/itbaima-monitor-web/package.json @@ -18,6 +18,7 @@ }, "devDependencies": { "@vitejs/plugin-vue": "^4.2.3", + "less": "^4.2.0", "unplugin-auto-import": "^0.15.2", "unplugin-vue-components": "^0.24.1", "vite": "^4.4.6" diff --git a/itbaima-monitor-web/public/cpu-icons/AMD.png b/itbaima-monitor-web/public/cpu-icons/AMD.png new file mode 100644 index 0000000..1afc461 Binary files /dev/null and b/itbaima-monitor-web/public/cpu-icons/AMD.png differ diff --git a/itbaima-monitor-web/public/cpu-icons/Apple.png b/itbaima-monitor-web/public/cpu-icons/Apple.png new file mode 100644 index 0000000..ea0c7c9 Binary files /dev/null and b/itbaima-monitor-web/public/cpu-icons/Apple.png differ diff --git a/itbaima-monitor-web/public/cpu-icons/Intel.png b/itbaima-monitor-web/public/cpu-icons/Intel.png new file mode 100644 index 0000000..331a841 Binary files /dev/null and b/itbaima-monitor-web/public/cpu-icons/Intel.png differ diff --git a/itbaima-monitor-web/src/assets/css/element.less b/itbaima-monitor-web/src/assets/css/element.less new file mode 100644 index 0000000..d40937c --- /dev/null +++ b/itbaima-monitor-web/src/assets/css/element.less @@ -0,0 +1,53 @@ +.is-success { + .el-progress-bar__outer { + background-color: #18cb1822 !important; + } + + .el-progress-bar__inner { + background-color: #18cb18 !important; + } + + .el-progress-circle__track { + stroke: #18cb1822; + } + + .el-progress-circle__path { + stroke: #18cb18 !important; + } +} + +.is-warning { + .el-progress-bar__outer { + background-color: #ffa04622; + } + + .el-progress-circle__track { + stroke: #ffa04622; + } + + .el-progress-circle__path { + stroke: #ffa046 !important; + } + + .el-progress-bar__inner { + background-color: #ffa046 !important; + } +} + +.is-exception { + .el-progress-bar__outer { + background-color: #ef4e4e22; + } + + .el-progress-circle__track { + stroke: #ef4e4e22; + } + + .el-progress-circle__path { + stroke: #ef4e4e !important; + } + + .el-progress-bar__inner { + background-color: #ef4e4e !important; + } +} diff --git a/itbaima-monitor-web/src/component/ClientDetails.vue b/itbaima-monitor-web/src/component/ClientDetails.vue new file mode 100644 index 0000000..b025388 --- /dev/null +++ b/itbaima-monitor-web/src/component/ClientDetails.vue @@ -0,0 +1,228 @@ + + + + + diff --git a/itbaima-monitor-web/src/component/PreviewCard.vue b/itbaima-monitor-web/src/component/PreviewCard.vue index 435484d..b5807c9 100644 --- a/itbaima-monitor-web/src/component/PreviewCard.vue +++ b/itbaima-monitor-web/src/component/PreviewCard.vue @@ -1,33 +1,10 @@