sige 1 year ago
parent
commit
42462c4989
  1. 48
      src/components/ServiceConfiguration.vue
  2. 63
      src/components/ServiceConfigurationStatusViewer.vue

48
src/components/ServiceConfiguration.vue

@ -58,17 +58,7 @@
</div> </div>
</a-col> </a-col>
<a-col :span="8" class="h-full flex flex-col"> <a-col :span="8" class="h-full flex flex-col">
<a-row class="bg-white border-b p-5">
<a-col :span="8" v-for="(status,index) in statuses" :key="index" class="p-1">
<div class="py-1 px-2 rounded border">
{{ status.name }} :
<template v-if="isBoolean(status.value)">
<BulbOutlined class="align-text-bottom" :class="{'text-green-400':status.value}"/>
</template>
<span v-else>{{ status.value }}</span>
</div>
</a-col>
</a-row>
<service-configuration-status-viewer :service-key="props.serviceKey" />
<div class="h-0 grow p-5"> <div class="h-0 grow p-5">
<service-configuration-action-log :log="actionLog"/> <service-configuration-action-log :log="actionLog"/>
</div> </div>
@ -77,12 +67,12 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { BulbOutlined } from '@ant-design/icons-vue'
import { onUnmounted, ref, watch } from 'vue';
import { ref, watch } from 'vue';
import ApiClient from '@/utils/ApiClient'; import ApiClient from '@/utils/ApiClient';
import ServiceConfigurationParamValueEdit from './ServiceConfigurationParamValueEdit.vue' import ServiceConfigurationParamValueEdit from './ServiceConfigurationParamValueEdit.vue'
import ServiceConfigurationActionLog from './ServiceConfigurationActionLog.vue' import ServiceConfigurationActionLog from './ServiceConfigurationActionLog.vue'
import ServiceConfigurationActionParamFile from './ServiceConfigurationActionParamFile.vue' import ServiceConfigurationActionParamFile from './ServiceConfigurationActionParamFile.vue'
import ServiceConfigurationStatusViewer from './ServiceConfigurationStatusViewer.vue'
/** @var {Object} */ /** @var {Object} */
const props = defineProps({ const props = defineProps({
serviceKey : String, serviceKey : String,
@ -91,52 +81,20 @@ const props = defineProps({
const params = ref([]); const params = ref([]);
/** @var {Array} */ /** @var {Array} */
const actions = ref([]); const actions = ref([]);
/** @var {Array} */
const statuses = ref([]);
/** @var {Object} */ /** @var {Object} */
const actionLog = ref(null); const actionLog = ref(null);
/** @var {Integer} */
let statusRefreshTimer = null;
// watch service key // watch service key
watch(() => props.serviceKey, handleServiceKeyChange); watch(() => props.serviceKey, handleServiceKeyChange);
// on unmounted
onUnmounted(() => {
if ( null !== statusRefreshTimer ) {
clearTimeout(statusRefreshTimer);
statusRefreshTimer = false;
}
});
// is boolean
function isBoolean( value ) {
return 'boolean' === typeof(value);
}
// on mounted // on mounted
async function handleServiceKeyChange() { async function handleServiceKeyChange() {
actionLog.value = null; actionLog.value = null;
if ( null !== statusRefreshTimer ) {
clearTimeout(statusRefreshTimer);
statusRefreshTimer = null;
}
if ( null === props.serviceKey ) { if ( null === props.serviceKey ) {
return ; return ;
} }
await actionServiceParamReload(); await actionServiceParamReload();
await serviceActionReload(); await serviceActionReload();
await refreshServiceStatusList();
}
// refresh service status list
async function refreshServiceStatusList() {
try {
let client = ApiClient.getClient();
statuses.value = await client.call('service-config/service-status-list', {serviceKey:props.serviceKey});
if ( false !== statusRefreshTimer ) {
statusRefreshTimer = setTimeout(refreshServiceStatusList, 1000);
}
} catch ( e ) {/** nothing to do here */}
} }
// service param reload // service param reload

63
src/components/ServiceConfigurationStatusViewer.vue

@ -0,0 +1,63 @@
<template>
<div class="bg-white border-b p-5 flex flex-row flex-wrap">
<div class="p-1 grow" style="min-width:33.33%;" v-for="(status,index) in statuses" :key="index">
<div class="py-1 px-2 rounded border">
{{ status.name }} :
<template v-if="isBoolean(status.value)">
<BulbOutlined class="align-text-bottom" :class="{'text-green-400':status.value}"/>
</template>
<span v-else>{{ status.value }}</span>
</div>
</div>
</div>
</template>
<script setup>
import ApiClient from '@/utils/ApiClient';
import { BulbOutlined } from '@ant-design/icons-vue'
import { onUnmounted, watch, ref } from 'vue';
/** @var {Object} */
const props = defineProps({
serviceKey : String,
});
/** @var {Array} */
const statuses = ref([]);
/** @var {Integer} */
let statusRefreshTimer = null;
// watch service key
watch(() => props.serviceKey, handleServiceKeyChange);
// on unmounted
onUnmounted(() => {
if ( null !== statusRefreshTimer ) {
clearTimeout(statusRefreshTimer);
statusRefreshTimer = false;
}
});
// handle
async function handleServiceKeyChange() {
if ( null !== statusRefreshTimer ) {
clearTimeout(statusRefreshTimer);
statusRefreshTimer = null;
}
if ( null === props.serviceKey ) {
return ;
}
await refreshServiceStatusList();
}
// refresh service status list
async function refreshServiceStatusList() {
try {
let client = ApiClient.getClient();
statuses.value = await client.call('service-config/service-status-list', {serviceKey:props.serviceKey});
if ( false !== statusRefreshTimer ) {
statusRefreshTimer = setTimeout(refreshServiceStatusList, 1000);
}
} catch ( e ) {/** nothing to do here */}
}
// is boolean
function isBoolean( value ) {
return 'boolean' === typeof(value);
}
</script>
Loading…
Cancel
Save