From faeeee23f451dd9e495ad470d1e73c348d7df15c Mon Sep 17 00:00:00 2001 From: CodexAdrian <83074853+CodexAdrian@users.noreply.github.com> Date: Tue, 9 May 2023 03:35:59 -0400 Subject: [PATCH] Loading bar all the things --- theseus_gui/src/App.vue | 28 +- .../src/components/ui/RunningAppBar.vue | 17 +- .../src/components/ui/SplashScreen.vue | 49 ++ theseus_gui/src/pages/Browse.vue | 461 +++++++++--------- theseus_gui/src/pages/Index.vue | 35 +- theseus_gui/src/pages/Library.vue | 38 +- theseus_gui/src/pages/Settings.vue | 427 ++++++++-------- theseus_gui/src/pages/instance/Index.vue | 117 +++-- theseus_gui/src/pages/project/Index.vue | 425 ++++++++-------- 9 files changed, 877 insertions(+), 720 deletions(-) create mode 100644 theseus_gui/src/components/ui/SplashScreen.vue diff --git a/theseus_gui/src/App.vue b/theseus_gui/src/App.vue index f78920250..f9400de41 100644 --- a/theseus_gui/src/App.vue +++ b/theseus_gui/src/App.vue @@ -1,13 +1,14 @@ diff --git a/theseus_gui/src/components/ui/RunningAppBar.vue b/theseus_gui/src/components/ui/RunningAppBar.vue index 62d4eeff0..a48792fec 100644 --- a/theseus_gui/src/components/ui/RunningAppBar.vue +++ b/theseus_gui/src/components/ui/RunningAppBar.vue @@ -37,10 +37,10 @@

- {{ loadingBar.bar_type.PackDownload.pack_name }} + {{ loadingBar.bar_type.pack_name ?? 'Installing Modpack' }}

-
{{ loadingBar.message }}
+
{{ Math.floor(loadingBar.current) }}% {{ loadingBar.message }}
@@ -67,7 +67,8 @@ const showCard = ref(false) const currentProcesses = ref(await getRunningProfiles()) -await process_listener(async () => { +await process_listener(async (event) => { + console.log(event) await refresh() }) @@ -89,11 +90,7 @@ const goToTerminal = () => { router.push(`/instance/${encodeURIComponent(currentProcesses.value[0].path)}/logs`) } -const currentLoadingBars = ref( - Object.values(await progress_bars_list()).filter( - (bar) => bar.bar_type !== 'StateInit' && Object.keys(bar.bar_type)[0] === 'PackDownload' - ) -) +const currentLoadingBars = ref(Object.values(await progress_bars_list())) await loading_listener(async (event) => { console.log('loading listener', event.message, event) @@ -102,9 +99,7 @@ await loading_listener(async (event) => { const refreshInfo = async () => { const currentLoadingBarCount = currentLoadingBars.value.length - currentLoadingBars.value = Object.values(await progress_bars_list()).filter( - (bar) => bar.bar_type !== 'StateInit' && Object.keys(bar.bar_type)[0] === 'PackDownload' - ) + currentLoadingBars.value = Object.values(await progress_bars_list()) if (currentLoadingBars.value.length === 0) { showCard.value = false } else if (currentLoadingBarCount < currentLoadingBars.value.length) { diff --git a/theseus_gui/src/components/ui/SplashScreen.vue b/theseus_gui/src/components/ui/SplashScreen.vue new file mode 100644 index 000000000..c7ea66cfe --- /dev/null +++ b/theseus_gui/src/components/ui/SplashScreen.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/theseus_gui/src/pages/Browse.vue b/theseus_gui/src/pages/Browse.vue index fc42b1da7..c350e59e6 100644 --- a/theseus_gui/src/pages/Browse.vue +++ b/theseus_gui/src/pages/Browse.vue @@ -13,7 +13,6 @@ import { Card, ClientIcon, ServerIcon, - AnimatedLogo, NavRow, formatCategoryHeader, } from 'omorphia' @@ -23,6 +22,7 @@ import { useBreadcrumbs } from '@/store/breadcrumbs' import { get_categories, get_loaders, get_game_versions } from '@/helpers/tags' import { useRoute } from 'vue-router' import Instance from '@/components/ui/Instance.vue' +import SplashScreen from '@/components/ui/SplashScreen.vue' const route = useRoute() @@ -36,25 +36,28 @@ const breadcrumbs = useBreadcrumbs() const showSnapshots = ref(false) const loading = ref(true) -const [categories, loaders, availableGameVersions] = await Promise.all([ - get_categories(), - get_loaders(), - get_game_versions(), -]) +const categories = ref([]) +const loaders = ref([]) +const availableGameVersions = ref([]) -onMounted(() => { +onMounted(async () => { + ;[categories.value, loaders.value, availableGameVersions.value] = await Promise.all([ + get_categories(), + get_loaders(), + get_game_versions(), + ]) breadcrumbs.setContext({ name: 'Browse', link: route.path }) if (searchStore.projectType === 'modpack') { searchStore.instanceContext = null } searchStore.searchInput = '' - handleReset() - switchPage(1) + await handleReset(true) + loading.value = false }) const sortedCategories = computed(() => { const values = new Map() - for (const category of categories.filter( + for (const category of categories.value.filter( (cat) => cat.project_type === (searchStore.projectType === 'datapack' ? 'mod' : searchStore.projectType) @@ -67,7 +70,7 @@ const sortedCategories = computed(() => { return values }) -const getSearchResults = async (shouldLoad = false) => { +const getSearchResults = async () => { const queryString = searchStore.getQueryString() if (searchStore.instanceContext) { showVersions.value = false @@ -75,16 +78,10 @@ const getSearchResults = async (shouldLoad = false) => { searchStore.projectType === 'mod' || searchStore.projectType === 'resourcepack' ) } - if (shouldLoad === true) { - loading.value = true - } const response = await ofetch(`https://api.modrinth.com/v2/search${queryString}`) - loading.value = false searchStore.setSearchResults(response) } -getSearchResults(true) - const handleReset = async () => { searchStore.currentPage = 1 searchStore.offset = 0 @@ -131,221 +128,227 @@ watch( @@ -457,4 +460,14 @@ watch( } } } + +.fade-enter-active, +.fade-leave-active { + transition: opacity 0.3s ease; +} + +.fade-enter-from, +.fade-leave-to { + opacity: 0; +} diff --git a/theseus_gui/src/pages/Index.vue b/theseus_gui/src/pages/Index.vue index af4f812f2..b7602ba58 100644 --- a/theseus_gui/src/pages/Index.vue +++ b/theseus_gui/src/pages/Index.vue @@ -1,25 +1,34 @@ diff --git a/theseus_gui/src/pages/Library.vue b/theseus_gui/src/pages/Library.vue index 77836b1a0..77ac89b2e 100644 --- a/theseus_gui/src/pages/Library.vue +++ b/theseus_gui/src/pages/Library.vue @@ -1,19 +1,28 @@ + + diff --git a/theseus_gui/src/pages/Settings.vue b/theseus_gui/src/pages/Settings.vue index 9b21e00a1..6fb642fd1 100644 --- a/theseus_gui/src/pages/Settings.vue +++ b/theseus_gui/src/pages/Settings.vue @@ -1,5 +1,5 @@ diff --git a/theseus_gui/src/pages/instance/Index.vue b/theseus_gui/src/pages/instance/Index.vue index f3add623b..2544abf39 100644 --- a/theseus_gui/src/pages/instance/Index.vue +++ b/theseus_gui/src/pages/instance/Index.vue @@ -1,50 +1,53 @@