Skip to content

Commit

Permalink
allow background changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Weber committed Dec 3, 2018
1 parent 80f430b commit a1118ef
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
44 changes: 23 additions & 21 deletions api/login/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
if ( $session->isAuthenticated() && $session->isTimeout() ) {
session_destroy();
session_start();
//$session = &\OMV\Session::getInstance();
}

$params = array(
Expand All @@ -55,7 +54,9 @@

//construction de la config
$str = buildConfig($context,$session);
file_put_contents('/etc/webdesk/webdesk_config.js',$str);
$js = 'WEBDESK_CONFIG = '.json_encode($str, JSON_PRETTY_PRINT );

file_put_contents('/etc/webdesk/webdesk_config.js',$js);

}
echo json_encode($object);
Expand All @@ -69,25 +70,27 @@
*/

function buildConfig($context,$session) {
return 'WEBDESK_CONFIG = {
"iconWidth": 100,
"username": "'.$session->getUsername().'",
"navbar" : '.buildNavBar($context,$session).',
"dock" : '.buildDock($context,$session).'
}';
$CONF = require('./config.php');
$CONF["iconWidth"] = 100;
$CONF["username"] = $session->getUsername();
$CONF["navbar"] = buildNavBar($context,$session);
$CONF["dock"] = buildDock($context,$session);

return $CONF;
};

function buildNavBar($context,$session) {
return '[
{
"label": "'.$session->getUsername().'",
"submenu":[{
"label": "Disconnect",
"link":"/login/logout.php"
}]
},
]';
return [
[
"label" => $session->getUsername(),
"submenu" => [
[
"label" => "Disconnect",
"link" => "/login/logout.php"
]
]
]
];

/*{
"label": "File",
Expand Down Expand Up @@ -130,7 +133,7 @@ function buildDock($context,$session) {
$prep[] = $link;
}

return json_encode([
return [
"default" => [
[
"uuid" => "about",
Expand All @@ -149,6 +152,5 @@ function buildDock($context,$session) {
]
],
$session->getUsername() => $prep
], JSON_PRETTY_PRINT );
];
};

24 changes: 16 additions & 8 deletions api/login/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,18 @@ function login(){
document.location = "/";
}
else{
input_user.classList.remove("hide");
input_pass.classList.remove("hide");
loader.classList.remove("visible");
shake();
handleError()
}
});
}
},
handleError);
}

function handleError(){
input_user.classList.remove("hide");
input_pass.classList.remove("hide");
loader.classList.remove("visible");
shake();
}

function shake(){
login_box.classList.add("init-shake");
Expand All @@ -237,7 +242,7 @@ function shake(){
}, 1000);
}

function post(url,obj,callback){
function post(url,obj,callback,error){
var http = new XMLHttpRequest();
var str = "";
for (var key in obj) {
Expand All @@ -254,7 +259,10 @@ function post(url,obj,callback){
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
callback(http.responseText);
}
}
else{
error(http);
}
}
http.send(str);
}
Expand Down
6 changes: 6 additions & 0 deletions openmediavault-webdesk/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
openmediavault-webdesk (0.4.0) UNRELEASED; urgency=low

* Allow background change

-- Antoine Weber <[email protected]> TODO

openmediavault-webdesk (0.3.0) UNRELEASED; urgency=low

* Fix folder permission, to write configuration file
Expand Down
4 changes: 4 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@
<body>
<app-root>Loading...</app-root>
</body>
<script>
if(typeof WEBDESK_CONFIG !== "undefined" && typeof WEBDESK_CONFIG["desktop_background"] !== "undefined"){
document.body.style.background = "url("+WEBDESK_CONFIG["desktop_background"]+") no-repeat center center fixed";
}</script>
</html>

0 comments on commit a1118ef

Please sign in to comment.