Merge "Add data table in OTAGUI." am: dae4cdad62

Original change: https://android-review.googlesource.com/c/platform/development/+/1764566

Change-Id: I42f026a1601d23db62b08eb953607903f016f19e
This commit is contained in:
Treehugger Robot
2021-07-14 20:47:57 +00:00
committed by Automerger Merge Worker
2 changed files with 140 additions and 23 deletions

View File

@@ -0,0 +1,114 @@
<template>
<TableLite
:columns="columns"
:is-re-search="isReSearch"
:is-loading="isLoading"
:rows="rows"
:sortable="sortable"
:total="total"
@do-search="doSearch"
/>
</template>
<script>
import TableLite from 'vue3-table-lite'
import FormDate from '../services/FormDate.js'
export default {
components: {
TableLite
},
props: {
jobs: {
type: Array,
required: true
}
},
data () {
return {
rows: null,
columns: [
{
label: "Source build",
field: "incremental_name",
sortable: true
},
{
label: "Target build",
field: "target_name",
sortable: true
},
{
label: "Status",
field: "status",
sortable: true,
display: function (row) {
return (
"<a href=/check/" + row.id + '>'
+ row.status
+ "</a>"
);
}
},
{
label: "Partial",
field: "isPartial",
sortable: true
},
{
label: "Start Time",
field: "start_time",
sortable: true,
display: function (row) {
return FormDate.formDate(row.start_time)
}
},
{
label: "Finish Time",
field: "finish_time",
sortable: true,
display: function (row) {
return FormDate.formDate(row.finish_time)
}
}
],
sortable: {
order: "start_time",
sort: "desc",
},
isReSearch: false,
isLoading: false,
total: 0
}
},
created() {
this.rows = this.jobs
this.total = this.jobs.length
},
methods: {
sort(arr, key, sortOrder, offset, limit) {
let orderNumber = 1
if (sortOrder==="asc") {
orderNumber = -1
}
return arr.sort(function(a, b) {
var keyA = a[key],
keyB = b[key];
if (keyA < keyB) return -1*orderNumber;
if (keyA > keyB) return 1*orderNumber;
return 0;
}).slice(offset, limit);
},
doSearch(offset, limit, order, sort) {
this.isLoading = true
setTimeout(() => {
this.sortable.order = order
this.sortable.sort = sort
this.rows = this.sort(this.jobs, order, sort, offset, limit)
this.total = this.jobs.length
}, 600)
setTimeout(() => {this.isLoading=false}, 1000)
}
}
}
</script>

View File

@@ -1,30 +1,42 @@
<template>
<div class="jobs">
<JobDisplay
<OTAJobTable
v-if="jobs"
:jobs="jobs"
/>
<v-row>
<v-cow
v-for="job in jobs"
:key="job.id"
:job="job"
:active="overStatus.get(job.id)"
@mouseover="mouseOver(job.id, true)"
@mouseout="mouseOver(job.id, false)"
/>
<v-btn
block
@click="updateStatus"
cols="3"
sm="12"
class="ma-5"
>
Update
</v-btn>
</div>
<JobDisplay
:job="job"
:active="overStatus.get(job.id)"
@mouseover="mouseOver(job.id, true)"
@mouseout="mouseOver(job.id, false)"
/>
</v-cow>
</v-row>
<v-btn
block
@click="updateStatus"
>
Update
</v-btn>
</template>
<script>
import JobDisplay from '@/components/JobDisplay.vue'
import ApiService from '../services/ApiService.js'
import OTAJobTable from '@/components/OTAJobTable.vue'
export default {
name: 'JobList',
components: {
JobDisplay,
OTAJobTable
},
data() {
return {
@@ -50,13 +62,4 @@ export default {
}
}
</script>
<style scoped>
.jobs {
display: flex;
flex-direction: column;
align-items: center;
}
</style>
</script>