Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 4 additions & 45 deletions apps/theming/src/components/BackgroundSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,12 @@
</template>

<script>
import { generateFilePath, generateRemoteUrl, generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { generateFilePath, generateUrl } from '@nextcloud/router'
import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
import { loadState } from '@nextcloud/initial-state'
import { Palette } from 'node-vibrant/lib/color.js'
import axios from '@nextcloud/axios'
import debounce from 'debounce'
import NcColorPicker from '@nextcloud/vue/dist/Components/NcColorPicker.js'
import Vibrant from 'node-vibrant'

import Check from 'vue-material-design-icons/Check.vue'
import ImageEdit from 'vue-material-design-icons/ImageEdit.vue'
Expand Down Expand Up @@ -217,9 +214,9 @@ export default {
this.update(result.data)
},

async setFile(path, color = null) {
async setFile(path) {
this.loading = 'custom'
const result = await axios.post(generateUrl('/apps/theming/background/custom'), { value: path, color })
const result = await axios.post(generateUrl('/apps/theming/background/custom'), { value: path })
this.update(result.data)
},

Expand Down Expand Up @@ -264,45 +261,7 @@ export default {
}

this.loading = 'custom'

// Extract primary color from image
let response = null
let color = null
try {
const fileUrl = generateRemoteUrl('dav/files/' + getCurrentUser().uid + path)
response = await axios.get(fileUrl, { responseType: 'blob' })
const blobUrl = URL.createObjectURL(response.data)
const palette = await this.getColorPaletteFromBlob(blobUrl)

// DarkVibrant is accessible AND visually pleasing
// Vibrant is not accessible enough and others are boring
color = palette?.DarkVibrant?.hex
this.setFile(path, color)

// Log data
console.debug('Extracted colour', color, 'from custom image', path, palette)
} catch (error) {
this.setFile(path)
console.error('Unable to extract colour from custom image', { error, path, response, color })
}
},

/**
* Extract a Vibrant color palette from a blob URL
*
* @param {string} blobUrl the blob URL
* @return {Promise<Palette>}
*/
getColorPaletteFromBlob(blobUrl) {
return new Promise((resolve, reject) => {
const vibrant = new Vibrant(blobUrl)
vibrant.getPalette((error, palette) => {
if (error) {
reject(error)
}
resolve(palette)
})
})
this.setFile(path)
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/dav-settings-personal-availability.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dav-settings-personal-availability.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-personal-webauthn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-personal-webauthn.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/theming-personal-theming.js

Large diffs are not rendered by default.

66 changes: 0 additions & 66 deletions dist/theming-personal-theming.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,19 @@ SPDX-License-Identifier: BSD-3-Clause
SPDX-License-Identifier: AGPL-3.0-or-later
SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0)
SPDX-FileCopyrightText: xiaokai <[email protected]>
SPDX-FileCopyrightText: qs developers
SPDX-FileCopyrightText: inherits developers
SPDX-FileCopyrightText: escape-html developers
SPDX-FileCopyrightText: defunctzombie
SPDX-FileCopyrightText: debounce developers
SPDX-FileCopyrightText: akfish
SPDX-FileCopyrightText: Varun A P
SPDX-FileCopyrightText: Tobias Koppers @sokra
SPDX-FileCopyrightText: T. Jameson Little <[email protected]>
SPDX-FileCopyrightText: Roman Shtylman <[email protected]>
SPDX-FileCopyrightText: Rob Cresswell <[email protected]>
SPDX-FileCopyrightText: Raynos <[email protected]>
SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
SPDX-FileCopyrightText: Matt Zabriskie
SPDX-FileCopyrightText: Mathias Bynens
SPDX-FileCopyrightText: Joyent
SPDX-FileCopyrightText: Jordan Harband <[email protected]>
SPDX-FileCopyrightText: Jordan Harband
SPDX-FileCopyrightText: John-David Dalton <[email protected]> (http://allyoucanleet.com/)
SPDX-FileCopyrightText: John-David Dalton <[email protected]>
SPDX-FileCopyrightText: John Molakvoæ (skjnldsv) <[email protected]>
SPDX-FileCopyrightText: James Halliday
SPDX-FileCopyrightText: Hiroki Osame
SPDX-FileCopyrightText: Guillaume Chau <[email protected]>
SPDX-FileCopyrightText: GitHub Inc.
Expand Down Expand Up @@ -83,27 +74,15 @@ This file is generated from multiple sources. Included packages:
- base64-js
- version: 1.5.1
- license: MIT
- call-bind
- version: 1.0.7
- license: MIT
- css-loader
- version: 7.1.2
- license: MIT
- debounce
- version: 2.2.0
- license: MIT
- define-data-property
- version: 1.1.4
- license: MIT
- dompurify
- version: 3.1.7
- license: (MPL-2.0 OR Apache-2.0)
- es-define-property
- version: 1.0.0
- license: MIT
- es-errors
- version: 1.3.0
- license: MIT
- escape-html
- version: 1.0.3
- license: MIT
Expand All @@ -113,48 +92,18 @@ This file is generated from multiple sources. Included packages:
- focus-trap
- version: 7.6.0
- license: MIT
- function-bind
- version: 1.1.2
- license: MIT
- get-intrinsic
- version: 1.2.4
- license: MIT
- gopd
- version: 1.0.1
- license: MIT
- has-property-descriptors
- version: 1.0.2
- license: MIT
- has-proto
- version: 1.0.3
- license: MIT
- has-symbols
- version: 1.0.3
- license: MIT
- hasown
- version: 2.0.2
- license: MIT
- ieee754
- version: 1.2.1
- license: BSD-3-Clause
- lodash.get
- version: 4.4.2
- license: MIT
- lodash
- version: 4.17.21
- license: MIT
- node-gettext
- version: 3.0.0
- license: MIT
- buffer
- version: 6.0.3
- license: MIT
- node-vibrant
- version: 3.1.6
- license: MIT
- object-inspect
- version: 1.13.2
- license: MIT
- inherits
- version: 2.0.3
- license: ISC
Expand All @@ -167,18 +116,6 @@ This file is generated from multiple sources. Included packages:
- process
- version: 0.11.10
- license: MIT
- punycode
- version: 1.4.1
- license: MIT
- qs
- version: 6.13.0
- license: BSD-3-Clause
- set-function-length
- version: 1.2.2
- license: MIT
- side-channel
- version: 1.0.6
- license: MIT
- style-loader
- version: 4.0.0
- license: MIT
Expand All @@ -188,9 +125,6 @@ This file is generated from multiple sources. Included packages:
- toastify-js
- version: 1.12.0
- license: MIT
- url
- version: 0.11.4
- license: MIT
- vue-color
- version: 2.8.1
- license: MIT
Expand Down
2 changes: 1 addition & 1 deletion dist/theming-personal-theming.js.map

Large diffs are not rendered by default.

Loading
Loading