feat: remove needTotal and total fields from query conditions (#94)

This commit is contained in:
Fine0830 2022-05-19 19:29:02 +08:00 committed by GitHub
parent b953904c71
commit b544decbbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 18 deletions

View File

@ -45,6 +45,5 @@ export const Alarm = {
endTime
}
}
total
}`,
};

View File

@ -35,6 +35,5 @@ export const FetchEvents = {
startTime
endTime
}
total
}`,
};

View File

@ -30,7 +30,6 @@ export const QueryBrowserErrorLogs = {
stack
grade
}
total
}`,
};

View File

@ -25,7 +25,6 @@ import { useAppStoreWithOut } from "@/store/modules/app";
interface eventState {
loading: boolean;
events: Event[];
total: number;
services: Service[];
instances: Instance[];
endpoints: Endpoint[];
@ -37,12 +36,11 @@ export const eventStore = defineStore({
state: (): eventState => ({
loading: false,
events: [],
total: 0,
services: [{ value: "", label: "All" }],
instances: [{ value: "", label: "All" }],
endpoints: [{ value: "", label: "All" }],
condition: {
paging: { pageNum: 1, pageSize: 15, needTotal: true },
paging: { pageNum: 1, pageSize: 15 },
},
}),
actions: {
@ -117,7 +115,6 @@ export const eventStore = defineStore({
return item;
}
);
this.total = res.data.data.fetchEvents.total;
}
return res.data;
},

View File

@ -39,8 +39,8 @@ limitations under the License. -->
<el-pagination
v-model:currentPage="pageNum"
v-model:page-size="pageSize"
layout="prev, jumper, total, next"
:total="alarmStore.total"
layout="prev, pager, next"
:total="total"
@current-change="changePage"
:pager-count="5"
small
@ -55,7 +55,7 @@ limitations under the License. -->
</nav>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { ref, computed } from "vue";
import { useI18n } from "vue-i18n";
import ConditionTags from "@/views/components/ConditionTags.vue";
import { AlarmOptions } from "./data";
@ -70,6 +70,11 @@ const pageSize = 20;
const entity = ref<string>("");
const keyword = ref<string>("");
const pageNum = ref<number>(1);
const total = computed(() =>
alarmStore.alarms.length === pageSize
? pageSize * pageNum.value + 1
: pageSize * pageNum.value
);
refreshAlarms({ pageNum: 1 });
@ -79,7 +84,6 @@ async function refreshAlarms(param: { pageNum: number; tagsMap?: any }) {
paging: {
pageNum: param.pageNum,
pageSize,
needTotal: true,
},
tags: param.tagsMap,
};

View File

@ -37,9 +37,9 @@ limitations under the License. -->
/>
</div>
<div class="mr-5" v-if="dashboardStore.entity !== EntityType[2].value">
<span class="grey mr-5"
>{{ isBrowser ? t("page") : t("endpoint") }}:</span
>
<span class="grey mr-5">
{{ isBrowser ? t("page") : t("endpoint") }}:
</span>
<Selector
size="small"
:value="state.endpoint.value"

View File

@ -75,8 +75,8 @@ limitations under the License. -->
<el-pagination
v-model:currentPage="pageNum"
v-model:page-size="pageSize"
layout="prev, jumper, total, next"
:total="eventStore.total"
layout="prev, pager, next"
:total="total"
@current-change="updatePage"
:pager-count="5"
small
@ -92,7 +92,7 @@ limitations under the License. -->
</nav>
</template>
<script lang="ts" setup>
import { ref, reactive } from "vue";
import { ref, reactive, computed } from "vue";
import { useI18n } from "vue-i18n";
import { EventTypes } from "./data";
import { useEventStore } from "@/store/modules/event";
@ -119,6 +119,11 @@ const state = reactive<{
instance: "",
endpoint: "",
});
const total = computed(() =>
eventStore.events.length === pageSize
? pageSize * pageNum.value + 1
: pageSize * pageNum.value
);
getSelectors();
@ -180,7 +185,6 @@ async function queryEvents() {
paging: {
pageNum: pageNum.value,
pageSize: pageSize,
needTotal: true,
},
source: {
service: state.service || "",