From 448de384d1174c70e37af10d8d5758c7c885029a Mon Sep 17 00:00:00 2001 From: "Adrian O.V" <83074853+CodexAdrian@users.noreply.github.com> Date: Thu, 20 Jul 2023 12:56:48 -0400 Subject: [PATCH] Sharing logs (#325) * Sharing * Mod UI changes * Final touches * update UI * Run lint * Addressed changes --- theseus_gui/package.json | 4 +- theseus_gui/pnpm-lock.yaml | 36 +- theseus_gui/src/assets/external/github.svg | 1 + theseus_gui/src/assets/external/index.js | 4 + theseus_gui/src/assets/external/mastodon.svg | 1 + theseus_gui/src/assets/external/reddit.svg | 1 + theseus_gui/src/assets/external/twitter.svg | 1 + theseus_gui/src/assets/icons/add-project.svg | 121 +++ theseus_gui/src/assets/icons/index.js | 6 + theseus_gui/src/assets/icons/menu.svg | 1 + theseus_gui/src/assets/icons/more.svg | 1 + theseus_gui/src/assets/icons/new-instance.svg | 138 +++ .../src/assets/icons/text-cursor-input.svg | 1 + theseus_gui/src/assets/icons/toggle.svg | 1 + theseus_gui/src/helpers/utils.js | 10 + theseus_gui/src/pages/Library.vue | 42 +- theseus_gui/src/pages/instance/Index.vue | 18 + theseus_gui/src/pages/instance/Logs.vue | 51 +- theseus_gui/src/pages/instance/Mods.vue | 816 ++++++++++++------ 19 files changed, 957 insertions(+), 297 deletions(-) create mode 100644 theseus_gui/src/assets/external/github.svg create mode 100644 theseus_gui/src/assets/external/mastodon.svg create mode 100644 theseus_gui/src/assets/external/reddit.svg create mode 100644 theseus_gui/src/assets/external/twitter.svg create mode 100644 theseus_gui/src/assets/icons/add-project.svg create mode 100644 theseus_gui/src/assets/icons/menu.svg create mode 100644 theseus_gui/src/assets/icons/more.svg create mode 100644 theseus_gui/src/assets/icons/new-instance.svg create mode 100644 theseus_gui/src/assets/icons/text-cursor-input.svg create mode 100644 theseus_gui/src/assets/icons/toggle.svg diff --git a/theseus_gui/package.json b/theseus_gui/package.json index a5f51b3e..6797f2b7 100644 --- a/theseus_gui/package.json +++ b/theseus_gui/package.json @@ -18,7 +18,7 @@ "floating-vue": "^2.0.0-beta.20", "mixpanel-browser": "^2.47.0", "ofetch": "^1.0.1", - "omorphia": "^0.4.31", + "omorphia": "^0.4.33", "pinia": "^2.1.3", "tauri-plugin-window-state-api": "github:tauri-apps/tauri-plugin-window-state#v1", "vite-svg-loader": "^4.0.0", @@ -38,5 +38,5 @@ "vite": "^4.3.9", "vite-plugin-eslint": "^1.8.1" }, - "packageManager": "pnpm@8.5.1" + "packageManager": "pnpm@8.6.0" } diff --git a/theseus_gui/pnpm-lock.yaml b/theseus_gui/pnpm-lock.yaml index 251c9dac..1051f77d 100644 --- a/theseus_gui/pnpm-lock.yaml +++ b/theseus_gui/pnpm-lock.yaml @@ -1,4 +1,8 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false dependencies: '@tauri-apps/api': @@ -17,14 +21,14 @@ dependencies: specifier: ^1.0.1 version: 1.0.1 omorphia: - specifier: ^0.4.31 - version: 0.4.31 + specifier: ^0.4.33 + version: 0.4.33 pinia: specifier: ^2.1.3 version: 2.1.3(vue@3.3.4) tauri-plugin-window-state-api: specifier: github:tauri-apps/tauri-plugin-window-state#v1 - version: github.com/tauri-apps/tauri-plugin-window-state/56fd671f8d5ac2d8b826a358af486f220a125c3d + version: github.com/tauri-apps/tauri-plugin-window-state/347c792535d2623fc21f66590d06f4c8dadd85ba vite-svg-loader: specifier: ^4.0.0 version: 4.0.0 @@ -409,6 +413,11 @@ packages: engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} dev: false + /@tauri-apps/api@1.4.0: + resolution: {integrity: sha512-Jd6HPoTM1PZSFIzq7FB8VmMu3qSSyo/3lSwLpoapW+lQ41CL5Dow2KryLg+gyazA/58DRWI9vu/XpEeHK4uMdw==} + engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'} + dev: false + /@tauri-apps/cli-darwin-arm64@1.3.1: resolution: {integrity: sha512-QlepYVPgOgspcwA/u4kGG4ZUijlXfdRtno00zEy+LxinN/IRXtk+6ErVtsmoLi1ZC9WbuMwzAcsRvqsD+RtNAg==} engines: {node: '>= 10'} @@ -1336,13 +1345,14 @@ packages: ufo: 1.1.2 dev: false - /omorphia@0.4.31: - resolution: {integrity: sha512-xeb9bD42VFRDKCkKz678hBYCIS//Atd4/hx6/YmboJLMEIjIJfS2Ocf9G53G52XkfS4DWs9CIzKz71NDh86kxQ==} + /omorphia@0.4.33: + resolution: {integrity: sha512-Wo0t16zRL8ZLJSKVAYv6pdYhL4YXYjDYs18shO7V5cfxjcynvd5j0sui6uBR8ghVMWFEJH994AEC/urLwcHiBA==} dependencies: dayjs: 1.11.7 floating-vue: 2.0.0-beta.20(vue@3.3.4) highlight.js: 11.8.0 markdown-it: 13.0.1 + qrcode.vue: 3.4.0(vue@3.3.4) vue: 3.3.4 vue-router: 4.2.1(vue@3.3.4) vue-select: 4.0.0-beta.6(vue@3.3.4) @@ -1460,6 +1470,14 @@ packages: engines: {node: '>=6'} dev: true + /qrcode.vue@3.4.0(vue@3.3.4): + resolution: {integrity: sha512-4XeImbv10Fin16Fl2DArCMhGyAdvIg2jb7vDT+hZiIAMg/6H6mz9nUZr/dR8jBcun5VzNzkiwKhiqOGbloinwA==} + peerDependencies: + vue: ^3.0.0 + dependencies: + vue: 3.3.4 + dev: false + /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true @@ -1791,10 +1809,10 @@ packages: engines: {node: '>=10'} dev: true - github.com/tauri-apps/tauri-plugin-window-state/56fd671f8d5ac2d8b826a358af486f220a125c3d: - resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-window-state/tar.gz/56fd671f8d5ac2d8b826a358af486f220a125c3d} + github.com/tauri-apps/tauri-plugin-window-state/347c792535d2623fc21f66590d06f4c8dadd85ba: + resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-window-state/tar.gz/347c792535d2623fc21f66590d06f4c8dadd85ba} name: tauri-plugin-window-state-api version: 0.0.0 dependencies: - '@tauri-apps/api': 1.3.0 + '@tauri-apps/api': 1.4.0 dev: false diff --git a/theseus_gui/src/assets/external/github.svg b/theseus_gui/src/assets/external/github.svg new file mode 100644 index 00000000..2f0f9348 --- /dev/null +++ b/theseus_gui/src/assets/external/github.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theseus_gui/src/assets/external/index.js b/theseus_gui/src/assets/external/index.js index b7aff27d..2ac283e1 100644 --- a/theseus_gui/src/assets/external/index.js +++ b/theseus_gui/src/assets/external/index.js @@ -4,3 +4,7 @@ export { default as KoFiIcon } from './kofi.svg' export { default as PatreonIcon } from './patreon.svg' export { default as PaypalIcon } from './paypal.svg' export { default as OpenCollectiveIcon } from './opencollective.svg' +export { default as TwitterIcon } from './twitter.svg' +export { default as GithubIcon } from './github.svg' +export { default as MastodonIcon } from './mastodon.svg' +export { default as RedditIcon } from './reddit.svg' diff --git a/theseus_gui/src/assets/external/mastodon.svg b/theseus_gui/src/assets/external/mastodon.svg new file mode 100644 index 00000000..9e96c941 --- /dev/null +++ b/theseus_gui/src/assets/external/mastodon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theseus_gui/src/assets/external/reddit.svg b/theseus_gui/src/assets/external/reddit.svg new file mode 100644 index 00000000..5cfd1124 --- /dev/null +++ b/theseus_gui/src/assets/external/reddit.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theseus_gui/src/assets/external/twitter.svg b/theseus_gui/src/assets/external/twitter.svg new file mode 100644 index 00000000..a43d68d9 --- /dev/null +++ b/theseus_gui/src/assets/external/twitter.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theseus_gui/src/assets/icons/add-project.svg b/theseus_gui/src/assets/icons/add-project.svg new file mode 100644 index 00000000..8a166536 --- /dev/null +++ b/theseus_gui/src/assets/icons/add-project.svg @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/theseus_gui/src/assets/icons/index.js b/theseus_gui/src/assets/icons/index.js index 195e41cf..020e1231 100644 --- a/theseus_gui/src/assets/icons/index.js +++ b/theseus_gui/src/assets/icons/index.js @@ -2,5 +2,11 @@ export { default as ServerIcon } from './server.svg' export { default as MinimizeIcon } from './minimize.svg' export { default as MaximizeIcon } from './maximize.svg' export { default as SwapIcon } from './arrow-left-right.svg' +export { default as ToggleIcon } from './toggle.svg' export { default as PackageIcon } from './package.svg' export { default as VersionIcon } from './milestone.svg' +export { default as MoreIcon } from './more.svg' +export { default as TextInputIcon } from './text-cursor-input.svg' +export { default as AddProjectImage } from './add-project.svg' +export { default as NewInstanceImage } from './new-instance.svg' +export { default as MenuIcon } from './menu.svg' diff --git a/theseus_gui/src/assets/icons/menu.svg b/theseus_gui/src/assets/icons/menu.svg new file mode 100644 index 00000000..7bafeae4 --- /dev/null +++ b/theseus_gui/src/assets/icons/menu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theseus_gui/src/assets/icons/more.svg b/theseus_gui/src/assets/icons/more.svg new file mode 100644 index 00000000..98f4a4df --- /dev/null +++ b/theseus_gui/src/assets/icons/more.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theseus_gui/src/assets/icons/new-instance.svg b/theseus_gui/src/assets/icons/new-instance.svg new file mode 100644 index 00000000..b526f23c --- /dev/null +++ b/theseus_gui/src/assets/icons/new-instance.svg @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/theseus_gui/src/assets/icons/text-cursor-input.svg b/theseus_gui/src/assets/icons/text-cursor-input.svg new file mode 100644 index 00000000..7bf2628d --- /dev/null +++ b/theseus_gui/src/assets/icons/text-cursor-input.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theseus_gui/src/assets/icons/toggle.svg b/theseus_gui/src/assets/icons/toggle.svg new file mode 100644 index 00000000..202f4537 --- /dev/null +++ b/theseus_gui/src/assets/icons/toggle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theseus_gui/src/helpers/utils.js b/theseus_gui/src/helpers/utils.js index ea8d6141..ae5b478c 100644 --- a/theseus_gui/src/helpers/utils.js +++ b/theseus_gui/src/helpers/utils.js @@ -57,3 +57,13 @@ export const installVersionDependencies = async (profile, version) => { } } } + +export const openLink = (url) => { + window.__TAURI_INVOKE__('tauri', { + __tauriModule: 'Shell', + message: { + cmd: 'open', + path: url, + }, + }) +} diff --git a/theseus_gui/src/pages/Library.vue b/theseus_gui/src/pages/Library.vue index 54af6a5f..354f90f0 100644 --- a/theseus_gui/src/pages/Library.vue +++ b/theseus_gui/src/pages/Library.vue @@ -6,6 +6,9 @@ import { useRoute } from 'vue-router' import { useBreadcrumbs } from '@/store/breadcrumbs' import { profile_listener } from '@/helpers/events.js' import { handleError } from '@/store/notifications.js' +import { Button, PlusIcon } from 'omorphia' +import InstanceCreationModal from '@/components/ui/InstanceCreationModal.vue' +import { NewInstanceImage } from '@/assets/icons' const route = useRoute() const breadcrumbs = useBreadcrumbs() @@ -23,7 +26,23 @@ onUnmounted(() => unlisten()) - + + + + + + No instances found + + + Create new instance + + + diff --git a/theseus_gui/src/pages/instance/Index.vue b/theseus_gui/src/pages/instance/Index.vue index 8db75a1e..f479b1d4 100644 --- a/theseus_gui/src/pages/instance/Index.vue +++ b/theseus_gui/src/pages/instance/Index.vue @@ -101,6 +101,17 @@ Open Folder Copy Link Open In Modrinth + Copy names + Copy slugs + Copy Links + Toggle selected + Disable selected + Enable selected + Show/Hide unselected + Update {{ selected.length > 0 ? 'selected' : 'all' }} + Select Updatable @@ -120,6 +131,12 @@ import { ClipboardCopyIcon, PlusIcon, ExternalIcon, + HashIcon, + GlobeIcon, + EyeIcon, + XIcon, + CheckCircleIcon, + UpdatedIcon, } from 'omorphia' import { get, run } from '@/helpers/profile' import { @@ -340,6 +357,7 @@ Button { flex-direction: row; overflow: auto; gap: 1rem; + min-height: 100%; } .content { diff --git a/theseus_gui/src/pages/instance/Logs.vue b/theseus_gui/src/pages/instance/Logs.vue index c9eaa163..185e0594 100644 --- a/theseus_gui/src/pages/instance/Logs.vue +++ b/theseus_gui/src/pages/instance/Logs.vue @@ -15,8 +15,8 @@ {{ copied ? 'Copied' : 'Copy' }} - - + + Share + @@ -48,8 +55,9 @@ import { CheckIcon, ClipboardCopyIcon, DropdownSelect, - SendIcon, + ShareIcon, TrashIcon, + ShareModal, } from 'omorphia' import { delete_logs_by_datetime, get_logs, get_output_by_datetime } from '@/helpers/logs.js' import { nextTick, onBeforeUnmount, onMounted, onUnmounted, ref, watch } from 'vue' @@ -59,6 +67,7 @@ import { get_output_by_uuid, get_uuids_by_profile_path } from '@/helpers/process import { useRoute } from 'vue-router' import { process_listener } from '@/helpers/events.js' import { handleError } from '@/store/notifications.js' +import { ofetch } from 'ofetch' dayjs.extend(calendar) @@ -71,6 +80,17 @@ const props = defineProps({ }, }) +const logs = ref([]) +await setLogs() + +const selectedLogIndex = ref(0) +const copied = ref(false) +const logContainer = ref(null) +const interval = ref(null) +const userScrolled = ref(false) +const isAutoScrolling = ref(false) +const shareModal = ref(null) + async function getLiveLog() { if (route.params.id) { const uuids = await get_uuids_by_profile_path(route.params.id).catch(handleError) @@ -101,12 +121,6 @@ async function setLogs() { logs.value = [liveLog, ...allLogs] } -const logs = ref([]) -await setLogs() - -const selectedLogIndex = ref(0) -const copied = ref(false) - const copyLog = () => { if (logs.value[selectedLogIndex.value]) { navigator.clipboard.writeText(logs.value[selectedLogIndex.value].stdout) @@ -114,6 +128,20 @@ const copyLog = () => { } } +const share = async () => { + if (logs.value[selectedLogIndex.value]) { + const url = await ofetch('https://api.mclo.gs/1/log', { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: `content=${encodeURIComponent(logs.value[selectedLogIndex.value].stdout)}`, + }).catch(handleError) + + shareModal.value.show(url.url) + } +} + watch(selectedLogIndex, async (newIndex) => { copied.value = false userScrolled.value = false @@ -143,11 +171,6 @@ const deleteLog = async () => { } } -const logContainer = ref(null) -const interval = ref(null) -const userScrolled = ref(false) -const isAutoScrolling = ref(false) - function handleUserScroll() { if (!isAutoScrolling.value) { userScrolled.value = true diff --git a/theseus_gui/src/pages/instance/Mods.vue b/theseus_gui/src/pages/instance/Mods.vue index a82bac80..d408e787 100644 --- a/theseus_gui/src/pages/instance/Mods.vue +++ b/theseus_gui/src/pages/instance/Mods.vue @@ -1,5 +1,12 @@ - + + + + @@ -18,16 +25,6 @@ - - Sort by - - - - - - - - Update {{ selected.length > 0 ? 'selected' : 'all' }} - - - - Select updatable - - - - - Remove selected - - - - - Toggle selected - - - - Disable selected - - - - Enable selected - - - - {{ hideNonSelected ? 'Show' : 'Hide' }} unselected - - - - - - Copy names - - - - Copy slugs - - - - Copy URLs - - - - - - - - - Name - Version - Author - Actions - - handleRightClick(c, mod)" - > - - - - - - - {{ mod.name }} - - - - {{ mod.name }} + + + + + + + + + Name + + + + + + Version + + + + + + Author + + + + + + Actions + + + + + (showingOptions = !showingOptions)" + @mouseover="selectedOption = 'Share'" + > + + + + + Share + + + + Delete + + + + Update + + + + Toggle + - {{ mod.version }} - {{ mod.author }} - - - - - - - - - - + + + + + Share names + + + + Share URLs + + + + Share file names + + + + Share as markdown + + + + + + Delete selected + + + + Delete disabled + + + + + + Update all + + + + Select updatable + + + + + + Toggle on + + + + Toggle off + + + + + {{ hideNonSelected ? 'Show' : 'Hide' }} untoggled + + + + handleRightClick(c, mod)" + > + + selectionMap.set(mod.path, newValue)" + /> + + + + + {{ mod.name }} + + + + {{ mod.name }} + + + {{ mod.version }} + {{ mod.author }} + + + + + + + + + + + + + + + + No projects found + Add a project to get started + + + + + Add content + + + + Add from file + + + + - Are you sure you want to remove {{ selected.length }} projects from - {{ instance.metadata.name }}? + Are you sure you want to remove + {{ functionValues.length }} project(s) from {{ instance.metadata.name }}? This action cannot be undone. @@ -191,6 +274,34 @@ + + + + + Are you sure you want to remove + {{ Array.from(projects.values()).filter((x) => x.disabled).length }} disabled + project(s) + from {{ instance.metadata.name }}? + + This action cannot be undone. + + + + Cancel + + + Remove + + + + +
Add a project to get started
- Are you sure you want to remove {{ selected.length }} projects from - {{ instance.metadata.name }}? + Are you sure you want to remove + {{ functionValues.length }} project(s) from {{ instance.metadata.name }}? This action cannot be undone.
+ Are you sure you want to remove + {{ Array.from(projects.values()).filter((x) => x.disabled).length }} disabled + project(s) + from {{ instance.metadata.name }}? + + This action cannot be undone. +