Skip to content

Commit

Permalink
github backup and logs
Browse files Browse the repository at this point in the history
  • Loading branch information
evandor committed Oct 16, 2024
1 parent 85f4755 commit 0a7e788
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/app/BrowserApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {useTabsetService} from "src/tabsets/services/TabsetService2";
import {useFeaturesStore} from "src/features/stores/featuresStore";
import {useRequestsService} from "src/requests/services/ContentService";
import {useCommandExecutor} from "src/core/services/CommandExecutor";
import {GithubBackupCommand} from "src/tabsets/commands/GithubBackupCommand";
import {GithubBackupCommand} from "src/tabsets/commands/github/GithubBackupCommand";


function runHousekeeping() {
Expand Down
4 changes: 3 additions & 1 deletion src/boot/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const GITHUB_USERNAME = "github.username"
const GITHUB_REPONAME = "github.reponame"
const GITHUB_TOKEN = "github.token"
const GITHUB_AUTO_BACKUP = "github.autobackup"
const GITHUB_LOG = "github.log"
const GITHUB_PATH = "github.path"

export default boot(({}) => {
})
Expand All @@ -65,6 +67,6 @@ export {
CURRENT_USER_ID,
CURRENT_USER_EMAIL,
UI_WINDOWS_ITEMS_PER_PAGE,
GITHUB_USERNAME, GITHUB_REPONAME, GITHUB_TOKEN, GITHUB_AUTO_BACKUP
GITHUB_USERNAME, GITHUB_REPONAME, GITHUB_TOKEN, GITHUB_AUTO_BACKUP,GITHUB_LOG,GITHUB_PATH
}

2 changes: 1 addition & 1 deletion src/core
Submodule core updated 1 files
+30 −23 services/CommandExecutor.ts
6 changes: 2 additions & 4 deletions src/pages/SettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@

<div v-if="tab === 'importExport'">

<ImportExportSettings />
<ImportExportSettings @show-tab="(t:string) => setTab(t)"/>

</div>

Expand Down Expand Up @@ -549,8 +549,6 @@ const unarchive = (tabset: Tabset) =>
sendMsg('reload-tabset', {tabsetId: tabset.id})
})
// const ignoredUrls = () => useTabsStore().ignoredTabset?.tabs
const simulateNewVersion = (version: string) => NavigationService.updateAvailable({version: version})
const restoreHints = () => useUiStore().restoreHints()
Expand All @@ -564,7 +562,7 @@ const simulateStaticSuggestion = () => {
useSuggestionsStore().addSuggestion(suggestions[suggestionsCounter++ % 2])
}
const setTab = (a: any) => tab.value = a['tab' as keyof object]
const setTab = (t: string) => tab.value = t
</script>

61 changes: 49 additions & 12 deletions src/pages/helper/BackupSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div class="row q-pa-md">
<div class="col-3"><b>Username</b></div>
<div class="col-3">Your github username</div>
<div class="col-3 text-grey-8">Your github username</div>
<div class="col-1"></div>
<div class="col-5">
<q-input v-model="username" dense label="Username"/>
Expand All @@ -16,7 +16,7 @@

<div class="row q-pa-md">
<div class="col-3"><b>Repository</b></div>
<div class="col-3">A preferrably empty public repository</div>
<div class="col-3 text-grey-8">A preferrably empty public repository</div>
<div class="col-1"></div>
<div class="col-5">
<q-input v-model="reponame" dense label="Repository Name"/>
Expand All @@ -25,7 +25,7 @@

<div class="row q-pa-md">
<div class="col-3"><b>GitHub Access Token</b></div>
<div class="col-3">Click <a href="https://github.com/settings/tokens" target="_blank">here</a> to create a new
<div class="col-3 text-grey-8">Click <a href="https://github.com/settings/tokens" target="_blank">here</a> to create a new
token (use scope <em>public_repo</em>).
</div>
<div class="col-1"></div>
Expand All @@ -34,14 +34,26 @@
</div>
</div>

<div class="row q-pa-md">
<div class="col-3"><b>Path</b></div>
<div class="col-3 text-grey-8">optional path where to store the backups and logs
</div>
<div class="col-1"></div>
<div class="col-5">
<q-input v-model="githubPath" dense label="Path"/>
</div>
</div>

<div class="row q-pa-md" v-if="username && reponame && githubToken">
<div class="col-3"><b>Save</b></div>
<div class="col-3">
<q-checkbox v-model="autobackup" label="Automatically daily backup"/>
<q-checkbox v-model="autobackup" label="Automatic daily backup"/>
<br>
<q-checkbox v-model="githubLog" label="Keep action log"/>
</div>
<div class="col-1"></div>
<div class="col-5">
<q-btn dense label="Backup now" @click="runGithubBackup()"/>
<q-btn class="q-px-md" dense label="Backup now" :loading="useUiStore().commandExecuting" @click="runGithubBackup()"/>
</div>
</div>

Expand All @@ -54,37 +66,62 @@
import {ref, watchEffect} from "vue";
import {LocalStorage} from "quasar";
import {useCommandExecutor} from "src/core/services/CommandExecutor";
import {GithubBackupCommand} from "src/tabsets/commands/GithubBackupCommand";
import {GITHUB_AUTO_BACKUP, GITHUB_REPONAME, GITHUB_TOKEN, GITHUB_USERNAME} from "boot/constants";
import {
GITHUB_AUTO_BACKUP,
GITHUB_LOG,
GITHUB_PATH,
GITHUB_REPONAME,
GITHUB_TOKEN,
GITHUB_USERNAME
} from "boot/constants";
import {GithubBackupCommand} from "src/tabsets/commands/github/GithubBackupCommand";
import {NotificationType} from "src/core/services/ErrorHandler";
import {useUiStore} from "src/ui/stores/uiStore";
const username = ref<string>(LocalStorage.getItem(GITHUB_USERNAME) as string)
const reponame = ref<string>(LocalStorage.getItem(GITHUB_REPONAME) as string)
const githubToken = ref<string>(LocalStorage.getItem(GITHUB_TOKEN) as string)
const autobackup = ref<boolean>(LocalStorage.getItem(GITHUB_AUTO_BACKUP) || false)
const githubLog = ref<boolean>(LocalStorage.getItem(GITHUB_LOG) || false)
const githubPath = ref<string>(LocalStorage.getItem(GITHUB_PATH) as string)
const loading = ref(false)
function clearIncluding(idenfier: string) {
LocalStorage.remove(idenfier)
githubLog.value = false
autobackup.value = false
}
watchEffect(() => {
(username.value && username.value.trim().length > 0)
? LocalStorage.set(GITHUB_USERNAME, username.value)
: LocalStorage.remove(GITHUB_USERNAME)
: clearIncluding(GITHUB_USERNAME)
})
watchEffect(() => {
(reponame.value && reponame.value.trim().length > 0)
? LocalStorage.set(GITHUB_REPONAME, reponame.value)
: LocalStorage.remove(GITHUB_REPONAME)
: clearIncluding(GITHUB_REPONAME)
})
watchEffect(() => {
(githubToken.value && githubToken.value.trim().length > 0)
? LocalStorage.set(GITHUB_TOKEN, githubToken.value)
: LocalStorage.remove(GITHUB_TOKEN)
: clearIncluding(GITHUB_TOKEN)
})
watchEffect(() => {
LocalStorage.set(GITHUB_AUTO_BACKUP, autobackup.value)
(githubPath.value && githubPath.value.trim().length > 0)
? LocalStorage.set(GITHUB_PATH, githubPath.value)
: clearIncluding(GITHUB_PATH)
})
watchEffect(() => LocalStorage.set(GITHUB_AUTO_BACKUP, autobackup.value))
watchEffect(() => LocalStorage.set(GITHUB_LOG, githubLog.value))
const runGithubBackup = () => {
useCommandExecutor().executeFromUi(new GithubBackupCommand())
useCommandExecutor().executeFromUi(new GithubBackupCommand(["tabsets_backup_current", "tabset_backup_" + new Date().getTime()]), NotificationType.NOTIFY)
}
</script>
8 changes: 4 additions & 4 deletions src/pages/helper/ImportExportSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="col-3"><b>Export</b></div>
<div class="col-3">
as json or as bookmarks<br>
export to github is available <em @click="router.push('/mainpanel/settings?tab=backup')">here</em>.
export to github is available <span class="cursor-pointer text-blue-8" @click="emits('showTab', 'backup')">here</span>.
</div>
<div class="col-1"></div>
<div class="col-5">
Expand All @@ -26,7 +26,7 @@
<div class="row q-pa-md">
<div class="col-3"><b>Import</b></div>
<div class="col-3">
from json<br>
from json or <span class="cursor-pointer text-blue-8" @click="emits('showTab','backup')">github backup</span><br>
You might need to restart tabsets.
</div>
<div class="col-1"></div>
Expand All @@ -47,10 +47,10 @@
import ExportDialog from "src/tabsets/dialogues/ExportDialog.vue";
import ImportDialog from "src/tabsets/dialogues/ImportDialog.vue";
import {useQuasar} from "quasar";
import {useRouter} from "vue-router";
const $q = useQuasar()
const router = useRouter()
const emits = defineEmits(['showTab'])
const showExportDialog = () => $q.dialog({component: ExportDialog, componentProps: {inSidePanel: true}})
const showImportDialog = () => $q.dialog({component: ImportDialog, componentProps: {inSidePanel: true}})
Expand Down
2 changes: 1 addition & 1 deletion src/ui
Submodule ui updated 1 files
+3 −1 stores/uiStore.ts

0 comments on commit 0a7e788

Please sign in to comment.