diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f51d123..dfa4826a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Link settings that enable registrations and invites +- Ability to upload logo, background, default user avatar, instance thumbnail, and NSFW hiding images ### Changed diff --git a/src/api/mediaUpload.js b/src/api/mediaUpload.js new file mode 100644 index 00000000..1cbde204 --- /dev/null +++ b/src/api/mediaUpload.js @@ -0,0 +1,19 @@ +import { getToken } from '@/utils/auth' +import { baseName } from './utils' + +const UPLOAD_URL = '/api/v1/media' + +export function uploadMedia({ formData, authHost }) { + const url = baseName(authHost) + UPLOAD_URL + + return fetch(url, { + body: formData, + method: 'POST', + headers: authHeaders() + }) + .then((data) => data.json()) +} + +const authHeaders = () => { + return { 'Authorization': `Bearer ${getToken()}` } +} diff --git a/src/lang/en.js b/src/lang/en.js index 2e504315..a6f65378 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -388,7 +388,10 @@ export default { instanceReboot: 'Reboot Instance', restartApp: 'You must restart the instance to apply settings', restartSuccess: 'Instance rebooted successfully!', - removeSettingConfirmation: 'Are you sure you want to remove this setting\'s value from the database?' + removeSettingConfirmation: 'Are you sure you want to remove this setting\'s value from the database?', + changeImage: 'Change image', + uploadImage: 'Upload image', + remove: 'Remove' }, invites: { inviteTokens: 'Invite tokens', diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue index 3214485f..a30e8e19 100644 --- a/src/views/settings/components/Inputs.vue +++ b/src/views/settings/components/Inputs.vue @@ -33,8 +33,16 @@
+ +
+
+
+
+ +
+ {{ $t('settings.changeImage') }} +
+ +
+
+
+
+ + {{ $t('settings.uploadImage') }} + + + + {{ $t('settings.remove') }} + +
+
+ + + + + diff --git a/src/views/settings/components/inputComponents/index.js b/src/views/settings/components/inputComponents/index.js index 3b9bc788..11281950 100644 --- a/src/views/settings/components/inputComponents/index.js +++ b/src/views/settings/components/inputComponents/index.js @@ -2,6 +2,7 @@ export { default as AutoLinkerInput } from './AutoLinkerInput' export { default as EditableKeywordInput } from './EditableKeywordInput' export { default as CrontabInput } from './CrontabInput' export { default as IconsInput } from './IconsInput' +export { default as ImageUploadInput } from './ImageUploadInput' export { default as MascotsInput } from './MascotsInput' export { default as ProxyUrlInput } from './ProxyUrlInput' export { default as PruneInput } from './PruneInput'