Skip to content

Commit

Permalink
fix: disable the query button without containers on the on-demand log…
Browse files Browse the repository at this point in the history
… widget. (#105)
  • Loading branch information
Fine0830 committed Jun 8, 2022
1 parent 3c37d7c commit f9aa660
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/views/dashboard/related/demand-log/Content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ 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. -->
<template>
<span v-if="demandLogStore.message">{{ demandLogStore.message }}</span>
<div
v-else
v-loading="demandLogStore.loadLogs"
class="log-content"
ref="logContent"
style="width: calc(100% - 10px); height: calc(100% - 140px)"
>
<span v-if="demandLogStore.message">{{ demandLogStore.message }}</span>
</div>
></div>
</template>
<script lang="ts" setup>
import { onMounted, ref, onUnmounted, watch, toRaw } from "vue";
Expand All @@ -36,7 +36,9 @@ onMounted(() => {
});
async function init() {
const monaco = await import("monaco-editor");
monacoInstanceGen(monaco);
setTimeout(() => {
monacoInstanceGen(monaco);
}, 500);
window.addEventListener("resize", () => {
editorLayout();
});
Expand All @@ -50,6 +52,7 @@ function monacoInstanceGen(monaco: any) {
readonly: true,
});
toRaw(monacoInstance.value).updateOptions({ readOnly: true });
editorLayout();
}
function editorLayout() {
if (!logContent.value) {
Expand All @@ -67,6 +70,7 @@ onUnmounted(() => {
}
toRaw(monacoInstance.value).dispose();
monacoInstance.value = null;
demandLogStore.setLogs("");
});
watch(
() => demandLogStore.logs,
Expand Down
9 changes: 9 additions & 0 deletions src/views/dashboard/related/demand-log/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ limitations under the License. -->
size="small"
type="primary"
@click="runInterval"
:disabled="disabled"
>
<Icon
size="middle"
Expand Down Expand Up @@ -158,6 +159,7 @@ const state = reactive<any>({
duration: { label: "From 30 minutes ago", value: 1800 },
interval: { label: "30 seconds", value: 30 },
});
const disabled = ref<boolean>(true);
/*global Nullable */
const intervalFn = ref<Nullable<any>>(null);
Expand Down Expand Up @@ -187,11 +189,18 @@ async function getContainers() {
state.instance.id || selectorStore.currentPod.id
);
if (resp.errors) {
disabled.value = true;
ElMessage.error(resp.errors);
return;
}
if (resp.data.containers.errorReason) {
disabled.value = true;
ElMessage.warning(resp.data.containers.errorReason);
return;
}
if (demandLogStore.containers.length) {
state.container = demandLogStore.containers[0];
disabled.value = false;
}
}
async function getInstances() {
Expand Down

0 comments on commit f9aa660

Please sign in to comment.