diff --git a/src/store/modules/continous-profiling.ts b/src/store/modules/continous-profiling.ts index 12182fff..19f74f37 100644 --- a/src/store/modules/continous-profiling.ts +++ b/src/store/modules/continous-profiling.ts @@ -20,7 +20,9 @@ import type { EBPFTaskList, EBPFProfilingSchedule, AnalyzationTrees } from "@/ty import type { Instance } from "@/types/selector"; import { store } from "@/store"; import graphql from "@/graphql"; +import type { MonitorInstance, MonitorProcess } from "@/types/continous-profiling"; import type { AxiosResponse } from "axios"; +import { dateFormat } from "@/utils/dateFormat"; interface ContinousProfilingState { strategyList: Array>; @@ -106,16 +108,20 @@ export const continousProfilingStore = defineStore({ if (res.data.errors) { return res.data; } - this.strategyList = (res.data.data.strategyList || []).map((d: StrategyItem, index: number) => { + const list = res.data.data.strategyList || []; + if (!list.length) { + this.taskList = []; + this.instances = []; + this.instance = null; + } + const arr = list.length ? res.data.data.strategyList : [{ type: "", checkItems: [{ type: "" }] }]; + this.strategyList = arr.map((d: StrategyItem, index: number) => { return { ...d, id: index, }; }); - this.setSelectedStrategy(this.strategyList[0] || {}); - if (!this.strategyList.length) { - this.taskList = []; - } + this.setSelectedStrategy(list[0] || {}); if (!this.selectedStrategy.type) { return res.data; } @@ -132,10 +138,29 @@ export const continousProfilingStore = defineStore({ target: this.selectedStrategy.type, }); this.instancesLoading = false; - if (!res.data.errors) { - this.instances = res.data.data.instances || []; - this.instance = this.instances[0] || null; + if (res.data.errors) { + return res.data; } + this.instances = (res.data.data.instances || []) + .map((d: MonitorInstance) => { + const processes = (d.processes || []) + .sort((c: MonitorProcess, d: MonitorProcess) => d.lastTriggerTimestamp - c.lastTriggerTimestamp) + .map((p: MonitorProcess) => { + return { + ...p, + lastTriggerTime: d.lastTriggerTimestamp ? dateFormat(d.lastTriggerTimestamp) : "", + labels: p.labels.join("; "), + }; + }); + + return { + ...d, + processes, + lastTriggerTime: d.lastTriggerTimestamp ? dateFormat(d.lastTriggerTimestamp) : "", + }; + }) + .sort((a: MonitorInstance, b: MonitorInstance) => b.lastTriggerTimestamp - a.lastTriggerTimestamp); + this.instance = this.instances[0] || null; return res.data; }, }, diff --git a/src/types/components.d.ts b/src/types/components.d.ts index fa07aadd..05ec63bd 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -22,6 +22,7 @@ declare module '@vue/runtime-core' { ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup'] ElOption: typeof import('element-plus/es')['ElOption'] ElPagination: typeof import('element-plus/es')['ElPagination'] + ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm'] ElPopover: typeof import('element-plus/es')['ElPopover'] ElProgress: typeof import('element-plus/es')['ElProgress'] ElRadio: typeof import('element-plus/es')['ElRadio'] diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index 2fdbfd69..6f7f807d 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -285,7 +285,7 @@ limitations under the License. --> } .tab-name { - max-width: 110px; + max-width: 130px; height: 20px; line-height: 20px; outline: none; @@ -348,7 +348,7 @@ limitations under the License. --> .vue-grid-item:not(.vue-grid-placeholder) { background: #fff; - box-shadow: 0px 1px 4px 0px #00000029; + box-shadow: 0 1px 4px 0 #00000029; border-radius: 3px; } diff --git a/src/views/dashboard/related/continuous-profiling/components/InstanceList.vue b/src/views/dashboard/related/continuous-profiling/components/InstanceList.vue index e059b996..bb8d641f 100644 --- a/src/views/dashboard/related/continuous-profiling/components/InstanceList.vue +++ b/src/views/dashboard/related/continuous-profiling/components/InstanceList.vue @@ -68,14 +68,14 @@ limitations under the License. --> background layout="prev, pager, next" :page-size="pageSize" - :total="instances.length" + :total="continousProfilingStore.instances.length" @current-change="changePage" @prev-click="changePage" @next-click="changePage" /> diff --git a/src/views/dashboard/related/continuous-profiling/components/PolicyList.vue b/src/views/dashboard/related/continuous-profiling/components/PolicyList.vue index 314a1990..9787903c 100644 --- a/src/views/dashboard/related/continuous-profiling/components/PolicyList.vue +++ b/src/views/dashboard/related/continuous-profiling/components/PolicyList.vue @@ -37,6 +37,7 @@ limitations under the License. --> :class="{ selected: continousProfilingStore.selectedStrategy.id === i.id, }" + v-if="i.type" >
diff --git a/src/views/dashboard/related/task-timeline/Content.vue b/src/views/dashboard/related/task-timeline/Content.vue index c88fa898..b8cacf40 100644 --- a/src/views/dashboard/related/task-timeline/Content.vue +++ b/src/views/dashboard/related/task-timeline/Content.vue @@ -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 limitations under the License. -->