Skip to content

Commit

Permalink
some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky-sideburn committed Aug 30, 2024
1 parent 61e04d1 commit a50ca60
Show file tree
Hide file tree
Showing 5 changed files with 375 additions and 5 deletions.
129 changes: 126 additions & 3 deletions html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,50 @@
left: 10px;
z-index: 999; /* Ensure it's above other elements */
}

.settings {
background: #fff;
padding: 20px;
margin-top: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

.settings h2 {
margin-top: 0;
}

.setting-group {
margin-bottom: 20px;
}

.setting-group label {
display: block;
margin-bottom: 5px;
}

.setting-group input,
.setting-group select {
width: 100%;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 4px;
}

.setting-group button {
background: #333;
color: #fff;
border: none;
padding: 10px 20px;
cursor: pointer;
border-radius: 4px;
}

.setting-group button:hover {
background: #555;
}

</style>
</head>
<body id="kinvBody">
Expand Down Expand Up @@ -399,7 +443,7 @@ <h2 class="accordion-header" id="specialkeys-headingThree">
<!-- START METRICS ROW -->
<div class="row text-justify" align="center" id="metricsPresetsRow">
<div style="margin-top: 1%;" class="text-justify" id="metricsGroup">

<!--
<span style="color: #b2afaf;" class="text-kinv text-wrap" id="currentGameNamespaceLabel">Selected Namespace:&nbsp;&nbsp;<span id="currentGameNamespace" style="color: #3ac961;" class="text-break">NULL</span></span><br>
<span style="color: #b2afaf;" class="text-kinv" id="deletedPodsTotalText">Deleted Pods Total:&nbsp;&nbsp;<span id="deleted_pods_total" style="color: #3ac961">0</span></span><br>
<span style="color: #b2afaf" class="text-kinv" id="chaosJobTotalText">Chaos Jobs Total:&nbsp;&nbsp;<span id="chaos_jobs_total" style="color: #3ac961">0</span></span><br>
Expand All @@ -409,8 +453,71 @@ <h2 class="accordion-header" id="specialkeys-headingThree">
<span style="color: #b2afaf" class="text-kinv" id="currentReplicasStateDelayText">Current Replicas State Delay:&nbsp;&nbsp;</span><span id="fewer_replicas_seconds" style="color: #3ac961">0</span><font color="#4f4f4f">&nbsp;sec</font></span><br>
<span style="color: #b2afaf" class="text-kinv" id="latestReplicasStateDelayText">Latest Replicas State Delay:&nbsp;&nbsp;<span id="latest_fewer_replicas_seconds" style="color: #3ac961">0</span><font color="#4f4f4f">&nbsp;sec</font>&nbsp;</span><br>
<div id="mainChaosMetrics" style="width: 100%;height: 70%; margin-top: 1%;"></div>

<div id="mainChaosMetrics" style="width: 100%;height: 70%; margin-top: 1%;"></div>
-->
<style>
.status-label {
color: #444242; /* Colore per le etichette */
font-weight: bold;
font-size: 14px;
}

.status-value {
color: #000000; /* Colore blu scuro per i valori */
font-weight: normal;
font-size: 14px;
}

.status-unit {
color: #6c757d; /* Colore per le unità */
font-size: 12px;
}

.status-container {
margin-bottom: 8px; /* Spazio tra le righe */
}
</style>

<div class="status-container">
<span class="status-label">Selected Namespace:&nbsp;</span>
<span id="currentGameNamespace" class="status-value">NULL</span>
</div>

<div class="status-container">
<span class="status-label">Deleted Pods Total:&nbsp;</span>
<span id="deleted_pods_total" class="status-value">0</span>
</div>

<div class="status-container">
<span class="status-label">Chaos Jobs Total:&nbsp;</span>
<span id="chaos_jobs_total" class="status-value">0</span>
</div>

<div class="status-container">
<span class="status-label">Current Chaos Pods:&nbsp;</span>
<span id="current_chaos_job_pod" class="status-value">0</span>
</div>

<div class="status-container">
<span class="status-label">Not Running Pods:&nbsp;</span>
<span id="pods_not_running_on" class="status-value">0</span>
</div>

<div class="status-container">
<span class="status-label">Current Replicas State Delay:&nbsp;</span>
<span id="fewer_replicas_seconds" class="status-value">0</span>
<span class="status-unit">sec</span>
</div>

<div class="status-container">
<span class="status-label">Latest Replicas State Delay:&nbsp;</span>
<span id="latest_fewer_replicas_seconds" class="status-value">0</span>
<span class="status-unit">sec</span>
</div>

<div id="mainChaosMetrics" style="width: 100%; height: 70%; margin-top: 16px;"></div>


<!-- <span style="color: #000000" class="text-kinv" id="podsMatchRegexText">PODs match regex:&nbsp;&nbsp;</span><span id="pods_match_regex" style="color: #3ac961">0</span><font color="#4f4f4f">&nbsp;</font></span> -->
</div>
<!-- <div class="progress" style="margin-top: 1%;">
Expand Down Expand Up @@ -574,6 +681,22 @@ <h2 class="accordion-header" id="specialkeys-headingThree">
<div id="alert_placeholder" style="margin-top: 3%;"></div>
<div id="alert_placeholder3" style="margin-top: 3%;"></div>
</div>
<div class="settings">
<h2></h2>
<div class="setting-group">
<label for="sys_cluster_endpoint">k-inv url</label>
<input type="text" id="sys_cluster_endpoint" name="sys_cluster_endpoint" readonly="true">
<label for="sys_insecure_endpoint_flag">Insecure Endpoint Flag</label>
<input type="text" id="sys_insecure_endpoint_flag" name="sys_insecure_endpoint_flag" readonly="true">
<label for="sys_k8s_proxied_api_http_status_code">k-inv/k8s http status code</label>
<input type="text" id="sys_k8s_proxied_api_http_status_code" name="sys_k8s_proxied_api_http_status_code" readonly="true">
<label for="sys_openresty_env_vars">OpenResty Environment Variables</label>
<input type="text" id="sys_openresty_env_vars" name="sys_openresty_env_vars" readonly="true">
</div>
</div>
<div class="setting-group" style="margin-top: 2%;">
<button class="export-button" onclick="exportSettings()">Export</button>
</div>
</div>

<div id="footer" style="margin-top: 5%;">
Expand Down
57 changes: 56 additions & 1 deletion html5/kubeinvaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var clu_insecure = insecure_endpoint_placeholder;
var demo_mode = demo_mode_placeholder;
var k8s_url = "";
var chaos_report_post_data = "";
var selected_env_vars = "selected_env_vars_placeholder";

// when zoomIn is 12
var maxAliensPerRow = 20;
Expand Down Expand Up @@ -140,9 +141,62 @@ var chart_status_code_dict = {
"Other": 1
};


function checkHTTP(url, elementId) {
var oReq = new XMLHttpRequest();
oReq.onreadystatechange = function () {
if (this.readyState === XMLHttpRequest.DONE) {
$("#" + elementId).val(this.status);
}
};;
oReq.open("GET", url);
oReq.send();
}

function exportSettings() {
// Crea un oggetto con i dati delle impostazioni
const settings = {
sys_cluster_endpoint: document.getElementById('sys_cluster_endpoint').value,
sys_insecure_endpoint_flag: document.getElementById('sys_insecure_endpoint_flag').value,
sys_k8s_proxied_api_http_status_code: document.getElementById('sys_k8s_proxied_api_http_status_code').value,
sys_openresty_env_vars: document.getElementById('sys_openresty_env_vars').value
};

// Converti l'oggetto in una stringa JSON
const jsonSettings = JSON.stringify(settings, null, 2);

// Crea un blob e un URL per il download
const blob = new Blob([jsonSettings], { type: 'application/json' });
const url = URL.createObjectURL(blob);

// Crea un link temporaneo per il download
const a = document.createElement('a');
a.href = url;
a.download = 'settings.json';
document.body.appendChild(a);
a.click();

// Pulisci
document.body.removeChild(a);
URL.revokeObjectURL(url);
}

function setSystemSettings() {
var sys_element = document.getElementById('sys_cluster_endpoint');
sys_element.value = k8s_url;

sys_element = document.getElementById('sys_insecure_endpoint_flag');
sys_element.value = clu_insecure;

sys_element = document.getElementById('sys_openresty_env_vars');
sys_element.value = selected_env_vars;

checkHTTP(k8s_url, 'sys_k8s_proxied_api_http_status_code')
}

function currentChaosContainerJsonTextAreaVal() {
return editor_chaos_container_definition.getValue();
}
}

function getCodeName() {
const prefixes = ['astro', 'cosmo', 'space', 'star', 'nova', 'nebula', 'galaxy', 'super', 'hyper', 'quantum'];
Expand Down Expand Up @@ -918,6 +972,7 @@ window.setInterval(function backgroundTasks() {
document.addEventListener("keydown", keyDownHandler, false);
document.addEventListener("keyup", keyUpHandler, false);

setSystemSettings();
getEndpoint();
getNamespaces();
getSavedPresets();
Expand Down
Loading

0 comments on commit a50ca60

Please sign in to comment.