Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mcis control error #51

Merged
merged 1 commit into from
May 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 25 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,11 @@ function getMcis() {
//makePoly5( [-15.712891, 47.09024], [-25.712891, 12.09024], [25.712891, 32.09024],[-25.712891, 31.09024], [-15.712891, 47.09024]);

mcisName[cnt] = "[" + item.name + "]"
mcisStatus[cnt] = item.status
if (item.targetAction == "None" || item.targetAction == "") {
mcisStatus[cnt] = item.status
} else {
mcisStatus[cnt] = item.targetAction + '-> ' + item.status
}

console.log("item.status is" + item.status);

Expand Down Expand Up @@ -1682,43 +1686,32 @@ function controlMCIS(action) {

var hostname = hostnameElement.value;
var port = portElement.value;

var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
var auth = "Basic " + new Buffer(username + ":" + password).toString("base64");

var namespace = document.getElementById("namespace").value;
var mcisid = document.getElementById("mcisid").value;

// var http = require('http');
var mcisOptions = {
hostname: hostname,
port: port,
path: '/tumblebug/ns/' + namespace + '/control/mcis/' + mcisid + '?action=' + action,
method: 'GET',
headers: {
"Authorization" : auth
}
};
var url = `http://${hostname}:${port}/tumblebug/ns/${namespace}/control/mcis/${mcisid}?action=${action}`

function handleResponse(response) {
var serverData = '';
response.on('data', function (chunk) {
serverData += chunk;
});
response.on('end', function () {
console.log("[Control MCIS]");
var obj = JSON.parse(serverData);
if ( obj.message != null ){
console.log(obj.message);
messageTextArea.value = obj.message;
}
});
}
console.log('MCIS control:['+ action + ']');

http.request(mcisOptions, function (response) {
handleResponse(response);
axios({
method: 'get',
url: url,
auth: {
username: `${username}`,
password: `${password}`
}

})
.then((res)=>{

if ( res.data != null ){
console.log(res.data);
messageTextArea.value = res.data.message;
}
});

}
window.controlMCIS = controlMCIS;

Expand Down Expand Up @@ -1785,6 +1778,8 @@ function deleteMCIS() {

var url = `http://${hostname}:${port}/tumblebug/ns/${namespace}/mcis/${mcisid}?option=terminate`

infoAlert('Deleting MCIS (option=terminate): ' + mcisid);

axios({
method: 'delete',
url: url,
Expand Down