disable button

This commit is contained in:
Qiuxia Fan 2022-06-08 10:43:34 +08:00
parent eac13da81d
commit 0af7851174
2 changed files with 16 additions and 4 deletions

View File

@ -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 See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<span v-if="demandLogStore.message">{{ demandLogStore.message }}</span>
<div <div
v-else
v-loading="demandLogStore.loadLogs" v-loading="demandLogStore.loadLogs"
class="log-content" class="log-content"
ref="logContent" ref="logContent"
style="width: calc(100% - 10px); height: calc(100% - 140px)" style="width: calc(100% - 10px); height: calc(100% - 140px)"
> ></div>
<span v-if="demandLogStore.message">{{ demandLogStore.message }}</span>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, ref, onUnmounted, watch, toRaw } from "vue"; import { onMounted, ref, onUnmounted, watch, toRaw } from "vue";
@ -36,7 +36,9 @@ onMounted(() => {
}); });
async function init() { async function init() {
const monaco = await import("monaco-editor"); const monaco = await import("monaco-editor");
setTimeout(() => {
monacoInstanceGen(monaco); monacoInstanceGen(monaco);
}, 500);
window.addEventListener("resize", () => { window.addEventListener("resize", () => {
editorLayout(); editorLayout();
}); });
@ -50,6 +52,7 @@ function monacoInstanceGen(monaco: any) {
readonly: true, readonly: true,
}); });
toRaw(monacoInstance.value).updateOptions({ readOnly: true }); toRaw(monacoInstance.value).updateOptions({ readOnly: true });
editorLayout();
} }
function editorLayout() { function editorLayout() {
if (!logContent.value) { if (!logContent.value) {

View File

@ -118,6 +118,7 @@ limitations under the License. -->
size="small" size="small"
type="primary" type="primary"
@click="runInterval" @click="runInterval"
:disabled="disabled"
> >
<Icon <Icon
size="middle" size="middle"
@ -158,6 +159,7 @@ const state = reactive<any>({
duration: { label: "From 30 minutes ago", value: 1800 }, duration: { label: "From 30 minutes ago", value: 1800 },
interval: { label: "30 seconds", value: 30 }, interval: { label: "30 seconds", value: 30 },
}); });
const disabled = ref<boolean>(true);
/*global Nullable */ /*global Nullable */
const intervalFn = ref<Nullable<any>>(null); const intervalFn = ref<Nullable<any>>(null);
@ -187,11 +189,18 @@ async function getContainers() {
state.instance.id || selectorStore.currentPod.id state.instance.id || selectorStore.currentPod.id
); );
if (resp.errors) { if (resp.errors) {
disabled.value = true;
ElMessage.error(resp.errors); ElMessage.error(resp.errors);
return; return;
} }
if (resp.data.containers.errorReason) {
disabled.value = true;
ElMessage.error(resp.data.containers.errorReason);
return;
}
if (demandLogStore.containers.length) { if (demandLogStore.containers.length) {
state.container = demandLogStore.containers[0]; state.container = demandLogStore.containers[0];
disabled.value = false;
} }
} }
async function getInstances() { async function getInstances() {