Skip to content

Commit

Permalink
feat(#117): jfr, tasks, backups refactor and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukashornych committed Sep 22, 2024
1 parent 04b7132 commit 05fc04c
Show file tree
Hide file tree
Showing 92 changed files with 2,079 additions and 1,627 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"vue-router": "^4.0.0",
"vue-toastification": "^2.0.0-rc.5",
"vue3-apexcharts": "^1.4.4",
"vuetify": "^3.1.0",
"vuetify": "^3.6.0",
"webfontloader": "^1.0.0",
"xml-formatter": "^3.5.0",
"xxhashjs": "^0.2.2"
Expand Down
14 changes: 14 additions & 0 deletions src/modules/backup-viewer/BackupViewerModuleRegistrar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ModuleContextBuilder } from "@/ModuleContextBuilder";
import { ModuleRegistrar } from "@/ModuleRegistrar";
import { BackupViewerService, backupViewerServiceInjectionKey } from "./service/BackupViewerService";
import { ConnectionService, connectionServiceInjectionKey } from '@/modules/connection/service/ConnectionService'

//TODO: docs
export class BackupViewerModuleRegistrar implements ModuleRegistrar {

register(builder: ModuleContextBuilder): void {
const connectionService: ConnectionService = builder.inject(connectionServiceInjectionKey)
const backupViewerService: BackupViewerService = new BackupViewerService(connectionService)
builder.provide(backupViewerServiceInjectionKey, backupViewerService)
}
}
141 changes: 141 additions & 0 deletions src/modules/backup-viewer/components/BackupCatalogDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<script setup lang="ts">
import { OffsetDateTime } from '@/modules/connection/model/data-type/OffsetDateTime'
import { computed, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import VFormDialog from '@/modules/base/component/VFormDialog.vue'
import { DateTime } from 'luxon'
import { Timestamp } from '@bufbuild/protobuf'
import { BackupViewerService, useBackupViewerService } from '@/modules/backup-viewer/service/BackupViewerService'
import { Connection } from '@/modules/connection/model/Connection'
import { Toaster, useToaster } from '@/modules/notification/service/Toaster'
import { CatalogVersionAtResponse } from '@/modules/connection/model/CatalogVersionAtResponse'
const backupViewerService: BackupViewerService = useBackupViewerService()
const toaster: Toaster = useToaster()
const { t } = useI18n()
const props = defineProps<{
modelValue: boolean,
connection: Connection,
catalogName: string
}>()
const emit = defineEmits<{
(e: 'update:modelValue', value: boolean): void,
(e: 'backup', date: string): void
}>()
const pastMomentRules = [
(value: any): any => {
if (value != undefined && value.trim().length > 0) return true
return t('backupViewer.backup.form.pastMoment.validations.required')
}
]
const minimalDate = ref<string | undefined>()
const minimalDateLoaded = ref<boolean>(false)
const pastMoment = ref<string>()
const includeWal = ref<boolean>(false)
const changed = computed<boolean>(() => pastMoment.value != undefined)
async function loadMinimalDate(): Promise<CatalogVersionAtResponse> {
return await backupViewerService.getMinimalBackupDate(
props.connection,
props.catalogName
)
}
function reset(): void {
pastMoment.value = ''
includeWal.value = false
}
async function backup(): Promise<boolean> {
try {
// todo lho simplify
// todo lho verify date data type
const jsDate = new Date(pastMoment.value!)
const offsetDateTime: DateTime = DateTime.fromJSDate(jsDate)
const timestamp: Timestamp = Timestamp.fromDate(jsDate)
await backupViewerService.backupCatalog(
props.connection,
props.catalogName,
includeWal.value,
new OffsetDateTime(timestamp, offsetDateTime.toFormat('ZZ'))
)
toaster.success(t(
'backupViewer.backup.notification.backupRequested',
{ catalogName: props.catalogName }
))
return true
} catch (e: any) {
toaster.error(t(
'backupViewer.backup.notification.couldNotRequestBackup',
{
catalogName: props.catalogName,
reason: e.message
}
))
return false
}
}
loadMinimalDate().then((catalogVersionAt) => {
minimalDate.value = catalogVersionAt.introducedAt.toString()
minimalDateLoaded.value = true
})
</script>

<template>
<VFormDialog
:model-value="modelValue"
:changed="changed"
confirm-button-icon="mdi-cloud-download-outline"
:confirm="backup"
:reset="reset"
@update:model-value="emit('update:modelValue', $event)"
>
<template #title>
{{ t('backupViewer.backup.title') }}
</template>

<template #prepend-form>
<I18nT keypath="backupViewer.backup.description">
<template #catalogName>
<strong>{{ catalogName }}</strong>
</template>
</I18nT>
</template>

<template #default>
<VDateInput
v-model="pastMoment"
:label="t('backupViewer.backup.form.pastMoment.label')"
:disabled="!minimalDateLoaded"
:min="minimalDate"
:max="new Date().toISOString()"
:rules="pastMomentRules"
/>
<VCheckbox
v-model="includeWal"
:label="t('backupViewer.backup.form.includeWal.label')"
:messages="t('backupViewer.backup.form.includeWal.description')"
/>
</template>

<template #append-form>
<VAlert type="info" icon="mdi-information-outline">
{{ t('backupViewer.backup.info') }}
</VAlert>
</template>

<template #confirm-button-body>
{{ t('backupViewer.backup.button.backup') }}
</template>
</VFormDialog>
</template>

<style scoped>
</style>
Loading

0 comments on commit 05fc04c

Please sign in to comment.