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>
|
||||||
|
|
||||||
<MDBCol md="12" v-if="report">
|
<MDBCol md="12" v-if="report">
|
||||||
<ReportDetails :meta="report.meta"/>
|
<ReportDetails :time="reportTime" :meta="report.meta"/>
|
||||||
</MDBCol>
|
</MDBCol>
|
||||||
|
|
||||||
<MDBCol md="12" v-if="report">
|
<MDBCol md="12" v-if="report">
|
||||||
@@ -130,8 +130,18 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
files: async function (value) {
|
files: async function (value) {
|
||||||
|
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
formData.append('file', value[0]);
|
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'}})
|
this.report = await this.axios.post('/v1/parse', formData, {headers: {'Content-Type': 'multipart/form-data'}})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(`Report parsing took ${response.data.stats.parseTime}`);
|
console.log(`Report parsing took ${response.data.stats.parseTime}`);
|
||||||
@@ -160,6 +170,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
files: ref([]),
|
files: ref([]),
|
||||||
report: ref(),
|
report: ref(),
|
||||||
|
reportTime: undefined,
|
||||||
errorModal: ref(false),
|
errorModal: ref(false),
|
||||||
errorContent: undefined
|
errorContent: undefined
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<MDBCard>
|
<MDBCard>
|
||||||
<MDBCardBody>
|
<MDBCardBody>
|
||||||
<MDBCardTitle class="d-flex">
|
<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>
|
<MDBBadge color="primary">OT-v1.0</MDBBadge>
|
||||||
</MDBCardTitle>
|
</MDBCardTitle>
|
||||||
<MDBRow>
|
<MDBRow>
|
||||||
@@ -41,6 +41,7 @@ export default {
|
|||||||
MDBCol
|
MDBCol
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
time: Date,
|
||||||
meta: Object
|
meta: Object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user