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,31 +21,34 @@
</div>
<fieldset id="settings" class="hidden">
<fieldset>
<legend>Repositories</legend>
<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="mb-3">
<label for="registry">Please add a new repository name:</label>
<input type="registry" class="form-control" name="repository" id="repository" value="" required>
<div class="mb-3" style="text-align:left">
<label for="registry">Please add a new GIT repository URL: </label>
<input type="registry" class="form-control" name="repository" id="repository" size="100" value="" required>
<div class="invalid-feedback">
Please enter a valid repository name.
Please enter a valid repository url.
</div>
</div>
</div>
<div class="row">
<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>
</form>
</fieldset>
<fieldset>
<legend>System</legend>
<legend>System services</legend>
<div id="system" style="text-align:left">Loading...</div>
</fieldset>
</fieldset>
<fieldset>
<legend>Deployments</legend>
@@ -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() {
var url = 'scan.php?op=check_system&services=1';
jQuery.get(url, function(data) {
@@ -162,6 +173,12 @@ jQuery(document).ready(function(){
jQuery('#settings').toggle();
});
jQuery('#add_repo').submit(function() {
jQuery('#repositories').html('Loading...');
add_repository();
return false;
});
jQuery('select#smarthost').click(function() {
if (jQuery(this).val()=='yes') jQuery('#div_smarthost').show();
else jQuery('#div_smarthost').hide();

View File

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