refactor frontend

This commit is contained in:
Julian Freeman
2026-04-16 16:26:21 -04:00
parent 6cc694754f
commit dabd8789f4
14 changed files with 1574 additions and 1357 deletions

View File

@@ -1,11 +1,8 @@
<script setup lang="ts">
import SortDropdown from "./components/SortDropdown.vue";
import {
browserIconOptions,
browserIconSrc,
configurationIconSrc,
} from "./features/browser-assistant/icons";
import { useBrowserAssistant } from "./features/browser-assistant/useBrowserAssistant";
import BrowserDataView from "./components/browser-data/BrowserDataView.vue";
import ConfigurationView from "./components/config/ConfigurationView.vue";
import AppSidebar from "./components/sidebar/AppSidebar.vue";
import { useBrowserManager } from "./composables/useBrowserManager";
const {
activeSection,
@@ -44,199 +41,42 @@ const {
sortedProfiles,
toggleBookmarkProfiles,
toggleExtensionProfiles,
} = useBrowserAssistant();
} = useBrowserManager();
</script>
<template>
<div class="app-shell">
<aside class="sidebar">
<div class="sidebar-toolbar">
<div class="sidebar-title-group">
<h1>Browser Assistant</h1>
<p>Local Chromium profile manager</p>
</div>
</div>
<div v-if="browsers.length" class="browser-nav">
<button
v-for="browser in browsers"
:key="browser.browserId"
class="browser-nav-item"
:class="[browser.browserFamilyId ?? browser.browserId, { active: browser.browserId === currentBrowser?.browserId }]"
type="button"
@click="selectedBrowserId = browser.browserId; page = 'browserData'"
>
<div class="browser-nav-icon">
<img
v-if="browserIconSrc(browser.iconKey ?? browser.browserFamilyId)"
:src="browserIconSrc(browser.iconKey ?? browser.browserFamilyId) ?? undefined"
:alt="`${browser.browserName} icon`"
/>
<span v-else>{{ browserMonogram(browser.browserId) }}</span>
</div>
<div class="browser-nav-body">
<strong>{{ browser.browserName }}</strong>
<span>{{ browser.dataRoot }}</span>
</div>
</button>
</div>
<div v-else class="sidebar-empty">
<p>No supported Chromium browser data was found yet.</p>
</div>
<button
class="browser-nav-item utility sidebar-utility-nav"
:class="{ active: page === 'configuration' }"
type="button"
@click="page = 'configuration'"
>
<div class="browser-nav-icon config-nav-icon">
<img :src="configurationIconSrc" alt="Configuration icon" />
</div>
<div class="browser-nav-body">
<strong>Configuration</strong>
<span>Manage custom scan sources and paths</span>
</div>
</button>
<button class="refresh-button sidebar-refresh" type="button" @click="refreshAll">
{{ loading || configsLoading ? "Refreshing..." : "Refresh" }}
</button>
</aside>
<AppSidebar
:browsers="browsers"
:current-browser-id="currentBrowser?.browserId ?? null"
:page="page"
:loading="loading"
:configs-loading="configsLoading"
:browser-monogram="browserMonogram"
@select-browser="selectedBrowserId = $event; page = 'browserData'"
@select-configuration="page = 'configuration'"
@refresh="refreshAll"
/>
<main class="content-panel">
<template v-if="page === 'configuration'">
<section class="content-scroll-area">
<section class="content-section">
<div v-if="configError" class="inline-error">
{{ configError }}
</div>
<div class="config-form-card">
<div class="config-form-header">
<h3>Add Custom Browser</h3>
<p>Provide a name, executable path, and Chromium user data path.</p>
</div>
<div class="config-form-layout">
<div class="config-form-fields">
<label class="field-group">
<span>Name</span>
<input v-model="createConfigForm.name" placeholder="Work Chrome" />
</label>
<label class="field-group">
<span>Executable Path</span>
<div class="path-input-row">
<input
v-model="createConfigForm.executablePath"
placeholder="C:\Program Files\...\chrome.exe"
/>
<button
class="secondary-button"
type="button"
@click="pickExecutablePath"
>
Browse File
</button>
</div>
</label>
<label class="field-group">
<span>User Data Path</span>
<div class="path-input-row">
<input
v-model="createConfigForm.userDataPath"
placeholder="C:\Users\...\User Data"
/>
<button
class="secondary-button"
type="button"
@click="pickUserDataPath"
>
Browse Folder
</button>
</div>
</label>
</div>
<div class="config-form-side">
<label class="field-group">
<span>Icon</span>
<div class="icon-option-grid">
<button
v-for="option in browserIconOptions"
:key="option.key"
class="icon-option-button"
:class="{ active: createConfigForm.iconKey === option.key }"
type="button"
@click="createConfigForm.iconKey = option.key"
>
<img :src="option.src" :alt="option.label" />
<span>{{ option.label }}</span>
</button>
</div>
</label>
<div class="config-form-actions">
<button
class="primary-button"
type="button"
:disabled="savingConfig"
@click="createCustomBrowserConfig"
>
{{ savingConfig ? "Saving..." : "Add Config" }}
</button>
</div>
</div>
</div>
</div>
<div v-if="configsLoading" class="empty-card">
<p>Loading browser configs...</p>
</div>
<div v-else class="stack-list">
<article
v-for="config in browserConfigs"
:key="config.id"
class="config-card"
>
<div class="config-card-header">
<div class="config-card-lead">
<div class="browser-nav-icon config-icon">
<img
v-if="browserIconSrc(config.iconKey ?? config.browserFamilyId)"
:src="browserIconSrc(config.iconKey ?? config.browserFamilyId) ?? undefined"
:alt="`${config.name} icon`"
/>
<span v-else>{{ configMonogram(config) }}</span>
</div>
<div>
<div class="config-title-row">
<h4>{{ config.name }}</h4>
</div>
</div>
</div>
<button
v-if="config.deletable"
class="danger-button"
type="button"
:disabled="isDeletingConfig(config.id)"
@click="deleteCustomBrowserConfig(config.id)"
>
{{ isDeletingConfig(config.id) ? "Deleting..." : "Delete" }}
</button>
</div>
<div class="config-meta">
<div class="config-meta-row">
<span class="config-label">Executable</span>
<p :title="config.executablePath">{{ config.executablePath || "Not resolved" }}</p>
</div>
<div class="config-meta-row">
<span class="config-label">User Data</span>
<p :title="config.userDataPath">{{ config.userDataPath }}</p>
</div>
</div>
</article>
</div>
</section>
</section>
<ConfigurationView
:config-error="configError"
:configs-loading="configsLoading"
:browser-configs="browserConfigs"
:create-config-form="createConfigForm"
:saving-config="savingConfig"
:config-monogram="configMonogram"
:is-deleting-config="isDeletingConfig"
@update-name="createConfigForm.name = $event"
@update-executable-path="createConfigForm.executablePath = $event"
@update-user-data-path="createConfigForm.userDataPath = $event"
@update-icon-key="createConfigForm.iconKey = $event"
@pick-executable-path="pickExecutablePath"
@pick-user-data-path="pickUserDataPath"
@create-config="createCustomBrowserConfig"
@delete-config="deleteCustomBrowserConfig"
/>
</template>
<template v-else-if="loading">
@@ -255,208 +95,31 @@ const {
</section>
</template>
<template v-else-if="currentBrowser">
<section class="section-tabs">
<button
class="section-tab"
:class="{ active: activeSection === 'profiles' }"
type="button"
@click="activeSection = 'profiles'"
>
<span>Profiles</span>
<span class="count-pill">{{ sectionCount("profiles") }}</span>
</button>
<button
class="section-tab"
:class="{ active: activeSection === 'extensions' }"
type="button"
@click="activeSection = 'extensions'"
>
<span>Extensions</span>
<span class="count-pill">{{ sectionCount("extensions") }}</span>
</button>
<button
class="section-tab"
:class="{ active: activeSection === 'bookmarks' }"
type="button"
@click="activeSection = 'bookmarks'"
>
<span>Bookmarks</span>
<span class="count-pill">{{ sectionCount("bookmarks") }}</span>
</button>
</section>
<div class="content-scroll-area">
<section v-if="activeSection === 'profiles'" class="content-section">
<div v-if="openProfileError" class="inline-error">
{{ openProfileError }}
</div>
<div class="sort-bar">
<SortDropdown
v-model="profileSortKey"
label="Sort by"
:options="[
{ label: 'Name', value: 'name' },
{ label: 'Email', value: 'email' },
{ label: 'Profile ID', value: 'id' },
]"
/>
</div>
<div v-if="sortedProfiles.length" class="stack-list">
<article v-for="profile in sortedProfiles" :key="profile.id" class="profile-card">
<div class="profile-avatar">
<img
v-if="profile.avatarDataUrl"
:src="profile.avatarDataUrl"
:alt="`${profile.name} avatar`"
/>
<span v-else>{{ profile.avatarLabel }}</span>
</div>
<div class="profile-body">
<div class="profile-topline">
<h4>{{ profile.name }}</h4>
<div class="profile-actions">
<button
class="card-action-button"
:disabled="isOpeningProfile(currentBrowser.browserId, profile.id)"
type="button"
@click="openBrowserProfile(currentBrowser.browserId, profile.id)"
>
{{
isOpeningProfile(currentBrowser.browserId, profile.id)
? "Opening..."
: "Open"
}}
</button>
<span class="badge neutral">{{ profile.id }}</span>
</div>
</div>
<p class="profile-email">{{ profile.email || "No email found" }}</p>
</div>
</article>
</div>
<div v-else class="empty-card">
<p>No profile directories were found for this browser.</p>
</div>
</section>
<section v-else-if="activeSection === 'extensions'" class="content-section">
<div class="sort-bar">
<SortDropdown
v-model="extensionSortKey"
label="Sort by"
:options="[
{ label: 'Name', value: 'name' },
{ label: 'Extension ID', value: 'id' },
]"
/>
</div>
<div v-if="sortedExtensions.length" class="stack-list">
<article
v-for="extension in sortedExtensions"
:key="extension.id"
class="extension-card"
>
<div class="extension-icon">
<img
v-if="extension.iconDataUrl"
:src="extension.iconDataUrl"
:alt="`${extension.name} icon`"
/>
<span v-else>{{ extensionMonogram(extension.name) }}</span>
</div>
<div class="extension-body">
<div class="extension-topline">
<h4>{{ extension.name }}</h4>
<span v-if="extension.version" class="badge neutral">
v{{ extension.version }}
</span>
</div>
<p class="meta-line">{{ extension.id }}</p>
<div class="source-disclosure">
<button
class="disclosure-button"
type="button"
@click="toggleExtensionProfiles(extension.id)"
>
<span>Profiles</span>
<span class="badge neutral">{{ extension.profileIds.length }}</span>
</button>
<div
v-if="extensionProfilesExpanded(extension.id)"
class="disclosure-panel"
>
<span
v-for="profileId in extension.profileIds"
:key="`${extension.id}-${profileId}`"
class="badge"
>
{{ profileId }}
</span>
</div>
</div>
</div>
</article>
</div>
<div v-else class="empty-card">
<p>No extensions were discovered for this browser.</p>
</div>
</section>
<section v-else class="content-section">
<div class="sort-bar">
<SortDropdown
v-model="bookmarkSortKey"
label="Sort by"
:options="[
{ label: 'Name', value: 'title' },
{ label: 'URL', value: 'url' },
]"
/>
</div>
<div v-if="sortedBookmarks.length" class="bookmark-list">
<article v-for="bookmark in sortedBookmarks" :key="bookmark.url" class="bookmark-card">
<div class="bookmark-body">
<div class="bookmark-topline">
<h4>{{ bookmark.title }}</h4>
<span class="badge neutral">{{ domainFromUrl(bookmark.url) }}</span>
</div>
<p class="bookmark-url" :title="bookmark.url">{{ bookmark.url }}</p>
<div class="source-disclosure">
<button
class="disclosure-button"
type="button"
@click="toggleBookmarkProfiles(bookmark.url)"
>
<span>Profiles</span>
<span class="badge neutral">{{ bookmark.profileIds.length }}</span>
</button>
<div
v-if="bookmarkProfilesExpanded(bookmark.url)"
class="disclosure-panel"
>
<span
v-for="profileId in bookmark.profileIds"
:key="`${bookmark.url}-${profileId}`"
class="badge"
>
{{ profileId }}
</span>
</div>
</div>
</div>
</article>
</div>
<div v-else class="empty-card">
<p>No bookmarks were discovered for this browser.</p>
</div>
</section>
</div>
</template>
<BrowserDataView
v-else-if="currentBrowser"
:current-browser="currentBrowser"
:active-section="activeSection"
:profile-sort-key="profileSortKey"
:extension-sort-key="extensionSortKey"
:bookmark-sort-key="bookmarkSortKey"
:sorted-profiles="sortedProfiles"
:sorted-extensions="sortedExtensions"
:sorted-bookmarks="sortedBookmarks"
:open-profile-error="openProfileError"
:section-count="sectionCount"
:is-opening-profile="isOpeningProfile"
:extension-monogram="extensionMonogram"
:extension-profiles-expanded="extensionProfilesExpanded"
:bookmark-profiles-expanded="bookmarkProfilesExpanded"
:domain-from-url="domainFromUrl"
@update:active-section="activeSection = $event"
@update:profile-sort-key="profileSortKey = $event"
@update:extension-sort-key="extensionSortKey = $event"
@update:bookmark-sort-key="bookmarkSortKey = $event"
@open-profile="(browserId, profileId) => openBrowserProfile(browserId, profileId)"
@toggle-extension-profiles="toggleExtensionProfiles"
@toggle-bookmark-profiles="toggleBookmarkProfiles"
/>
<template v-else>
<section class="state-panel">