mirror of
https://github.com/lissy93/networking-toolbox.git
synced 2026-11-20 21:23:10 +03:00
Implemented import/export settings, and easy custom styles
This commit is contained in:
1 parent
8520d2fa03
commit
ad6df3f78b
7 files changed
+260
-5
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { site } from '$lib/constants/site';
|
||||
import { SITE_ICON, SITE_DESCRIPTION } from '$lib/config/customizable-settings';
|
||||
import { SITE_ICON, SITE_DESCRIPTION, DISABLE_SETTINGS } from '$lib/config/customizable-settings';
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import GlobalSearch from '$lib/components/global/GlobalSearch.svelte';
|
||||
import BurgerMenu from '$lib/components/furniture/BurgerMenu.svelte';
|
||||
@@ -50,7 +50,9 @@
|
||||
<Icon name="cli" size="sm" />
|
||||
</button>
|
||||
|
||||
<SettingsMenu />
|
||||
{#if !DISABLE_SETTINGS}
|
||||
<SettingsMenu />
|
||||
{/if}
|
||||
|
||||
<BurgerMenu />
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
import { browser } from '$app/environment';
|
||||
@@ -45,6 +46,11 @@
|
||||
isOpen = false;
|
||||
}
|
||||
|
||||
// Handle double-click to navigate to settings page
|
||||
function handleDoubleClick() {
|
||||
goto('/settings');
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
document.addEventListener('click', handleClickOutside);
|
||||
document.addEventListener('keydown', handleKeydown);
|
||||
@@ -69,6 +75,7 @@
|
||||
bind:this={triggerRef}
|
||||
class="action-button settings-trigger"
|
||||
onclick={() => (isOpen = !isOpen)}
|
||||
ondblclick={handleDoubleClick}
|
||||
aria-label="Open Settings"
|
||||
aria-expanded={isOpen}
|
||||
aria-haspopup="menu"
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
let envVarsCopied = $state(false);
|
||||
let envFormat = $state<'env' | 'docker'>('env');
|
||||
let showExportSettings = $state(false);
|
||||
let showExportStyles = $state(false);
|
||||
|
||||
// Constants
|
||||
const PRIMARY_A11Y_OPTIONS: string[] = [];
|
||||
@@ -606,6 +607,65 @@
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<button
|
||||
class="show-more-btn"
|
||||
onclick={() => (showExportStyles = !showExportStyles)}
|
||||
aria-expanded={showExportStyles}
|
||||
>
|
||||
<Icon name={showExportStyles ? 'chevron-up' : 'chevron-down'} size="sm" />
|
||||
<span>Export Styles</span>
|
||||
</button>
|
||||
{#if showExportStyles}
|
||||
<div class="env-vars-section" transition:slide={{ duration: 300 }}>
|
||||
<div class="env-header">
|
||||
<h4>Custom CSS</h4>
|
||||
</div>
|
||||
<p class="section-description">Apply your custom CSS to your self-hosted instance by mounting a CSS file.</p>
|
||||
|
||||
<div class="code-block-section">
|
||||
<p class="code-label">1. Create a file named <code>custom-styles.css</code></p>
|
||||
|
||||
<p class="code-label">2. Paste the following content:</p>
|
||||
<pre class="code-block"><code
|
||||
>{$currentCustomCss ||
|
||||
'/* No custom CSS saved yet */\n/* Add your custom styles in the Custom CSS section above */'}</code
|
||||
></pre>
|
||||
|
||||
<p class="code-label">3. Mount the file to your Docker container:</p>
|
||||
|
||||
<div class="mount-options">
|
||||
<p class="mount-option-label"><strong>Option A:</strong> Docker Compose</p>
|
||||
<pre class="code-block"><code
|
||||
>services:
|
||||
networking-toolbox:
|
||||
volumes:
|
||||
- ./custom-styles.css:/app/static/custom-styles.css:ro</code
|
||||
></pre>
|
||||
|
||||
<p class="mount-option-label"><strong>Option B:</strong> Docker Run</p>
|
||||
<pre class="code-block"><code
|
||||
>docker run -v $(pwd)/custom-styles.css:/app/static/custom-styles.css:ro ...</code
|
||||
></pre>
|
||||
|
||||
<p class="mount-option-label"><strong>Option C:</strong> Edit file directly in container</p>
|
||||
<pre class="code-block"><code
|
||||
>docker exec -it <container-name> sh -c 'cat > /app/static/custom-styles.css << "EOF"
|
||||
{$currentCustomCss || '/* Your custom CSS here */'}
|
||||
EOF'</code
|
||||
></pre>
|
||||
</div>
|
||||
|
||||
<div class="info-message">
|
||||
<Icon name="info" size="sm" />
|
||||
<p>
|
||||
<strong>Note:</strong> For Options A & B, create the <code>custom-styles.css</code> file before starting
|
||||
your container. Docker cannot mount individual files that don't exist yet.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -1103,8 +1163,9 @@
|
||||
}
|
||||
|
||||
.show-more-btn {
|
||||
max-width: 16rem;
|
||||
margin: var(--spacing-sm) auto;
|
||||
margin-top: var(--spacing-md);
|
||||
width: 12rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
&[aria-expanded='true'] {
|
||||
@@ -1526,6 +1587,108 @@
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.code-block-section {
|
||||
margin-top: var(--spacing-md);
|
||||
|
||||
.code-label {
|
||||
font-size: var(--font-size-sm);
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
margin: var(--spacing-md) 0 var(--spacing-xs) 0;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
code {
|
||||
background: var(--bg-tertiary);
|
||||
padding: 0.125rem 0.375rem;
|
||||
border-radius: var(--radius-xs);
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
}
|
||||
|
||||
.mount-options {
|
||||
margin-top: var(--spacing-sm);
|
||||
padding-left: var(--spacing-md);
|
||||
border-left: 2px solid var(--border-primary);
|
||||
|
||||
.mount-option-label {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-secondary);
|
||||
margin: var(--spacing-md) 0 var(--spacing-xs) 0;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
strong {
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.code-block {
|
||||
width: 100%;
|
||||
padding: var(--spacing-md);
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
margin-bottom: var(--spacing-sm);
|
||||
overflow-x: auto;
|
||||
|
||||
code {
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-primary);
|
||||
line-height: 1.6;
|
||||
white-space: pre;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.info-message {
|
||||
display: flex;
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-md);
|
||||
background: linear-gradient(
|
||||
135deg,
|
||||
color-mix(in srgb, var(--color-info), transparent 90%),
|
||||
color-mix(in srgb, var(--color-info), transparent 95%)
|
||||
);
|
||||
border: 1px solid color-mix(in srgb, var(--color-info), transparent 70%);
|
||||
border-radius: var(--radius-sm);
|
||||
margin-top: var(--spacing-md);
|
||||
|
||||
:global(svg) {
|
||||
flex-shrink: 0;
|
||||
color: var(--color-info);
|
||||
margin-top: 0.125rem;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--text-primary);
|
||||
line-height: 1.5;
|
||||
|
||||
strong {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
code {
|
||||
background: var(--bg-tertiary);
|
||||
padding: 0.125rem 0.375rem;
|
||||
border-radius: var(--radius-xs);
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,13 @@ export const DEFAULT_FONT_SCALE = parseInt(env.NTB_FONT_SCALE ?? '2', 10);
|
||||
|
||||
export const SHOW_TIPS_ON_HOMEPAGE = !!env.NTB_SHOW_TIPS_ON_HOMEPAGE;
|
||||
|
||||
/**
|
||||
* Disable settings page and settings menu
|
||||
* When true, hides the settings button and locks the settings page
|
||||
* Default: false
|
||||
*/
|
||||
export const DISABLE_SETTINGS = env.NTB_DISABLE_SETTINGS === 'true';
|
||||
|
||||
/**
|
||||
* DNS Security Settings
|
||||
* These settings protect against SSRF attacks by validating custom DNS server IPs
|
||||
@@ -142,6 +149,7 @@ export function getUserSettingsList(): Array<{ name: string; value: string }> {
|
||||
{ name: 'NTB_PRIMARY_COLOR', value: userPrimaryColor || env.NTB_PRIMARY_COLOR || '' },
|
||||
{ name: 'NTB_FONT_SCALE', value: userFontScale || env.NTB_FONT_SCALE || '' },
|
||||
{ name: 'NTB_SHOW_TIPS_ON_HOMEPAGE', value: env.NTB_SHOW_TIPS_ON_HOMEPAGE || '' },
|
||||
{ name: 'NTB_DISABLE_SETTINGS', value: env.NTB_DISABLE_SETTINGS || '' },
|
||||
{ name: 'NTB_ALLOW_CUSTOM_DNS', value: env.NTB_ALLOW_CUSTOM_DNS || '' },
|
||||
{ name: 'NTB_BLOCK_PRIVATE_DNS_IPS', value: env.NTB_BLOCK_PRIVATE_DNS_IPS || '' },
|
||||
{ name: 'NTB_ALLOWED_DNS_SERVERS', value: env.NTB_ALLOWED_DNS_SERVERS || '' },
|
||||
|
||||
@@ -402,6 +402,10 @@
|
||||
|
||||
<!-- Plausible Analytics -->
|
||||
<script defer data-domain="networking-toolbox.as93.net" src="https://no-track.as93.net/js/script.js"></script>
|
||||
|
||||
<!-- Custom Styles for Self-Hosted Instances -->
|
||||
<!-- This loads last to ensure custom styles can override defaults -->
|
||||
<link rel="stylesheet" href="/custom-styles.css" />
|
||||
</svelte:head>
|
||||
|
||||
<!-- Skip Links for Accessibility -->
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import SettingsPanel from '$lib/components/furniture/SettingsPanel.svelte';
|
||||
import Icon from '$lib/components/global/Icon.svelte';
|
||||
import { accessibility } from '$lib/stores/accessibility';
|
||||
import { theme } from '$lib/stores/theme';
|
||||
import { navbarDisplay } from '$lib/stores/navbarDisplay';
|
||||
import { homepageLayout } from '$lib/stores/homepageLayout';
|
||||
import { DISABLE_SETTINGS } from '$lib/config/customizable-settings';
|
||||
|
||||
onMount(() => {
|
||||
// Initialize stores
|
||||
@@ -21,7 +23,17 @@
|
||||
<p>Customize your experience with themes, layouts, and accessibility options.</p>
|
||||
</div>
|
||||
|
||||
<SettingsPanel standalone={true} />
|
||||
{#if DISABLE_SETTINGS}
|
||||
<div class="settings-disabled">
|
||||
<div class="disabled-icon">
|
||||
<Icon name="lock" size="xl" />
|
||||
</div>
|
||||
<h2>Settings Disabled</h2>
|
||||
<p>Settings for this instance have been disabled by your administrator.</p>
|
||||
</div>
|
||||
{:else}
|
||||
<SettingsPanel standalone={true} />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
@@ -46,4 +58,43 @@
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-disabled {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
padding: var(--spacing-2xl);
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-lg);
|
||||
margin: var(--spacing-2xl) auto;
|
||||
max-width: 600px;
|
||||
|
||||
.disabled-icon {
|
||||
margin-bottom: var(--spacing-lg);
|
||||
color: var(--text-tertiary);
|
||||
opacity: 0.5;
|
||||
|
||||
:global(svg) {
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: var(--font-size-xl);
|
||||
font-weight: 600;
|
||||
margin: 0 0 var(--spacing-md) 0;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: var(--font-size-md);
|
||||
color: var(--text-secondary);
|
||||
margin: 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Custom Styles for Self-Hosted Instances
|
||||
*
|
||||
* This file can be used to apply custom CSS to your self-hosted Networking Toolbox.
|
||||
*
|
||||
* To use this file:
|
||||
* 1. Add your custom CSS rules below
|
||||
* 2. Mount this file as a volume in your Docker container
|
||||
*
|
||||
* Docker Compose example:
|
||||
* volumes:
|
||||
* - ./custom-styles.css:/app/static/custom-styles.css:ro
|
||||
*
|
||||
* Docker Run example:
|
||||
* docker run -v $(pwd)/custom-styles.css:/app/static/custom-styles.css:ro ...
|
||||
*
|
||||
* Your custom styles will automatically override the default styles.
|
||||
*/
|
||||
|
||||
/* Add your custom CSS here */
|
||||
Reference in new issue
Block a user