add DB export
This commit is contained in:
@@ -27,7 +27,7 @@ type NonsensitiveTables = {
|
||||
* https://9to5answer.com/how-to-bypass-warning-unexpected-any-specify-a-different-type-typescript-eslint-no-explicit-any
|
||||
*/
|
||||
export type SensitiveDexie<T extends unknown = SensitiveTables> = BaseDexie & T;
|
||||
export const accountsDB = new BaseDexie("KickStartSensitive") as SensitiveDexie;
|
||||
export const accountsDB = new BaseDexie("KickStartAccounts") as SensitiveDexie;
|
||||
const SensitiveSchemas = Object.assign({}, AccountsSchema);
|
||||
|
||||
export type NonsensitiveDexie<T extends unknown = NonsensitiveTables> =
|
||||
|
||||
@@ -122,29 +122,34 @@
|
||||
<router-link
|
||||
:to="{ name: 'new-edit-account' }"
|
||||
class="block text-center text-lg font-bold uppercase bg-blue-600 text-white px-2 py-3 rounded-md mb-8"
|
||||
>Edit Identity</router-link
|
||||
>
|
||||
Edit Identity
|
||||
</router-link>
|
||||
|
||||
<h3 class="text-sm uppercase font-semibold mb-3">Contact Actions</h3>
|
||||
|
||||
<a
|
||||
href="contact-scan.html"
|
||||
class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-6"
|
||||
>Scan New Contact</a
|
||||
>
|
||||
Scan New Contact
|
||||
</a>
|
||||
|
||||
<h3 class="text-sm uppercase font-semibold mb-3">Identity Actions</h3>
|
||||
<h3 class="text-sm uppercase font-semibold mb-3">Data</h3>
|
||||
|
||||
<a
|
||||
href=""
|
||||
class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-2"
|
||||
>Backup Seed</a
|
||||
>
|
||||
Backup Identifier Seed
|
||||
</a>
|
||||
<a
|
||||
href=""
|
||||
class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-6"
|
||||
>Backup Other Data</a
|
||||
@click="exportDatabase()"
|
||||
>
|
||||
Download Settings & Contacts (excluding Identifier Data)
|
||||
</a>
|
||||
<a ref="downloadLink" />
|
||||
|
||||
<!-- QR code popup -->
|
||||
<dialog id="dlgQR" class="backdrop:bg-black/75 rounded-md">
|
||||
@@ -198,6 +203,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import "dexie-export-import";
|
||||
import { Options, Vue } from "vue-class-component";
|
||||
import { useClipboard } from "@vueuse/core";
|
||||
import { db, accountsDB } from "@/db";
|
||||
@@ -299,6 +305,30 @@ export default class AccountViewView extends Vue {
|
||||
};
|
||||
}
|
||||
|
||||
public async exportDatabase() {
|
||||
try {
|
||||
const blob = await db.export({ prettyJson: true });
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
console.log("typeof", typeof this.$refs.downloadLink);
|
||||
const downloadAnchor = this.$refs.downloadLink as HTMLAnchorElement;
|
||||
downloadAnchor.href = url;
|
||||
downloadAnchor.download = db.name + "-backup.json";
|
||||
downloadAnchor.click();
|
||||
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
this.alertTitle = "Download Started";
|
||||
this.alertMessage = "See your downloads directory for the backup.";
|
||||
this.isAlertVisible = true;
|
||||
} catch (error) {
|
||||
this.alertTitle = "Export Error";
|
||||
this.alertMessage = "See console logs for more info.";
|
||||
this.isAlertVisible = true;
|
||||
console.error("Export Error:", error);
|
||||
}
|
||||
}
|
||||
|
||||
alertMessage = "";
|
||||
alertTitle = "";
|
||||
isAlertVisible = false;
|
||||
|
||||
Reference in New Issue
Block a user