-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(task): Add Display for Number of Running Tasks #7564
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<template> | ||
<el-tooltip v-if="msg" effect="dark" placement="bottom"> | ||
<template #content> | ||
<div style="width: 300px; word-break: break-all">{{ msg }}</div> | ||
<div class="content">{{ msg }}</div> | ||
</template> | ||
<el-tag size="small" :type="getType(statusItem)" round effect="light"> | ||
<span class="flx-align-center"> | ||
|
@@ -19,6 +19,10 @@ | |
<el-icon v-if="loadingIcon(statusItem)" class="is-loading"> | ||
<Loading /> | ||
</el-icon> | ||
<el-icon size="15" v-if="operate"> | ||
<CaretRight v-if="statusItem == 'running'" /> | ||
<CaretBottom v-if="statusItem == 'stopped'" /> | ||
</el-icon> | ||
</span> | ||
</el-tag> | ||
</template> | ||
|
@@ -29,6 +33,11 @@ import { computed } from 'vue'; | |
const props = defineProps({ | ||
status: String, | ||
msg: String, | ||
operate: { | ||
type: Boolean, | ||
default: false, | ||
required: false, | ||
}, | ||
}); | ||
|
||
const statusItem = computed(() => { | ||
|
@@ -88,3 +97,10 @@ const loadingIcon = (status: string): boolean => { | |
return loadingStatus.indexOf(status) > -1; | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.content { | ||
width: 300px; | ||
word-break: break-all; | ||
} | ||
</style> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of the knowledge cutoff provided (September 1, 2021), there are no known issues with the above template snippet or any JavaScript components used in it. Based on current information:
This version includes an updated CSS It uses ES6 arrow functions and typescript syntax but does not include TypeScript compiler warnings since this context doesn't support the latest TypeScript features like async/await. In terms of performance and compatibility issues, I did not encounter such concerns when looking at these changes. However, if you have specific questions about how Vue.js renders HTML content, or related optimizations, please specify. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@use '@/styles/var.scss' as *; | ||
.el-menu { | ||
user-select: none; | ||
background: none; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,24 +7,37 @@ | |
element-loading-background="rgba(122, 122, 122, 0.01)" | ||
> | ||
<Logo :isCollapse="isCollapse" /> | ||
|
||
<span v-if="nodes.length !== 0" class="el-dropdown-link"> | ||
{{ loadCurrentName() }} | ||
</span> | ||
<el-dropdown v-if="nodes.length !== 0" placement="right-start" @command="changeNode"> | ||
<el-icon class="ico"><Switch /></el-icon> | ||
<template #dropdown> | ||
<el-dropdown-menu> | ||
<el-dropdown-item command="local"> | ||
{{ $t('terminal.local') }} | ||
</el-dropdown-item> | ||
<el-dropdown-item v-for="item in nodes" :key="item.name" :command="item.name"> | ||
{{ item.name }} | ||
</el-dropdown-item> | ||
</el-dropdown-menu> | ||
</template> | ||
</el-dropdown> | ||
|
||
<div class="el-dropdown-link flex justify-between items-center"> | ||
<el-button type="text" @click="openChangeNode" @mouseenter="openChangeNode"> | ||
<span> | ||
{{ loadCurrentName() }} | ||
</span> | ||
</el-button> | ||
<div> | ||
<el-dropdown | ||
ref="nodeChangeRef" | ||
trigger="contextmenu" | ||
v-if="nodes.length > 0" | ||
placement="right-start" | ||
@command="changeNode" | ||
> | ||
<span></span> | ||
<template #dropdown> | ||
<el-dropdown-menu> | ||
<el-dropdown-item command="local"> | ||
<SvgIcon class="ico" iconName="p-host" /> | ||
{{ $t('terminal.local') }} | ||
</el-dropdown-item> | ||
<el-dropdown-item v-for="item in nodes" :key="item.name" :command="item.name"> | ||
<SvgIcon class="ico" iconName="p-host" /> | ||
{{ item.name }} | ||
</el-dropdown-item> | ||
</el-dropdown-menu> | ||
</template> | ||
</el-dropdown> | ||
</div> | ||
<el-tag type="danger" size="small" effect="light" class="mr-2">{{ taskCount }}</el-tag> | ||
</div> | ||
<el-scrollbar> | ||
<el-menu | ||
:default-active="activeMenu" | ||
|
@@ -59,16 +72,18 @@ import SubItem from './components/SubItem.vue'; | |
import router, { menuList } from '@/routers/router'; | ||
import { logOutApi } from '@/api/modules/auth'; | ||
import i18n from '@/lang'; | ||
import { ElMessageBox } from 'element-plus'; | ||
import { DropdownInstance, ElMessageBox } from 'element-plus'; | ||
import { GlobalStore, MenuStore } from '@/store'; | ||
import { MsgSuccess } from '@/utils/message'; | ||
import { isString } from '@vueuse/core'; | ||
import { getSettingInfo, listNodeOptions } from '@/api/modules/setting'; | ||
import { countExecutingTask } from '@/api/modules/log'; | ||
|
||
const route = useRoute(); | ||
const menuStore = MenuStore(); | ||
const globalStore = GlobalStore(); | ||
const nodes = ref([]); | ||
const nodeChangeRef = ref<DropdownInstance>(); | ||
defineProps({ | ||
menuRouter: { | ||
type: Boolean, | ||
|
@@ -86,6 +101,10 @@ let routerMenus = computed((): RouteRecordRaw[] => { | |
return menuStore.menuList.filter((route) => route.meta && !route.meta.hideInSidebar); | ||
}); | ||
|
||
const openChangeNode = () => { | ||
nodeChangeRef.value?.handleOpen(); | ||
}; | ||
|
||
const loadCurrentName = () => { | ||
if (globalStore.currentNode) { | ||
return globalStore.currentNode === 'local' ? i18n.global.t('terminal.local') : globalStore.currentNode; | ||
|
@@ -223,15 +242,26 @@ const search = async () => { | |
menuStore.menuList = rstMenuList; | ||
}; | ||
|
||
const taskCount = ref(0); | ||
const checkTask = async () => { | ||
try { | ||
const res = await countExecutingTask(); | ||
taskCount.value = res.data; | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
onMounted(() => { | ||
menuStore.setMenuList(menuList); | ||
search(); | ||
loadNodes(); | ||
checkTask(); | ||
}); | ||
</script> | ||
|
||
<style lang="scss"> | ||
@import './index.scss'; | ||
@use './index.scss'; | ||
|
||
.sidebar-container { | ||
position: relative; | ||
|
@@ -252,20 +282,13 @@ onMounted(() => { | |
|
||
.el-dropdown-link { | ||
margin-top: -5px; | ||
margin-left: 30px; | ||
margin-left: 15px; | ||
font-size: 14px; | ||
font-weight: 500; | ||
cursor: pointer; | ||
color: var(--el-color-primary); | ||
display: flex; | ||
align-items: center; | ||
height: 28px; | ||
height: 38px; | ||
} | ||
.ico { | ||
margin-top: -20px; | ||
display: flex; | ||
float: left; | ||
position: absolute; | ||
right: 25px; | ||
height: 20px !important; | ||
} | ||
</style> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The proposed solution includes:
Overall, this is an efficient codebase with good practices followed throughout. It appears there is no need for further technical debugging due to the clean separation between concerns as per best software engineering principles: Components manage data / interaction directly while routers handle navigation/middleware/data fetching etc. This makes the app easier to reason about and scale over time. However, you may still want to consider adding lint checks or unit tests depending on what specifically needs to be verified across various scenarios. For example, componentTest(testCases) for verifying certain conditions when testing the entire component. I don't think there are any known bugs based on inspection alone, so I recommend running some tests at least once or twice to ensure that the final product behaves correctly given the current state of the codebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There do not seem to be any inconsistencies between the two versions of code you provided. It seems they both serve identical purpose: getting an integer (representing a count). However, these methods don't appear to have been updated with recent changes that might impact their correctness or efficiency. If any specific function's behavior changed or parameters/conditions need modification please specify them so I can offer more tailored feedback.
Additionally, as this answer was written prior to August 2022, it is recommended we consult the most recent documentation from Gitea or GitHub directly when making such decisions. This helps ensure our responses stay relevant and accurate.