feat: add loading

This commit is contained in:
Fine 2023-06-05 16:00:59 +08:00
parent 7fd2ec9466
commit 993a0ca0eb
5 changed files with 22 additions and 10 deletions

View File

@ -43,6 +43,8 @@ interface ContinousProfilingState {
analyzeTrees: AnalyzationTrees[]; analyzeTrees: AnalyzationTrees[];
ebpfTips: string; ebpfTips: string;
aggregateType: string; aggregateType: string;
instancesLoading: boolean;
policyLoading: boolean;
} }
export const continousProfilingStore = defineStore({ export const continousProfilingStore = defineStore({
@ -62,6 +64,8 @@ export const continousProfilingStore = defineStore({
analyzeTrees: [], analyzeTrees: [],
aggregateType: "COUNT", aggregateType: "COUNT",
instance: null, instance: null,
instancesLoading: false,
policyLoading: false,
}), }),
actions: { actions: {
setSelectedStrategy(task: Recordable<StrategyItem>) { setSelectedStrategy(task: Recordable<StrategyItem>) {
@ -103,8 +107,10 @@ export const continousProfilingStore = defineStore({
if (!params.serviceId) { if (!params.serviceId) {
return new Promise((resolve) => resolve({})); return new Promise((resolve) => resolve({}));
} }
this.policyLoading = true;
const res: AxiosResponse = await graphql.query("getStrategyList").params(params); const res: AxiosResponse = await graphql.query("getStrategyList").params(params);
this.policyLoading = false;
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;
} }
@ -127,6 +133,7 @@ export const continousProfilingStore = defineStore({
return res.data; return res.data;
}, },
async getMonitoringInstances(serviceId: string): Promise<Nullable<AxiosResponse>> { async getMonitoringInstances(serviceId: string): Promise<Nullable<AxiosResponse>> {
this.instancesLoading = true;
if (!serviceId) { if (!serviceId) {
return null; return null;
} }
@ -134,6 +141,7 @@ export const continousProfilingStore = defineStore({
serviceId, serviceId,
target: this.selectedStrategy.type, target: this.selectedStrategy.type,
}); });
this.instancesLoading = false;
if (!res.data.errors) { if (!res.data.errors) {
this.instances = res.data.data.instances || []; this.instances = res.data.data.instances || [];
this.instance = this.instances[0] || null; this.instance = this.instances[0] || null;

View File

@ -15,16 +15,19 @@ limitations under the License. -->
<template> <template>
<div class="flex-h content"> <div class="flex-h content">
<policy-list /> <policy-list />
<div class="instance-list"> <div class="instance-list" v-loading="continousProfilingStore.instancesLoading">
<instance-list /> <instance-list />
</div> </div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { PropType } from "vue"; import type { PropType } from "vue";
import { useContinousProfilingStore } from "@/store/modules/continous-profiling";
import PolicyList from "./components/PolicyList.vue"; import PolicyList from "./components/PolicyList.vue";
import InstanceList from "./components/InstanceList.vue"; import InstanceList from "./components/InstanceList.vue";
const continousProfilingStore = useContinousProfilingStore();
/*global defineProps */ /*global defineProps */
defineProps({ defineProps({
config: { config: {

View File

@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<el-table :data="currentInstances" style="width: 100%"> <el-table :data="currentInstances" style="width: 99%">
<el-table-column type="expand"> <el-table-column type="expand">
<template #default="props"> <template #default="props">
<div class="child"> <div class="child">
@ -21,13 +21,14 @@ limitations under the License. -->
<div v-for="(attr, index) in props.row.attributes" :key="index"> <div v-for="(attr, index) in props.row.attributes" :key="index">
{{ `${attr.name}: ${attr.value}` }} {{ `${attr.name}: ${attr.value}` }}
</div> </div>
<div class="title mt-20">Processes</div> <div class="title mt-10">Processes</div>
<el-table :data="props.row.processes" size="small"> <el-table :data="props.row.processes" size="small" max-height="300">
<el-table-column <el-table-column
v-for="item in HeaderChildLabels" v-for="item in HeaderChildLabels"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
:prop="item.value" :prop="item.value"
:width="item.width"
/> />
</el-table> </el-table>
</div> </div>

View File

@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="profile-task-list flex-v"> <div class="profile-task-list flex-v" v-loading="continousProfilingStore.policyLoading">
<div class="profile-task-wrapper flex-v"> <div class="profile-task-wrapper flex-v">
<div class="profile-t-tool"> <div class="profile-t-tool">
<span>{{ t("policyList") }}</span> <span>{{ t("policyList") }}</span>

View File

@ -32,15 +32,15 @@ export const TargetTypes = [
export const ComponentType = "CONTINOUS_PROFILING"; export const ComponentType = "CONTINOUS_PROFILING";
export const HeaderLabels = [ export const HeaderLabels = [
{ value: "name", label: "Name", width: 400 }, { value: "name", label: "Name" },
{ value: "triggeredCount", label: "Triggered Count", width: 150 }, { value: "triggeredCount", label: "Triggered Count", width: 150 },
{ value: "lastTriggerTime", label: "Last Trigger Time", width: 150 }, { value: "lastTriggerTime", label: "Last Trigger Time", width: 170 },
]; ];
export const HeaderChildLabels = [ export const HeaderChildLabels = [
{ value: "name", label: "Name" }, { value: "name", label: "Name" },
{ value: "detectType", label: "Detect Type" }, { value: "detectType", label: "Detect Type", width: 100 },
{ value: "triggeredCount", label: "Triggered Count" }, { value: "triggeredCount", label: "Triggered Count", width: 120 },
{ value: "labels", label: "Labels" }, { value: "labels", label: "Labels" },
{ value: "lastTriggerTime", label: "Last Trigger Time" }, { value: "lastTriggerTime", label: "Last Trigger Time", width: 160 },
]; ];