Skip to content

Commit d3a7b5a

Browse files
committed
added device local site settings (beta);
1 parent adaed34 commit d3a7b5a

File tree

5 files changed

+177
-1
lines changed

5 files changed

+177
-1
lines changed

www/device-site.html

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<div id='sepiaFW-frame-carousel' class="sepiaFW-inner-container sepiaFW-carousel">
2+
<div class='sepiaFW-carousel-pane-container'>
3+
<!-- Page 1 -->
4+
<div id="sepiaFW-frame-page-1" class='sepiaFW-frames-page sepiaFW-carousel-pane'>
5+
<h3>Device Local Site</h3>
6+
<p>Here you can configure the local site (location) data for this device.</p>
7+
<div id="sepiaFW-device-site-settings" class="group-container">
8+
<div class="group">
9+
<label>Location:</label>
10+
<div id="sepiaFW-device-site-location-box" data-device-site="location"></div>
11+
</div>
12+
<div class="group">
13+
<label>Type:</label>
14+
<div id="sepiaFW-device-site-type-box" data-device-site="type"></div>
15+
</div>
16+
<div class="group">
17+
<label>Name:</label>
18+
<div id="sepiaFW-device-site-name-box" data-device-site="name"></div>
19+
</div>
20+
<div class="group">
21+
<label>Index:</label>
22+
<div id="sepiaFW-device-site-index-box" data-device-site="index"></div>
23+
</div>
24+
<div class="group">
25+
<label>Updates:</label>
26+
<div id="sepiaFW-device-site-updates-box" data-device-site="updates"></div>
27+
</div>
28+
<div class="group" style="justify-content: center;">
29+
<button id="SepiaFW-device-site-store" onclick="SepiaFW.frames.currentScope.store()">Store settings</button>
30+
</div>
31+
</div>
32+
</div>
33+
</div>
34+
</div>
35+
<div id="sepiaFW-frames-nav-bar" class='sepiaFW-layer-header'>
36+
<button id="sepiaFW-frames-close" class='entry'>
37+
<i class="material-icons md-btn2">&#xE5CD;</i>
38+
</button>
39+
<!--<button id="sepiaFW-frames-show-prev-page" class='entry'>
40+
<i class="material-icons md-btn2">keyboard_arrow_left</i><span data-localize="back">back</span>
41+
</button>
42+
<button id="sepiaFW-frames-show-next-page" class='entry'>
43+
<span data-localize="next">next</span><i class="material-icons md-btn2">keyboard_arrow_right</i>
44+
</button>-->
45+
<div id="sepiaFW-frames-nav-bar-page-indicator"><div>&nbsp;</div></div>
46+
</div>
47+
<script>
48+
$('#sepiaFW-frame-carousel').find('[data-localize]').each(function(){
49+
$(this).html(SepiaFW.local.g(this.dataset.localize));
50+
});
51+
52+
//Data
53+
SepiaFW.config.deviceLocalSiteOptions = {
54+
location: [
55+
{ "value": "", "name": "Not assigned" },
56+
{ "value": "home", "name": "Home" },
57+
{ "value": "mobile", "name": "Mobile" }
58+
],
59+
type: [
60+
{ "value": "", "name": "Not assigned" },
61+
{ "value": "room", "name": "Room" }
62+
],
63+
name: [
64+
{ "value": "unassigned", "name": "Not assigned" },
65+
{ "value": "livingroom", "name": "Living room" },
66+
{ "value": "diningroom", "name": "Dining room" },
67+
{ "value": "kitchen", "name": "Kitchen" },
68+
{ "value": "bedroom", "name": "Bedroom" },
69+
{ "value": "bath", "name": "Bath" },
70+
{ "value": "study", "name": "Study room" },
71+
{ "value": "office", "name": "Office" },
72+
{ "value": "childsroom", "name": "Child's room" },
73+
{ "value": "garage", "name": "Garage" },
74+
{ "value": "basement", "name": "Basement" },
75+
{ "value": "garden", "name": "Garden" },
76+
{ "value": "shack", "name": "Shack" },
77+
{ "value": "hallway", "name": "Hallway" },
78+
{ "value": "other", "name": "Other" }
79+
],
80+
//index: undefined, //free input, e.g. numbers: 1, 2, 212, ...
81+
updates: [
82+
{ "value": "off", "name": "Off" }
83+
//, { "value": "auto", "name": "Automatic" }
84+
]
85+
};
86+
//TODO: we should load this data from server
87+
88+
//Define scope
89+
SepiaFW.frames.currentScope = {
90+
91+
onFinishSetup: function(){
92+
$('#sepiaFW-device-site-settings').find('[data-device-site]').each(function(){
93+
var tag = this.dataset.deviceSite;
94+
var options = SepiaFW.config.deviceLocalSiteOptions[tag];
95+
var eleId = "sepiaFW-device-site-settings-" + tag;
96+
if (options){
97+
this.appendChild(SepiaFW.ui.build.optionSelector(eleId, options, options[0], function(ele){})); //console.log(ele.value);
98+
}else{
99+
this.innerHTML = "<input id='" + eleId + "' style='max-width: 100px;' placeholder='" + tag + "'>";
100+
}
101+
});
102+
},
103+
104+
onOpen: function(){
105+
var siteData = SepiaFW.config.getDeviceLocalSiteData();
106+
$('#sepiaFW-device-site-settings-location').val(siteData.location);
107+
$('#sepiaFW-device-site-settings-type').val(siteData.type);
108+
$('#sepiaFW-device-site-settings-name').val(siteData.name);
109+
$('#sepiaFW-device-site-settings-index').val(siteData.index);
110+
$('#sepiaFW-device-site-settings-updates').val(siteData.updates);
111+
},
112+
113+
store: function(){
114+
var siteData = {
115+
location: $('#sepiaFW-device-site-settings-location').val(),
116+
type: $('#sepiaFW-device-site-settings-type').val(),
117+
name: $('#sepiaFW-device-site-settings-name').val(),
118+
index: $('#sepiaFW-device-site-settings-index').val() || "",
119+
updates: $('#sepiaFW-device-site-settings-updates').val()
120+
};
121+
//console.log(siteData);
122+
SepiaFW.config.setDeviceLocalSiteData(siteData);
123+
SepiaFW.ui.showPopup(SepiaFW.local.g("done"));
124+
}
125+
}
126+
</script>

www/scripts/sepiaFW.app.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@ function sepiaFW_build_config(){
144144

145145
//------------ PLATFORM & APP CONNECTORS -------------
146146

147+
var deviceLocalSiteData = {
148+
location: "", //e.g.: "home", "mobile", empty
149+
type: "", //e.g.: "room" (location=home), empty
150+
name: "unassigned", //e.g.: "office" (type=room), "unassigned"
151+
index: "", //e.g.: 1, 2, 212, ...
152+
updates: "off" //e.g.: "off", "auto" (not supported yet)
153+
};
154+
Config.setDeviceLocalSiteData = function(data){
155+
if (data.location != undefined) deviceLocalSiteData.location = data.location;
156+
if (data.type != undefined) deviceLocalSiteData.type = data.type;
157+
if (data.name != undefined) deviceLocalSiteData.name = data.name;
158+
if (data.index != undefined) deviceLocalSiteData.index = data.index;
159+
if (data.updates != undefined) deviceLocalSiteData.updates = data.updates;
160+
SepiaFW.data.setPermanent('deviceLocalSiteData', deviceLocalSiteData);
161+
}
162+
Config.getDeviceLocalSiteData = function(){
163+
return deviceLocalSiteData;
164+
}
165+
//SEE: Config.deviceLocalSiteOptions in frames file - TODO: we should load this data from server
166+
147167
//Collection of universally supported apps and their names
148168
Config.musicApps = {
149169
"youtube": {name: "YouTube"},
@@ -240,6 +260,12 @@ function sepiaFW_build_config(){
240260
SepiaFW.clexi.initialize();
241261
}
242262

263+
//Device local site configuration
264+
var dlsData = SepiaFW.data.getPermanent('deviceLocalSiteData');
265+
if (dlsData){
266+
Config.setDeviceLocalSiteData(dlsData);
267+
}
268+
243269
//Default music app
244270
var defaultMusicAppStored = SepiaFW.data.get('defaultMusicApp');
245271
if (defaultMusicAppStored){

www/scripts/sepiaFW.assistant.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ function sepiaFW_build_assistant(){
126126
defaultMusicApp: SepiaFW.config.getDefaultMusicApp(),
127127
recentPAE: ((SepiaFW.events)? SepiaFW.events.getRecentProActiveEventsReduced() : ""),
128128
embeddedPlayers: SepiaFW.ui.cards.getSupportedWebPlayers(),
129-
prefTempUnit: (SepiaFW.account.getUserPreferredTemperatureUnit() || "C")
129+
prefTempUnit: (SepiaFW.account.getUserPreferredTemperatureUnit() || "C"),
130+
deviceLocalSite: SepiaFW.config.getDeviceLocalSiteData()
130131
};
131132
State.custom_data = JSON.stringify(cd);
132133

www/scripts/sepiaFW.local.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ function sepiaFW_build_strings(){
5555
StringsDE.userNotFound = 'Uups, dieser User scheint gerade nicht hier zu sein :-(';
5656
StringsDE.loading = 'Lädt';
5757
StringsDE.oneMoment = 'Einen Moment bitte ...';
58+
StringsDE.done = 'Erledigt';
5859
StringsDE.doit = 'Tu es!';
5960
StringsDE.looksGood = 'Sieht gut aus';
6061
StringsDE.betterNot = 'Besser nicht';
@@ -75,6 +76,7 @@ function sepiaFW_build_strings(){
7576
StringsDE.continueOffline = 'Offline weitermachen';
7677
StringsDE.locateMe = 'Standort bestimmen';
7778
StringsDE.deviceId = 'Geräte ID';
79+
StringsDE.deviceSite = 'Gerätestandort';
7880
StringsDE.allowedToExecuteThisCommand = 'Darf ich diesen Befehl ausführen: ';
7981
StringsDE.copyList = 'Diese Liste gehört einem anderen User, möchtest du sie in deinen Account kopieren?';
8082
StringsDE.cantCopyList = 'Diese Liste gehört einem anderen User und kann nicht gespeichert werden, aber du kannst eventuell einzelne Einträge via share-Funktion kopieren.';
@@ -204,6 +206,7 @@ function sepiaFW_build_strings(){
204206
StringsEN.userNotFound = 'Uups, this user seems to be not available right now :-(';
205207
StringsEN.loading = 'Loading';
206208
StringsEN.oneMoment = 'One moment please ...';
209+
StringsEN.done = 'Done';
207210
StringsEN.doit = 'Do it!';
208211
StringsEN.looksGood = 'Looks good';
209212
StringsEN.betterNot = 'Better not';
@@ -224,6 +227,7 @@ function sepiaFW_build_strings(){
224227
StringsEN.continueOffline = 'Continue offline';
225228
StringsEN.locateMe = 'Refresh my location';
226229
StringsEN.deviceId = 'Device ID';
230+
StringsEN.deviceSite = 'Device site';
227231
StringsEN.allowedToExecuteThisCommand = 'Am I allowed to send this request: ';
228232
StringsEN.copyList = 'This list belongs to another user, do you want to copy it to your account?';
229233
StringsEN.cantCopyList = 'This list belongs to another user and cannot be stored, but you might be able to copy single items with the share function.';

www/scripts/sepiaFW.ui.build.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ function sepiaFW_build_ui_build(){
545545
+ "<input id='sepiaFW-menu-assistant-host' type='url' placeholder='my.example.org/sepia' spellcheck='false'>"
546546
+ "</li>"
547547
+ "<li id='sepiaFW-menu-deviceId-li'><span>" + SepiaFW.local.g('deviceId') + ": </span><input id='sepiaFW-menu-deviceId' type='text' maxlength='24'></li>"
548+
+ "<li id='sepiaFW-menu-device-site-li' title='Settings for device local site'><span>" + SepiaFW.local.g('deviceSite') + ": </span></li>"
548549
+ "<li id='sepiaFW-menu-toggle-GPS-li'><span>GPS: </span></li>"
549550
+ "<li id='sepiaFW-menu-toggle-voice-li'><span>Voice output: </span></li>"
550551
+ "<li id='sepiaFW-menu-select-voice-li'><span>Voice: </span></li>" //option: <i class='material-icons md-mnu'>&#xE5C6;</i>
@@ -760,6 +761,24 @@ function sepiaFW_build_ui_build(){
760761
SepiaFW.config.setDeviceId(newDeviceId);
761762
this.blur();
762763
});
764+
//device site settings
765+
var deviceSite = document.getElementById('sepiaFW-menu-device-site-li');
766+
//settings
767+
deviceSite.appendChild(Build.inlineActionButton('sepiaFW-menu-device-site-settings', "<i class='material-icons md-inherit'>settings</i>",
768+
function(btn){
769+
SepiaFW.frames.open({
770+
pageUrl: "device-site.html",
771+
onFinishSetup: function(){
772+
SepiaFW.frames.currentScope.onFinishSetup();
773+
},
774+
onOpen: function(){
775+
SepiaFW.frames.currentScope.onOpen();
776+
},
777+
/*onClose: onSettingsClose,*/
778+
theme: "dark"
779+
});
780+
})
781+
);
763782
//Speech stuff
764783
if (SepiaFW.speech){
765784
//add voice toggle

0 commit comments

Comments
 (0)