diff --git a/api.php b/api.php index ad075d3..17cf94b 100644 --- a/api.php +++ b/api.php @@ -30,7 +30,7 @@ } } - if($currentContainer == NULL) + if(@$currentContainer == NULL) die("access denied!"); if(isset($_REQUEST['METODE'])) @@ -64,7 +64,7 @@ if(strtoupper($_REQUEST['METODE']) == "STATE") { - echo $container['Status']; + echo $currentContainer['Status']; } if(strtoupper($_REQUEST['METODE']) == "LOG") @@ -73,6 +73,12 @@ echo clean($logOutput); } + if(strtoupper($_REQUEST['METODE']) == "HTMLLOG") + { + $logOutput = $dockerClient->getContainerLogs($currentContainer['Id']); + echo html_entity_decode(clean($logOutput))."\n"; + } + if(strtoupper($_REQUEST['METODE']) == "COMMAND") { if(isset($_REQUEST['COMMAND'])) diff --git a/pages/dashboard.php b/pages/dashboard.php index 1202b2b..b925ee5 100644 --- a/pages/dashboard.php +++ b/pages/dashboard.php @@ -27,6 +27,7 @@ if(isset($_SESSION['LOGIN'])) $HTML->ReplaceLayoutInhalt("%%ContainerName%%", trim(ltrim($currentContainer['Names']['0'], '/'))); $HTML->ReplaceLayoutInhalt("%%ContainerLogOutput%%", html_entity_decode(clean($logOutput))); $HTML->ReplaceLayoutInhalt("%%STATUS%%", html_entity_decode($currentContainer['Status'])); + $HTML->ReplaceLayoutInhalt("%%APIKey%%", trim($currentContainer['Labels']['remotepass'])); $HTML->build(); echo $HTML->ausgabe(); diff --git a/style/default/dashboard.html b/style/default/dashboard.html index 147d1f7..bfa9928 100644 --- a/style/default/dashboard.html +++ b/style/default/dashboard.html @@ -13,16 +13,13 @@ - - - - + @@ -46,26 +43,28 @@

Container Manager

-

%%ContainerName%%

-

Status: %%STATUS%%

+

%%ContainerName%%

+

Status: %%STATUS%%

- + -
Logout
- - + // Update every 3 second + var timer = setInterval(function() { + let logrequest = new XMLHttpRequest(); + logrequest.responseType = 'text'; + logrequest.open('GET', "/api.php?METODE=HTMLLOG&CONTAINER=%%ContainerName%%&KEY=%%APIKey%%"); + + let statusrequest = new XMLHttpRequest(); + statusrequest.responseType = 'text'; + statusrequest.open('GET', "/api.php?METODE=STATE&CONTAINER=%%ContainerName%%&KEY=%%APIKey%%"); + + logrequest.onload = function() { + var messageBodyPreCheck = document.querySelector('#consoleview'); + var reload = messageBodyPreCheck.scrollTop == (messageBodyPreCheck.scrollHeight - messageBodyPreCheck.clientHeight); + + if (reload == true) + { + document.getElementById("consoleview").innerHTML = logrequest.response; + + var messageBody = document.querySelector('#consoleview'); + messageBody.scrollTop = messageBody.scrollHeight - messageBody.clientHeight; + } + }; + + statusrequest.onload = function() { + document.getElementById("servicestatus").innerHTML = "Status: " + statusrequest.response; + }; + + logrequest.send(); + statusrequest.send(); + }, 3000); + - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file