stash
This commit is contained in:
parent
d606de8773
commit
2218cc3543
12 changed files with 393 additions and 2204 deletions
|
|
@ -43,6 +43,8 @@
|
|||
<br>
|
||||
<small>Delete all your data including photos, videos,
|
||||
comments, profile information and more</small>
|
||||
<div v-if="deleteError" class="alert alert-danger mt-3 mb-0">{{ deleteError }}</div>
|
||||
<div v-if="deleteSuccess" class="alert alert-success mt-3 mb-0">{{ deleteSuccess }}</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -64,6 +66,8 @@
|
|||
</div>
|
||||
<br>
|
||||
<small>Import data from backup or other instances</small>
|
||||
<div v-if="importError" class="alert alert-danger mt-3 mb-0">{{ importError }}</div>
|
||||
<div v-if="importSuccess" class="alert alert-success mt-3 mb-0">{{ importSuccess }}</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -82,7 +86,11 @@ export default {
|
|||
components: {},
|
||||
data: () => ({
|
||||
selectedFile: null,
|
||||
localUserIdentityRecord: null
|
||||
localUserIdentityRecord: null,
|
||||
deleteError: null,
|
||||
deleteSuccess: null,
|
||||
importError: null,
|
||||
importSuccess: null
|
||||
}),
|
||||
computed: {
|
||||
...mapGetters(['signAuth'])
|
||||
|
|
@ -96,6 +104,8 @@ export default {
|
|||
}
|
||||
},
|
||||
async deleteData() {
|
||||
this.deleteError = null;
|
||||
this.deleteSuccess = null;
|
||||
if (!confirm('Are you sure you want to permanently delete all your data (inventory, locations, ' +
|
||||
'settings, friends and files)? Your account itself will stay - this cannot be undone.')) {
|
||||
return;
|
||||
|
|
@ -105,19 +115,19 @@ export default {
|
|||
const response = await servers.delete(this.signAuth, '/api/v1/account_data/');
|
||||
if (!response || !response.ok) {
|
||||
const errorBody = response ? await response.json().catch(() => ({})) : {};
|
||||
alert('Data deletion failed: ' + (errorBody.detail || response?.statusText || 'unknown error'));
|
||||
this.deleteError = 'Data deletion failed: ' + (errorBody.detail || response?.statusText || 'unknown error');
|
||||
return;
|
||||
}
|
||||
const summary = await response.json().catch(() => ({}));
|
||||
alert('All your data has been deleted: ' +
|
||||
this.deleteSuccess = 'All your data has been deleted: ' +
|
||||
`${summary.inventory_items || 0} inventory items, ` +
|
||||
`${summary.locations || 0} locations, ` +
|
||||
`${summary.settings || 0} settings, ` +
|
||||
`${summary.friends || 0} friends, ` +
|
||||
`${summary.files || 0} files.`);
|
||||
`${summary.files || 0} files.`;
|
||||
} catch (error) {
|
||||
console.error('Data deletion failed', error);
|
||||
alert('Data deletion failed: ' + error);
|
||||
this.deleteError = 'Data deletion failed: ' + error;
|
||||
}
|
||||
},
|
||||
exportKey() {
|
||||
|
|
@ -141,8 +151,10 @@ export default {
|
|||
});
|
||||
},
|
||||
async importData() {
|
||||
this.importError = null;
|
||||
this.importSuccess = null;
|
||||
if (!this.selectedFile) {
|
||||
alert('Please select a file to import');
|
||||
this.importError = 'Please select a file to import';
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
|
@ -150,16 +162,16 @@ export default {
|
|||
const servers = await this.getHomeServers();
|
||||
const summary = await servers.post(this.signAuth, '/api/v1/import/', {zip: base64});
|
||||
if (summary && summary.detail) {
|
||||
alert('Data import failed: ' + summary.detail);
|
||||
this.importError = 'Data import failed: ' + summary.detail;
|
||||
return;
|
||||
}
|
||||
alert('Data imported successfully: ' +
|
||||
this.importSuccess = 'Data imported successfully: ' +
|
||||
`${summary.profile ? 'profile, ' : ''}` +
|
||||
`${summary.settings || 0} settings, ` +
|
||||
`${summary.inventory_items || 0} inventory items, ` +
|
||||
`${summary.friends || 0} friends, ` +
|
||||
`${summary.locations || 0} locations, ` +
|
||||
`${summary.files || 0} files.`);
|
||||
`${summary.files || 0} files.`;
|
||||
this.selectedFile = null;
|
||||
const fileInput = document.getElementById('inputFile');
|
||||
if (fileInput) {
|
||||
|
|
@ -167,7 +179,7 @@ export default {
|
|||
}
|
||||
} catch (error) {
|
||||
console.error('Data import failed', error);
|
||||
alert('Data import failed: ' + error);
|
||||
this.importError = 'Data import failed: ' + error;
|
||||
}
|
||||
},
|
||||
async exportData() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue