mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-14 09:00:50 +00:00
verify widget name
This commit is contained in:
parent
bf218b330e
commit
437383d4b2
@ -14,12 +14,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||
export default function getDashboard(param: {
|
||||
name: string;
|
||||
layer: string;
|
||||
entity: string;
|
||||
}) {
|
||||
const dashboardStore = useDashboardStore();
|
||||
const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
|
||||
const dashboard = list.find(
|
||||
(d: { name: string; layer: string; entity: string }) =>
|
||||
@ -27,8 +28,9 @@ export default function getDashboard(param: {
|
||||
d.entity === param.entity &&
|
||||
d.layer === param.layer
|
||||
);
|
||||
const all = dashboardStore.layout;
|
||||
const widgets = [];
|
||||
for (const item of dashboard) {
|
||||
for (const item of all) {
|
||||
if (item.type === "Tab") {
|
||||
if (item.children && item.children.length) {
|
||||
for (const child of item.children) {
|
||||
|
@ -43,18 +43,18 @@ const widgets = computed(() => {
|
||||
const isRank = ["TopList"].includes(
|
||||
dashboardStore.selectedGrid.graph && dashboardStore.selectedGrid.graph.type
|
||||
);
|
||||
const w = getDashboard(dashboardStore.currentDashboard).widgets;
|
||||
const items = w.filter(
|
||||
const { widgets } = getDashboard(dashboardStore.currentDashboard);
|
||||
const items = widgets.filter(
|
||||
(d: { value: string; label: string } & LayoutConfig) => {
|
||||
if (dashboardStore.selectedGrid.id !== d.id) {
|
||||
if (isLinear) {
|
||||
if (isLinear && d.widget) {
|
||||
d.value = d.id || "";
|
||||
d.label = (d.widget && d.widget.title) || d.type || "";
|
||||
d.label = d.widget.name || d.id || "";
|
||||
return d;
|
||||
}
|
||||
if (isRank && d.type !== "Widget") {
|
||||
if (isRank && d.type !== "Widget" && d.widget) {
|
||||
d.value = d.id || "";
|
||||
d.label = (d.widget && d.widget.title) || d.type || "";
|
||||
d.label = d.widget.name || d.id || "";
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,14 @@ function updateWidgetConfig(param: { [key: string]: string }) {
|
||||
function updateWidgetName(param: { [key: string]: string }) {
|
||||
const key = Object.keys(param)[0];
|
||||
const n = decodeURIComponent(param[key]);
|
||||
const widgets = getDashboard(dashboardStore.currentDashboard).widgets;
|
||||
const pattern = /^[A-Za-z0-9-_\u4e00-\u9fa5]{4,30}$/;
|
||||
if (!pattern.test(n)) {
|
||||
ElMessage.warning(
|
||||
"The name only supports Chinese and English, horizontal lines and underscores"
|
||||
);
|
||||
return;
|
||||
}
|
||||
const { widgets } = getDashboard(dashboardStore.currentDashboard);
|
||||
const item = widgets.find(
|
||||
(d: LayoutConfig) => d.widget && d.widget.name === n
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user