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 endTime
} }
} }
total
}`, }`,
}; };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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