hc-busin-components 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CascaderCluster/index.d.ts +10 -0
- package/dist/CascaderCluster/index.js +490 -0
- package/dist/CascaderCluster/index.less +157 -0
- package/dist/CascaderCluster/locale.d.ts +3 -0
- package/dist/CascaderCluster/locale.js +17 -0
- package/dist/CascaderCluster/services.d.ts +37 -0
- package/dist/CascaderCluster/services.js +242 -0
- package/dist/CascaderCluster/types.d.ts +53 -0
- package/dist/CascaderCluster/types.js +1 -0
- package/dist/CascaderCluster/utils.d.ts +5 -0
- package/dist/CascaderCluster/utils.js +29 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CascaderClusterProps } from './types';
|
|
3
|
+
import './index.less';
|
|
4
|
+
export type { CascaderClusterProps, CascaderClusterTexts, CascaderClusterFilterCache, CascaderClusterStorage, CascaderClusterDataInterface, LogicalClusterItem, LogicalDatacenterItem, } from './types';
|
|
5
|
+
export { cascaderClusterLocaleZhCN, mergeCascaderClusterTexts, } from './locale';
|
|
6
|
+
export { CASCADER_CLUSTER_API, createCascaderClusterServices, buildCascaderClusterDataInterface, } from './services';
|
|
7
|
+
export type { CascaderClusterServices, CascaderClusterRequest } from './services';
|
|
8
|
+
export { detectIsBackend, readFilterCache, writeFilterCache } from './utils';
|
|
9
|
+
declare const CascaderCluster: React.FC<CascaderClusterProps>;
|
|
10
|
+
export default CascaderCluster;
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
import { SearchOutlined } from '@ant-design/icons';
|
|
17
|
+
import { ConfigProvider, Divider, Dropdown, Input, Popover } from 'antd';
|
|
18
|
+
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
19
|
+
import ComponentUninstalled from "../ComponentUninstalled";
|
|
20
|
+
import Icon from "../Icon";
|
|
21
|
+
import TextEllipsis from "../TextEllipsis";
|
|
22
|
+
import { mergeCascaderClusterTexts } from "./locale";
|
|
23
|
+
import { buildCascaderClusterDataInterface } from "./services";
|
|
24
|
+
import { detectIsBackend, readFilterCache, writeFilterCache } from "./utils";
|
|
25
|
+
import "./index.less";
|
|
26
|
+
export { cascaderClusterLocaleZhCN, mergeCascaderClusterTexts } from "./locale";
|
|
27
|
+
export { CASCADER_CLUSTER_API, createCascaderClusterServices, buildCascaderClusterDataInterface } from "./services";
|
|
28
|
+
export { detectIsBackend, readFilterCache, writeFilterCache } from "./utils";
|
|
29
|
+
var defaultStorage = {
|
|
30
|
+
getSession: function getSession(key, returnStr) {
|
|
31
|
+
var value = window.sessionStorage.getItem(key) || '';
|
|
32
|
+
if (returnStr) return value;
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(value);
|
|
35
|
+
} catch (_unused) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
setSession: function setSession(key, value) {
|
|
40
|
+
window.sessionStorage.setItem(key, typeof value === 'string' ? value : JSON.stringify(value));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var CascaderCluster = function CascaderCluster(props) {
|
|
44
|
+
var _useContext;
|
|
45
|
+
var space = props.space,
|
|
46
|
+
onClusterChange = props.onClusterChange,
|
|
47
|
+
_props$datacenters = props.datacenters,
|
|
48
|
+
datacenters = _props$datacenters === void 0 ? false : _props$datacenters,
|
|
49
|
+
_props$clusters = props.clusters,
|
|
50
|
+
clusters = _props$clusters === void 0 ? false : _props$clusters,
|
|
51
|
+
compoKey = props.compoKey,
|
|
52
|
+
dataInterfaceProp = props.dataInterface,
|
|
53
|
+
services = props.services,
|
|
54
|
+
_props$storage = props.storage,
|
|
55
|
+
storage = _props$storage === void 0 ? defaultStorage : _props$storage,
|
|
56
|
+
isBackendProp = props.isBackend,
|
|
57
|
+
pathnameProp = props.pathname,
|
|
58
|
+
onFilterCacheChange = props.onFilterCacheChange,
|
|
59
|
+
getClusterAddons = props.getClusterAddons,
|
|
60
|
+
_props$showComponentU = props.showComponentUninstalled,
|
|
61
|
+
showComponentUninstalled = _props$showComponentU === void 0 ? true : _props$showComponentU,
|
|
62
|
+
textsProp = props.texts;
|
|
63
|
+
var pathname = pathnameProp !== null && pathnameProp !== void 0 ? pathnameProp : typeof window !== 'undefined' ? window.location.pathname : '';
|
|
64
|
+
var search = typeof window !== 'undefined' ? window.location.search : '';
|
|
65
|
+
var isBackend = isBackendProp !== null && isBackendProp !== void 0 ? isBackendProp : detectIsBackend(pathname, search);
|
|
66
|
+
var antdLocale = (_useContext = useContext(ConfigProvider.ConfigContext)) === null || _useContext === void 0 ? void 0 : _useContext.locale;
|
|
67
|
+
var texts = useMemo(function () {
|
|
68
|
+
return mergeCascaderClusterTexts(_objectSpread(_objectSpread({}, antdLocale === null || antdLocale === void 0 ? void 0 : antdLocale.logical), textsProp));
|
|
69
|
+
}, [antdLocale === null || antdLocale === void 0 ? void 0 : antdLocale.logical, textsProp]);
|
|
70
|
+
var _useState = useState([]),
|
|
71
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
72
|
+
datacenterList = _useState2[0],
|
|
73
|
+
setDatacenterList = _useState2[1];
|
|
74
|
+
var _useState3 = useState([]),
|
|
75
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
76
|
+
clusterList = _useState4[0],
|
|
77
|
+
setClusterList = _useState4[1];
|
|
78
|
+
var _useState5 = useState([]),
|
|
79
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
80
|
+
allClusters = _useState6[0],
|
|
81
|
+
setAllClusters = _useState6[1];
|
|
82
|
+
var _useState7 = useState(null),
|
|
83
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
84
|
+
clusterKeyword = _useState8[0],
|
|
85
|
+
setClusterKeyword = _useState8[1];
|
|
86
|
+
var _useState9 = useState({}),
|
|
87
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
88
|
+
currentDatacenter = _useState10[0],
|
|
89
|
+
setCurrentDatacenter = _useState10[1];
|
|
90
|
+
var _useState11 = useState(''),
|
|
91
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
92
|
+
currentCluster = _useState12[0],
|
|
93
|
+
setCurrentCluster = _useState12[1];
|
|
94
|
+
var resolvedDataInterface = useMemo(function () {
|
|
95
|
+
if (dataInterfaceProp) return dataInterfaceProp;
|
|
96
|
+
if (services) return buildCascaderClusterDataInterface(space, isBackend, storage, services);
|
|
97
|
+
return null;
|
|
98
|
+
}, [dataInterfaceProp, services, space, isBackend, storage]);
|
|
99
|
+
var getCache = useCallback(function () {
|
|
100
|
+
return readFilterCache(storage, isBackend, pathname);
|
|
101
|
+
}, [storage, isBackend, pathname]);
|
|
102
|
+
var saveCache = useCallback(function (params) {
|
|
103
|
+
writeFilterCache(storage, isBackend, pathname, params);
|
|
104
|
+
onFilterCacheChange === null || onFilterCacheChange === void 0 || onFilterCacheChange(params);
|
|
105
|
+
}, [storage, isBackend, pathname, onFilterCacheChange]);
|
|
106
|
+
var getInitCluster = useCallback(function (list, dcData) {
|
|
107
|
+
var cachedClusterName = getCache().clusterName;
|
|
108
|
+
var all = list || [];
|
|
109
|
+
var cachedMatch = all.find(function (item) {
|
|
110
|
+
return item.clusterName === cachedClusterName;
|
|
111
|
+
}) || {};
|
|
112
|
+
var cluster = {};
|
|
113
|
+
if (Object.keys(cachedMatch).length > 0 && cachedMatch.clusterStatus === 'online') {
|
|
114
|
+
cluster = _objectSpread({}, cachedMatch);
|
|
115
|
+
} else {
|
|
116
|
+
cluster = all.find(function (item) {
|
|
117
|
+
return item.clusterStatus === 'online';
|
|
118
|
+
}) || {};
|
|
119
|
+
}
|
|
120
|
+
var clusterName = cluster.clusterName || '';
|
|
121
|
+
setCurrentCluster(clusterName);
|
|
122
|
+
if (clusterName) {
|
|
123
|
+
onClusterChange(clusterName);
|
|
124
|
+
}
|
|
125
|
+
saveCache(_objectSpread(_objectSpread({}, dcData), {}, {
|
|
126
|
+
clusterName: clusterName
|
|
127
|
+
}));
|
|
128
|
+
}, [getCache, onClusterChange, saveCache]);
|
|
129
|
+
var fetchClusterList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
130
|
+
var _resolvedDataInterfac;
|
|
131
|
+
var params,
|
|
132
|
+
list,
|
|
133
|
+
_args = arguments;
|
|
134
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
135
|
+
while (1) switch (_context.prev = _context.next) {
|
|
136
|
+
case 0:
|
|
137
|
+
params = _args.length > 0 && _args[0] !== undefined ? _args[0] : currentDatacenter;
|
|
138
|
+
if (resolvedDataInterface !== null && resolvedDataInterface !== void 0 && (_resolvedDataInterfac = resolvedDataInterface.resource) !== null && _resolvedDataInterfac !== void 0 && _resolvedDataInterfac.service) {
|
|
139
|
+
_context.next = 3;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
return _context.abrupt("return");
|
|
143
|
+
case 3:
|
|
144
|
+
_context.next = 5;
|
|
145
|
+
return resolvedDataInterface.resource.service(_objectSpread(_objectSpread({}, resolvedDataInterface.resource.params || {}), {}, {
|
|
146
|
+
dataCenterId: params === null || params === void 0 ? void 0 : params.dataCenterId,
|
|
147
|
+
logicalUnitId: params === null || params === void 0 ? void 0 : params.logicalUnitId
|
|
148
|
+
}));
|
|
149
|
+
case 5:
|
|
150
|
+
list = _context.sent;
|
|
151
|
+
setAllClusters(list);
|
|
152
|
+
setClusterList(list);
|
|
153
|
+
getInitCluster(list, params);
|
|
154
|
+
case 9:
|
|
155
|
+
case "end":
|
|
156
|
+
return _context.stop();
|
|
157
|
+
}
|
|
158
|
+
}, _callee);
|
|
159
|
+
})), [resolvedDataInterface, currentDatacenter, getInitCluster]);
|
|
160
|
+
var getLdcWriteBack = useCallback(function (list) {
|
|
161
|
+
var cache = getCache();
|
|
162
|
+
if (cache.id === '-1') {
|
|
163
|
+
var datacenter = list.find(function (item) {
|
|
164
|
+
return item.id === -1;
|
|
165
|
+
});
|
|
166
|
+
if (datacenter) {
|
|
167
|
+
return {
|
|
168
|
+
name: texts.unbound,
|
|
169
|
+
id: '-1',
|
|
170
|
+
dataCenterId: null,
|
|
171
|
+
logicalUnitId: null
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (cache.dataCenterId) {
|
|
176
|
+
var _datacenter = list.find(function (item) {
|
|
177
|
+
return item.id === cache.dataCenterId;
|
|
178
|
+
}) || list.find(function (item) {
|
|
179
|
+
return String(item.id) === String(cache.dataCenterId);
|
|
180
|
+
});
|
|
181
|
+
if (_datacenter) {
|
|
182
|
+
var unit = cache.logicalUnitId ? (_datacenter.logicalUnitList || []).find(function (item) {
|
|
183
|
+
return item.id === cache.logicalUnitId || String(item.id) === String(cache.logicalUnitId);
|
|
184
|
+
}) : undefined;
|
|
185
|
+
if (unit) {
|
|
186
|
+
return {
|
|
187
|
+
name: "".concat(_datacenter.name, "/").concat(unit.name),
|
|
188
|
+
id: String(unit.id),
|
|
189
|
+
dataCenterId: _datacenter.id,
|
|
190
|
+
logicalUnitId: unit.id
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
name: _datacenter.name,
|
|
195
|
+
id: String(_datacenter.id),
|
|
196
|
+
dataCenterId: _datacenter.id,
|
|
197
|
+
logicalUnitId: null
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}, [getCache, texts.unbound]);
|
|
203
|
+
var getInitDatacenter = useCallback(function (list) {
|
|
204
|
+
var data = {
|
|
205
|
+
name: null,
|
|
206
|
+
id: null,
|
|
207
|
+
dataCenterId: null,
|
|
208
|
+
logicalUnitId: null
|
|
209
|
+
};
|
|
210
|
+
if (list.length > 0) {
|
|
211
|
+
var selected = getLdcWriteBack(list);
|
|
212
|
+
if (selected) {
|
|
213
|
+
data = selected;
|
|
214
|
+
} else {
|
|
215
|
+
data = {
|
|
216
|
+
name: list[0].name,
|
|
217
|
+
id: String(list[0].id),
|
|
218
|
+
dataCenterId: list[0].id === -1 ? null : list[0].id,
|
|
219
|
+
logicalUnitId: null
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
setCurrentDatacenter(data);
|
|
224
|
+
if (clusters && clusters.length > 0) {
|
|
225
|
+
setAllClusters(clusters);
|
|
226
|
+
setClusterList(clusters);
|
|
227
|
+
getInitCluster(clusters, data);
|
|
228
|
+
} else {
|
|
229
|
+
fetchClusterList(data);
|
|
230
|
+
}
|
|
231
|
+
}, [clusters, fetchClusterList, getInitCluster, getLdcWriteBack]);
|
|
232
|
+
var fetchDatacenterList = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
233
|
+
var _resolvedDataInterfac2;
|
|
234
|
+
var list;
|
|
235
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
236
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
237
|
+
case 0:
|
|
238
|
+
if (resolvedDataInterface !== null && resolvedDataInterface !== void 0 && (_resolvedDataInterfac2 = resolvedDataInterface.datacenter) !== null && _resolvedDataInterfac2 !== void 0 && _resolvedDataInterfac2.service) {
|
|
239
|
+
_context2.next = 2;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
return _context2.abrupt("return");
|
|
243
|
+
case 2:
|
|
244
|
+
_context2.next = 4;
|
|
245
|
+
return resolvedDataInterface.datacenter.service(_objectSpread({}, resolvedDataInterface.datacenter.params || {}));
|
|
246
|
+
case 4:
|
|
247
|
+
list = _context2.sent;
|
|
248
|
+
setDatacenterList(list);
|
|
249
|
+
getInitDatacenter(list);
|
|
250
|
+
case 7:
|
|
251
|
+
case "end":
|
|
252
|
+
return _context2.stop();
|
|
253
|
+
}
|
|
254
|
+
}, _callee2);
|
|
255
|
+
})), [resolvedDataInterface, getInitDatacenter]);
|
|
256
|
+
useEffect(function () {
|
|
257
|
+
if (space === 'cluster') {
|
|
258
|
+
var cluster = String(storage.getSession('clusterName') || '');
|
|
259
|
+
setCurrentCluster(cluster);
|
|
260
|
+
onClusterChange(cluster);
|
|
261
|
+
setDatacenterList([]);
|
|
262
|
+
setClusterList([]);
|
|
263
|
+
setAllClusters([]);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (datacenters && datacenters.length > 0) {
|
|
267
|
+
setDatacenterList(datacenters);
|
|
268
|
+
getInitDatacenter(datacenters);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
fetchDatacenterList();
|
|
272
|
+
}, [space, datacenters, clusters, compoKey, fetchDatacenterList, getInitDatacenter, onClusterChange, storage]);
|
|
273
|
+
useEffect(function () {
|
|
274
|
+
if (!pathname.includes('resourceQuotaCenter')) return;
|
|
275
|
+
var timer = setTimeout(function () {
|
|
276
|
+
var currentCache = getCache();
|
|
277
|
+
if (currentCache && Object.keys(currentCache).length > 0) {
|
|
278
|
+
if (!datacenters || datacenters.length === 0) {
|
|
279
|
+
fetchDatacenterList();
|
|
280
|
+
} else {
|
|
281
|
+
getInitDatacenter(datacenters);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}, 200);
|
|
285
|
+
return function () {
|
|
286
|
+
return clearTimeout(timer);
|
|
287
|
+
};
|
|
288
|
+
}, [pathname, datacenters, fetchDatacenterList, getCache, getInitDatacenter]);
|
|
289
|
+
var handleChangeData = function handleChangeData(data, key) {
|
|
290
|
+
setClusterKeyword(null);
|
|
291
|
+
var current = {
|
|
292
|
+
name: null,
|
|
293
|
+
id: null,
|
|
294
|
+
dataCenterId: null,
|
|
295
|
+
logicalUnitId: null
|
|
296
|
+
};
|
|
297
|
+
if (key === 'unbound') {
|
|
298
|
+
current = {
|
|
299
|
+
name: texts.unbound,
|
|
300
|
+
id: String(data.id),
|
|
301
|
+
dataCenterId: null,
|
|
302
|
+
logicalUnitId: null
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
if (key === 'dataCenter') {
|
|
306
|
+
current = {
|
|
307
|
+
name: data.name,
|
|
308
|
+
id: String(data.id),
|
|
309
|
+
dataCenterId: data.id,
|
|
310
|
+
logicalUnitId: null
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
if (key === 'logicalUnit') {
|
|
314
|
+
var unit = data;
|
|
315
|
+
current = {
|
|
316
|
+
name: "".concat(unit.dataCenterName, "/").concat(unit.name),
|
|
317
|
+
id: String(unit.id),
|
|
318
|
+
dataCenterId: unit.dataCenterId,
|
|
319
|
+
logicalUnitId: unit.id
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
setCurrentDatacenter(current);
|
|
323
|
+
if (key === 'unbound' && space === 'system') {
|
|
324
|
+
var boundClusters = data.clusters || [];
|
|
325
|
+
setAllClusters(boundClusters);
|
|
326
|
+
setClusterList(boundClusters);
|
|
327
|
+
getInitCluster(boundClusters, current);
|
|
328
|
+
} else {
|
|
329
|
+
fetchClusterList(current);
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
var handleChangeCluster = function handleChangeCluster(cluster) {
|
|
333
|
+
setCurrentCluster(cluster.clusterName);
|
|
334
|
+
onClusterChange(cluster.clusterName);
|
|
335
|
+
saveCache(_objectSpread(_objectSpread({}, currentDatacenter), {}, {
|
|
336
|
+
clusterName: cluster.clusterName
|
|
337
|
+
}));
|
|
338
|
+
};
|
|
339
|
+
var handleFilterClusters = function handleFilterClusters(key) {
|
|
340
|
+
setClusterKeyword(key);
|
|
341
|
+
var list = allClusters.filter(function (item) {
|
|
342
|
+
return item.clusterName.indexOf(key) > -1;
|
|
343
|
+
});
|
|
344
|
+
setClusterList(list);
|
|
345
|
+
};
|
|
346
|
+
var getDatacentersForDropdown = function getDatacentersForDropdown(list) {
|
|
347
|
+
var items = [];
|
|
348
|
+
list.forEach(function (item) {
|
|
349
|
+
if (item.id === -1) {
|
|
350
|
+
items.push({
|
|
351
|
+
key: '-1',
|
|
352
|
+
label: texts.unbound,
|
|
353
|
+
onClick: function onClick() {
|
|
354
|
+
return handleChangeData(item, 'unbound');
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
} else {
|
|
358
|
+
var children = (item.logicalUnitList || []).map(function (unit) {
|
|
359
|
+
return {
|
|
360
|
+
key: String(unit.id),
|
|
361
|
+
label: /*#__PURE__*/React.createElement("div", {
|
|
362
|
+
className: "ldc-sub-menu-item"
|
|
363
|
+
}, /*#__PURE__*/React.createElement(TextEllipsis, {
|
|
364
|
+
content: unit.name,
|
|
365
|
+
popoverStyle: {
|
|
366
|
+
zIndex: 1090
|
|
367
|
+
}
|
|
368
|
+
})),
|
|
369
|
+
onClick: function onClick() {
|
|
370
|
+
return handleChangeData(_objectSpread(_objectSpread({}, unit), {}, {
|
|
371
|
+
dataCenterId: item.id,
|
|
372
|
+
dataCenterName: item.name
|
|
373
|
+
}), 'logicalUnit');
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
});
|
|
377
|
+
items.push({
|
|
378
|
+
key: String(item.id),
|
|
379
|
+
label: /*#__PURE__*/React.createElement("div", {
|
|
380
|
+
className: "parent-menu-item",
|
|
381
|
+
onClick: function onClick() {
|
|
382
|
+
return handleChangeData(item, 'dataCenter');
|
|
383
|
+
}
|
|
384
|
+
}, /*#__PURE__*/React.createElement(TextEllipsis, {
|
|
385
|
+
content: item.name,
|
|
386
|
+
popoverStyle: {
|
|
387
|
+
zIndex: 1090
|
|
388
|
+
}
|
|
389
|
+
})),
|
|
390
|
+
children: children.length > 0 ? children : undefined
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
return items;
|
|
395
|
+
};
|
|
396
|
+
var getClustersForDropdown = function getClustersForDropdown(list) {
|
|
397
|
+
return list.map(function (item) {
|
|
398
|
+
return {
|
|
399
|
+
key: item.clusterName,
|
|
400
|
+
label: /*#__PURE__*/React.createElement(Popover, {
|
|
401
|
+
placement: "right",
|
|
402
|
+
content: item.clusterStatus === 'online' ? null : texts.clusterOffline,
|
|
403
|
+
arrow: {
|
|
404
|
+
pointAtCenter: true
|
|
405
|
+
},
|
|
406
|
+
overlayClassName: "filter-dropdown-popover"
|
|
407
|
+
}, item.clusterName, item.clusterStatus !== 'online' && /*#__PURE__*/React.createElement(Icon, {
|
|
408
|
+
name: "v35_Disconnection"
|
|
409
|
+
})),
|
|
410
|
+
disabled: item.clusterStatus !== 'online',
|
|
411
|
+
onClick: function onClick() {
|
|
412
|
+
return handleChangeCluster(item);
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
});
|
|
416
|
+
};
|
|
417
|
+
var showDatacenter = !(datacenterList.length === 0 || datacenterList.length === 1 && datacenterList[0].id === -1);
|
|
418
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
419
|
+
className: "ldc-cascader-cluster-wrap"
|
|
420
|
+
}, showDatacenter && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, {
|
|
421
|
+
className: "button-divider",
|
|
422
|
+
type: "vertical"
|
|
423
|
+
}), /*#__PURE__*/React.createElement(Dropdown, {
|
|
424
|
+
trigger: ['click'],
|
|
425
|
+
overlayClassName: "filter-dropdown-items",
|
|
426
|
+
menu: {
|
|
427
|
+
items: getDatacentersForDropdown(datacenterList),
|
|
428
|
+
selectable: true,
|
|
429
|
+
selectedKeys: currentDatacenter !== null && currentDatacenter !== void 0 && currentDatacenter.id ? [String(currentDatacenter.id)] : []
|
|
430
|
+
}
|
|
431
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
432
|
+
className: "filter-dropdown-header"
|
|
433
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
434
|
+
name: "v35_Datacenter"
|
|
435
|
+
}), currentDatacenter !== null && currentDatacenter !== void 0 && currentDatacenter.name ? /*#__PURE__*/React.createElement(TextEllipsis, {
|
|
436
|
+
content: currentDatacenter.name
|
|
437
|
+
}) : /*#__PURE__*/React.createElement("span", {
|
|
438
|
+
className: "placeholder"
|
|
439
|
+
}, texts.selectLogicalUnit), /*#__PURE__*/React.createElement(Icon, {
|
|
440
|
+
name: "v35_ArrowDown"
|
|
441
|
+
})))), allClusters.length > 0 && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, {
|
|
442
|
+
className: "button-divider",
|
|
443
|
+
type: "vertical"
|
|
444
|
+
}), /*#__PURE__*/React.createElement(Dropdown, {
|
|
445
|
+
trigger: ['click'],
|
|
446
|
+
overlayClassName: "filter-dropdown-items",
|
|
447
|
+
menu: {
|
|
448
|
+
items: getClustersForDropdown(clusterList),
|
|
449
|
+
selectable: true,
|
|
450
|
+
selectedKeys: currentCluster ? [currentCluster] : []
|
|
451
|
+
},
|
|
452
|
+
dropdownRender: function dropdownRender(menu) {
|
|
453
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input, {
|
|
454
|
+
placeholder: texts.searchByClusterName,
|
|
455
|
+
prefix: /*#__PURE__*/React.createElement(SearchOutlined, null),
|
|
456
|
+
variant: "borderless",
|
|
457
|
+
allowClear: true,
|
|
458
|
+
value: clusterKeyword !== null && clusterKeyword !== void 0 ? clusterKeyword : undefined,
|
|
459
|
+
onPressEnter: function onPressEnter(e) {
|
|
460
|
+
handleFilterClusters(e.target.value);
|
|
461
|
+
},
|
|
462
|
+
onChange: function onChange(e) {
|
|
463
|
+
if (e.type === 'click') {
|
|
464
|
+
setClusterList(allClusters);
|
|
465
|
+
setClusterKeyword(null);
|
|
466
|
+
} else {
|
|
467
|
+
setClusterKeyword(e.target.value);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}), clusterList.length > 0 ? menu : /*#__PURE__*/React.createElement("div", {
|
|
471
|
+
className: "no-data"
|
|
472
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
473
|
+
name: "no-data"
|
|
474
|
+
}), texts.nodata));
|
|
475
|
+
}
|
|
476
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
477
|
+
className: "filter-dropdown-header"
|
|
478
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
479
|
+
name: "v35_Clusters"
|
|
480
|
+
}), currentCluster ? currentCluster : /*#__PURE__*/React.createElement("span", {
|
|
481
|
+
className: "placeholder"
|
|
482
|
+
}, texts.pleaseSelectCluster), /*#__PURE__*/React.createElement(Icon, {
|
|
483
|
+
name: "v35_ArrowDown"
|
|
484
|
+
}))))), showComponentUninstalled && /*#__PURE__*/React.createElement(ComponentUninstalled, {
|
|
485
|
+
clusterName: currentCluster,
|
|
486
|
+
isMask: true,
|
|
487
|
+
getClusterAddons: getClusterAddons
|
|
488
|
+
}));
|
|
489
|
+
};
|
|
490
|
+
export default CascaderCluster;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
.ldc-cascader-cluster-wrap {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.filter-dropdown-items {
|
|
7
|
+
&.ant-dropdown {
|
|
8
|
+
min-width: 150px;
|
|
9
|
+
padding: 4px;
|
|
10
|
+
background-color: #fff;
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
box-shadow:
|
|
13
|
+
0 3px 6px -4px rgba(0, 0, 0, 0.12),
|
|
14
|
+
0 6px 16px 0 rgba(0, 0, 0, 0.08),
|
|
15
|
+
0 9px 28px 8px rgba(0, 0, 0, 0.05);
|
|
16
|
+
|
|
17
|
+
.ant-dropdown-menu {
|
|
18
|
+
max-height: 200px;
|
|
19
|
+
padding: 0;
|
|
20
|
+
overflow-y: auto;
|
|
21
|
+
box-shadow: none;
|
|
22
|
+
|
|
23
|
+
.ant-dropdown-menu-item,
|
|
24
|
+
.ant-dropdown-menu-submenu {
|
|
25
|
+
margin: 8px 0;
|
|
26
|
+
border-radius: 4px;
|
|
27
|
+
|
|
28
|
+
&.ant-dropdown-menu-item-active {
|
|
29
|
+
&:active {
|
|
30
|
+
color: #2869f6;
|
|
31
|
+
background: rgba(40, 105, 246, 0.1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.ant-dropdown-menu-submenu-active {
|
|
36
|
+
.ant-dropdown-menu-submenu-title {
|
|
37
|
+
&:active {
|
|
38
|
+
color: #2869f6;
|
|
39
|
+
background: rgba(40, 105, 246, 0.1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.parent-menu-item {
|
|
45
|
+
display: inline-block;
|
|
46
|
+
width: 100%;
|
|
47
|
+
min-width: 124px;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.hc-icon {
|
|
52
|
+
margin-left: 4px;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.ant-dropdown-menu-item-selected,
|
|
57
|
+
.ant-dropdown-menu-submenu-title-selected {
|
|
58
|
+
background-color: #2869f61a;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.ant-input-affix-wrapper {
|
|
62
|
+
background: #f7f8fa;
|
|
63
|
+
.ant-input-prefix {
|
|
64
|
+
font-weight: 500;
|
|
65
|
+
font-size: 16px;
|
|
66
|
+
}
|
|
67
|
+
.ant-input {
|
|
68
|
+
background: none;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.ant-btn-text {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
width: 100%;
|
|
76
|
+
height: auto;
|
|
77
|
+
padding: 5px 8px;
|
|
78
|
+
color: rgba(0, 0, 0, 0.65);
|
|
79
|
+
text-align: left;
|
|
80
|
+
&:focus,
|
|
81
|
+
&:hover {
|
|
82
|
+
background: rgba(0, 0, 0, 0.03);
|
|
83
|
+
}
|
|
84
|
+
&:active,
|
|
85
|
+
&.active {
|
|
86
|
+
color: #2869f6;
|
|
87
|
+
background: rgba(40, 105, 246, 0.1);
|
|
88
|
+
}
|
|
89
|
+
.hc-icon {
|
|
90
|
+
margin-left: 4px;
|
|
91
|
+
font-size: 16px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.ant-divider-horizontal {
|
|
96
|
+
margin: 4px 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.no-data {
|
|
101
|
+
padding: 16px 24px 24px;
|
|
102
|
+
text-align: center;
|
|
103
|
+
.hc-icon {
|
|
104
|
+
display: block;
|
|
105
|
+
margin: 0 auto;
|
|
106
|
+
color: #333;
|
|
107
|
+
font-size: 72px;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.filter-dropdown-header {
|
|
113
|
+
color: rgba(0, 0, 0, 0.65);
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
.placeholder {
|
|
116
|
+
color: #bfbfbf;
|
|
117
|
+
}
|
|
118
|
+
.hc-icon {
|
|
119
|
+
font-size: 16px;
|
|
120
|
+
&:first-child {
|
|
121
|
+
margin-right: 4px;
|
|
122
|
+
}
|
|
123
|
+
&:last-child {
|
|
124
|
+
margin-left: 4px;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
&.ant-dropdown-open {
|
|
128
|
+
.hc-icon {
|
|
129
|
+
&:last-child {
|
|
130
|
+
color: #2869f6;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.filter-dropdown-popover {
|
|
137
|
+
&.ant-popover {
|
|
138
|
+
z-index: 1051;
|
|
139
|
+
.ant-popover-inner-content {
|
|
140
|
+
color: rgba(0, 0, 0, 0.65);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.ldc-sub-menu-item {
|
|
146
|
+
min-width: 124px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.ant-dropdown-menu-submenu-popup {
|
|
150
|
+
border-radius: 4px;
|
|
151
|
+
.ant-dropdown-menu {
|
|
152
|
+
padding: 4px;
|
|
153
|
+
.ant-dropdown-menu-item {
|
|
154
|
+
border-radius: 4px;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
export var cascaderClusterLocaleZhCN = {
|
|
8
|
+
unbound: '未绑定',
|
|
9
|
+
clusterOffline: '集群处于离线状态',
|
|
10
|
+
searchByClusterName: '根据集群名称搜索',
|
|
11
|
+
pleaseSelectCluster: '请选择集群',
|
|
12
|
+
selectLogicalUnit: '请选择逻辑单元',
|
|
13
|
+
nodata: '无数据'
|
|
14
|
+
};
|
|
15
|
+
export function mergeCascaderClusterTexts(texts) {
|
|
16
|
+
return _objectSpread(_objectSpread({}, cascaderClusterLocaleZhCN), texts);
|
|
17
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CascaderClusterDataInterface, CascaderClusterStorage } from './types';
|
|
2
|
+
export declare const CASCADER_CLUSTER_API: {
|
|
3
|
+
logicalUnitsInSystem: string;
|
|
4
|
+
logicalUnitsInOrganization: string;
|
|
5
|
+
logicalUnitsInProject: string;
|
|
6
|
+
logicalUnitClustersInSystem: string;
|
|
7
|
+
logicalUnitClustersInOrganization: string;
|
|
8
|
+
logicalUnitClustersInProject: string;
|
|
9
|
+
};
|
|
10
|
+
export interface CascaderClusterRequest {
|
|
11
|
+
get: (url: string, params?: Record<string, unknown>) => Promise<{
|
|
12
|
+
data?: unknown;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export declare function createCascaderClusterServices(request: CascaderClusterRequest): {
|
|
16
|
+
getSystemDatacenterLogicals: (params?: Record<string, unknown>) => Promise<{
|
|
17
|
+
data?: unknown;
|
|
18
|
+
}>;
|
|
19
|
+
getOrgDatacenterLogicals: (params: Record<string, unknown>) => Promise<{
|
|
20
|
+
data?: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
getProjectDatacenterLogicals: (params: Record<string, unknown>) => Promise<{
|
|
23
|
+
data?: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
getSystemLogicalClusters: (params: Record<string, unknown>) => Promise<{
|
|
26
|
+
data?: unknown;
|
|
27
|
+
}>;
|
|
28
|
+
getOrgLogicalClusters: (params: Record<string, unknown>) => Promise<{
|
|
29
|
+
data?: unknown;
|
|
30
|
+
}>;
|
|
31
|
+
getProjectLogicalClusters: (params: Record<string, unknown>) => Promise<{
|
|
32
|
+
data?: unknown;
|
|
33
|
+
}>;
|
|
34
|
+
};
|
|
35
|
+
export type CascaderClusterServices = ReturnType<typeof createCascaderClusterServices>;
|
|
36
|
+
/** 按 space / 前后台拼装 dataInterface */
|
|
37
|
+
export declare function buildCascaderClusterDataInterface(space: string, isBackend: boolean, storage: CascaderClusterStorage, services: CascaderClusterServices): CascaderClusterDataInterface | null;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
var olympusPortal = '/olympus-portal';
|
|
11
|
+
export var CASCADER_CLUSTER_API = {
|
|
12
|
+
logicalUnitsInSystem: "".concat(olympusPortal, "/apis/v1/listCenterAndUnit"),
|
|
13
|
+
logicalUnitsInOrganization: "".concat(olympusPortal, "/apis/v1/unitByOrgan/{organId}"),
|
|
14
|
+
logicalUnitsInProject: "".concat(olympusPortal, "/apis/v1/unitByOrgan/{organId}/{projectId}"),
|
|
15
|
+
logicalUnitClustersInSystem: "".concat(olympusPortal, "/apis/v1/getLogicalUnitCluster"),
|
|
16
|
+
logicalUnitClustersInOrganization: "".concat(olympusPortal, "/apis/v1/getOrganLogicalUnitCluster"),
|
|
17
|
+
logicalUnitClustersInProject: "".concat(olympusPortal, "/apis/v1/getProjectLogicalUnitCluster")
|
|
18
|
+
};
|
|
19
|
+
function restfulURL(url) {
|
|
20
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
21
|
+
if (!url.includes('{')) return {
|
|
22
|
+
url: url,
|
|
23
|
+
data: _objectSpread({}, params)
|
|
24
|
+
};
|
|
25
|
+
var data = _objectSpread({}, params);
|
|
26
|
+
var segments = url.split('/').map(function (segment) {
|
|
27
|
+
var _params$key;
|
|
28
|
+
if (!segment.includes('{')) return segment;
|
|
29
|
+
var key = segment.slice(1, -1);
|
|
30
|
+
delete data[key];
|
|
31
|
+
return String((_params$key = params[key]) !== null && _params$key !== void 0 ? _params$key : '');
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
url: segments.join('/'),
|
|
35
|
+
data: data
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function createCascaderClusterServices(request) {
|
|
39
|
+
var get = function get(api, params) {
|
|
40
|
+
var _restfulURL = restfulURL(api, params !== null && params !== void 0 ? params : {}),
|
|
41
|
+
url = _restfulURL.url,
|
|
42
|
+
data = _restfulURL.data;
|
|
43
|
+
return request.get(url, data);
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
getSystemDatacenterLogicals: function getSystemDatacenterLogicals(params) {
|
|
47
|
+
return get(CASCADER_CLUSTER_API.logicalUnitsInSystem, params);
|
|
48
|
+
},
|
|
49
|
+
getOrgDatacenterLogicals: function getOrgDatacenterLogicals(params) {
|
|
50
|
+
return get(CASCADER_CLUSTER_API.logicalUnitsInOrganization, params);
|
|
51
|
+
},
|
|
52
|
+
getProjectDatacenterLogicals: function getProjectDatacenterLogicals(params) {
|
|
53
|
+
return get(CASCADER_CLUSTER_API.logicalUnitsInProject, params);
|
|
54
|
+
},
|
|
55
|
+
getSystemLogicalClusters: function getSystemLogicalClusters(params) {
|
|
56
|
+
return get(CASCADER_CLUSTER_API.logicalUnitClustersInSystem, params);
|
|
57
|
+
},
|
|
58
|
+
getOrgLogicalClusters: function getOrgLogicalClusters(params) {
|
|
59
|
+
return get(CASCADER_CLUSTER_API.logicalUnitClustersInOrganization, params);
|
|
60
|
+
},
|
|
61
|
+
getProjectLogicalClusters: function getProjectLogicalClusters(params) {
|
|
62
|
+
return get(CASCADER_CLUSTER_API.logicalUnitClustersInProject, params);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
var toDatacenterList = function toDatacenterList(res) {
|
|
67
|
+
return Array.isArray(res === null || res === void 0 ? void 0 : res.data) ? res.data : [];
|
|
68
|
+
};
|
|
69
|
+
var toClusterList = function toClusterList(res) {
|
|
70
|
+
return Array.isArray(res === null || res === void 0 ? void 0 : res.data) ? res.data : [];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** 按 space / 前后台拼装 dataInterface */
|
|
74
|
+
export function buildCascaderClusterDataInterface(space, isBackend, storage, services) {
|
|
75
|
+
if (space === 'cluster') return null;
|
|
76
|
+
var organId = storage.getSession('organizationId', true);
|
|
77
|
+
var projectId = storage.getSession('projectId', true);
|
|
78
|
+
if (!isBackend && space === 'project') {
|
|
79
|
+
return {
|
|
80
|
+
datacenter: {
|
|
81
|
+
service: function () {
|
|
82
|
+
var _service = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
83
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
84
|
+
while (1) switch (_context.prev = _context.next) {
|
|
85
|
+
case 0:
|
|
86
|
+
_context.t0 = toDatacenterList;
|
|
87
|
+
_context.next = 3;
|
|
88
|
+
return services.getProjectDatacenterLogicals({
|
|
89
|
+
organId: organId,
|
|
90
|
+
projectId: projectId
|
|
91
|
+
});
|
|
92
|
+
case 3:
|
|
93
|
+
_context.t1 = _context.sent;
|
|
94
|
+
return _context.abrupt("return", (0, _context.t0)(_context.t1));
|
|
95
|
+
case 5:
|
|
96
|
+
case "end":
|
|
97
|
+
return _context.stop();
|
|
98
|
+
}
|
|
99
|
+
}, _callee);
|
|
100
|
+
}));
|
|
101
|
+
function service() {
|
|
102
|
+
return _service.apply(this, arguments);
|
|
103
|
+
}
|
|
104
|
+
return service;
|
|
105
|
+
}()
|
|
106
|
+
},
|
|
107
|
+
resource: {
|
|
108
|
+
service: function () {
|
|
109
|
+
var _service2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
110
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
111
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
112
|
+
case 0:
|
|
113
|
+
_context2.t0 = toClusterList;
|
|
114
|
+
_context2.next = 3;
|
|
115
|
+
return services.getProjectLogicalClusters(_objectSpread({
|
|
116
|
+
organId: organId,
|
|
117
|
+
projectId: projectId
|
|
118
|
+
}, params));
|
|
119
|
+
case 3:
|
|
120
|
+
_context2.t1 = _context2.sent;
|
|
121
|
+
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1));
|
|
122
|
+
case 5:
|
|
123
|
+
case "end":
|
|
124
|
+
return _context2.stop();
|
|
125
|
+
}
|
|
126
|
+
}, _callee2);
|
|
127
|
+
}));
|
|
128
|
+
function service(_x) {
|
|
129
|
+
return _service2.apply(this, arguments);
|
|
130
|
+
}
|
|
131
|
+
return service;
|
|
132
|
+
}()
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (space === 'org') {
|
|
137
|
+
return {
|
|
138
|
+
datacenter: {
|
|
139
|
+
service: function () {
|
|
140
|
+
var _service3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
141
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
142
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
143
|
+
case 0:
|
|
144
|
+
_context3.t0 = toDatacenterList;
|
|
145
|
+
_context3.next = 3;
|
|
146
|
+
return services.getOrgDatacenterLogicals({
|
|
147
|
+
organId: organId
|
|
148
|
+
});
|
|
149
|
+
case 3:
|
|
150
|
+
_context3.t1 = _context3.sent;
|
|
151
|
+
return _context3.abrupt("return", (0, _context3.t0)(_context3.t1));
|
|
152
|
+
case 5:
|
|
153
|
+
case "end":
|
|
154
|
+
return _context3.stop();
|
|
155
|
+
}
|
|
156
|
+
}, _callee3);
|
|
157
|
+
}));
|
|
158
|
+
function service() {
|
|
159
|
+
return _service3.apply(this, arguments);
|
|
160
|
+
}
|
|
161
|
+
return service;
|
|
162
|
+
}()
|
|
163
|
+
},
|
|
164
|
+
resource: {
|
|
165
|
+
service: function () {
|
|
166
|
+
var _service4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
167
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
168
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
169
|
+
case 0:
|
|
170
|
+
_context4.t0 = toClusterList;
|
|
171
|
+
_context4.next = 3;
|
|
172
|
+
return services.getOrgLogicalClusters(_objectSpread({
|
|
173
|
+
organId: organId
|
|
174
|
+
}, params));
|
|
175
|
+
case 3:
|
|
176
|
+
_context4.t1 = _context4.sent;
|
|
177
|
+
return _context4.abrupt("return", (0, _context4.t0)(_context4.t1));
|
|
178
|
+
case 5:
|
|
179
|
+
case "end":
|
|
180
|
+
return _context4.stop();
|
|
181
|
+
}
|
|
182
|
+
}, _callee4);
|
|
183
|
+
}));
|
|
184
|
+
function service(_x2) {
|
|
185
|
+
return _service4.apply(this, arguments);
|
|
186
|
+
}
|
|
187
|
+
return service;
|
|
188
|
+
}()
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
datacenter: {
|
|
194
|
+
service: function () {
|
|
195
|
+
var _service5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
196
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
197
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
198
|
+
case 0:
|
|
199
|
+
_context5.t0 = toDatacenterList;
|
|
200
|
+
_context5.next = 3;
|
|
201
|
+
return services.getSystemDatacenterLogicals();
|
|
202
|
+
case 3:
|
|
203
|
+
_context5.t1 = _context5.sent;
|
|
204
|
+
return _context5.abrupt("return", (0, _context5.t0)(_context5.t1));
|
|
205
|
+
case 5:
|
|
206
|
+
case "end":
|
|
207
|
+
return _context5.stop();
|
|
208
|
+
}
|
|
209
|
+
}, _callee5);
|
|
210
|
+
}));
|
|
211
|
+
function service() {
|
|
212
|
+
return _service5.apply(this, arguments);
|
|
213
|
+
}
|
|
214
|
+
return service;
|
|
215
|
+
}()
|
|
216
|
+
},
|
|
217
|
+
resource: {
|
|
218
|
+
service: function () {
|
|
219
|
+
var _service6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
|
|
220
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
221
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
222
|
+
case 0:
|
|
223
|
+
_context6.t0 = toClusterList;
|
|
224
|
+
_context6.next = 3;
|
|
225
|
+
return services.getSystemLogicalClusters(params);
|
|
226
|
+
case 3:
|
|
227
|
+
_context6.t1 = _context6.sent;
|
|
228
|
+
return _context6.abrupt("return", (0, _context6.t0)(_context6.t1));
|
|
229
|
+
case 5:
|
|
230
|
+
case "end":
|
|
231
|
+
return _context6.stop();
|
|
232
|
+
}
|
|
233
|
+
}, _callee6);
|
|
234
|
+
}));
|
|
235
|
+
function service(_x3) {
|
|
236
|
+
return _service6.apply(this, arguments);
|
|
237
|
+
}
|
|
238
|
+
return service;
|
|
239
|
+
}()
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { GetClusterAddons } from '../ComponentUninstalled';
|
|
2
|
+
import type { LogicalClusterItem, LogicalDatacenterItem } from '../LogicalResourceFilter';
|
|
3
|
+
import type { CascaderClusterServices } from './services';
|
|
4
|
+
export type { LogicalClusterItem, LogicalDatacenterItem };
|
|
5
|
+
export interface CascaderClusterFilterCache {
|
|
6
|
+
name?: string | null;
|
|
7
|
+
id?: string | null;
|
|
8
|
+
dataCenterId?: string | number | null;
|
|
9
|
+
logicalUnitId?: string | number | null;
|
|
10
|
+
clusterName?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CascaderClusterStorage {
|
|
13
|
+
getSession: (key: string, returnStr?: boolean) => unknown;
|
|
14
|
+
setSession: (key: string, value: unknown) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface CascaderClusterTexts {
|
|
17
|
+
unbound?: string;
|
|
18
|
+
clusterOffline?: string;
|
|
19
|
+
searchByClusterName?: string;
|
|
20
|
+
pleaseSelectCluster?: string;
|
|
21
|
+
selectLogicalUnit?: string;
|
|
22
|
+
nodata?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface CascaderClusterDataInterface {
|
|
25
|
+
datacenter?: {
|
|
26
|
+
service?: (params: Record<string, unknown>) => Promise<LogicalDatacenterItem[]>;
|
|
27
|
+
params?: Record<string, unknown>;
|
|
28
|
+
};
|
|
29
|
+
resource?: {
|
|
30
|
+
service?: (params: Record<string, unknown>) => Promise<LogicalClusterItem[]>;
|
|
31
|
+
params?: Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface CascaderClusterProps {
|
|
35
|
+
/** project | org | system | cluster | networkManage */
|
|
36
|
+
space: string;
|
|
37
|
+
onClusterChange: (clusterName: string) => void;
|
|
38
|
+
/** false 表示组件内拉取;数组表示外部传入 */
|
|
39
|
+
datacenters?: LogicalDatacenterItem[] | false;
|
|
40
|
+
clusters?: LogicalClusterItem[] | false;
|
|
41
|
+
compoKey?: string | number;
|
|
42
|
+
dataInterface?: CascaderClusterDataInterface;
|
|
43
|
+
/** 与 space 配合自动拼装 dataInterface;与 dataInterface 二选一 */
|
|
44
|
+
services?: CascaderClusterServices;
|
|
45
|
+
storage?: CascaderClusterStorage;
|
|
46
|
+
/** 未传时根据 URL 自动判断后台/用户侧 */
|
|
47
|
+
isBackend?: boolean;
|
|
48
|
+
pathname?: string;
|
|
49
|
+
onFilterCacheChange?: (params: CascaderClusterFilterCache) => void;
|
|
50
|
+
getClusterAddons?: GetClusterAddons;
|
|
51
|
+
showComponentUninstalled?: boolean;
|
|
52
|
+
texts?: CascaderClusterTexts;
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CascaderClusterFilterCache, CascaderClusterStorage } from './types';
|
|
2
|
+
export declare function detectIsBackend(pathname?: string, search?: string): boolean;
|
|
3
|
+
export declare function getCacheSessionKey(isBackend: boolean, pathname: string): "quotaCenterFilterLdcCluster" | "mFilterLdcCluster" | "uFilterLdcCluster";
|
|
4
|
+
export declare function readFilterCache(storage: CascaderClusterStorage, isBackend: boolean, pathname: string): CascaderClusterFilterCache;
|
|
5
|
+
export declare function writeFilterCache(storage: CascaderClusterStorage, isBackend: boolean, pathname: string, params: CascaderClusterFilterCache): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function detectIsBackend() {
|
|
2
|
+
var pathname = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
3
|
+
var search = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
4
|
+
if (typeof window === 'undefined') return false;
|
|
5
|
+
return search.includes('isBackend') || pathname.includes('/system/') || window.location.hash.includes('/system/');
|
|
6
|
+
}
|
|
7
|
+
export function getCacheSessionKey(isBackend, pathname) {
|
|
8
|
+
if (pathname.includes('resourceQuotaCenter')) {
|
|
9
|
+
return 'quotaCenterFilterLdcCluster';
|
|
10
|
+
}
|
|
11
|
+
return isBackend ? 'mFilterLdcCluster' : 'uFilterLdcCluster';
|
|
12
|
+
}
|
|
13
|
+
export function readFilterCache(storage, isBackend, pathname) {
|
|
14
|
+
var key = getCacheSessionKey(isBackend, pathname);
|
|
15
|
+
var cacheData = storage.getSession(key);
|
|
16
|
+
if (!cacheData) return {};
|
|
17
|
+
if (typeof cacheData === 'string') {
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(cacheData);
|
|
20
|
+
} catch (_unused) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return cacheData;
|
|
25
|
+
}
|
|
26
|
+
export function writeFilterCache(storage, isBackend, pathname, params) {
|
|
27
|
+
var key = getCacheSessionKey(isBackend, pathname);
|
|
28
|
+
storage.setSession(key, params);
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export { default as IconPopTips } from './IconPopTips';
|
|
|
46
46
|
export type { IconPopTipsProps } from './IconPopTips';
|
|
47
47
|
export { default as ComponentUninstalled, componentUninstalledLocaleZhCN, } from './ComponentUninstalled';
|
|
48
48
|
export type { ComponentUninstalledProps, ComponentUninstalledTexts, ComponentUninstalledMenuData, ComponentUninstalledStorage, GetClusterAddons, } from './ComponentUninstalled';
|
|
49
|
+
export { default as CascaderCluster, cascaderClusterLocaleZhCN, CASCADER_CLUSTER_API, createCascaderClusterServices, buildCascaderClusterDataInterface, } from './CascaderCluster';
|
|
50
|
+
export type { CascaderClusterProps, CascaderClusterTexts, CascaderClusterFilterCache, CascaderClusterStorage, CascaderClusterDataInterface, CascaderClusterServices, CascaderClusterRequest, } from './CascaderCluster';
|
|
49
51
|
export { default as LogicalResourceFilter, logicalResourceLocaleZhCN } from './LogicalResourceFilter';
|
|
50
52
|
export type { LogicalResourceFilterProps, LogicalResourceFilterTexts, LogicalResourceInitParams, LogicalResourceChangeValue, LogicalDatacenterItem, LogicalClusterItem, } from './LogicalResourceFilter';
|
|
51
53
|
import useTableParams from './CombinTable/hooks/useTableParams';
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ export { metadataLocaleZhCN } from "./metadata/locale";
|
|
|
27
27
|
export { default as DeleteConfirm, deleteConfirmLocaleZhCN } from "./DeleteConfirm";
|
|
28
28
|
export { default as IconPopTips } from "./IconPopTips";
|
|
29
29
|
export { default as ComponentUninstalled, componentUninstalledLocaleZhCN } from "./ComponentUninstalled";
|
|
30
|
+
export { default as CascaderCluster, cascaderClusterLocaleZhCN, CASCADER_CLUSTER_API, createCascaderClusterServices, buildCascaderClusterDataInterface } from "./CascaderCluster";
|
|
30
31
|
export { default as LogicalResourceFilter, logicalResourceLocaleZhCN } from "./LogicalResourceFilter";
|
|
31
32
|
import useTableParams from "./CombinTable/hooks/useTableParams";
|
|
32
33
|
export { useTableParams };
|
package/package.json
CHANGED