forked from mirrors/homebox
fix: add custom action for fixing broken date/times (#268)
This commit is contained in:
parent
bd933af874
commit
ce2fc7712a
11 changed files with 240 additions and 59 deletions
|
@ -4,4 +4,5 @@
|
|||
|
||||
.btn {
|
||||
text-transform: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,11 @@
|
|||
const selected = computed({
|
||||
get() {
|
||||
// return modelValue as string as YYYY-MM-DD or null
|
||||
return props.modelValue ? props.modelValue.toISOString().split("T")[0] : null;
|
||||
if (validDate(props.modelValue)) {
|
||||
return props.modelValue ? props.modelValue.toISOString().split("T")[0] : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
set(value: string | null) {
|
||||
// emit update:modelValue with a Date object or null
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
import { BaseAPI, route } from "../base";
|
||||
import { EnsureAssetIDResult } from "../types/data-contracts";
|
||||
import { ActionAmountResult } from "../types/data-contracts";
|
||||
|
||||
export class ActionsAPI extends BaseAPI {
|
||||
ensureAssetIDs() {
|
||||
return this.http.post<void, EnsureAssetIDResult>({
|
||||
return this.http.post<void, ActionAmountResult>({
|
||||
url: route("/actions/ensure-asset-ids"),
|
||||
});
|
||||
}
|
||||
|
||||
resetItemDateTimes() {
|
||||
return this.http.post<void, ActionAmountResult>({
|
||||
url: route("/actions/zero-item-time-fields"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ export interface DocumentOut {
|
|||
}
|
||||
|
||||
export interface Group {
|
||||
createdAt: string;
|
||||
createdAt: Date;
|
||||
currency: string;
|
||||
id: string;
|
||||
name: string;
|
||||
|
@ -39,7 +39,7 @@ export interface GroupUpdate {
|
|||
}
|
||||
|
||||
export interface ItemAttachment {
|
||||
createdAt: string;
|
||||
createdAt: Date;
|
||||
document: DocumentOut;
|
||||
id: string;
|
||||
type: string;
|
||||
|
@ -76,7 +76,7 @@ export interface ItemOut {
|
|||
assetId: string;
|
||||
attachments: ItemAttachment[];
|
||||
children: ItemSummary[];
|
||||
createdAt: string;
|
||||
createdAt: Date;
|
||||
description: string;
|
||||
fields: ItemField[];
|
||||
id: string;
|
||||
|
@ -96,7 +96,7 @@ export interface ItemOut {
|
|||
/** @example "0" */
|
||||
purchasePrice: string;
|
||||
/** Purchase */
|
||||
purchaseTime: Date;
|
||||
purchaseTime: string;
|
||||
quantity: number;
|
||||
serialNumber: string;
|
||||
soldNotes: string;
|
||||
|
@ -112,7 +112,7 @@ export interface ItemOut {
|
|||
|
||||
export interface ItemSummary {
|
||||
archived: boolean;
|
||||
createdAt: string;
|
||||
createdAt: Date;
|
||||
description: string;
|
||||
id: string;
|
||||
insured: boolean;
|
||||
|
@ -148,7 +148,7 @@ export interface ItemUpdate {
|
|||
/** @example "0" */
|
||||
purchasePrice: string;
|
||||
/** Purchase */
|
||||
purchaseTime: Date;
|
||||
purchaseTime: string;
|
||||
quantity: number;
|
||||
/** Identifications */
|
||||
serialNumber: string;
|
||||
|
@ -169,7 +169,7 @@ export interface LabelCreate {
|
|||
}
|
||||
|
||||
export interface LabelOut {
|
||||
createdAt: string;
|
||||
createdAt: Date;
|
||||
description: string;
|
||||
id: string;
|
||||
items: ItemSummary[];
|
||||
|
@ -178,7 +178,7 @@ export interface LabelOut {
|
|||
}
|
||||
|
||||
export interface LabelSummary {
|
||||
createdAt: string;
|
||||
createdAt: Date;
|
||||
description: string;
|
||||
id: string;
|
||||
name: string;
|
||||
|
@ -193,7 +193,7 @@ export interface LocationCreate {
|
|||
|
||||
export interface LocationOut {
|
||||
children: LocationSummary[];
|
||||
createdAt: string;
|
||||
createdAt: Date;
|
||||
description: string;
|
||||
id: string;
|
||||
items: ItemSummary[];
|
||||
|
@ -203,7 +203,7 @@ export interface LocationOut {
|
|||
}
|
||||
|
||||
export interface LocationOutCount {
|
||||
createdAt: string;
|
||||
createdAt: Date;
|
||||
description: string;
|
||||
id: string;
|
||||
itemCount: number;
|
||||
|
@ -212,7 +212,7 @@ export interface LocationOutCount {
|
|||
}
|
||||
|
||||
export interface LocationSummary {
|
||||
createdAt: string;
|
||||
createdAt: Date;
|
||||
description: string;
|
||||
id: string;
|
||||
name: string;
|
||||
|
@ -229,7 +229,7 @@ export interface LocationUpdate {
|
|||
export interface MaintenanceEntry {
|
||||
/** @example "0" */
|
||||
cost: string;
|
||||
date: Date;
|
||||
date: string;
|
||||
description: string;
|
||||
id: string;
|
||||
name: string;
|
||||
|
@ -238,7 +238,7 @@ export interface MaintenanceEntry {
|
|||
export interface MaintenanceEntryCreate {
|
||||
/** @example "0" */
|
||||
cost: string;
|
||||
date: Date;
|
||||
date: string;
|
||||
description: string;
|
||||
name: string;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ export interface MaintenanceEntryCreate {
|
|||
export interface MaintenanceEntryUpdate {
|
||||
/** @example "0" */
|
||||
cost: string;
|
||||
date: Date;
|
||||
date: string;
|
||||
description: string;
|
||||
name: string;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ export interface MaintenanceLog {
|
|||
itemId: string;
|
||||
}
|
||||
|
||||
export interface PaginationResultRepoItemSummary {
|
||||
export interface PaginationResultItemSummary {
|
||||
items: ItemSummary[];
|
||||
page: number;
|
||||
pageSize: number;
|
||||
|
@ -302,7 +302,7 @@ export interface ValueOverTime {
|
|||
}
|
||||
|
||||
export interface ValueOverTimeEntry {
|
||||
date: Date;
|
||||
date: string;
|
||||
name: string;
|
||||
value: number;
|
||||
}
|
||||
|
@ -330,6 +330,10 @@ export interface UserRegistration {
|
|||
token: string;
|
||||
}
|
||||
|
||||
export interface ActionAmountResult {
|
||||
completed: number;
|
||||
}
|
||||
|
||||
export interface ApiSummary {
|
||||
build: Build;
|
||||
demo: boolean;
|
||||
|
@ -350,18 +354,14 @@ export interface ChangePassword {
|
|||
new: string;
|
||||
}
|
||||
|
||||
export interface EnsureAssetIDResult {
|
||||
completed: number;
|
||||
}
|
||||
|
||||
export interface GroupInvitation {
|
||||
expiresAt: Date;
|
||||
expiresAt: string;
|
||||
token: string;
|
||||
uses: number;
|
||||
}
|
||||
|
||||
export interface GroupInvitationCreate {
|
||||
expiresAt: Date;
|
||||
expiresAt: string;
|
||||
uses: number;
|
||||
}
|
||||
|
||||
|
@ -371,6 +371,6 @@ export interface ItemAttachmentToken {
|
|||
|
||||
export interface TokenResponse {
|
||||
attachmentToken: string;
|
||||
expiresAt: Date;
|
||||
expiresAt: string;
|
||||
token: string;
|
||||
}
|
||||
|
|
|
@ -180,6 +180,25 @@
|
|||
|
||||
notify.success(`${result.data.completed} assets have been updated.`);
|
||||
}
|
||||
|
||||
async function resetItemDateTimes() {
|
||||
const { isCanceled } = await confirm.open(
|
||||
"Are you sure you want to reset all date and time values? This will take a while and cannot be undone."
|
||||
);
|
||||
|
||||
if (isCanceled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await api.actions.resetItemDateTimes();
|
||||
|
||||
if (result.error) {
|
||||
notify.error("Failed to reset date and time values.");
|
||||
return;
|
||||
}
|
||||
|
||||
notify.success(`${result.data.completed} assets have been updated.`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -313,7 +332,7 @@
|
|||
</template>
|
||||
</BaseSectionHeader>
|
||||
|
||||
<div class="py-4 border-t-2 border-gray-300">
|
||||
<div class="py-4 border-t-2 border-gray-300 space-y-8">
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-10">
|
||||
<div class="col-span-3">
|
||||
<h4>Manage Asset IDs</h4>
|
||||
|
@ -325,6 +344,20 @@
|
|||
</div>
|
||||
<BaseButton class="btn-primary mt-auto" @click="ensureAssetIDs"> Ensure Asset IDs </BaseButton>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-10">
|
||||
<div class="col-span-3">
|
||||
<h4>Zero Item Date Times</h4>
|
||||
<p class="text-sm">
|
||||
Resets the time value for all date time fields in your inventory to the beginning of the date. This is
|
||||
to fix a bug that was introduced early on in the development of the site that caused the time value to
|
||||
be stored with the time which caused issues with date fields displaying accurate values.
|
||||
<a class="link" href="https://github.com/hay-kot/homebox/issues/236" target="_blank">
|
||||
See Github Issue #236 for more details
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<BaseButton class="btn-primary mt-auto" @click="resetItemDateTimes"> Zero Item Date Times </BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</BaseCard>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue