mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-24 08:30:26 +00:00
Add restAPI doc link when svc is active
This commit is contained in:
parent
1e840abbaf
commit
f81c68de26
2 changed files with 24 additions and 2 deletions
|
@ -49,11 +49,18 @@ function DisplayRestAPI()
|
|||
array_shift($output);
|
||||
$serviceLog = implode("\n", $output);
|
||||
|
||||
if ($serviceStatus == "up") {
|
||||
$docUrl = getDocUrl();
|
||||
$faicon = "<i class=\"text-gray-500 fas fa-external-link-alt ml-1\"></i>";
|
||||
$docMsg = sprintf(_("RestAPI docs are accessible <a href=\"%s\" target=\"_blank\">here%s</a>"),$docUrl, $faicon);
|
||||
}
|
||||
|
||||
echo renderTemplate("restapi", compact(
|
||||
"status",
|
||||
"apiKey",
|
||||
"serviceStatus",
|
||||
"serviceLog"
|
||||
"serviceLog",
|
||||
"docMsg"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -72,3 +79,13 @@ function saveAPISettings($status, $apiKey, $dotenv)
|
|||
return $status;
|
||||
}
|
||||
|
||||
// Returns a url for fastapi's automatic docs
|
||||
function getDocUrl()
|
||||
{
|
||||
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
|
||||
$server_name = $_SERVER['SERVER_NAME'];
|
||||
$port = 8081;
|
||||
$url = $protocol . $server_name .':'. $port . '/docs';
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
<div class="tab-pane active" id="restapisettings">
|
||||
<h4 class="mt-3"><?php echo ("RestAPI settings") ;?></h4>
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-12 mt-3">
|
||||
<div class="form-group col-lg-12 mt-2">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<?php echo $docMsg; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
<div class="form-group col-md-6" required>
|
||||
<label for="txtapikey"><?php echo _("API Key"); ?></label>
|
||||
<div class="input-group">
|
||||
|
|
Loading…
Reference in a new issue