mirror of
https://github.com/OkaeriPoland/okaeri-timings.git
synced 2026-01-18 03:28:20 +01:00
Read report time from the report name
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
</MDBCol>
|
||||
|
||||
<MDBCol md="12" v-if="report">
|
||||
<ReportDetails :meta="report.meta"/>
|
||||
<ReportDetails :time="reportTime" :meta="report.meta"/>
|
||||
</MDBCol>
|
||||
|
||||
<MDBCol md="12" v-if="report">
|
||||
@@ -130,8 +130,18 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
files: async function (value) {
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append('file', value[0]);
|
||||
|
||||
const match = /okaeri-timings-([0-9]+)\.csv/.exec(value[0].name);
|
||||
if (match === null) {
|
||||
this.showError(`Invalid file name '${value[0].name}'!`)
|
||||
return;
|
||||
} else {
|
||||
this.reportTime = new Date(parseInt(match[1]) * 1000);
|
||||
}
|
||||
|
||||
this.report = await this.axios.post('/v1/parse', formData, {headers: {'Content-Type': 'multipart/form-data'}})
|
||||
.then((response) => {
|
||||
console.log(`Report parsing took ${response.data.stats.parseTime}`);
|
||||
@@ -160,6 +170,7 @@ export default {
|
||||
return {
|
||||
files: ref([]),
|
||||
report: ref(),
|
||||
reportTime: undefined,
|
||||
errorModal: ref(false),
|
||||
errorContent: undefined
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<MDBCard>
|
||||
<MDBCardBody>
|
||||
<MDBCardTitle class="d-flex">
|
||||
<span class="me-1">Report from {{ new Date().toLocaleString() }}</span>
|
||||
<span class="me-1">Report from {{ time.toLocaleString() }}</span>
|
||||
<MDBBadge color="primary">OT-v1.0</MDBBadge>
|
||||
</MDBCardTitle>
|
||||
<MDBRow>
|
||||
@@ -41,6 +41,7 @@ export default {
|
||||
MDBCol
|
||||
},
|
||||
props: {
|
||||
time: Date,
|
||||
meta: Object
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user