mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-07 10:42:56 +00:00
feat: add and use loading
This commit is contained in:
parent
4b9d1dd362
commit
9ae1f26d84
@ -52,6 +52,7 @@ const msg = {
|
|||||||
endpoint: "Endpoint",
|
endpoint: "Endpoint",
|
||||||
instance: "Instance",
|
instance: "Instance",
|
||||||
create: "Create",
|
create: "Create",
|
||||||
|
loading: "Loading",
|
||||||
hourTip: "Select Hour",
|
hourTip: "Select Hour",
|
||||||
minuteTip: "Select Minute",
|
minuteTip: "Select Minute",
|
||||||
secondTip: "Select Second",
|
secondTip: "Select Second",
|
||||||
|
@ -50,6 +50,7 @@ const msg = {
|
|||||||
layer: "层",
|
layer: "层",
|
||||||
endpoint: "端点",
|
endpoint: "端点",
|
||||||
create: "新建",
|
create: "新建",
|
||||||
|
loading: "加载中",
|
||||||
hourTip: "选择小时",
|
hourTip: "选择小时",
|
||||||
minuteTip: "选择分钟",
|
minuteTip: "选择分钟",
|
||||||
secondTip: "选择秒数",
|
secondTip: "选择秒数",
|
||||||
|
31
src/utils/loading.ts
Normal file
31
src/utils/loading.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You 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 { ElLoading, ILoadingInstance } from "element-plus";
|
||||||
|
type Props = { text?: string; fullscreen?: boolean };
|
||||||
|
|
||||||
|
export default function (): {
|
||||||
|
loading: (props: Props) => ILoadingInstance;
|
||||||
|
} {
|
||||||
|
const loading = (props: Props) => {
|
||||||
|
const loadingInstance = ElLoading.service(props);
|
||||||
|
return loadingInstance;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
loading,
|
||||||
|
};
|
||||||
|
}
|
@ -53,10 +53,12 @@ limitations under the License. -->
|
|||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { ValuesTypes, MetricQueryTypes } from "../data";
|
import { ValuesTypes, MetricQueryTypes } from "../data";
|
||||||
import { Option } from "@/types/app";
|
import { Option } from "@/types/app";
|
||||||
|
import Loading from "@/utils/loading";
|
||||||
|
|
||||||
const states = reactive<{
|
const states = reactive<{
|
||||||
metrics: string;
|
metrics: string;
|
||||||
@ -69,9 +71,18 @@ const states = reactive<{
|
|||||||
valueType: "",
|
valueType: "",
|
||||||
metricQueryType: "",
|
metricQueryType: "",
|
||||||
});
|
});
|
||||||
|
const { t } = useI18n();
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
|
const { loading } = Loading();
|
||||||
async function changeMetrics(val: Option[]) {
|
async function changeMetrics(val: Option[]) {
|
||||||
|
if (!val.length) {
|
||||||
|
states.valueTypes = [];
|
||||||
|
states.valueType = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const loadingInstance = loading({ text: t("loading"), fullscreen: true });
|
||||||
const resp = await dashboardStore.fetchMetricType(val[0].value);
|
const resp = await dashboardStore.fetchMetricType(val[0].value);
|
||||||
|
loadingInstance.close();
|
||||||
if (resp.error) {
|
if (resp.error) {
|
||||||
ElMessage.error(resp.data.error);
|
ElMessage.error(resp.data.error);
|
||||||
return;
|
return;
|
||||||
|
@ -112,8 +112,6 @@ const states = reactive({
|
|||||||
key: EntityType.filter((d: any) => d.value === params.entity)[0].key || 0,
|
key: EntityType.filter((d: any) => d.value === params.entity)[0].key || 0,
|
||||||
...params,
|
...params,
|
||||||
});
|
});
|
||||||
console.log(states);
|
|
||||||
|
|
||||||
function changeService(val: { value: string; label: string }) {
|
function changeService(val: { value: string; label: string }) {
|
||||||
states.service = val.value;
|
states.service = val.value;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user