add_repo
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
root
2024-08-23 13:04:33 +02:00
parent b4d2d8c3fc
commit 7454f6710c
2 changed files with 52 additions and 24 deletions

View File

@@ -21,30 +21,33 @@
</div> </div>
<fieldset id="settings" class="hidden"> <fieldset id="settings" class="hidden">
<legend>Repositories</legend> <fieldset>
<legend>Repositories</legend>
<div id="repositories" style="text-align:left">Loading...</div> <div id="repositories" style="text-align:left">Loading...</div>
<form class="form-install" action="#" method="post"> <hr>
<form class="form-install" action="#" method="post" id="add_repo">
<div class="row"> <div class="row">
<div class="mb-3"> <div class="mb-3" style="text-align:left">
<label for="registry">Please add a new repository name:</label> <label for="registry">Please add a new GIT repository URL: </label>
<input type="registry" class="form-control" name="repository" id="repository" value="" required> <input type="registry" class="form-control" name="repository" id="repository" size="100" value="" required>
<div class="invalid-feedback"> <div class="invalid-feedback">
Please enter a valid repository name. Please enter a valid repository url.
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="mb-3"> <div class="mb-3">
<button class="btn btn-lg btn-primary btn-block" type="button"> Add </button> <button class="btn btn-lg btn-primary btn-block" type="submit" id="repo_add_btn"> Add </button>
</div> </div>
</div> </div>
</form> </form>
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>System</legend> <legend>System services</legend>
<div id="system" style="text-align:left">Loading...</div> <div id="system" style="text-align:left">Loading...</div>
</fieldset>
</fieldset> </fieldset>
<fieldset> <fieldset>
@@ -95,6 +98,14 @@ function get_repositories() {
}); });
} }
function add_repository() {
var url = 'scan.php?op=add_repository&repo='+jQuery('#repository').val();
jQuery.get(url, function(data) {
if (data=="OK") {
}
get_repositories();
});
}
function check_system() { function check_system() {
var url = 'scan.php?op=check_system&services=1'; var url = 'scan.php?op=check_system&services=1';
jQuery.get(url, function(data) { jQuery.get(url, function(data) {
@@ -162,6 +173,12 @@ jQuery(document).ready(function(){
jQuery('#settings').toggle(); jQuery('#settings').toggle();
}); });
jQuery('#add_repo').submit(function() {
jQuery('#repositories').html('Loading...');
add_repository();
return false;
});
jQuery('select#smarthost').click(function() { jQuery('select#smarthost').click(function() {
if (jQuery(this).val()=='yes') jQuery('#div_smarthost').show(); if (jQuery(this).val()=='yes') jQuery('#div_smarthost').show();
else jQuery('#div_smarthost').hide(); else jQuery('#div_smarthost').hide();

View File

@@ -92,19 +92,30 @@ switch ($_GET["op"]) {
$op = "repositories"; $op = "repositories";
redis_set($op,$json); redis_set($op,$json);
echo "OK"; // TODO? echo "OK"; // TODO?
break;
case "check_repositories": case "check_repositories":
$arr = check_redis("web_out","repositories"); $arr = check_redis("web_out","repositories");
if (!empty($arr)) { if (!empty($arr)) {
foreach ($arr as $key=>$data) { foreach ($arr as $key=>$data) {
if ($key=="repositories") { if ($key=="repositories") {
echo base64_decode($data["REPOSITORIES"]); $repos = json_decode(base64_decode($data["REPOSITORIES"]));
foreach ($repos->repositories as $repo) {
echo $repo."<br>";
}
redis_remove("$key"); redis_remove("$key");
} }
} }
} }
else echo ""; else echo "";
break; break;
case "add_repository":
$arr = array("NEW_REPO" => $_GET["repo"]);
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$op = "add_repository";
redis_set($op,$json);
echo "OK"; // TODO?
break;
case "containers": case "containers":
$arr = array("STATUS" => 0); $arr = array("STATUS" => 0);
$json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); $json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
@@ -112,7 +123,7 @@ switch ($_GET["op"]) {
$op = "containers"; $op = "containers";
redis_set($op,$json); redis_set($op,$json);
echo "OK"; // TODO? echo "OK"; // TODO?
break;
case "check_containers": case "check_containers":
$arr = check_redis("web_out","containers"); $arr = check_redis("web_out","containers");
if (!empty($arr)) { if (!empty($arr)) {