Skip to content

Commit

Permalink
Compaction now blocks user interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
lybekk committed Jul 21, 2020
1 parent bd593cb commit e985702
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 57 deletions.
77 changes: 45 additions & 32 deletions src/components/app/DatabaseCompaction.vue
Original file line number Diff line number Diff line change
@@ -1,36 +1,48 @@
<template>
<v-list-item
:disabled="compactingDone || compactInProgress"
@click="compactDB"
>
<v-list-item-icon>
<v-icon>mdi-database-refresh</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>
Compact database
<v-progress-linear
v-if="compactInProgress"
color="info"
buffer-value="0"
stream
/>
</v-list-item-title>
</v-list-item-content>
<v-list-item-icon>
<v-icon
v-if="compactingDone"
color="success"
>
mdi-check
</v-icon>
</v-list-item-icon>
</v-list-item>
<div>
<OverlayDisruptive
:title="'Compaction in progress'"
:message="'Keep the browser open while compaction is in progress to avoid damage to the database. Compaction may take a while on large databases'"
:show-overlay="compactInProgress"
/>
<v-list-item
:disabled="compactingDone || compactInProgress"
@click="compactDB"
>
<v-list-item-icon>
<v-icon>mdi-database-refresh</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>
Compact database
<v-progress-linear
v-if="compactInProgress"
color="info"
buffer-value="0"
stream
/>
</v-list-item-title>
</v-list-item-content>
<v-list-item-icon>
<v-icon
v-if="compactingDone"
color="success"
>
mdi-check
</v-icon>
</v-list-item-icon>
</v-list-item>
</div>
</template>

<script>
import OverlayDisruptive from "@/components/app/OverlayDisruptive.vue";
export default {
name: "DatabaseCompaction",
components: {
OverlayDisruptive
},
props: {
whatdb: {
type: String,
Expand All @@ -50,15 +62,16 @@ export default {
if (this.whatdb == "remoteDB") {
result = await window.remoteDB.compact();
} else {
this.$store.dispatch("infoBridge", {
color: "info",
text:
"Local compaction may take a while. Feel free to get things done. Just don't close the browser."
});
result = await window.db.compact();
}
if (result.ok) {
this.compactingDone = true;
} else {
this.$store.dispatch("infoBridge", {
color: "error",
text:
JSON.stringify(result)
});
}
this.compactInProgress = false;
} catch (error) {
Expand Down
56 changes: 56 additions & 0 deletions src/components/app/OverlayDisruptive.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<v-overlay
:value="showOverlay"
color="warning"
:z-index="9000"
:opacity="0.2"
>
<v-alert
color="primary"
dark
:icon="false"
border="left"
elevation="2"
prominent
>
<template v-slot:prepend>
<v-avatar
class="ma-3"
size="125"
tile
>
<v-progress-circular
color="warning"
indeterminate
size="64"
/>
</v-avatar>
</template>
<h3
class="headline"
v-text="title"
/>
<div v-text="message" />
</v-alert>
</v-overlay>
</template>

<script>
export default {
name: 'OverlayDisruptive',
props: {
showOverlay: {
type: Boolean,
default: false
},
title: {
type: String,
default: ''
},
message: {
type: String,
default: ''
}
}
}
</script>
32 changes: 8 additions & 24 deletions src/components/settings/LocalDatabase.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
<template>
<v-card-text>
<v-overlay
:value="destroyInProgress"
color="warning"
>
<v-card>
<v-card-text>
<v-row>
<v-col>Destroying local database. This may take a while if it's a large database.</v-col>
</v-row>
<v-row>
<v-col>
<div class="text-center">
<v-progress-circular
color="error"
indeterminate
size="64"
/>
</div>
</v-col>
</v-row>
</v-card-text>
</v-card>
</v-overlay>
<OverlayDisruptive
:title="'Destroying local database'"
:message="'This may take a while on a large database.'"
:show-overlay="destroyInProgress"
/>
<v-list>
<v-dialog max-width="500">
<template v-slot:activator="{ on }">
Expand Down Expand Up @@ -107,12 +89,14 @@
<script>
import DatabaseCompaction from "@/components/app/DatabaseCompaction.vue";
import LocalDatabaseImport from "@/components/settings/LocalDatabaseImport.vue";
import OverlayDisruptive from "@/components/app/OverlayDisruptive.vue";
export default {
name: "Settingslocaldb",
components: {
DatabaseCompaction,
LocalDatabaseImport
LocalDatabaseImport,
OverlayDisruptive
},
data: () => ({
backupPreparing: false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/RemoteDatabase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<p
v-for="(tip,i) in remoteTips"
:key="i"
,v-html="tip"
v-html="tip"
/>
</v-card-text>
</v-card>
Expand Down

0 comments on commit e985702

Please sign in to comment.