diff --git a/src/client/client/request.js b/src/client/client/request.js index f5f69abc..a37145ca 100644 --- a/src/client/client/request.js +++ b/src/client/client/request.js @@ -46,6 +46,52 @@ export class HttpRequest { } } + addRequestId(config) { + const uuid = uuidv4(); + config.headers['X-Openstack-Request-Id'] = `req-${uuid}`; + } + + addToken(config) { + const keystoneToken = getLocalStorageItem('keystone_token') || ''; + if (keystoneToken) { + config.headers['X-Auth-Token'] = keystoneToken; + } + } + + addVersion(config, url) { + const { getOpenstackApiVersion } = require('./constants'); + const apiVersionMap = getOpenstackApiVersion(url); + + if (apiVersionMap) { + config.headers[apiVersionMap.key] = apiVersionMap.value; + } + } + + updateHeaderByConfig(config) { + const { options: { headers, isFormData, ...rest } = {} } = config; + if (!isEmpty(headers)) { + config.headers = { + ...config.headers, + ...headers, + }; + console.log('new config headers', config.headers); + } + if (isFormData) { + delete config.headers['Content-Type']; + } + Object.keys(rest).forEach((key) => { + config[key] = rest[key]; + }); + } + + updateRequestConfig(config, url) { + this.addRequestId(config); + this.addToken(config); + this.addVersion(config, url); + this.updateHeaderByConfig(config); + return config; + } + /** * @param instance instance of axios * @param url request url @@ -55,32 +101,7 @@ export class HttpRequest { interceptors(instance, url) { instance.interceptors.request.use( (config) => { - const uuid = uuidv4(); - config.headers['X-Openstack-Request-Id'] = `req-${uuid}`; - const keystoneToken = getLocalStorageItem('keystone_token') || ''; - const { getOpenstackApiVersion } = require('./constants'); - const apiVersionMap = getOpenstackApiVersion(url); - if (keystoneToken) { - config.headers['X-Auth-Token'] = keystoneToken; - } - if (apiVersionMap) { - config.headers[apiVersionMap.key] = apiVersionMap.value; - } - const { options: { headers, isFormData, ...rest } = {} } = config; - if (!isEmpty(headers)) { - config.headers = { - ...config.headers, - ...headers, - }; - console.log('new config headers', config.headers); - } - if (isFormData) { - delete config.headers['Content-Type']; - } - Object.keys(rest).forEach((key) => { - config[key] = rest[key]; - }); - return config; + return this.updateRequestConfig(config, url); }, (err) => Promise.reject(err) ); diff --git a/src/client/manila/index.js b/src/client/manila/index.js index d74d2e00..074522c9 100644 --- a/src/client/manila/index.js +++ b/src/client/manila/index.js @@ -90,6 +90,24 @@ class ManilaClient extends Base { }, ], }, + { + name: 'shareInstances', + key: 'share_instances', + responseKey: 'share_instance', + extendOperations: [ + { + key: 'action', + method: 'post', + }, + ], + subResources: [ + { + name: 'exportLocations', + key: 'export_locations', + responseKey: 'export_location', + }, + ], + }, ]; } } diff --git a/src/layouts/admin-menu.jsx b/src/layouts/admin-menu.jsx index d2a6d122..57260f9b 100644 --- a/src/layouts/admin-menu.jsx +++ b/src/layouts/admin-menu.jsx @@ -437,6 +437,22 @@ const renderMenu = (t) => { }, ], }, + { + path: '/share/share-instance-admin', + name: t('Share Instance'), + key: 'shareInstanceAdmin', + level: 1, + endpoints: 'manilav2', + children: [ + { + path: /^\/share\/share-instance-admin\/detail\/.[^/]+$/, + name: t('Share Instance Detail'), + key: 'shareInstanceDetailAdmin', + level: 2, + routePath: '/share/share-instance-admin/detail/:id', + }, + ], + }, ], }, { diff --git a/src/locales/en.json b/src/locales/en.json index f849d269..c2570fcb 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -37,6 +37,7 @@ "Abandoning this stack will preserve the resources deployed by the stack.": "Abandoning this stack will preserve the resources deployed by the stack.", "Accept Volume Transfer": "Accept Volume Transfer", "Access Control": "Access Control", + "Access Rules Status": "Access Rules Status", "Access Type": "Access Type", "Access Type Setting": "Access Type Setting", "Action": "Action", @@ -263,6 +264,7 @@ "Cancel upload successfully.": "Cancel upload successfully.", "Capacity (GB)": "Capacity (GB)", "Cape Verde": "Cape Verde", + "Cast Rules To Read Only": "Cast Rules To Read Only", "Category": "Category", "Cayman Islands": "Cayman Islands", "CentOS": "CentOS", @@ -446,6 +448,7 @@ "Created At": "Created At", "Created Time": "Created Time", "Creating": "Creating", + "Creating From Snapshot": "Creating From Snapshot", "Creation Timeout (Minutes)": "Creation Timeout (Minutes)", "Credential Type": "Credential Type", "Croatia (local name: Hrvatska)": "Croatia (local name: Hrvatska)", @@ -742,10 +745,13 @@ "Expand Advanced Options": "Expand Advanced Options", "Expired Time": "Expired Time", "Expires At": "Expires At", + "Export Location": "Export Location", + "Export Locations": "Export Locations", "Extend Root Volume": "Extend Root Volume", "Extend Volume": "Extend Volume", "Extend volume": "Extend volume", "Extending": "Extending", + "Extending Error": "Extending Error", "External": "External", "External Fixed IP": "External Fixed IP", "External Fixed IPs": "External Fixed IPs", @@ -972,6 +978,7 @@ "In the last 7 days": "In the last 7 days", "In the last hour": "In the last hour", "In-use": "In-use", + "Inactive": "Inactive", "Increment Backup": "Increment Backup", "Incremental": "Incremental", "Incremental Backup": "Incremental Backup", @@ -1063,6 +1070,7 @@ "Ironic Instance Name": "Ironic Instance Name", "Is Current Project": "Is Current Project", "Is Public": "Is Public", + "Is admin only": "Is admin only", "Is associate to floating ip: ": "Is associate to floating ip: ", "Is external network port": "Is external network port", "Isolate": "Isolate", @@ -1175,11 +1183,13 @@ "Mali": "Mali", "Malta": "Malta", "Manage Access": "Manage Access", + "Manage Error": "Manage Error", "Manage Host": "Manage Host", "Manage Metadata": "Manage Metadata", "Manage QoS": "Manage QoS", "Manage Resource Types": "Manage Resource Types", "Manage Security Group": "Manage Security Group", + "Manage Starting": "Manage Starting", "Manage State": "Manage State", "Manage User": "Manage User", "Manage User Group": "Manage User Group", @@ -1230,6 +1240,7 @@ "Migrate Volume": "Migrate Volume", "Migrate volume": "Migrate volume", "Migrating": "Migrating", + "Migrating To": "Migrating To", "Min Memory": "Min Memory", "Min Memory(GB)": "Min Memory(GB)", "Min System Disk": "Min System Disk", @@ -1375,6 +1386,7 @@ "Other Service": "Other Service", "Others": "Others", "Out Cluster": "Out Cluster", + "Out of Sync": "Out of Sync", "Outputs": "Outputs", "Overlapping allocation pools: {pools}": "Overlapping allocation pools: {pools}", "Owned Network": "Owned Network", @@ -1403,6 +1415,7 @@ "Password must be the same with confirm password.": "Password must be the same with confirm password.", "Paste": "Paste", "Paste File": "Paste File", + "Path": "Path", "Pause": "Pause", "Pause Instance": "Pause Instance", "Paused": "Paused", @@ -1535,12 +1548,14 @@ "Pre-Shared Key(PSK) String": "Pre-Shared Key(PSK) String", "Prefer": "Prefer", "Prefer(Thread siblings are preferred)": "Prefer(Thread siblings are preferred)", + "Preferred": "Preferred", "Prefix": "Prefix", "Prep Resize": "Prep Resize", "Prepare Template": "Prepare Template", "Previous": "Previous", "Private": "Private", "Profile": "Profile", + "Progress": "Progress", "Project": "Project", "Project Admin": "Project Admin", "Project Detail": "Project Detail", @@ -1633,6 +1648,7 @@ "Remove Router": "Remove Router", "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", "Republic Of The Congo": "Republic Of The Congo", "Request ID": "Request ID", "Require": "Require", @@ -1674,6 +1690,7 @@ "Revert Resize or Migrate": "Revert Resize or Migrate", "Revert Resize/Migrate": "Revert Resize/Migrate", "Reverting": "Reverting", + "Reverting Error": "Reverting Error", "Reverting Resize or Migrate": "Reverting Resize or Migrate", "Role": "Role", "Role Detail": "Role Detail", @@ -1753,6 +1770,11 @@ "Share File Storage": "Share File Storage", "Share Group Type": "Share Group Type", "Share Group Type Detail": "Share Group Type Detail", + "Share Id": "Share Id", + "Share Instance": "Share Instance", + "Share Instance Detail": "Share Instance Detail", + "Share Network": "Share Network", + "Share Server": "Share Server", "Share Type": "Share Type", "Share Type Detail": "Share Type Detail", "Shared": "Shared", @@ -1770,6 +1792,9 @@ "Show All Domain": "Show All Domain", "Show Instance": "Show Instance", "Show all Data": "Show all Data", + "Shrinking": "Shrinking", + "Shrinking Error": "Shrinking Error", + "Shrinking Possible Data Loss Error": "Shrinking Possible Data Loss Error", "Shut Down": "Shut Down", "Shut Off": "Shut Off", "Shutoff": "Shutoff", @@ -1884,6 +1909,7 @@ "Switch Language": "Switch Language", "Switch Project": "Switch Project", "Switzerland": "Switzerland", + "Syncing": "Syncing", "Syrian Arab Republic": "Syrian Arab Republic", "System": "System", "System Admin": "System Admin", @@ -2057,6 +2083,9 @@ "Unlimit": "Unlimit", "Unlock": "Unlock", "Unlock Instance": "Unlock Instance", + "Unmanage Error": "Unmanage Error", + "Unmanage Starting": "Unmanage Starting", + "Unmanaged": "Unmanaged", "Unpause": "Unpause", "Unpause Instance": "Unpause Instance", "Unrescuing": "Unrescuing", @@ -2405,6 +2434,8 @@ "services": "services", "settings": "settings", "share group type": "share group type", + "share instance": "share instance", + "share instances": "share instances", "share type": "share type", "share types": "share types", "shelve instance": "shelve instance", diff --git a/src/locales/zh.json b/src/locales/zh.json index 85810e9d..e228d008 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -37,6 +37,7 @@ "Abandoning this stack will preserve the resources deployed by the stack.": "废弃此堆栈将保留堆栈部署的资源。", "Accept Volume Transfer": "接受云硬盘转让", "Access Control": "访问控制", + "Access Rules Status": "访问规则状态", "Access Type": "访问类型", "Access Type Setting": "访问类型设置", "Action": "操作", @@ -263,6 +264,7 @@ "Cancel upload successfully.": "取消上传成功。", "Capacity (GB)": "容量(GB)", "Cape Verde": "佛得角", + "Cast Rules To Read Only": "规则强制只读", "Category": "类别", "Cayman Islands": "开曼群岛", "CentOS": "", @@ -446,6 +448,7 @@ "Created At": "创建于", "Created Time": "创建时间", "Creating": "创建中", + "Creating From Snapshot": "正在从快照创建共享", "Creation Timeout (Minutes)": "创建超时(分钟)", "Credential Type": "凭证类型", "Croatia (local name: Hrvatska)": "克罗地亚", @@ -742,10 +745,13 @@ "Expand Advanced Options": "展开高级选项", "Expired Time": "到期时间", "Expires At": "到期时间", + "Export Location": "导入位置", + "Export Locations": "导入位置", "Extend Root Volume": "扩容根硬盘", "Extend Volume": "扩容云硬盘", "Extend volume": "扩容云硬盘", "Extending": "扩展中", + "Extending Error": "扩展失败", "External": "外部网络", "External Fixed IP": "外部固定IP", "External Fixed IPs": "外部固定IP", @@ -972,6 +978,7 @@ "In the last 7 days": "最近7天", "In the last hour": "最近1小时", "In-use": "正在使用", + "Inactive": "非活动状态", "Increment Backup": "增量备份", "Incremental": "增量", "Incremental Backup": "增量备份", @@ -1063,6 +1070,7 @@ "Ironic Instance Name": "裸机名称", "Is Current Project": "属于当前项目", "Is Public": "公有", + "Is admin only": "仅限管理员", "Is associate to floating ip: ": "已绑定浮动IP:", "Is external network port": "是外部网络的网卡", "Isolate": "", @@ -1175,11 +1183,13 @@ "Mali": "马里", "Malta": "马尔他", "Manage Access": "访问管理", + "Manage Error": "管理失败", "Manage Host": "管理主机", "Manage Metadata": "管理元数据", "Manage QoS": "管理QoS", "Manage Resource Types": "管理资源类型", "Manage Security Group": "管理安全组", + "Manage Starting": "管理开始", "Manage State": "管理状态", "Manage User": "管理用户", "Manage User Group": "管理用户组", @@ -1230,6 +1240,7 @@ "Migrate Volume": "迁移云硬盘", "Migrate volume": "迁移云硬盘", "Migrating": "迁移", + "Migrating To": "迁移目标", "Min Memory": "最小内存", "Min Memory(GB)": "最小内存(GB)", "Min System Disk": "最小系统盘", @@ -1375,6 +1386,7 @@ "Other Service": "其他服务", "Others": "其他", "Out Cluster": "集群外", + "Out of Sync": "不同步", "Outputs": "输出", "Overlapping allocation pools: {pools}": "重叠的分配地址池: {pools}", "Owned Network": "所属网络", @@ -1403,6 +1415,7 @@ "Password must be the same with confirm password.": "密码和确认密码必须一致。", "Paste": "粘贴", "Paste File": "粘贴文件", + "Path": "路径", "Pause": "暂停", "Pause Instance": "暂停云主机", "Paused": "已暂停", @@ -1535,12 +1548,14 @@ "Pre-Shared Key(PSK) String": "预共享密钥(PSK)", "Prefer": "", "Prefer(Thread siblings are preferred)": "Prefer(最好有多线程, 若有的话则使用线程的兄弟节点)", + "Preferred": "首选", "Prefix": "前缀", "Prep Resize": "预调整", "Prepare Template": "准备模板", "Previous": "上一步", "Private": "私有", "Profile": "概要", + "Progress": "进度", "Project": "项目", "Project Admin": "项目管理权限", "Project Detail": "项目详情", @@ -1633,6 +1648,7 @@ "Remove Router": "移除路由器", "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": "复制更改中", "Republic Of The Congo": "刚果共和国", "Request ID": "请求ID", "Require": "强制", @@ -1674,6 +1690,7 @@ "Revert Resize or Migrate": "回滚修改配置/迁移", "Revert Resize/Migrate": "回滚修改配置/迁移", "Reverting": "恢复中", + "Reverting Error": "恢复失败", "Reverting Resize or Migrate": "正在回滚修改配置/迁移", "Role": "角色", "Role Detail": "角色详情", @@ -1753,6 +1770,11 @@ "Share File Storage": "文件存储", "Share Group Type": "共享组类型", "Share Group Type Detail": "共享组类型详情", + "Share Id": "共享ID", + "Share Instance": "共享实例", + "Share Instance Detail": "共享实例详情", + "Share Network": "共享网络", + "Share Server": "共享服务器", "Share Type": "共享类型", "Share Type Detail": "共享类型详情", "Shared": "共享", @@ -1770,6 +1792,9 @@ "Show All Domain": "展开所有域", "Show Instance": "展示云主机", "Show all Data": "展开所有数据", + "Shrinking": "缩容中", + "Shrinking Error": "缩容失败", + "Shrinking Possible Data Loss Error": "由数据丢失导致的缩容失败", "Shut Down": "关闭", "Shut Off": "关闭", "Shutoff": "关闭", @@ -1884,6 +1909,7 @@ "Switch Language": "切换语言", "Switch Project": "切换项目", "Switzerland": "瑞士", + "Syncing": "同步中", "Syrian Arab Republic": "叙利亚", "System": "系统", "System Admin": "系统管理权限", @@ -2057,6 +2083,9 @@ "Unlimit": "无限制", "Unlock": "解锁", "Unlock Instance": "解锁云主机", + "Unmanage Error": "取消管理出错", + "Unmanage Starting": "取消管理已开始", + "Unmanaged": "已取消管理", "Unpause": "恢复", "Unpause Instance": "恢复云主机", "Unrescuing": "", @@ -2405,6 +2434,8 @@ "services": "服务", "settings": "配置", "share group type": "共享组类型", + "share instance": "共享实例", + "share instances": "共享实例", "share type": "共享类型", "share types": "共享类型", "shelve instance": "归档云主机", diff --git a/src/pages/share/containers/ShareInstance/Detail/BaseDetail.jsx b/src/pages/share/containers/ShareInstance/Detail/BaseDetail.jsx new file mode 100644 index 00000000..995ff496 --- /dev/null +++ b/src/pages/share/containers/ShareInstance/Detail/BaseDetail.jsx @@ -0,0 +1,110 @@ +// 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 { inject, observer } from 'mobx-react'; +import Base from 'containers/BaseDetail'; +import { accessRuleStatus } from 'resources/share'; +import { getYesNo } from 'utils/index'; + +export class BaseDetail extends Base { + get leftCards() { + return [this.baseInfoCard]; + } + + get rightCards() { + return [this.exportLocations]; + } + + get baseInfoCard() { + const options = [ + { + label: t('Host'), + dataIndex: 'host', + }, + { + label: t('Availability Zone'), + dataIndex: 'availability_zone', + }, + { + label: t('Share Network'), + dataIndex: 'share_network_id', + }, + { + label: t('Share Server'), + dataIndex: 'share_server_id', + }, + { + label: t('Share Id'), + dataIndex: 'share_id', + }, + { + label: t('Access Rules Status'), + dataIndex: 'access_rules_status', + render: (value) => accessRuleStatus[value] || value, + }, + { + label: t('Progress'), + dataIndex: 'progress', + }, + { + label: t('Cast Rules To Read Only'), + dataIndex: 'cast_rules_to_readonly', + valueRender: 'yesNo', + }, + ]; + + return { + title: t('Base Info'), + options, + }; + } + + get exportLocations() { + const { exportLocations = [] } = this.detailData || {}; + const options = exportLocations.map((location, index) => { + return { + label: `${t('Export Location')} ${index + 1}`, + dataIndex: 'exportLocations', + render: () => { + return ( +