mirror of
https://github.com/lucky-sideburn/kubeinvaders.git
synced 2026-02-14 17:50:00 +00:00
fixed ping
This commit is contained in:
@@ -74,7 +74,7 @@ function chaosReportHttpEndpointAdd() {
|
||||
<div class="row">
|
||||
<div class="col col-xl-10" style="margin-top: 2%;">
|
||||
<label for="ingressHostList">Ingress Host List</label>
|
||||
<select id="ingressHostList" class="form-select" aria-label="Ingress Host List" onchange="setChaosReportURL(this)">
|
||||
<select id="ingressHostList" class="form-select" aria-label="Ingress Host List" onclick="setModalState(true)">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -105,7 +105,7 @@ function chaosReportHttpEndpointAdd() {
|
||||
<div class="row" style="margin-top: 2%;">
|
||||
<div class="col col-xl-10">
|
||||
<label for="chaosReportCheckSiteURLHeaders">Headers</label>
|
||||
<input type="text" class="form-control input-sm" id="chaosReportCheckSiteURLHeaders" value='{"Content-Type": "application/json; charset=utf-8"}' style="margin-top: 1%; margin-bottom: 1%; width: 80%;">
|
||||
<input type="text" class="form-control input-sm" id="chaosReportCheckSiteURLHeaders" value='{"Content-Type": "application/json; charset=utf-8"}' style="margin-top: 1%; margin-bottom: 1%; width: 80%;" onclick="setModalState(true)">
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
<div id="main-game-div" style="display: block;">
|
||||
|
||||
<div class="modal fade" id="kubePingModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h6 class="modal-title">Help us improve KubeInvaders</h6>
|
||||
@@ -178,6 +178,7 @@
|
||||
|
||||
Thank you for you feedback!
|
||||
</p>
|
||||
<textarea id="kubePingJsonTextArea" rows=10 style="width: 50%; height: 50%; font-size: small; font-weight: normal; font-family: 'Courier New', Courier, monospace;" onclick="setModalState(true);">Please leave your feedback or suggestions here on how we can improve and make this product more enterprise-ready (it will always remain 100% open-source!)</textarea>
|
||||
<div class="modal-footer">
|
||||
<button type="button" id="saveButton" class="btn btn-light" onclick="setKubePingStatusPing(1)">Ping</button>
|
||||
<button type="button" id="closeButton3" class="btn btn-dark" data-dismiss="modal" onclick="setKubePingStatusPing(0)">Don't ping</button>
|
||||
|
||||
@@ -986,3 +986,8 @@ document.getElementById("gameContainer").style.visibility = "visible";
|
||||
document.getElementById("metricsPresetsRow").style.visibility = "visible";
|
||||
document.getElementById("gameContainer").style.opacity = 1;
|
||||
document.getElementById("metricsPresetsRow").style.opacity = 1;
|
||||
|
||||
// TO DO: Apply also when modals are opened
|
||||
$('.modal').on('hidden.bs.modal', function () {
|
||||
setModalState(false);
|
||||
});
|
||||
@@ -6,12 +6,17 @@ function setModalState(state) {
|
||||
function showKubePingModal() {
|
||||
if (!kubeping_sent) {
|
||||
$('#kubePingModal').modal('show');
|
||||
KubePingStatus();
|
||||
}
|
||||
|
||||
$('#kubePingModal').on('shown.bs.modal', function () {
|
||||
setModalState(true);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function closeKubePingModal() {
|
||||
$('#kubePingModal').modal('hide');
|
||||
setModalState(false);
|
||||
}
|
||||
|
||||
function showCurrentChaosContainer() {
|
||||
@@ -64,6 +69,9 @@ function wrapShowPrepareChaosReportModal(checkbox) {
|
||||
|
||||
function showPrepareChaosReportModal(checkbox) {
|
||||
if(checkbox.checked){
|
||||
$('#kubePingModal').on('shown.bs.modal', function () {
|
||||
setModalState(true);
|
||||
});
|
||||
$('#prepareChaosReportModal').modal('show');
|
||||
$("#chaosReportHeader").text("Select Ingress - Namespace:" + namespace);
|
||||
setCodeNameToTextInput("chaosReportAuthor");
|
||||
@@ -81,10 +89,12 @@ function closePrepareChaosReportModal() {
|
||||
$('#prepareChaosReportModal').modal('hide');
|
||||
document.getElementById("flagChaosReport").checked = false;
|
||||
setModalState(false);
|
||||
kubePingModalSwitch();
|
||||
}
|
||||
|
||||
function closePrepareChaosReportModalAndUncheck() {
|
||||
$('#prepareChaosReportModal').modal('hide');
|
||||
document.getElementById("flagChaosReport").checked = false;
|
||||
setModalState(false);
|
||||
kubePingModalSwitch();
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
/* Functions for controlling game modes */
|
||||
|
||||
function startGameMode() {
|
||||
kubePingModalSwitch();
|
||||
if (game_mode_switch) {
|
||||
game_mode_switch = false;
|
||||
$("#gameModeButton").text("Enable Game Mode");
|
||||
|
||||
@@ -48,23 +48,36 @@ function is_demo_mode() {
|
||||
return demo_mode;
|
||||
}
|
||||
|
||||
function sanitizeStringToURLFriendly(str) {
|
||||
return str.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
function kubePingModalSwitch() {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.onreadystatechange = function () {
|
||||
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
|
||||
console.log("[K-INV STARTUP] kubeping status is: |" + this.responseText.trim() + "|");
|
||||
if (this.responseText.trim() == "Key not found" || is_demo_mode()) {
|
||||
setModalState(true)
|
||||
showKubePingModal()
|
||||
}
|
||||
}
|
||||
};;
|
||||
|
||||
oReq.open("GET", k8s_url + "/chaos/redis/get?key=kubeping", true);
|
||||
oReq.send();
|
||||
}
|
||||
|
||||
function setKubePingStatusPing(value) {
|
||||
var oReq = new XMLHttpRequest();
|
||||
oReq.open("POST", k8s_url + "/chaos/redis/set?key=kubeping", true);
|
||||
|
||||
if (value == 1) {
|
||||
oReq.open("POST", k8s_url + "/chaos/redis/set?key=kubeping&msg=" + sanitizeStringToURLFriendly(document.getElementById("kubePingJsonTextArea").value), true);
|
||||
}
|
||||
else {
|
||||
oReq.open("POST", k8s_url + "/chaos/redis/set?key=kubeping", true);
|
||||
}
|
||||
|
||||
oReq.onreadystatechange = function () {
|
||||
if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
|
||||
|
||||
@@ -140,6 +140,7 @@ server {
|
||||
local args = ngx.req.get_uri_args()
|
||||
local key = args["key"]
|
||||
ngx.log(ngx.INFO, "[KUBEPING] Setting key " .. key .. " with data |" .. tostring(data) .. "|")
|
||||
|
||||
ngx.say(tostring(red:set(key, tostring(data))))
|
||||
|
||||
if key == "kubeping" and data == "1" then
|
||||
@@ -156,10 +157,10 @@ server {
|
||||
end
|
||||
return respbody
|
||||
end
|
||||
|
||||
local data = get_data("https://devopstribe.it/kubeping")
|
||||
local data = get_data("https://devopstribe.it/kubeping?msg=" .. args["msg"])
|
||||
print(data.result)
|
||||
end
|
||||
ngx.say("OK")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user