Merge pull request #22214 from nextcloud/dashboard/design-fixes
Custom dashboard backgroundpull/13712/head
-
2apps/dashboard/appinfo/routes.php
-
71apps/dashboard/css/dashboard.scss
-
BINapps/dashboard/img/anatoly-mikhaltsov-butterfly-wing-scale.jpg
-
BINapps/dashboard/img/bernard-spragg-new-zealand-fern.jpg
-
BINapps/dashboard/img/bernie-cetonia-aurata-take-off-composition.jpg
-
BINapps/dashboard/img/dejan-krsmanovic-ribbed-red-metal.jpg
-
BINapps/dashboard/img/eduardo-neves-pedra-azul.jpg
-
BINapps/dashboard/img/european-space-agency-barents-bloom.jpg
-
BINapps/dashboard/img/flickr-148302424@N05-36591009215-mobile.jpg
-
BINapps/dashboard/img/flickr-148302424@N05-36591009215.jpg
-
BINapps/dashboard/img/flickr-paszczak000-8715851521-mobile.jpg
-
BINapps/dashboard/img/flickr-paszczak000-8715851521.jpg
-
BINapps/dashboard/img/hannes-fritz-flippity-floppity.jpg
-
BINapps/dashboard/img/hannes-fritz-roulette.jpg
-
BINapps/dashboard/img/hannes-fritz-sea-spray.jpg
-
BINapps/dashboard/img/kamil-porembinski-clouds.jpg
-
BINapps/dashboard/img/lali-masriera-yellow-bricks.jpg
-
BINapps/dashboard/img/nasa-waxing-crescent-moon.jpg
-
BINapps/dashboard/img/previews/anatoly-mikhaltsov-butterfly-wing-scale.jpg
-
BINapps/dashboard/img/previews/bernard-spragg-new-zealand-fern.jpg
-
BINapps/dashboard/img/previews/bernie-cetonia-aurata-take-off-composition.jpg
-
BINapps/dashboard/img/previews/dejan-krsmanovic-ribbed-red-metal.jpg
-
BINapps/dashboard/img/previews/eduardo-neves-pedra-azul.jpg
-
BINapps/dashboard/img/previews/european-space-agency-barents-bloom.jpg
-
BINapps/dashboard/img/previews/hannes-fritz-flippity-floppity.jpg
-
BINapps/dashboard/img/previews/hannes-fritz-roulette.jpg
-
BINapps/dashboard/img/previews/hannes-fritz-sea-spray.jpg
-
BINapps/dashboard/img/previews/kamil-porembinski-clouds.jpg
-
BINapps/dashboard/img/previews/lali-masriera-yellow-bricks.jpg
-
BINapps/dashboard/img/previews/nasa-waxing-crescent-moon.jpg
-
BINapps/dashboard/img/previews/rawpixel-pink-tapioca-bubbles.jpg
-
BINapps/dashboard/img/previews/tommy-chau-already.jpg
-
BINapps/dashboard/img/previews/tommy-chau-lion-rock-hill.jpg
-
BINapps/dashboard/img/rawpixel-pink-tapioca-bubbles.jpg
-
BINapps/dashboard/img/tommy-chau-already.jpg
-
BINapps/dashboard/img/tommy-chau-lion-rock-hill.jpg
-
2apps/dashboard/js/dashboard.js
-
2apps/dashboard/js/dashboard.js.map
-
64apps/dashboard/lib/Controller/DashboardController.php
-
63apps/dashboard/lib/Controller/LayoutApiController.php
-
173apps/dashboard/lib/Service/BackgroundService.php
-
220apps/dashboard/src/App.vue
-
194apps/dashboard/src/components/BackgroundSettings.vue
-
36apps/dashboard/src/helpers/getBackgroundUrl.js
-
24apps/dashboard/src/helpers/prefixWithBaseUrl.js
@ -0,0 +1,71 @@ |
|||
// Show Dashboard background image beneath header |
|||
#body-user #header { |
|||
background-size: cover !important; |
|||
background-position: center 50% !important; |
|||
background-repeat: no-repeat !important; |
|||
background-attachment: fixed !important; |
|||
} |
|||
|
|||
#content { |
|||
padding-top: 0 !important; |
|||
} |
|||
|
|||
// Hide triangle indicators from navigation since they are out of place without the header bar |
|||
#appmenu li a.active::before, |
|||
#appmenu li:hover a::before, |
|||
#appmenu li:hover a.active::before, |
|||
#appmenu li a:focus::before { |
|||
display: none !important; |
|||
} |
|||
|
|||
$has-custom-logo: variable_exists('theming-logo-mime') and $theming-logo-mime != ''; |
|||
|
|||
body.dashboard-inverted:not(.dashboard-dark) { |
|||
// Do not invert the default logo |
|||
@if ($has-custom-logo == false) { |
|||
$image-logo: url(icon-color-path('logo', 'logo', #ffffff, 1, true)); |
|||
#header .logo { |
|||
background-image: $image-logo !important; |
|||
opacity: 1; |
|||
} |
|||
} |
|||
|
|||
#app-dashboard > h2 { |
|||
color: #fff; |
|||
} |
|||
#appmenu li span { |
|||
color: #fff; |
|||
} |
|||
#appmenu svg image { |
|||
filter: invert(0); |
|||
} |
|||
#appmenu .icon-more-white, |
|||
.header-right > div:not(#settings) > *:first-child { |
|||
filter: invert(1) hue-rotate(180deg); |
|||
} |
|||
} |
|||
|
|||
body.dashboard-dark:not(.dashboard-inverted) { |
|||
// invert the default logo |
|||
@if ($has-custom-logo == false) { |
|||
$image-logo: url(icon-color-path('logo', 'logo', #000000, 1, true)); |
|||
#header .logo { |
|||
background-image: $image-logo !important; |
|||
opacity: 1; |
|||
} |
|||
} |
|||
|
|||
#app-dashboard > h2 { |
|||
color: #000; |
|||
} |
|||
#appmenu li span { |
|||
color: #000; |
|||
} |
|||
#appmenu svg { |
|||
filter: invert(1) hue-rotate(180deg) !important; |
|||
} |
|||
#appmenu .icon-more-white, |
|||
.header-right > div:not(#settings) > *:first-child { |
|||
filter: invert(1) hue-rotate(180deg) !important; |
|||
} |
|||
} |
After Width: 3840 | Height: 2560 | Size: 1.0 MiB |
After Width: 3840 | Height: 2594 | Size: 1.1 MiB |
After Width: 3840 | Height: 2292 | Size: 249 KiB |
After Width: 3840 | Height: 2521 | Size: 1.6 MiB |
After Width: 3840 | Height: 2558 | Size: 1.7 MiB |
After Width: 3840 | Height: 3262 | Size: 523 KiB |
Before Width: 1536 | Height: 1024 | Size: 627 KiB |
Before Width: 1920 | Height: 1280 | Size: 1.1 MiB |
Before Width: 1542 | Height: 1024 | Size: 121 KiB |
Before Width: 1920 | Height: 1275 | Size: 165 KiB |
After Width: 3840 | Height: 2559 | Size: 1.1 MiB |
After Width: 3840 | Height: 2560 | Size: 1.0 MiB |
After Width: 3840 | Height: 2560 | Size: 1.2 MiB |
After Width: 3840 | Height: 2550 | Size: 186 KiB |
After Width: 3840 | Height: 2949 | Size: 934 KiB |
After Width: 3840 | Height: 2560 | Size: 279 KiB |
After Width: 352 | Height: 235 | Size: 21 KiB |
After Width: 352 | Height: 238 | Size: 28 KiB |
After Width: 352 | Height: 210 | Size: 6.5 KiB |
After Width: 352 | Height: 231 | Size: 18 KiB |
After Width: 352 | Height: 234 | Size: 15 KiB |
After Width: 352 | Height: 299 | Size: 15 KiB |
After Width: 352 | Height: 235 | Size: 23 KiB |
After Width: 352 | Height: 235 | Size: 21 KiB |
After Width: 352 | Height: 235 | Size: 14 KiB |
After Width: 352 | Height: 234 | Size: 6.4 KiB |
After Width: 352 | Height: 270 | Size: 18 KiB |
After Width: 352 | Height: 235 | Size: 4.4 KiB |
After Width: 352 | Height: 235 | Size: 13 KiB |
After Width: 352 | Height: 235 | Size: 18 KiB |
After Width: 352 | Height: 235 | Size: 6.3 KiB |
After Width: 3840 | Height: 2560 | Size: 454 KiB |
After Width: 3840 | Height: 2560 | Size: 1.2 MiB |
After Width: 3840 | Height: 2560 | Size: 239 KiB |
2
apps/dashboard/js/dashboard.js
File diff suppressed because it is too large
View File
2
apps/dashboard/js/dashboard.js.map
File diff suppressed because it is too large
View File
@ -0,0 +1,63 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net> |
|||
* |
|||
* @author Julius Härtl <jus@bitgrid.net> |
|||
* |
|||
* @license GNU AGPL version 3 or any later version |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
declare(strict_types=1); |
|||
|
|||
|
|||
namespace OCA\Dashboard\Controller; |
|||
|
|||
use OCP\AppFramework\Http\JSONResponse; |
|||
use OCP\AppFramework\OCSController; |
|||
use OCP\IConfig; |
|||
use OCP\IRequest; |
|||
|
|||
class LayoutApiController extends OCSController { |
|||
|
|||
/** @var IConfig */ |
|||
private $config; |
|||
/** @var string */ |
|||
private $userId; |
|||
|
|||
public function __construct( |
|||
string $appName, |
|||
IRequest $request, |
|||
IConfig $config, |
|||
$userId |
|||
) { |
|||
parent::__construct($appName, $request); |
|||
|
|||
$this->config = $config; |
|||
$this->userId = $userId; |
|||
} |
|||
|
|||
/** |
|||
* @NoAdminRequired |
|||
* |
|||
* @param string $layout |
|||
* @return JSONResponse |
|||
*/ |
|||
public function create(string $layout): JSONResponse { |
|||
$this->config->setUserValue($this->userId, 'dashboard', 'layout', $layout); |
|||
return new JSONResponse(['layout' => $layout]); |
|||
} |
|||
} |
@ -0,0 +1,173 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net> |
|||
* |
|||
* @author Julius Härtl <jus@bitgrid.net> |
|||
* |
|||
* @license GNU AGPL version 3 or any later version |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
* |
|||
*/ |
|||
|
|||
declare(strict_types=1); |
|||
|
|||
|
|||
namespace OCA\Dashboard\Service; |
|||
|
|||
use OCP\Files\IAppData; |
|||
use OCP\Files\IRootFolder; |
|||
use OCP\Files\NotFoundException; |
|||
use OCP\Files\SimpleFS\ISimpleFile; |
|||
use OCP\IConfig; |
|||
|
|||
class BackgroundService { |
|||
public const THEMING_MODE_DARK = 'dark'; |
|||
|
|||
public const SHIPPED_BACKGROUNDS = [ |
|||
'anatoly-mikhaltsov-butterfly-wing-scale.jpg' => [ |
|||
'attribution' => 'Butterfly wing scale (Anatoly Mikhaltsov, CC BY-SA)', |
|||
'attribution_url' => 'https://commons.wikimedia.org/wiki/File:%D0%A7%D0%B5%D1%88%D1%83%D0%B9%D0%BA%D0%B8_%D0%BA%D1%80%D1%8B%D0%BB%D0%B0_%D0%B1%D0%B0%D0%B1%D0%BE%D1%87%D0%BA%D0%B8.jpg', |
|||
], |
|||
'bernie-cetonia-aurata-take-off-composition.jpg' => [ |
|||
'attribution' => 'Cetonia aurata take off composition (Bernie, Public Domain)', |
|||
'attribution_url' => 'https://commons.wikimedia.org/wiki/File:Cetonia_aurata_take_off_composition_05172009.jpg', |
|||
'theming' => self::THEMING_MODE_DARK, |
|||
], |
|||
'dejan-krsmanovic-ribbed-red-metal.jpg' => [ |
|||
'attribution' => 'Ribbed red metal (Dejan Krsmanovic, CC BY)', |
|||
'attribution_url' => 'https://www.flickr.com/photos/dejankrsmanovic/42971456774/', |
|||
], |
|||
'eduardo-neves-pedra-azul.jpg' => [ |
|||
'attribution' => 'Pedra azul milky way (Eduardo Neves, CC BY-SA)', |
|||
'attribution_url' => 'https://commons.wikimedia.org/wiki/File:Pedra_Azul_Milky_Way.jpg', |
|||
], |
|||
'european-space-agency-barents-bloom.jpg' => [ |
|||
'attribution' => 'Barents bloom (European Space Agency, CC BY-SA)', |
|||
'attribution_url' => 'https://www.esa.int/ESA_Multimedia/Images/2016/08/Barents_bloom', |
|||
], |
|||
'hannes-fritz-flippity-floppity.jpg' => [ |
|||
'attribution' => 'Flippity floppity (Hannes Fritz, CC BY-SA)', |
|||
'attribution_url' => 'http://hannes.photos/flippity-floppity', |
|||
], |
|||
'hannes-fritz-roulette.jpg' => [ |
|||
'attribution' => 'Roulette (Hannes Fritz, CC BY-SA)', |
|||
'attribution_url' => 'http://hannes.photos/roulette', |
|||
], |
|||
'hannes-fritz-sea-spray.jpg' => [ |
|||
'attribution' => 'Sea spray (Hannes Fritz, CC BY-SA)', |
|||
'attribution_url' => 'http://hannes.photos/sea-spray', |
|||
], |
|||
'kamil-porembinski-clouds.jpg' => [ |
|||
'attribution' => 'Clouds (Kamil Porembiński, CC BY-SA)', |
|||
'attribution_url' => 'https://www.flickr.com/photos/paszczak000/8715851521/', |
|||
], |
|||
'bernard-spragg-new-zealand-fern.jpg' => [ |
|||
'attribution' => 'New zealand fern (Bernard Spragg, CC0)', |
|||
'attribution_url' => 'https://commons.wikimedia.org/wiki/File:NZ_Fern.(Blechnum_chambersii)_(11263534936).jpg', |
|||
], |
|||
'rawpixel-pink-tapioca-bubbles.jpg' => [ |
|||
'attribution' => 'Pink tapioca bubbles (Rawpixel, CC BY)', |
|||
'attribution_url' => 'https://www.flickr.com/photos/byrawpixel/27665140298/in/photostream/', |
|||
'theming' => self::THEMING_MODE_DARK, |
|||
], |
|||
'nasa-waxing-crescent-moon.jpg' => [ |
|||
'attribution' => 'Waxing crescent moon (NASA, Public Domain)', |
|||
'attribution_url' => 'https://www.nasa.gov/image-feature/a-waxing-crescent-moon', |
|||
], |
|||
'tommy-chau-already.jpg' => [ |
|||
'attribution' => 'Cityscape (Tommy Chau, CC BY)', |
|||
'attribution_url' => 'https://www.flickr.com/photos/90975693@N05/16910999368', |
|||
], |
|||
'tommy-chau-lion-rock-hill.jpg' => [ |
|||
'attribution' => 'Lion rock hill (Tommy Chau, CC BY)', |
|||
'attribution_url' => 'https://www.flickr.com/photos/90975693@N05/17136440246', |
|||
'theming' => self::THEMING_MODE_DARK, |
|||
], |
|||
'lali-masriera-yellow-bricks.jpg' => [ |
|||
'attribution' => 'Yellow bricks (Lali Masriera, CC BY)', |
|||
'attribution_url' => 'https://www.flickr.com/photos/visualpanic/3982464447', |
|||
'theming' => self::THEMING_MODE_DARK, |
|||
] |
|||
]; |
|||
/** |
|||
* @var \OCP\Files\Folder |
|||
*/ |
|||
private $userFolder; |
|||
/** |
|||
* @var \OCP\Files\SimpleFS\ISimpleFolder |
|||
*/ |
|||
private $dashboardUserFolder; |
|||
/** |
|||
* @var IConfig |
|||
*/ |
|||
private $config; |
|||
private $userId; |
|||
|
|||
public function __construct(IRootFolder $rootFolder, IAppData $appData, IConfig $config, $userId) { |
|||
if ($userId === null) { |
|||
return; |
|||
} |
|||
$this->userFolder = $rootFolder->getUserFolder($userId); |
|||
try { |
|||
$this->dashboardUserFolder = $appData->getFolder($userId); |
|||
} catch (NotFoundException $e) { |
|||
$this->dashboardUserFolder = $appData->newFolder($userId); |
|||
} |
|||
$this->config = $config; |
|||
$this->userId = $userId; |
|||
} |
|||
|
|||
public function setDefaultBackground(): void { |
|||
$this->config->deleteUserValue($this->userId, 'dashboard', 'background'); |
|||
} |
|||
|
|||
/** |
|||
* @param $path |
|||
* @throws NotFoundException |
|||
* @throws \OCP\Files\NotPermittedException |
|||
* @throws \OCP\PreConditionNotMetException |
|||
*/ |
|||
public function setFileBackground($path): void { |
|||
$this->config->setUserValue($this->userId, 'dashboard', 'background', 'custom'); |
|||
/** @var \OCP\Files\File $file */ |
|||
$file = $this->userFolder->get($path); |
|||
$this->dashboardUserFolder->newFile('background.jpg', $file->fopen('r')); |
|||
} |
|||
|
|||
public function setShippedBackground($fileName): void { |
|||
if (!array_key_exists($fileName, self::SHIPPED_BACKGROUNDS)) { |
|||
throw new \InvalidArgumentException('The given file name is invalid'); |
|||
} |
|||
$this->config->setUserValue($this->userId, 'dashboard', 'background', $fileName); |
|||
} |
|||
|
|||
public function setColorBackground(string $color): void { |
|||
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) { |
|||
throw new \InvalidArgumentException('The given color is invalid'); |
|||
} |
|||
$this->config->setUserValue($this->userId, 'dashboard', 'background', $color); |
|||
} |
|||
|
|||
public function getBackground(): ?ISimpleFile { |
|||
$background = $this->config->getUserValue($this->userId, 'dashboard', 'background', 'default'); |
|||
if ($background === 'custom') { |
|||
try { |
|||
return $this->dashboardUserFolder->getFile('background.jpg'); |
|||
} catch (NotFoundException $e) { |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
@ -0,0 +1,194 @@ |
|||
<!-- |
|||
- @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net> |
|||
- |
|||
- @author Julius Härtl <jus@bitgrid.net> |
|||
- |
|||
- @license GNU AGPL version 3 or any later version |
|||
- |
|||
- This program is free software: you can redistribute it and/or modify |
|||
- it under the terms of the GNU Affero General Public License as |
|||
- published by the Free Software Foundation, either version 3 of the |
|||
- License, or (at your option) any later version. |
|||
- |
|||
- This program is distributed in the hope that it will be useful, |
|||
- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
- GNU Affero General Public License for more details. |
|||
- |
|||
- You should have received a copy of the GNU Affero General Public License |
|||
- along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
- |
|||
--> |
|||
|
|||
<template> |
|||
<div class="background-selector"> |
|||
<a class="background filepicker" |
|||
:class="{ active: background === 'custom' }" |
|||
tabindex="0" |
|||
@click="pickFile" |
|||
@keyup.enter="pickFile" |
|||
@keyup.space="pickFile"> |
|||
{{ t('dashboard', 'Pick from files') }} |
|||
</a> |
|||
<a class="background default" |
|||
tabindex="0" |
|||
:class="{ 'icon-loading': loading === 'default', active: background === 'default' }" |
|||
@click="setDefault" |
|||
@keyup.enter="setDefault" |
|||
@keyup.space="setDefault"> |
|||
{{ t('dashboard', 'Default images') }} |
|||
</a> |
|||
<a class="background color" |
|||
:class="{ active: background === 'custom' }" |
|||
tabindex="0" |
|||
@click="pickColor" |
|||
@keyup.enter="pickColor" |
|||
@keyup.space="pickColor"> |
|||
{{ t('dashboard', 'Plain background') }} |
|||
</a> |
|||
<a v-for="shippedBackground in shippedBackgrounds" |
|||
:key="shippedBackground.name" |
|||
v-tooltip="shippedBackground.details.attribution" |
|||
:class="{ 'icon-loading': loading === shippedBackground.name, active: background === shippedBackground.name }" |
|||
tabindex="0" |
|||
class="background" |
|||
:style="{ 'background-image': 'url(' + shippedBackground.preview + ')' }" |
|||
@click="setShipped(shippedBackground.name)" |
|||
@keyup.enter="setShipped(shippedBackground.name)" |
|||
@keyup.space="setShipped(shippedBackground.name)" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import axios from '@nextcloud/axios' |
|||
import { generateUrl } from '@nextcloud/router' |
|||
import { loadState } from '@nextcloud/initial-state' |
|||
import getBackgroundUrl from './../helpers/getBackgroundUrl' |
|||
import prefixWithBaseUrl from './../helpers/prefixWithBaseUrl' |
|||
const shippedBackgroundList = loadState('dashboard', 'shippedBackgrounds') |
|||
|
|||
export default { |
|||
name: 'BackgroundSettings', |
|||
props: { |
|||
background: { |
|||
type: String, |
|||
default: 'default', |
|||
}, |
|||
}, |
|||
data() { |
|||
return { |
|||
backgroundImage: generateUrl('/apps/dashboard/background') + '?v=' + Date.now(), |
|||
loading: false, |
|||
} |
|||
}, |
|||
computed: { |
|||
shippedBackgrounds() { |
|||
return Object.keys(shippedBackgroundList).map((item) => { |
|||
return { |
|||
name: item, |
|||
url: prefixWithBaseUrl(item), |
|||
preview: prefixWithBaseUrl('previews/' + item), |
|||
details: shippedBackgroundList[item], |
|||
} |
|||
}) |
|||
}, |
|||
}, |
|||
methods: { |
|||
async update(data) { |
|||
const background = data.type === 'custom' || data.type === 'default' ? data.type : data.value |
|||
this.backgroundImage = getBackgroundUrl(background, data.version) |
|||
if (data.type === 'color') { |
|||
this.$emit('updateBackground', data) |
|||
this.loading = false |
|||
return |
|||
} |
|||
const image = new Image() |
|||
image.onload = () => { |
|||
this.$emit('updateBackground', data) |
|||
this.loading = false |
|||
} |
|||
image.src = this.backgroundImage |
|||
}, |
|||
async setDefault() { |
|||
this.loading = 'default' |
|||
const result = await axios.post(generateUrl('/apps/dashboard/background/default')) |
|||
this.update(result.data) |
|||
}, |
|||
async setShipped(shipped) { |
|||
this.loading = shipped |
|||
const result = await axios.post(generateUrl('/apps/dashboard/background/shipped'), { value: shipped }) |
|||
this.update(result.data) |
|||
}, |
|||
async setFile(path) { |
|||
this.loading = 'custom' |
|||
const result = await axios.post(generateUrl('/apps/dashboard/background/custom'), { value: path }) |
|||
this.update(result.data) |
|||
}, |
|||
async pickColor() { |
|||
this.loading = 'color' |
|||
const color = OCA && OCA.Theming ? OCA.Theming.color : '#0082c9' |
|||
const result = await axios.post(generateUrl('/apps/dashboard/background/color'), { value: color }) |
|||
this.update(result.data) |
|||
}, |
|||
pickFile() { |
|||
window.OC.dialogs.filepicker(t('dashboard', 'Insert from {productName}', { productName: OC.theme.name }), (path, type) => { |
|||
if (type === OC.dialogs.FILEPICKER_TYPE_CHOOSE) { |
|||
this.setFile(path) |
|||
} |
|||
}, false, ['image/png', 'image/gif', 'image/jpeg', 'image/svg'], true, OC.dialogs.FILEPICKER_TYPE_CHOOSE) |
|||
}, |
|||
}, |
|||
} |
|||
</script> |
|||
|
|||
<style scoped lang="scss"> |
|||
|
|||
.background-selector { |
|||
display: flex; |
|||
flex-wrap: wrap; |
|||
justify-content: center; |
|||
|
|||
.background { |
|||
width: 176px; |
|||
height: 96px; |
|||
margin: 8px; |
|||
background-size: cover; |
|||
background-position: center center; |
|||
text-align: center; |
|||
border-radius: var(--border-radius-large); |
|||
border: 2px solid var(--color-main-background); |
|||
overflow: hidden; |
|||
|
|||
&.current { |
|||
background-image: var(--color-background-dark); |
|||
} |
|||
|
|||
&.filepicker, &.default, &.color { |
|||
border-color: var(--color-border); |
|||
line-height: 96px; |
|||
} |
|||
|
|||
&.color { |
|||
background-color: var(--color-primary); |
|||
color: var(--color-primary-text); |
|||
} |
|||
|
|||
&.active, |
|||
&:hover, |
|||
&:focus { |
|||
border: 2px solid var(--color-primary); |
|||
} |
|||
|
|||
&.active:not(.icon-loading):after { |
|||
background-image: var(--icon-checkmark-fff); |
|||
background-repeat: no-repeat; |
|||
background-position: center; |
|||
background-size: 44px; |
|||
content: ''; |
|||
display: block; |
|||
height: 100%; |
|||
} |
|||
} |
|||
} |
|||
|
|||
</style> |
@ -0,0 +1,36 @@ |
|||
/* |
|||
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net> |
|||
* |
|||
* @author Julius Härtl <jus@bitgrid.net> |
|||
* |
|||
* @license GNU AGPL version 3 or any later version |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
|
|||
import { generateUrl } from '@nextcloud/router' |
|||
import prefixWithBaseUrl from './prefixWithBaseUrl' |
|||
|
|||
export default (background, time = 0) => { |
|||
if (background === 'default') { |
|||
if (window.OCA.Accessibility.theme === 'dark') { |
|||
return prefixWithBaseUrl('eduardo-neves-pedra-azul.jpg') |
|||
} |
|||
return prefixWithBaseUrl('kamil-porembinski-clouds.jpg') |
|||
} else if (background === 'custom') { |
|||
return generateUrl('/apps/dashboard/background') + '?v=' + time |
|||
} |
|||
return prefixWithBaseUrl(background) |
|||
} |
@ -0,0 +1,24 @@ |
|||
/* |
|||
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net> |
|||
* |
|||
* @author Julius Härtl <jus@bitgrid.net> |
|||
* |
|||
* @license GNU AGPL version 3 or any later version |
|||
* |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU Affero General Public License as |
|||
* published by the Free Software Foundation, either version 3 of the |
|||
* License, or (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Affero General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Affero General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* |
|||
*/ |
|||
import { generateFilePath } from '@nextcloud/router' |
|||
|
|||
export default (url) => generateFilePath('dashboard', '', 'img/') + url |