7373
7474 <a v-if =" isAdmin" :href =" appStoreUrl" class =" button" >{{ t('dashboard', 'Get more widgets from the App Store') }}</a >
7575
76- <h3 >{{ t('dashboard', 'Change background image') }}</h3 >
77- <BackgroundSettings :background =" background"
78- :theming-default-background =" themingDefaultBackground"
79- @update:background =" updateBackground" />
80-
8176 <h3 >{{ t('dashboard', 'Weather service') }}</h3 >
8277 <p >
8378 {{ t('dashboard', 'For your privacy, the weather data is requested by your Nextcloud server on your behalf so the weather service receives no personal information.') }}
9388</template >
9489
9590<script >
96- import { generateUrl } from ' @nextcloud/router'
91+ import { generateUrl , imagePath } from ' @nextcloud/router'
9792import { getCurrentUser } from ' @nextcloud/auth'
9893import { loadState } from ' @nextcloud/initial-state'
9994import axios from ' @nextcloud/axios'
@@ -103,16 +98,16 @@ import NcModal from '@nextcloud/vue/dist/Components/NcModal'
10398import Pencil from ' vue-material-design-icons/Pencil.vue'
10499import Vue from ' vue'
105100
106- import isMobile from ' ./mixins/isMobile'
107- import BackgroundSettings from ' ./components/BackgroundSettings'
108- import getBackgroundUrl from ' ./helpers/getBackgroundUrl'
101+ import isMobile from ' ./mixins/isMobile.js'
102+ import { getBackgroundUrl } from ' ./helpers/getBackgroundUrl.js'
109103
110104const panels = loadState (' dashboard' , ' panels' )
111105const firstRun = loadState (' dashboard' , ' firstRun' )
112- const background = loadState (' dashboard' , ' background' )
113- const themingDefaultBackground = loadState (' dashboard' , ' themingDefaultBackground' )
114- const version = loadState (' dashboard' , ' version' )
115- const shippedBackgroundList = loadState (' dashboard' , ' shippedBackgrounds' )
106+
107+ const background = loadState (' theming' , ' background' )
108+ const backgroundVersion = loadState (' theming' , ' backgroundVersion' )
109+ const themingDefaultBackground = loadState (' theming' , ' themingDefaultBackground' )
110+ const shippedBackgroundList = loadState (' theming' , ' shippedBackgrounds' )
116111
117112const statusInfo = {
118113 weather: {
@@ -128,7 +123,6 @@ const statusInfo = {
128123export default {
129124 name: ' DashboardApp' ,
130125 components: {
131- BackgroundSettings,
132126 NcButton,
133127 Draggable,
134128 NcModal,
@@ -158,12 +152,11 @@ export default {
158152 statuses: {},
159153 background,
160154 themingDefaultBackground,
161- version,
162155 }
163156 },
164157 computed: {
165158 backgroundImage () {
166- return getBackgroundUrl (this .background , this . version , this .themingDefaultBackground )
159+ return getBackgroundUrl (this .background , backgroundVersion , this .themingDefaultBackground )
167160 },
168161 backgroundStyle () {
169162 if ((this .background === ' default' && this .themingDefaultBackground === ' backgroundColor' )
@@ -175,7 +168,6 @@ export default {
175168 backgroundImage: this .background === ' default' ? ' var(--image-main-background)' : ` url('${ this .backgroundImage } ')` ,
176169 }
177170 },
178-
179171 greeting () {
180172 const time = this .timer .getHours ()
181173
@@ -280,6 +272,32 @@ export default {
280272 },
281273
282274 methods: {
275+ updateGlobalStyles () {
276+ // Override primary-invert-if-bright and color-primary-text if background is set
277+ const isBackgroundBright = shippedBackgroundList[this .background ]? .theming === ' dark'
278+ if (isBackgroundBright) {
279+ document .querySelector (' #header' ).style .setProperty (' --primary-invert-if-bright' , ' invert(100%)' )
280+ document .querySelector (' #header' ).style .setProperty (' --color-primary-text' , ' #000000' )
281+ // document.body.removeAttribute('data-theme-dark')
282+ // document.body.setAttribute('data-theme-light', 'true')
283+ } else {
284+ document .querySelector (' #header' ).style .setProperty (' --primary-invert-if-bright' , ' no' )
285+ document .querySelector (' #header' ).style .setProperty (' --color-primary-text' , ' #ffffff' )
286+ // document.body.removeAttribute('data-theme-light')
287+ // document.body.setAttribute('data-theme-dark', 'true')
288+ }
289+
290+ const themeElements = [document .documentElement , document .querySelector (' #header' ), document .querySelector (' body' )]
291+ for (const element of themeElements) {
292+ if (this .background === ' default' ) {
293+ element .style .setProperty (' --image-main-background' , ` url('${ imagePath (' core' , ' app-background.jpg' )} ')` )
294+ } else if (this .background .match (/ #[0-9A-Fa-f ] {6} / g )) {
295+ element .style .setProperty (' --image-main-background' , undefined )
296+ } else {
297+ element .style .setProperty (' --image-main-background' , this .backgroundStyle .backgroundImage )
298+ }
299+ }
300+ },
283301 /**
284302 * Method to register panels that will be called by the integrating apps
285303 *
@@ -354,30 +372,6 @@ export default {
354372 this .firstRun = false
355373 }, 1000 )
356374 },
357- updateBackground (data ) {
358- this .background = data .type === ' custom' || data .type === ' default' ? data .type : data .value
359- this .version = data .version
360- this .updateGlobalStyles ()
361- },
362- updateGlobalStyles () {
363- // Override primary-invert-if-bright and color-primary-text if background is set
364- const isBackgroundBright = shippedBackgroundList[this .background ]? .theming === ' dark'
365- if (isBackgroundBright) {
366- document .querySelector (' #header' ).style .setProperty (' --primary-invert-if-bright' , ' invert(100%)' )
367- document .querySelector (' #header' ).style .setProperty (' --color-primary-text' , ' #000000' )
368- // document.body.removeAttribute('data-theme-dark')
369- // document.body.setAttribute('data-theme-light', 'true')
370- } else {
371- document .querySelector (' #header' ).style .setProperty (' --primary-invert-if-bright' , ' no' )
372- document .querySelector (' #header' ).style .setProperty (' --color-primary-text' , ' #ffffff' )
373- // document.body.removeAttribute('data-theme-light')
374- // document.body.setAttribute('data-theme-dark', 'true')
375- }
376-
377- document .documentElement .style .setProperty (' --image-main-background' , this .backgroundStyle .backgroundImage )
378- document .querySelector (' #header' ).style .setProperty (' --image-main-background' , this .backgroundStyle .backgroundImage )
379- document .querySelector (' body' ).style .setProperty (' --image-main-background' , this .backgroundStyle .backgroundImage )
380- },
381375 updateSkipLink () {
382376 // Make sure "Skip to main content" link points to the app content
383377 document .getElementsByClassName (' skip-navigation' )[0 ].setAttribute (' href' , ' #app-dashboard' )
0 commit comments