mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-30 18:27:45 -05:00
Feature: app branding (#5357)
This commit is contained in:
@@ -39,4 +39,26 @@ describe('ConfigService', () => {
|
||||
)
|
||||
expect(req.request.method).toEqual('PATCH')
|
||||
})
|
||||
|
||||
it('should support upload file with form data', () => {
|
||||
service.uploadFile(new File([], 'test.png'), 1, 'app_logo').subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}config/1/`
|
||||
)
|
||||
expect(req.request.method).toEqual('PATCH')
|
||||
expect(req.request.body).not.toBeNull()
|
||||
})
|
||||
|
||||
it('should not pass string app_logo', () => {
|
||||
service
|
||||
.saveConfig({
|
||||
id: 1,
|
||||
app_logo: '/logo/foobar.png',
|
||||
} as PaperlessConfig)
|
||||
.subscribe()
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}config/1/`
|
||||
)
|
||||
expect(req.request.body).toEqual({ id: 1 })
|
||||
})
|
||||
})
|
||||
|
@@ -20,8 +20,22 @@ export class ConfigService {
|
||||
}
|
||||
|
||||
saveConfig(config: PaperlessConfig): Observable<PaperlessConfig> {
|
||||
// dont pass string
|
||||
if (typeof config.app_logo === 'string') delete config.app_logo
|
||||
return this.http
|
||||
.patch<PaperlessConfig>(`${this.baseUrl}${config.id}/`, config)
|
||||
.pipe(first())
|
||||
}
|
||||
|
||||
uploadFile(
|
||||
file: File,
|
||||
configID: number,
|
||||
configKey: string
|
||||
): Observable<PaperlessConfig> {
|
||||
let formData = new FormData()
|
||||
formData.append(configKey, file, file.name)
|
||||
return this.http
|
||||
.patch<PaperlessConfig>(`${this.baseUrl}${configID}/`, formData)
|
||||
.pipe(first())
|
||||
}
|
||||
}
|
||||
|
@@ -301,4 +301,16 @@ describe('SettingsService', () => {
|
||||
.expectOne(`${environment.apiBaseUrl}ui_settings/`)
|
||||
.flush(ui_settings)
|
||||
})
|
||||
|
||||
it('should update environment app title if set', () => {
|
||||
const settings = Object.assign({}, ui_settings)
|
||||
settings.settings['app_title'] = 'FooBar'
|
||||
const req = httpTestingController.expectOne(
|
||||
`${environment.apiBaseUrl}ui_settings/`
|
||||
)
|
||||
req.flush(settings)
|
||||
expect(environment.appTitle).toEqual('FooBar')
|
||||
// post for migrate
|
||||
httpTestingController.expectOne(`${environment.apiBaseUrl}ui_settings/`)
|
||||
})
|
||||
})
|
||||
|
@@ -270,6 +270,9 @@ export class SettingsService {
|
||||
first(),
|
||||
tap((uisettings) => {
|
||||
Object.assign(this.settings, uisettings.settings)
|
||||
if (this.get(SETTINGS_KEYS.APP_TITLE)?.length) {
|
||||
environment.appTitle = this.get(SETTINGS_KEYS.APP_TITLE)
|
||||
}
|
||||
this.maybeMigrateSettings()
|
||||
// to update lang cookie
|
||||
if (this.settings['language']?.length)
|
||||
|
Reference in New Issue
Block a user