From cf9349537b69e5146e79dc56d6e3f64ce9e467e7 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Thu, 11 Aug 2022 17:22:13 +0800 Subject: [PATCH] feat: support zun services Enables administrative users to view details for all Zun services. Change-Id: I9bcd7178b80882588bc1d777b68e82b81bd02062 --- src/client/zun/index.js | 4 + src/layouts/admin-menu.jsx | 7 ++ src/locales/en.json | 2 + src/locales/zh.json | 2 + .../containers/Services/index.jsx | 81 +++++++++++++++++++ src/pages/container-service/routes/index.js | 6 ++ src/stores/zun/services.js | 25 ++++++ 7 files changed, 127 insertions(+) create mode 100644 src/pages/container-service/containers/Services/index.jsx create mode 100644 src/stores/zun/services.js diff --git a/src/client/zun/index.js b/src/client/zun/index.js index 6f0b701d..323b2cf6 100644 --- a/src/client/zun/index.js +++ b/src/client/zun/index.js @@ -88,6 +88,10 @@ export class ZunClient extends Base { { key: 'quotas', }, + { + key: 'services', + responseKey: 'service', + }, ]; } } diff --git a/src/layouts/admin-menu.jsx b/src/layouts/admin-menu.jsx index 82c4760c..4016238c 100644 --- a/src/layouts/admin-menu.jsx +++ b/src/layouts/admin-menu.jsx @@ -870,6 +870,13 @@ const renderMenu = (t) => { }, ], }, + { + path: '/container/services-admin', + name: t('Services'), + key: 'zunServicesAdmin', + endpoints: 'zun', + level: 1, + }, ], }, ]; diff --git a/src/locales/en.json b/src/locales/en.json index 56d484ba..5a63667a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -970,6 +970,7 @@ "Force Delete Container": "Force Delete Container", "Force Delete Share Instance": "Force Delete Share Instance", "Force release": "Force release", + "Forced Down": "Forced Down", "Forced Shutdown": "Forced Shutdown", "Forced shutdown may result in data loss or file system damage. You can also take the initiative to shut down and perform operations.": "Forced shutdown may result in data loss or file system damage. You can also take the initiative to shut down and perform operations.", "Forgot your password?": "Forgot your password?", @@ -1912,6 +1913,7 @@ "Rename": "Rename", "Rename is to copy the current file to the new file address and delete the current file, which will affect the creation time of the file.": "Rename is to copy the current file to the new file address and delete the current file, which will affect the creation time of the file.", "Replication Change": "Replication Change", + "Report Count": "Report Count", "Republic of the Congo": "Republic of the Congo", "Request ID": "Request ID", "Require": "Require", diff --git a/src/locales/zh.json b/src/locales/zh.json index c78efc5b..1f78225d 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -970,6 +970,7 @@ "Force Delete Container": "强制删除容器", "Force Delete Share Instance": "强制删除共享实例", "Force release": "强制释放", + "Forced Down": "强制关闭", "Forced Shutdown": "强制关机", "Forced shutdown may result in data loss or file system damage. You can also take the initiative to shut down and perform operations.": "强制关机可能会导致数据丢失或文件系统损坏,您也可以主动关机后再进行操作。", "Forgot your password?": "忘记密码?", @@ -1912,6 +1913,7 @@ "Rename": "重命名", "Rename is to copy the current file to the new file address and delete the current file, which will affect the creation time of the file.": "重命名是把当前文件复制到新文件地址,并删除当前文件,会影响文件的创建时间。", "Replication Change": "复制更改中", + "Report Count": "报告数量", "Republic of the Congo": "刚果共和国", "Request ID": "请求ID", "Require": "强制", diff --git a/src/pages/container-service/containers/Services/index.jsx b/src/pages/container-service/containers/Services/index.jsx new file mode 100644 index 00000000..673d670f --- /dev/null +++ b/src/pages/container-service/containers/Services/index.jsx @@ -0,0 +1,81 @@ +// Copyright 2021 99cloud +// +// 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. + +// import React from 'react'; +import Base from 'containers/List'; +import { inject, observer } from 'mobx-react'; +import globalServicesStore from 'src/stores/zun/services'; +import { serviceState } from 'resources/nova/service'; + +export class Services extends Base { + init() { + this.store = globalServicesStore; + this.downloadStore = globalServicesStore; + } + + get name() { + return t('services'); + } + + get policy() { + return 'zun-service:get_all'; + } + + getColumns = () => [ + { + title: t('Name'), + dataIndex: 'binary', + }, + { + title: t('Hosts'), + dataIndex: 'host', + isHideable: true, + }, + { + title: t('Availability Zone'), + dataIndex: 'availability_zone', + isHideable: true, + }, + { + title: t('Report Count'), + dataIndex: 'report_count', + isHideable: true, + }, + { + title: t('Forced Down'), + dataIndex: 'forced_down', + valueRender: 'yesNo', + isHideable: true, + }, + { + title: t('Forbidden'), + dataIndex: 'disabled', + valueRender: 'yesNo', + isHideable: true, + }, + { + title: t('Service State'), + dataIndex: 'state', + render: (value) => serviceState[value] || value, + }, + { + title: t('Last Updated'), + dataIndex: 'updated_at', + isHideable: true, + valueRender: 'sinceTime', + }, + ]; +} + +export default inject('rootStore')(observer(Services)); diff --git a/src/pages/container-service/routes/index.js b/src/pages/container-service/routes/index.js index c2cb0eda..b88e8d02 100644 --- a/src/pages/container-service/routes/index.js +++ b/src/pages/container-service/routes/index.js @@ -21,6 +21,7 @@ import ContainersDetail from '../containers/Containers/Detail'; import CapsulesDetail from '../containers/Capsules/Detail'; import HostsDetail from '../containers/Hosts/Detail'; import StepCreateContainer from '../containers/Containers/actions/StepCreate'; +import Services from '../containers/Services'; const PATH = '/container'; export default [ @@ -66,6 +67,11 @@ export default [ component: HostsDetail, exact: true, }, + { + path: `${PATH}/services-admin`, + component: Services, + exact: true, + }, // All { path: '*', component: E404 }, ], diff --git a/src/stores/zun/services.js b/src/stores/zun/services.js new file mode 100644 index 00000000..e5d1419c --- /dev/null +++ b/src/stores/zun/services.js @@ -0,0 +1,25 @@ +// Copyright 2021 99cloud +// +// 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. + +import Base from 'stores/base'; +import client from 'client'; + +export class ServicesStore extends Base { + get client() { + return client.zun.services; + } +} + +const globalServicesStore = new ServicesStore(); +export default globalServicesStore;