App logo
This commit is contained in:
parent
37ae9aec2e
commit
97e25f26aa
@ -1,3 +1,6 @@
|
||||
@if (customLogo) {
|
||||
<img src="{{customLogo}}" height="100%" width="100%" [attr.style]="'height:'+height" />
|
||||
} @else {
|
||||
<svg [class]="getClasses()" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2897.4 896.6" [attr.style]="'height:'+height">
|
||||
<path class="leaf" d="M140,713.7c-3.4-16.4-10.3-49.1-11.2-49.1c-145.7-87.1-128.4-238-80.2-324.2C59,449,251.2,524,139.1,656.8 c-0.9,1.7,5.2,22.4,10.3,41.4c22.4-37.9,56-83.6,54.3-87.9C65.9,273.9,496.9,248.1,586.6,39.4c40.5,201.8-20.7,513.9-367.2,593.2 c-1.7,0.9-62.9,108.6-65.5,109.5c0-1.7-25.9-0.9-22.4-9.5C133.1,727.4,136.6,720.6,140,713.7L140,713.7z M135.7,632.6 c44-50.9-7.8-137.9-38.8-166.4C149.5,556.7,146,609.3,135.7,632.6L135.7,632.6z" transform="translate(0)" style="fill:#17541f"/>
|
||||
<g class="text" style="fill:#000">
|
||||
@ -16,3 +19,4 @@
|
||||
<path d="M757.6,293.7c-20-10.8-42.6-16.2-67.8-16.2H600c-8.5,39.2-21.1,76.4-37.6,111.3c-9.9,20.8-21.1,40.6-33.6,59.4v207.2h88.9 V521.5h72c25.2,0,47.8-5.4,67.8-16.2s35.7-25.6,47.1-44.2c11.4-18.7,17.1-39.1,17.1-61.3c0.1-22.7-5.6-43.3-17-61.9 C793.3,319.2,777.6,304.5,757.6,293.7z M716.6,434.3c-9.3,8.9-21.6,13.3-36.7,13.3l-62.2,0.4v-92.5l62.2-0.4 c15.1,0,27.3,4.4,36.7,13.3c9.4,8.9,14,19.9,14,32.9C730.6,414.5,726,425.4,716.6,434.3z" transform="translate(0)"/>
|
||||
</g>
|
||||
</svg>
|
||||
}
|
||||
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.5 KiB |
@ -1,4 +1,7 @@
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { environment } from 'src/environments/environment'
|
||||
|
||||
@Component({
|
||||
selector: 'pngx-logo',
|
||||
@ -12,6 +15,17 @@ export class LogoComponent {
|
||||
@Input()
|
||||
height = '6em'
|
||||
|
||||
get customLogo(): string {
|
||||
return this.settingsService.get(SETTINGS_KEYS.APP_LOGO)?.length
|
||||
? environment.apiBaseUrl.replace(
|
||||
/\/api\/$/,
|
||||
this.settingsService.get(SETTINGS_KEYS.APP_LOGO)
|
||||
)
|
||||
: null
|
||||
}
|
||||
|
||||
constructor(private settingsService: SettingsService) {}
|
||||
|
||||
getClasses() {
|
||||
return ['logo'].concat(this.extra_classes).join(' ')
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ export enum ConfigOptionType {
|
||||
Select = 'select',
|
||||
Boolean = 'boolean',
|
||||
JSON = 'json',
|
||||
File = 'file',
|
||||
}
|
||||
|
||||
export const ConfigCategory = {
|
||||
@ -165,6 +166,13 @@ export const PaperlessConfigOptions: ConfigOption[] = [
|
||||
config_key: 'PAPERLESS_OCR_USER_ARGS',
|
||||
category: ConfigCategory.OCR,
|
||||
},
|
||||
{
|
||||
key: 'app_logo',
|
||||
title: $localize`Application Logo`,
|
||||
type: ConfigOptionType.File,
|
||||
config_key: 'PAPERLESS_APP_LOGO',
|
||||
category: ConfigCategory.General,
|
||||
},
|
||||
{
|
||||
key: 'app_title',
|
||||
title: $localize`Application Title`,
|
||||
@ -188,5 +196,6 @@ export interface PaperlessConfig extends ObjectWithId {
|
||||
max_image_pixels: number
|
||||
color_conversion_strategy: ColorConvertConfig
|
||||
user_args: object
|
||||
app_logo: string
|
||||
app_title: string
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ export interface UiSetting {
|
||||
|
||||
export const SETTINGS_KEYS = {
|
||||
LANGUAGE: 'language',
|
||||
APP_LOGO: 'app_logo',
|
||||
APP_TITLE: 'app_title',
|
||||
// maintain old general-settings: for backwards compatibility
|
||||
BULK_EDIT_CONFIRMATION_DIALOGS:
|
||||
@ -195,6 +196,11 @@ export const SETTINGS: UiSetting[] = [
|
||||
type: 'array',
|
||||
default: [],
|
||||
},
|
||||
{
|
||||
key: SETTINGS_KEYS.APP_LOGO,
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
key: SETTINGS_KEYS.APP_TITLE,
|
||||
type: 'string',
|
||||
|
@ -1171,6 +1171,9 @@ class UiSettingsView(GenericAPIView):
|
||||
ui_settings["app_title"] = settings.APP_TITLE
|
||||
if general_config.app_title is not None and len(general_config.app_title) > 0:
|
||||
ui_settings["app_title"] = general_config.app_title
|
||||
ui_settings["app_logo"] = settings.APP_LOGO
|
||||
if general_config.app_logo is not None and len(general_config.app_logo) > 0:
|
||||
ui_settings["app_logo"] = general_config.app_logo
|
||||
|
||||
user_resp = {
|
||||
"id": user.id,
|
||||
|
@ -102,8 +102,10 @@ class GeneralConfig(BaseConfig):
|
||||
"""
|
||||
|
||||
app_title: str = dataclasses.field(init=False)
|
||||
app_logo: str = dataclasses.field(init=False)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
app_config = self._get_config_instance()
|
||||
|
||||
self.app_title = app_config.app_title or None
|
||||
self.app_logo = app_config.app_logo.url if app_config.app_logo else None
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Generated by Django 4.2.8 on 2024-01-07 07:31
|
||||
# Generated by Django 4.2.9 on 2024-01-12 05:33
|
||||
|
||||
from django.db import migrations
|
||||
from django.db import models
|
||||
@ -10,6 +10,16 @@ class Migration(migrations.Migration):
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="applicationconfiguration",
|
||||
name="app_logo",
|
||||
field=models.FileField(
|
||||
blank=True,
|
||||
null=True,
|
||||
upload_to="",
|
||||
verbose_name="Application logo",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="applicationconfiguration",
|
||||
name="app_title",
|
||||
@ -17,7 +27,7 @@ class Migration(migrations.Migration):
|
||||
blank=True,
|
||||
max_length=48,
|
||||
null=True,
|
||||
verbose_name="Application Title",
|
||||
verbose_name="Application title",
|
||||
),
|
||||
),
|
||||
]
|
@ -1,3 +1,4 @@
|
||||
from django.core.validators import FileExtensionValidator
|
||||
from django.core.validators import MinValueValidator
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@ -167,12 +168,22 @@ class ApplicationConfiguration(AbstractSingletonModel):
|
||||
)
|
||||
|
||||
app_title = models.CharField(
|
||||
verbose_name=_("Application Title"),
|
||||
verbose_name=_("Application title"),
|
||||
null=True,
|
||||
blank=True,
|
||||
max_length=48,
|
||||
)
|
||||
|
||||
app_logo = models.FileField(
|
||||
verbose_name=_("Application logo"),
|
||||
null=True,
|
||||
blank=True,
|
||||
validators=[
|
||||
FileExtensionValidator(allowed_extensions=["jpg", "png", "gif", "svg"]),
|
||||
],
|
||||
upload_to="logo/",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("paperless application settings")
|
||||
|
||||
|
@ -129,6 +129,11 @@ class ApplicationConfigurationSerializer(serializers.ModelSerializer):
|
||||
data["user_args"] = None
|
||||
return super().run_validation(data)
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
if instance.app_logo and "app_logo" in validated_data:
|
||||
instance.app_logo.delete()
|
||||
return super().update(instance, validated_data)
|
||||
|
||||
class Meta:
|
||||
model = ApplicationConfiguration
|
||||
fields = "__all__"
|
||||
|
@ -367,6 +367,7 @@ STORAGES = {
|
||||
"staticfiles": {
|
||||
"BACKEND": _static_backend,
|
||||
},
|
||||
"default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
|
||||
}
|
||||
|
||||
_CELERY_REDIS_URL, _CHANNELS_REDIS_URL = _parse_redis_url(
|
||||
@ -1000,6 +1001,7 @@ if ENABLE_UPDATE_CHECK != "default":
|
||||
ENABLE_UPDATE_CHECK = __get_boolean("PAPERLESS_ENABLE_UPDATE_CHECK")
|
||||
|
||||
APP_TITLE = os.getenv("PAPERLESS_APP_TITLE", None)
|
||||
APP_LOGO = os.getenv("PAPERLESS_APP_LOGO", None)
|
||||
|
||||
###############################################################################
|
||||
# Machine Learning #
|
||||
|
@ -1,3 +1,5 @@
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls import include
|
||||
from django.contrib import admin
|
||||
@ -8,6 +10,7 @@ from django.utils.translation import gettext_lazy as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.views.generic import RedirectView
|
||||
from django.views.static import serve
|
||||
from rest_framework.authtoken import views
|
||||
from rest_framework.routers import DefaultRouter
|
||||
|
||||
@ -181,6 +184,12 @@ urlpatterns = [
|
||||
url=settings.STATIC_URL + "frontend/en-US/assets/%(path)s",
|
||||
),
|
||||
),
|
||||
# App logo
|
||||
re_path(
|
||||
r"^%s(?P<path>.*)$" % re.escape(settings.MEDIA_URL.lstrip("/")),
|
||||
serve,
|
||||
kwargs={"document_root": settings.MEDIA_ROOT},
|
||||
),
|
||||
# TODO: with localization, this is even worse! :/
|
||||
# login, logout
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
|
Loading…
x
Reference in New Issue
Block a user