Skip to content

Commit

Permalink
Merge pull request #82 from fangshun-z/fix/80
Browse files Browse the repository at this point in the history
Fix/80
  • Loading branch information
Ruby-rc authored Apr 2, 2024
2 parents 9c3ee98 + 6ed93ee commit fecd2d0
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/services/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ContentType, HttpClient, RequestParams } from "./http-client";

export class Metric<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
/**
* @description EventList 排序 resourceType枚举(Cluster;StorageNode;DiskNode;Pool;Volume;DiskVolume;Disk) sort枚举 (time、name、type)
* @description EventList 排序 resourceType枚举(Cluster;StorageNode;DiskNode;Pool;Volume;DiskVolume;Disk) sort枚举 (time、name、type) sortDir:升序"ASC" 降序"DESC"
*
* @tags Metric
* @name EventsList
Expand Down
4 changes: 2 additions & 2 deletions src/services/Volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { ContentType, HttpClient, RequestParams } from "./http-client";

export class Volume<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
/**
* @description list Volume 排序sortBy:"time","name","namespace" sortDir:升序"ASC" 降序"DESC"
* @description list Volume sortBy排序:"time","name","namespace" sortDir:升序"ASC" 降序"DESC" 默认按时间降序
*
* @tags Volume
* @name VolumesList
Expand Down Expand Up @@ -106,7 +106,7 @@ export class Volume<SecurityDataType = unknown> extends HttpClient<SecurityDataT
*
* @tags Volume
* @name VolumesEventsDetail
* @summary 摘要 获取指定数据卷审计日志 sort=time ,先不做按操作查询
* @summary 摘要 获取指定数据卷审计日志 sort=time, sortDir:升序"ASC" 降序"DESC"
* @request GET:/cluster/volumes/{volumeName}/events
*/
volumesEventsDetail = ({ volumeName, ...query }: VolumesEventsDetailParams, params: RequestParams = {}) =>
Expand Down
4 changes: 4 additions & 0 deletions src/services/data-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2216,6 +2216,8 @@ export interface EventsListParams {
resourceType?: string;
/** sort */
sort?: string;
/** sortDir */
sortDir?: string;
}

export interface NodesListParams {
Expand Down Expand Up @@ -2410,6 +2412,8 @@ export interface VolumesEventsDetailParams {
action?: string;
/** sort */
sort?: string;
/** sortDir */
sortDir?: string;
/** volumeName */
volumeName: string;
}
Expand Down
17 changes: 11 additions & 6 deletions src/views/dashboard/components/EventList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import { computed, reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useQueryTable, useDateFormat, createDialog } from '@dao-style/extend';
import type { ApiEventAction, OperationsListParams } from '@/services/data-contracts';
import type { ApiEventAction, EventsListParams } from '@/services/data-contracts';
import MonacoEditorDialog from '@/components/dialogs/MonacoEditorDialog.vue';
import type {
DaoTableSort, SearchOption, SearchValue,
Expand Down Expand Up @@ -141,10 +141,9 @@ const sortMap: Record<string, string> = {
time: 'time',
};
const queryEvents = async (req: OperationsListParams) => {
const queryEvents = async (req: EventsListParams) => {
const { data } = await MetricApi.eventsList({
...req,
sort: sortMap[sort.value.id],
resourceName: search.resourceName?.[0] as string,
resourceType: search.resourceType?.[0] as string,
});
Expand All @@ -160,13 +159,19 @@ const [{
handleRefresh,
}, {
handleSearch,
filterData,
}] = useQueryTable(queryEvents, {
page: 1,
pageSize: 10,
name: '',
sort: 'name',
sortDir: 'DESC',
});
const sortChangeEvent = () => {
sort.value.desc = true;
const sortChangeEvent = ({ id, desc }: { id: string, desc: boolean }) => {
sort.value.id = id;
sort.value.desc = desc;
filterData.sort = sortMap[sort.value.id];
filterData.sortDir = sort.value.desc ? 'DESC' : 'ASC';
handleRefresh();
};
Expand Down
23 changes: 21 additions & 2 deletions src/views/local-volumes/components/LocalVolumeEvents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
id="local-volume-event-list"
:data="state.items"
:columns="columns"
:sort="initialSort"
:page-size="pagination.pageSize"
:current-page="pagination.page"
:total="pagination.total"
@sort-change="handleSortChange"
@page-change="handleChangePage"
@size-change="handleChangePageSize"
@refresh="handleRefresh"
Expand Down Expand Up @@ -47,7 +49,7 @@
</template>

<script setup lang="ts">
import { computed, defineProps } from 'vue';
import { ref, computed, defineProps } from 'vue';
import { useI18n } from 'vue-i18n';
import { createDialog, useDateFormat, useQueryTable } from '@dao-style/extend';
import { Volume } from '@/services/Volume';
Expand All @@ -56,6 +58,7 @@ import type {
VolumesEventsDetailParams,
} from '@/services/data-contracts';
import MonacoEditorDialog from '@/components/dialogs/MonacoEditorDialog.vue';
import type { DaoTableSort } from '@dao-style/core';
const props = defineProps({
volume: {
Expand All @@ -79,13 +82,19 @@ const columns = computed(() => [
{
id: 'time',
header: t('views.local-volumes.components.LocalVolumeEvents.operateTime'),
sortable: true,
},
{
id: 'content',
header: t('views.local-volumes.components.LocalVolumeEvents.eventContent'),
},
]);
const initialSort = ref<DaoTableSort>({
id: 'time',
desc: true,
});
const queryEvents = async (req: VolumesEventsDetailParams) => {
const { data } = await VolumeAPi.volumesEventsDetail({
...req,
Expand All @@ -107,10 +116,20 @@ const [{
page: 1,
pageSize: 10,
sort: 'time',
sortDir: 'DESC',
volumeName: props.volume,
action: '',
});
const handleSortChange = ({ id, desc }: { id: string, desc: boolean }) => {
initialSort.value.id = id;
initialSort.value.desc = desc;
filterData.sort = id;
filterData.sortDir = initialSort.value.desc ? 'DESC' : 'ASC';
handleRefresh();
};
const viewEventContent = (row: ApiEventAction) => {
const dialog = createDialog(MonacoEditorDialog);
let content = row.eventRecord?.actionContent ?? '';
Expand Down
18 changes: 15 additions & 3 deletions swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
},
"/cluster/events": {
"get": {
"description": "EventList 排序 resourceType枚举(Cluster;StorageNode;DiskNode;Pool;Volume;DiskVolume;Disk) sort枚举 (time、name、type)",
"description": "EventList 排序 resourceType枚举(Cluster;StorageNode;DiskNode;Pool;Volume;DiskVolume;Disk) sort枚举 (time、name、type) sortDir:升序\"ASC\" 降序\"DESC\"",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -205,6 +205,12 @@
"description": "sort",
"name": "sort",
"in": "query"
},
{
"type": "string",
"description": "sortDir",
"name": "sortDir",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -1442,7 +1448,7 @@
},
"/cluster/volumes": {
"get": {
"description": "list Volume 排序sortBy:\"time\",\"name\",\"namespace\" sortDir:升序\"ASC\" 降序\"DESC\"",
"description": "list Volume sortBy排序:\"time\",\"name\",\"namespace\" sortDir:升序\"ASC\" 降序\"DESC\" 默认按时间降序",
"consumes": [
"application/json"
],
Expand Down Expand Up @@ -1642,7 +1648,7 @@
"tags": [
"Volume"
],
"summary": "摘要 获取指定数据卷审计日志 sort=time ,先不做按操作查询",
"summary": "摘要 获取指定数据卷审计日志 sort=time, sortDir:升序\"ASC\" 降序\"DESC\"",
"parameters": [
{
"type": "string",
Expand Down Expand Up @@ -1676,6 +1682,12 @@
"description": "sort",
"name": "sort",
"in": "query"
},
{
"type": "string",
"description": "sortDir",
"name": "sortDir",
"in": "query"
}
],
"responses": {
Expand Down

0 comments on commit fecd2d0

Please sign in to comment.