Skip to content

Commit cd27aa7

Browse files
committed
Gestion du background
1 parent 9ddf1a4 commit cd27aa7

18 files changed

+134
-23
lines changed
32 KB
Loading

assets/data/backgrounds/home1.jpg

582 KB
Loading
75.6 KB
Loading

assets/data/backgrounds/wall.jpg

1.48 MB
Loading

dash/css/app.d43809be.css dash/css/app.0ade64ad.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/dash/favicon.ico><title>dash</title><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css><link href=/dash/css/app.d43809be.css rel=preload as=style><link href=/dash/css/chunk-vendors.604e650f.css rel=preload as=style><link href=/dash/js/app.d33ea983.js rel=preload as=script><link href=/dash/js/chunk-vendors.6963660c.js rel=preload as=script><link href=/dash/css/chunk-vendors.604e650f.css rel=stylesheet><link href=/dash/css/app.d43809be.css rel=stylesheet></head><body><noscript><strong>We're sorry but dash doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/dash/js/chunk-vendors.6963660c.js></script><script src=/dash/js/app.d33ea983.js></script></body></html>
1+
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/dash/favicon.ico><title>dash</title><link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"><link rel=stylesheet href=https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css><link href=/dash/css/app.0ade64ad.css rel=preload as=style><link href=/dash/css/chunk-vendors.604e650f.css rel=preload as=style><link href=/dash/js/app.1ecb4b3e.js rel=preload as=script><link href=/dash/js/chunk-vendors.6963660c.js rel=preload as=script><link href=/dash/css/chunk-vendors.604e650f.css rel=stylesheet><link href=/dash/css/app.0ade64ad.css rel=stylesheet></head><body><noscript><strong>We're sorry but dash doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/dash/js/chunk-vendors.6963660c.js></script><script src=/dash/js/app.1ecb4b3e.js></script></body></html>

dash/js/app.1ecb4b3e.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash/js/app.1ecb4b3e.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash/js/app.d33ea983.js

-2
This file was deleted.

dash/js/app.d33ea983.js.map

-1
This file was deleted.

src/Rest/DashRest.php

+32
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,36 @@ public static function pictures($path = '')
115115
$path = Utils::sanitizeString($path);
116116
return FileSystemHelper::ls(NEXTDOM_DATA . '/data/pictures/' . $path, '*.png', true);
117117
}
118+
119+
/**
120+
* @param string $path
121+
* @return array
122+
*/
123+
public static function backgrounds($path = '')
124+
{
125+
$path = Utils::sanitizeString($path);
126+
$backgroundsList = FileSystemHelper::ls(NEXTDOM_DATA . '/data/backgrounds/' . $path, '*.jpg', true);
127+
$result = [];
128+
foreach ($backgroundsList as $backgroundFile) {
129+
$thumbPos = strpos($backgroundFile, '-thumb');
130+
$fileInfo = pathinfo($backgroundFile);
131+
$code = $fileInfo['filename'];
132+
if ($thumbPos === false) {
133+
if (!isset($result[$code])) {
134+
$result[$code] = ['thumb' => false];
135+
}
136+
}
137+
else {
138+
$code = substr($backgroundFile, 0, $thumbPos);
139+
if (!isset($result[$code])) {
140+
$result[$code] = ['thumb' => true];
141+
}
142+
else {
143+
$result[$code]['thumb'] = true;
144+
}
145+
}
146+
$result[$code]['ext'] = $fileInfo['extension'];
147+
}
148+
return $result;
149+
}
118150
}

src/Rest/rest.yml

+4
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,7 @@ dash_pictures:
150150
methods: GET
151151
requirements:
152152
path: "[a-zA-Z0-9\\-_]*"
153+
dash_backgrounds:
154+
path: '/dash/backgrounds'
155+
controller: NextDom\Rest\DashRest::backgrounds
156+
methods: GET

src/dash/src/components/Dash.vue

+25-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Composant global du Dash
33
-->
44
<template>
5-
<div id="global-container" v-bind:style="dashSize">
5+
<div id="global-container" v-bind:style="dashStyle">
66
<ConnectDialog v-on:connected="start" />
77
<DashPreferences v-model="dashData" v-on:startWizard="startWizard" />
88
<ManualDash v-if="dashData !== undefined && dashData.positioning === 'manual'" />
@@ -50,6 +50,7 @@ export default {
5050
title: "Dash",
5151
width: 640,
5252
height: 480,
53+
background: "no",
5354
grid: {
5455
id: "0",
5556
children: [],
@@ -77,24 +78,31 @@ export default {
7778
/**
7879
* Taille de l'écran
7980
*/
80-
dashSize() {
81+
dashStyle() {
82+
let result = {};
8183
if (!this.initialized) {
82-
return {
84+
result = {
8385
width: 0,
8486
height: 0
8587
};
86-
}
87-
if (this.dashData.size === "fix") {
88-
return {
89-
width: this.dashData.width + "px",
90-
height: this.dashData.height + "px"
91-
};
9288
} else {
93-
return {
94-
width: "100%",
95-
height: "100%"
96-
};
89+
if (this.dashData.size === "fix") {
90+
result = {
91+
width: this.dashData.width + "px",
92+
height: this.dashData.height + "px"
93+
};
94+
} else {
95+
result = {
96+
width: "100%",
97+
height: "100%"
98+
};
99+
}
100+
}
101+
if (this.dashData.background !== "no") {
102+
result["backgroundImage"] =
103+
"url('/data/backgrounds/" + this.dashData.background + "')";
97104
}
105+
return result;
98106
}
99107
},
100108
methods: {
@@ -143,6 +151,7 @@ export default {
143151
if (!this.initialized) {
144152
this.dashData = {
145153
id: -1,
154+
background: "no",
146155
name: "Dash",
147156
width: 640,
148157
height: 480,
@@ -172,10 +181,12 @@ export default {
172181
};
173182
</script>
174183

175-
<style scoped>
184+
<style>
176185
#global-container {
177186
padding: 0 !important;
178187
position: absolute;
188+
background-size: cover;
189+
background-position: center;
179190
top: 0;
180191
left: 0;
181192
width: 100%;

src/dash/src/components/DashEditor.vue

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div>
33
<h1>Editeur avancé</h1>
4+
<v-btn v-bind:to="{name: 'dash', params: {dashId: dashId}}">Retour au Dash</v-btn>
45
<ConnectDialog v-on:connected="start" />
56
<vue-json-editor
67
v-bind:lang="language"
@@ -86,6 +87,7 @@ export default {
8687
},
8788
widgetsSave() {
8889
this.savedWidgetsData = JSON.parse(JSON.stringify(this.widgetsData));
90+
this.save();
8991
},
9092
save() {
9193
Communication.postWithOptions("/api/dash/save", {

src/dash/src/components/DashPreferences.vue

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Fenêtre de configuration du dash
2020
<v-text-field v-model="formData.height" label="Hauteur" />
2121
</v-col>
2222
</v-row>
23+
<v-row>
24+
<BackgroundStyle v-model="formData.background" />
25+
</v-row>
2326
<v-row>
2427
<v-col cols="4" left>
2528
<v-btn href="/dash/index.html" color="success" dark>
@@ -45,9 +48,13 @@ Fenêtre de configuration du dash
4548

4649
<script>
4750
import Communication from "@/libs/Communication";
51+
import BackgroundStyle from "@/components/Wizards/Helpers/BackgroundStyle";
4852

4953
export default {
5054
name: "DashPreferences",
55+
components: {
56+
BackgroundStyle
57+
},
5158
props: {
5259
value: {
5360
type: Object,

src/dash/src/components/Wizards/AddDashWizard.vue

+7-2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Assistant de création d'un nouveau dash
7070
<v-card-title>Personnalisation</v-card-title>
7171
<v-card-text>
7272
<v-text-field v-model="title" label="Nom" />
73+
<BackgroundStyle v-model="background" />
7374
</v-card-text>
7475
</v-card>
7576
<StepperButtons v-model="step" last v-on:next="endOfWizard" />
@@ -81,11 +82,13 @@ Assistant de création d'un nouveau dash
8182

8283
<script>
8384
import StepperButtons from "@/components/Wizards/Helpers/StepperButtons";
85+
import BackgroundStyle from "@/components/Wizards/Helpers/BackgroundStyle";
8486

8587
export default {
8688
name: "AddDashWizard",
8789
components: {
88-
StepperButtons
90+
StepperButtons,
91+
BackgroundStyle
8992
},
9093
props: {
9194
showWizard: null
@@ -96,7 +99,8 @@ export default {
9699
positioning: "manual",
97100
size: "fix",
98101
width: 1280,
99-
height: 720
102+
height: 720,
103+
background: "no"
100104
}),
101105
watch: {
102106
step: function(newStep) {
@@ -115,6 +119,7 @@ export default {
115119
size: this.size,
116120
width: this.width,
117121
height: this.height,
122+
background: this.background,
118123
grid: {
119124
id: "0",
120125
children: [],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<template>
2+
<v-radio-group v-model="background" row>
3+
<v-radio value="no" label="Aucun" />
4+
<v-radio
5+
v-for="(backgroundData, backgroundName, index) in backgroundsList"
6+
v-bind:key="`background-${index}`"
7+
v-bind:value="`${backgroundName}.${backgroundData['ext']}`"
8+
>
9+
<template v-slot:label>
10+
<img v-if="backgroundData.thumb" v-bind:src="basePath + backgroundName + '-thumb.' + backgroundData.ext" />
11+
<img v-else v-bind:src="basePath + backgroundName + '.' + backgroundData.ext" />
12+
</template>
13+
</v-radio>
14+
</v-radio-group>
15+
</template>
16+
17+
<script>
18+
import Communication from "@/libs/Communication";
19+
20+
export default {
21+
name: "BackgroundStyle",
22+
props: {
23+
value: {
24+
type: String,
25+
default: "no"
26+
}
27+
},
28+
data: () => ({
29+
basePath: "/data/backgrounds/",
30+
backgroundsList: []
31+
}),
32+
mounted() {
33+
Communication.get("/api/dash/backgrounds", files => {
34+
console.log(this.value);
35+
this.backgroundsList = files;
36+
console.log(this.value);
37+
});
38+
},
39+
computed: {
40+
background: {
41+
get() {
42+
return this.value;
43+
},
44+
set(newValue) {
45+
this.$emit("input", newValue);
46+
}
47+
}
48+
}
49+
};
50+
</script>

src/dash/src/components/Wizards/Helpers/LevelImgStyle.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<v-radio-group v-model="picture" row>
33
<v-radio v-for="(pictureData, index) in picturesList" v-bind:key="`pictures-${index}`" v-bind:value="index">
44
<template v-slot:label>
5-
<img v-bind:src="'/data/pictures/level/' + pictureData.name + '-0.png'" />/
6-
<img v-bind:src="'/data/pictures/level/' + pictureData.name + '-100.png'" />/
5+
<img v-bind:src="basePath + pictureData.name + '-0.png'" />/
6+
<img v-bind:src="basePath + pictureData.name + '-100.png'" />
77
</template>
88
</v-radio>
99
</v-radio-group>

0 commit comments

Comments
 (0)