Standardized date formatting across components by introducing buildDate utility:
- Replaced duplicate date-handling logic in multiple components (e.g., `CountryProperties.vue`, `Rates.vue`, `ErrorLog.vue`) with centralized `buildDate` method from `common.js`. - Improved date consistency and readability by adopting `YYYY/MM/DD` format with optional time support.
This commit is contained in:
parent
af7b51578b
commit
5d775a7dda
9 changed files with 33 additions and 27 deletions
|
|
@ -161,4 +161,19 @@ export class UrlSafeBase64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const buildDate = (date, time) => {
|
||||||
|
if (!date) return 'unkown';
|
||||||
|
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
||||||
|
const day = date.getDate().toString().padStart(2, '0');
|
||||||
|
|
||||||
|
if (!time) return `${year}/${month}/${day}`;
|
||||||
|
const hours = time.getHours().toString().padStart(2, '0');
|
||||||
|
const minutes = time.getMinutes().toString().padStart(2, '0');
|
||||||
|
const seconds = time.getSeconds().toString().padStart(2, '0');
|
||||||
|
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="bulk-operation-info">
|
<div class="bulk-operation-info">
|
||||||
<div>{{ operation.processing_type.toLowerCase() }} {{ operation.file_type.toLowerCase() }}</div>
|
<div>{{ operation.processing_type.toLowerCase() }} {{ operation.file_type.toLowerCase() }}</div>
|
||||||
<div class="bulk-operation-date">{{ operation.timestamp }}</div>
|
<div class="bulk-operation-date">{{ buildDate(operation.timestamp) }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bulk-operation-status">
|
<div class="bulk-operation-status">
|
||||||
<div v-if="operation.state === 'EXCEPTION'">
|
<div v-if="operation.state === 'EXCEPTION'">
|
||||||
<tooltip min-width="500px" :text="shortend(operation.error.message)" position="left">
|
<tooltip min-width="500px" :text="shortend(operation.error.message)" position="left">
|
||||||
<basic-badge variant="exception">ERROR</basic-badge>
|
<basic-badge variant="exception">ERROR</basic-badge>
|
||||||
</tooltip>
|
</tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -41,6 +41,7 @@ import IconButton from "@/components/UI/IconButton.vue";
|
||||||
import Tooltip from "@/components/UI/Tooltip.vue";
|
import Tooltip from "@/components/UI/Tooltip.vue";
|
||||||
import Spinner from "@/components/UI/Spinner.vue";
|
import Spinner from "@/components/UI/Spinner.vue";
|
||||||
import BasicBadge from "@/components/UI/BasicBadge.vue";
|
import BasicBadge from "@/components/UI/BasicBadge.vue";
|
||||||
|
import {buildDate} from "@/common.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "BulkOperation",
|
name: "BulkOperation",
|
||||||
|
|
@ -53,15 +54,13 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
shortend(string) {
|
shortend(string) {
|
||||||
if(((string ?? null) === null) || string.length < 350)
|
if (((string ?? null) === null) || string.length < 350)
|
||||||
return string;
|
return string;
|
||||||
|
|
||||||
return string.substring(0,350) + "..."
|
return string.substring(0, 350) + "..."
|
||||||
},
|
},
|
||||||
buildDate(date) {
|
buildDate(date) {
|
||||||
if(date === null) return "not set";
|
return buildDate(date, true);
|
||||||
|
|
||||||
return `${date[0]}-${date[1].toString().padStart(2, '0')}-${date[2].toString().padStart(2, '0')} ${date[3]?.toString().padStart(2, '0') ?? '00'}:${date[4]?.toString().padStart(2, '0') ?? '00'}:${date[5]?.toString().padStart(2, '0') ?? '00'}`
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ import {useBulkOperationStore} from "@/store/bulkOperation.js";
|
||||||
import BulkOperation from "@/components/layout/bulkoperation/BulkOperation.vue";
|
import BulkOperation from "@/components/layout/bulkoperation/BulkOperation.vue";
|
||||||
import logger from "@/logger.js";
|
import logger from "@/logger.js";
|
||||||
import {useActiveUserStore} from "@/store/activeuser.js";
|
import {useActiveUserStore} from "@/store/activeuser.js";
|
||||||
|
import {buildDate} from "@/common.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "BulkOperations",
|
name: "BulkOperations",
|
||||||
|
|
@ -198,9 +199,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buildDate(date) {
|
buildDate(date) {
|
||||||
if (date === null) return "not set";
|
return buildDate(date, true);
|
||||||
|
|
||||||
return `${date[0]}-${date[1].toString().padStart(2, '0')}-${date[2].toString().padStart(2, '0')} ${date[3]?.toString().padStart(2, '0') ?? '00'}:${date[4]?.toString().padStart(2, '0') ?? '00'}:${date[5]?.toString().padStart(2, '0') ?? '00'}`
|
|
||||||
},
|
},
|
||||||
async fetchFile(id) {
|
async fetchFile(id) {
|
||||||
logger.info(`Fetching file ${id}`);
|
logger.info(`Fetching file ${id}`);
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ import ModalDialog from "@/components/UI/ModalDialog.vue";
|
||||||
import Dropdown from "@/components/UI/Dropdown.vue";
|
import Dropdown from "@/components/UI/Dropdown.vue";
|
||||||
import {usePropertiesStore} from "@/store/properties.js";
|
import {usePropertiesStore} from "@/store/properties.js";
|
||||||
import CollapsibleBox from "@/components/UI/CollapsibleBox.vue";
|
import CollapsibleBox from "@/components/UI/CollapsibleBox.vue";
|
||||||
|
import {buildDate} from "@/common.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "CountryProperties",
|
name: "CountryProperties",
|
||||||
|
|
@ -131,10 +132,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
buildDate(date) {
|
buildDate(date) {
|
||||||
if(date === null) return "not set";
|
return buildDate(date, false);
|
||||||
return date;
|
|
||||||
|
|
||||||
// return `${date[0]}-${date[1].toString().padStart(2, '0')}-${date[2].toString().padStart(2, '0')} ${date[3]?.toString().padStart(2, '0') ?? '00'}:${date[4]?.toString().padStart(2, '0') ?? '00'}:${date[5]?.toString().padStart(2, '0') ?? '00'}`
|
|
||||||
},
|
},
|
||||||
async saveProperty(property) {
|
async saveProperty(property) {
|
||||||
this.countryStore.setProperty(property);
|
this.countryStore.setProperty(property);
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import {useCountryStore} from "@/store/country.js";
|
||||||
import CountryProperties from "@/components/layout/config/CountryProperties.vue";
|
import CountryProperties from "@/components/layout/config/CountryProperties.vue";
|
||||||
import Box from "@/components/UI/Box.vue";
|
import Box from "@/components/UI/Box.vue";
|
||||||
import StagedChanges from "@/components/layout/config/StagedChanges.vue";
|
import StagedChanges from "@/components/layout/config/StagedChanges.vue";
|
||||||
|
import {buildDate} from "@/common.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Properties",
|
name: "Properties",
|
||||||
|
|
@ -124,9 +125,7 @@ export default {
|
||||||
this.propertiesStore.setProperty(property);
|
this.propertiesStore.setProperty(property);
|
||||||
},
|
},
|
||||||
buildDate(date) {
|
buildDate(date) {
|
||||||
if(date === null) return "not set";
|
return buildDate(date, false);
|
||||||
|
|
||||||
return `${date[0]}-${date[1].toString().padStart(2, '0')}-${date[2].toString().padStart(2, '0')} ${date[3]?.toString().padStart(2, '0') ?? '00'}:${date[4]?.toString().padStart(2, '0') ?? '00'}:${date[5]?.toString().padStart(2, '0') ?? '00'}`
|
|
||||||
},
|
},
|
||||||
deletePeriod() {
|
deletePeriod() {
|
||||||
if (!this.disableDeleteButton) {
|
if (!this.disableDeleteButton) {
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ import RadioOption from "@/components/UI/RadioOption.vue";
|
||||||
import {useMatrixRateStore} from "@/store/matrixRate.js";
|
import {useMatrixRateStore} from "@/store/matrixRate.js";
|
||||||
import {useContainerRateStore} from "@/store/containerRate.js";
|
import {useContainerRateStore} from "@/store/containerRate.js";
|
||||||
import StagedRates from "@/components/layout/config/StagedRates.vue";
|
import StagedRates from "@/components/layout/config/StagedRates.vue";
|
||||||
|
import {buildDate} from "@/common.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Rates",
|
name: "Rates",
|
||||||
|
|
@ -184,9 +185,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
buildDate(date) {
|
buildDate(date) {
|
||||||
if(date === null) return "not set";
|
return buildDate(date, false);
|
||||||
|
|
||||||
return `${date[0]}-${date[1].toString().padStart(2, '0')}-${date[2].toString().padStart(2, '0')} ${date[3]?.toString().padStart(2, '0') ?? '00'}:${date[4]?.toString().padStart(2, '0') ?? '00'}:${date[5]?.toString().padStart(2, '0') ?? '00'}`
|
|
||||||
},
|
},
|
||||||
async fetch(query) {
|
async fetch(query) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,6 @@ app.component("PhHardDrives", PhHardDrives );
|
||||||
app.use(router);
|
app.use(router);
|
||||||
|
|
||||||
|
|
||||||
//app.component('base-button', () => import('./components/UI/BasicButton.vue'));
|
|
||||||
//app.component('base-badge', () => import('./components/UI/BasicBadge.vue'));
|
|
||||||
setupErrorBuffer()
|
setupErrorBuffer()
|
||||||
startSessionRefresh();
|
startSessionRefresh();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import {mapStores} from "pinia";
|
||||||
import Modal from "@/components/UI/Modal.vue";
|
import Modal from "@/components/UI/Modal.vue";
|
||||||
import TraceView from "@/components/layout/TraceView.vue";
|
import TraceView from "@/components/layout/TraceView.vue";
|
||||||
import ErrorLogModal from "@/components/layout/ErrorLogModal.vue";
|
import ErrorLogModal from "@/components/layout/ErrorLogModal.vue";
|
||||||
|
import {buildDate} from "@/common.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ErrorLog",
|
name: "ErrorLog",
|
||||||
|
|
@ -79,10 +80,7 @@ export default {
|
||||||
return this.errorLogStore.getErrors;
|
return this.errorLogStore.getErrors;
|
||||||
},
|
},
|
||||||
buildDate(date) {
|
buildDate(date) {
|
||||||
if(date === null) return "not set";
|
return buildDate(date, true);
|
||||||
|
|
||||||
return date;
|
|
||||||
// return `${date[0]}-${date[1].toString().padStart(2, '0')}-${date[2].toString().padStart(2, '0')} ${date[3]?.toString().padStart(2, '0') ?? '00'}:${date[4]?.toString().padStart(2, '0') ?? '00'}:${date[5]?.toString().padStart(2, '0') ?? '00'}`
|
|
||||||
},
|
},
|
||||||
showDetails(error) {
|
showDetails(error) {
|
||||||
console.log("click")
|
console.log("click")
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import Spinner from "@/components/UI/Spinner.vue";
|
||||||
import ReportChart from "@/components/UI/ReportChart.vue";
|
import ReportChart from "@/components/UI/ReportChart.vue";
|
||||||
import Report from "@/components/layout/report/Report.vue";
|
import Report from "@/components/layout/report/Report.vue";
|
||||||
import BasicBadge from "@/components/UI/BasicBadge.vue";
|
import BasicBadge from "@/components/UI/BasicBadge.vue";
|
||||||
|
import {buildDate} from "@/common.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Reporting",
|
name: "Reporting",
|
||||||
|
|
@ -119,7 +120,7 @@ export default {
|
||||||
this.showModal = true;
|
this.showModal = true;
|
||||||
},
|
},
|
||||||
buildDate(date) {
|
buildDate(date) {
|
||||||
return new Date(date).toLocaleDateString('en-EN')
|
return buildDate(date, false);
|
||||||
},
|
},
|
||||||
async closeModal(data) {
|
async closeModal(data) {
|
||||||
if (data.action === 'accept') {
|
if (data.action === 'accept') {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue