Skip to content

Commit

Permalink
small tuning around (#169)
Browse files Browse the repository at this point in the history
* show backend version
* add job.id to results list view
* list today results by default to ensure it's fast by default
* increase list timeout to 40s and handle it properly in query
* fix case where query is empty
  • Loading branch information
jupe committed Mar 24, 2024
1 parent 282e1e7 commit af0fe6a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/api/results.js
Expand Up @@ -53,6 +53,7 @@ export function resultsList(query) {
return request({
url: '/api/v0/results',
method: 'get',
params: query
params: query,
timeout: query.to + 1000
})
}
8 changes: 8 additions & 0 deletions src/api/version.js
@@ -0,0 +1,8 @@
import request from '@/utils/request'

export function getVersion() {
return request({
url: `/api/v0/version`,
method: 'get'
}).then(({ data }) => data)
}
17 changes: 16 additions & 1 deletion src/layout/components/Navbar.vue
Expand Up @@ -30,8 +30,11 @@
<router-link to="/">
<el-dropdown-item>Dashboard</el-dropdown-item>
</router-link>
<a :href="'https://github.com/opentmi/opentmi/releases/v' + serverVersion" target="_blank">
<el-dropdown-item>opentmi/backend@{{ serverVersion }}</el-dropdown-item>
</a>
<a target="_blank" href="https://github.com/opentmi/opentmi-default-gui/">
<el-dropdown-item>Github</el-dropdown-item>
<el-dropdown-item>Github/ui</el-dropdown-item>
</a>
<el-dropdown-item divided @click.native="logout">
<span style="display:block;">Log Out</span>
Expand All @@ -50,6 +53,7 @@ import ErrorLog from '@/components/ErrorLog'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import Search from '@/components/HeaderSearch'
import { getVersion } from '@/api/version'
export default {
components: {
Expand All @@ -67,6 +71,17 @@ export default {
'device'
])
},
data() {
return {
serverVersion: '',
commitId: ''
}
},
async created() {
const { OpenTMI, commitId } = await getVersion()
this.serverVersion = OpenTMI
this.commitId = commitId
},
methods: {
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
Expand Down
17 changes: 14 additions & 3 deletions src/views/result/list.vue
Expand Up @@ -173,6 +173,11 @@ export default {
sortable: true,
label: 'Campaign'
},
{
key: 'job.id',
sortable: true,
label: 'JobID'
},
{
key: 'exec.verdict',
sortable: true,
Expand Down Expand Up @@ -235,7 +240,8 @@ export default {
listLoading: false,
listQuery: {
page: 1,
limit: 20
limit: 20,
'cre.time': `{gt}${new Date().toISOString().split('T')[0].replace(/-/g, '.')}`
},
availableCampaigns: []
}
Expand All @@ -258,7 +264,7 @@ export default {
},
methods: {
lengthLimiter(value, maxLength = 20) {
let out = value.substr(0, maxLength)
let out = value.substring(0, maxLength)
if (value.length > maxLength) {
out += '...'
}
Expand Down Expand Up @@ -301,6 +307,8 @@ export default {
const query = this._.omitBy(this.listQuery, this._.isNil)
query.l = query.limit
query.sk = (query.page - 1) * query.limit
query.to = 40000
this._.unset(query, 'limit')
this._.unset(query, 'page')
if (this.sortBy) {
Expand All @@ -313,7 +321,9 @@ export default {
return
}
let value = query[key]
if (value.startsWith('*')) {
if (typeof value !== 'string') {
// empty string
} else if (value.startsWith('*')) {
value = value.slice(1)
if (value.endsWith('*')) {
query[key] = `/${value.slice(0, -1)}/`
Expand All @@ -338,6 +348,7 @@ export default {
.then(({ data }) => data)
.catch(error => {
console.error(error)
this.total = 0
// Returning an empty array, allows table to correctly handle
// internal busy state in case of error
Expand Down

0 comments on commit af0fe6a

Please sign in to comment.