This commit is contained in:
Qiuxia Fan 2022-06-02 17:47:54 +08:00
parent c9b1d43448
commit cbde86c6c1
3 changed files with 37 additions and 21 deletions

View File

@ -57,9 +57,11 @@ function editorLayout() {
}); });
} }
onUnmounted(() => { onUnmounted(() => {
if (!toRaw(monacoInstance.value)) {
return;
}
toRaw(monacoInstance.value).dispose(); toRaw(monacoInstance.value).dispose();
monacoInstance.value = null; monacoInstance.value = null;
window.removeEventListener("resize", editorLayout);
}); });
watch( watch(
() => demandLogStore.logs, () => demandLogStore.logs,

View File

@ -59,15 +59,12 @@ limitations under the License. -->
</div> </div>
<div class="mr-5"> <div class="mr-5">
<span class="grey mr-5">{{ t("interval") }}:</span> <span class="grey mr-5">{{ t("interval") }}:</span>
<el-input-number <Selector
v-model="intervalTime"
:min="5"
:max="120"
size="small" size="small"
controls-position="right" :value="state.interval.value"
:options="IntervalOpts"
@change="changeField('interval', $event)" @change="changeField('interval', $event)"
/> />
{{ t("seconds") }}
</div> </div>
</div> </div>
<div class="flex-h row"> <div class="flex-h row">
@ -126,7 +123,12 @@ limitations under the License. -->
type="primary" type="primary"
@click="runInterval" @click="runInterval"
> >
<Icon size="middle" iconName="retry" :loading="intervalFn" class="mr-5" /> <Icon
size="middle"
iconName="retry"
:loading="!!intervalFn"
class="mr-5"
/>
{{ intervalFn ? t("pause") : t("start") }} {{ intervalFn ? t("pause") : t("start") }}
</el-button> </el-button>
</div> </div>
@ -140,7 +142,7 @@ import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors"; import { useSelectorStore } from "@/store/modules/selectors";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import { EntityType } from "../../data"; import { EntityType } from "../../data";
import { TimeRanges } from "./data"; import { TimeRanges, IntervalOpts } from "./data";
import getLocalTime from "@/utils/localtime"; import getLocalTime from "@/utils/localtime";
import dateFormatStep from "@/utils/dateFormat"; import dateFormatStep from "@/utils/dateFormat";
@ -154,11 +156,11 @@ const excludingKeywordsOfContent = ref<string[]>([]);
const contentStr = ref<string>(""); const contentStr = ref<string>("");
const excludingContentStr = ref<string>(""); const excludingContentStr = ref<string>("");
// const limit = ref<number>(20); // const limit = ref<number>(20);
const intervalTime = ref<number>(30);
const state = reactive<any>({ const state = reactive<any>({
instance: { value: "", label: "" }, instance: { value: "", label: "" },
container: { value: "", label: "" }, container: { value: "", label: "" },
duration: { label: "Last 30 min", value: 1800 }, duration: { label: "Last 30 min", value: 1800 },
interval: { label: "30 seconds", value: 30 },
}); });
/*global Nullable */ /*global Nullable */
const intervalFn = ref<Nullable<any>>(null); const intervalFn = ref<Nullable<any>>(null);
@ -217,7 +219,10 @@ function runInterval() {
return; return;
} }
searchLogs(); searchLogs();
intervalFn.value = setInterval(searchLogs, intervalTime.value * 1000); if (state.interval.value === 0) {
return;
}
intervalFn.value = setInterval(searchLogs, state.interval.value * 1000);
setTimeout(() => { setTimeout(() => {
clearTimer(); clearTimer();
}, state.duration.value * 1000); }, state.duration.value * 1000);
@ -248,10 +253,10 @@ async function queryLogs() {
} }
function changeField(type: string, opt: any) { function changeField(type: string, opt: any) {
clearTimer(); clearTimer();
if (["limit", "interval"].includes(type)) { // if (["limit"].includes(type)) {
state[type] = opt; // state[type] = opt;
return; // return;
} // }
state[type] = opt[0]; state[type] = opt[0];
if (type === "instance") { if (type === "instance") {
getContainers(); getContainers();
@ -310,8 +315,8 @@ watch(
() => selectorStore.currentService, () => selectorStore.currentService,
() => { () => {
if (dashboardStore.entity === EntityType[0].value) { if (dashboardStore.entity === EntityType[0].value) {
demandLogStore.setLogs("");
fetchSelectors(); fetchSelectors();
demandLogStore.setLogs("");
} }
} }
); );
@ -319,8 +324,8 @@ watch(
() => [selectorStore.currentPod], () => [selectorStore.currentPod],
() => { () => {
if (dashboardStore.entity === EntityType[3].value) { if (dashboardStore.entity === EntityType[3].value) {
demandLogStore.setLogs("");
fetchSelectors(); fetchSelectors();
demandLogStore.setLogs("");
} }
} }
); );

View File

@ -21,8 +21,17 @@ export const TimeRanges = [
{ label: "Last 15 seconds", value: 15 }, { label: "Last 15 seconds", value: 15 },
{ label: "Last 30 seconds", value: 30 }, { label: "Last 30 seconds", value: 30 },
{ label: "Last 45 seconds", value: 45 }, { label: "Last 45 seconds", value: 45 },
{ label: "Last 1 min", value: 60 }, { label: "Last 1 minute", value: 60 },
{ label: "Last 5 min", value: 300 }, { label: "Last 5 minute", value: 300 },
{ label: "Last 15 min", value: 900 }, { label: "Last 15 minute", value: 900 },
{ label: "Last 30 min", value: 1800 }, { label: "Last 30 minute", value: 1800 },
];
export const IntervalOpts = [
{ label: "None", value: 0 },
{ label: "5 seconds", value: 5 },
{ label: "10 seconds", value: 10 },
{ label: "15 seconds", value: 15 },
{ label: "30 seconds", value: 30 },
{ label: "45 seconds", value: 45 },
{ label: "1 minute", value: 60 },
]; ];