From c911f5941d0c4e53b6b86194e678bd1f2bbd86c9 Mon Sep 17 00:00:00 2001 From: choryang Date: Thu, 22 Dec 2022 14:03:37 +0900 Subject: [PATCH 1/2] Fix: Show Spec List when Adding Worker --- .../manages/mcksmng/nodeconfigure.js | 273 +++++++++--------- .../manages/mcksmng/NodeConfigure.html | 19 +- 2 files changed, 153 insertions(+), 139 deletions(-) diff --git a/src/static/assets/js/operation/manages/mcksmng/nodeconfigure.js b/src/static/assets/js/operation/manages/mcksmng/nodeconfigure.js index 115f0fc0..d4accf8f 100644 --- a/src/static/assets/js/operation/manages/mcksmng/nodeconfigure.js +++ b/src/static/assets/js/operation/manages/mcksmng/nodeconfigure.js @@ -1,44 +1,52 @@ // connection 정보가 바뀌었을 때, 변경 될 object : 원래는 각각 만들어야 하나, 가져오는게 spec만 있어서 plane, worker 같이 씀. //('mcksWorker', this.value, 'worker', '0') -function changeConnectionInfo(caller, configName, targetPrefix, objIndex){ - console.log("config name : ",configName) - if( configName == ""){ +function changeConnectionInfo(caller, configName, targetPrefix, objIndex) { + + console.log("config name : ", configName) + if (configName == "") { // 0번째면 selectbox들을 초기화한다.(vmInfo, sshKey, image 등) } + // 추가된 worker node config에 spec을 가져오기 위한 임시방편 + if (objIndex != "0") { + objIndex = addWorkerIndex + } + var provider = $("#" + targetPrefix + "Provider_" + objIndex).val(); - + var specObjId = targetPrefix + "SpecId_" + objIndex; var rootDiskTypeId = targetPrefix + "RootDiskType_" + objIndex; + console.log("mcks : " + provider, specObjId, rootDiskTypeId); + getSpecInfo(provider, configName, specObjId); - + getCommonLookupDiskInfo(rootDiskTypeId, provider, configName);// -> getCommonLookupDiskInfoSuccess } // connection에 맞는 spec들 조회 -function getSpecInfo(provider, configName, targetObjId){ - +function getSpecInfo(provider, configName, targetObjId) { + var url = "/setting/resources/vmspec/list" var html = ""; - axios.get(url,{ + axios.get(url, { // headers:{ // 'Authorization': apiInfo // } - }).then(result=>{ + }).then(result => { console.log(result.data) var data = result.data.VmSpecList - if(data){ - html +="" - data.filter(csp => csp.connectionName === configName).map(item =>( - html += '' + if (data) { + html += "" + data.filter(csp => csp.connectionName === configName).map(item => ( + html += '' )) - }else{ - html +="" + } else { + html += "" } $("#" + targetObjId).empty(); - $("#" + targetObjId).append(html); + $("#" + targetObjId).append(html); }) } @@ -48,76 +56,76 @@ var DISK_SIZE = []; function getCommonLookupDiskInfoSuccess(caller, provider, data) { var targetObjId = caller; console.log("getCommonLookupDiskInfoSuccess", data); - var root_disk_type = []; - var res_item = data; - res_item.forEach(item => { + var root_disk_type = []; + var res_item = data; + res_item.forEach(item => { var temp_provider = item.provider - if (temp_provider == provider) { - root_disk_type = item.rootdisktype - DISK_SIZE = item.disksize - } - }) - - var html = '' - root_disk_type.forEach(item => { - html += '' - }) - $("#" +targetObjId).empty(); - $("#" +targetObjId).append(html); + if (temp_provider == provider) { + root_disk_type = item.rootdisktype + DISK_SIZE = item.disksize + } + }) + + var html = '' + root_disk_type.forEach(item => { + html += '' + }) + $("#" + targetObjId).empty(); + $("#" + targetObjId).append(html); } // diskType이 변경되면 사용가능한 disk size의 range가 바뀜 function changeDiskType(type, targetObjId) { - var disk_size = DISK_SIZE; + var disk_size = DISK_SIZE; var maxDiskSize = 0; var minDiskSize = 0; - if (disk_size) { - disk_size.forEach(item => { - var temp_size = item.split("|") - var temp_type = temp_size[0]; - if (temp_type == type) { - maxDiskSize = temp_size[1]; - minDiskSize = temp_size[2] - } - }) - } + if (disk_size) { + disk_size.forEach(item => { + var temp_size = item.split("|") + var temp_type = temp_size[0]; + if (temp_type == type) { + maxDiskSize = temp_size[1]; + minDiskSize = temp_size[2] + } + }) + } // min / max 표시 - console.log("maxDiskSize : ", maxDiskSize) - console.log("ROOT_DISK_MIN_VALUE : ", minDiskSize) - //$("#targetObjId").val(type); + console.log("maxDiskSize : ", maxDiskSize) + console.log("ROOT_DISK_MIN_VALUE : ", minDiskSize) + //$("#targetObjId").val(type); } // mcks , node deploy // 우선 mcks 부터 -function nodeDone_btn(){ +function nodeDone_btn() { var mcksID = $("#mcksID").val(); var mcksName = $("#mcksName").val(); - + var workerCountLength = $("input[name='workerCount']").length; console.log("workerCountLength1 " + workerCountLength) var workerConnectionData = new Array(); var workerCountData = new Array(); var workerSpecIdData = new Array(); - for(var i=0; i -1) continue;// 복사를 위한 영역이 있으므로 + if (workerId.indexOf("hidden_worker") > -1) continue;// 복사를 위한 영역이 있으므로 console.log("aa " + workerId) workerConnectionData.push($("select[name='workerConnectionName']")[i].value); workerCountData.push($("input[name='workerCount']")[i].value); workerSpecIdData.push($("select[name='workerSpecId']")[i].value); - if( !workerConnectionData[i]){ + if (!workerConnectionData[i]) { commonAlert("Please Select Connection " + i) return; } - if( !workerCountData[i]){ + if (!workerCountData[i]) { commonAlert("Please Input Worker Count" + i) return; } - if( !workerSpecIdData[i]){ + if (!workerSpecIdData[i]) { commonAlert("Please Select Worker Spec" + i) return; } @@ -127,7 +135,7 @@ function nodeDone_btn(){ console.log(workerSpecIdData) var new_obj = {} - + // VM추가시에는 controlPlane 없음. // var controlPlanes = new Array(controlPlaneLength); // console.log("controlPlaneConnectionLength " + controlPlaneLength) @@ -142,13 +150,13 @@ function nodeDone_btn(){ // new_obj['controlPlane'] = controlPlanes; var workers = new Array(workerCountData.length); - for(var i=0; i{ - console.log("data : ",result); - console.log("Result Status : ",result.status); + axios.post(url, new_obj, { + headers: { + }, + }).then(result => { + console.log("data : ", result); + console.log("Result Status : ", result.status); var statusCode = result.data.status; var message = result.data.message; - console.log("Result Status : ",statusCode); - console.log("Result message : ",message); + console.log("Result Status : ", statusCode); + console.log("Result message : ", message); - if(result.status == 201 || result.status == 200){ + if (result.status == 201 || result.status == 200) { commonAlert("Node Add Success") changePage("McksMngForm"); - - }else{ - commonErrorAlert(statusCode, message) + + } else { + commonErrorAlert(statusCode, message) } }).catch((error) => { console.log(error); console.log(error.response) var errorMessage = error.response.data.error; - commonErrorAlert(statusCode, errorMessage) + commonErrorAlert(statusCode, errorMessage) }) - }finally{ - + } finally { + } } // WorkNode 추가 var lastWorkerId = ""; -function addWorkNode(){ +var addWorkerIndex = 0 +function addWorkNode() { console.log("addWorkNode start"); - try{ - // 마지막 name의 index 추출 - var maxWorkerId = ""; - var nameCount = 0; - $("input[name='workerCount']").each(function (i) { - var currentWorkCountID = $(this).attr('id'); - console.log("::: " + currentWorkCountID) - if( currentWorkCountID.indexOf("hidden") == -1){ - //console.log( i + "번째 : " + $("input[name='workerCount']").eq(i).attr("value") ); - console.log("currentWorkCountID=" + currentWorkCountID) - maxWorkerId = currentWorkCountID; - nameCount++; + try { + // 마지막 name의 index 추출 + var maxWorkerId = ""; + var nameCount = 0; + $("input[name='workerCount']").each(function (i) { + var currentWorkCountID = $(this).attr('id'); + console.log("::: " + currentWorkCountID) + if (currentWorkCountID.indexOf("hidden") == -1) { + //console.log( i + "번째 : " + $("input[name='workerCount']").eq(i).attr("value") ); + console.log("currentWorkCountID=" + currentWorkCountID) + maxWorkerId = currentWorkCountID; + nameCount++; + } + }); + + if (lastWorkerId == "") { + lastWorkerId = maxWorkerId; } - }); - if( lastWorkerId == "" ){ - lastWorkerId = maxWorkerId; - } + var lastIndexArr = lastWorkerId.split("_") + var lastIndex = lastIndexArr[lastIndexArr.length - 1]; - var lastIndexArr = lastWorkerId.split ("_") - var lastIndex = lastIndexArr[lastIndexArr.length-1]; - - var maxIndexArr = maxWorkerId.split ("_") - var maxIndex = maxIndexArr[maxIndexArr.length-1]; - // console.log( lastWorkerId + " <> " + maxWorkerId) - // console.log(maxIndexArr) - // console.log( lastIndex + " : " + maxIndex + " : " + nameCount) - if( lastIndex <= maxIndex){ - nameCount = Number(maxIndex) + 1; - lastWorkerId = maxWorkerId; - } -// var lastIndexArr = lastWorkerId.split ("_") -// var lastIndex = lastIndexArr[lastIndexArr.length-1]; -// console.log("lastIndex=" + lastIndex) - // var addWorkerIndex = Number(lastIndex) +1; - var addWorkerIndex = Number(nameCount); - - // console.log("addWorkerIndex=" + addWorkerIndex) - var addWorkerHtml = $('#hidden_work_area').clone(); - // console.log(addWorkerHtml.html()); - var addW = ""; - // 최초 1번만 .html() 이 먹고 다음부터는 string으로 인식함. - addW = addWorkerHtml.html().replace('hidden_mcks_Worker_list', 'mcks_Worker_list_' + addWorkerIndex); - addW = addW.replace(/hidden_workerProvider/gi, 'workerProvider_' + addWorkerIndex); - addW = addW.replace(/hidden_workerConnectionName/gi, 'workerConnectionName_' + addWorkerIndex); - addW = addW.replace(/hidden_workerCount/gi, 'workerCount_' + addWorkerIndex); - addW = addW.replace(/hidden_workerSpecId/gi, 'workerSpecId_' + addWorkerIndex); - addW = addW.replace(/hidden_workerRemove/gi, 'workerRemove_' + addWorkerIndex); - addW = addW.replace(/hidden_workerAddCount/gi, 'workerAddCount_' + addWorkerIndex); - - - //$("#mcks_Worker_list").append(addW); - $("#mcksNodeArea").append(addW); - $("#mcks_Worker_list_" + addWorkerIndex).css("display", "block"); - //$("#aa").css("display", "block"); - // console.log($("#mcks_Worker_list").html()) - - $("#workerAddCount_" + addWorkerIndex).text( (addWorkerIndex + 1 )); - }catch(e){ + var maxIndexArr = maxWorkerId.split("_") + var maxIndex = maxIndexArr[maxIndexArr.length - 1]; + // console.log( lastWorkerId + " <> " + maxWorkerId) + // console.log(maxIndexArr) + // console.log( lastIndex + " : " + maxIndex + " : " + nameCount) + if (lastIndex <= maxIndex) { + nameCount = Number(maxIndex) + 1; + lastWorkerId = maxWorkerId; + } + // var lastIndexArr = lastWorkerId.split ("_") + // var lastIndex = lastIndexArr[lastIndexArr.length-1]; + // console.log("lastIndex=" + lastIndex) + // var addWorkerIndex = Number(lastIndex) +1; + addWorkerIndex = Number(nameCount); + + // console.log("addWorkerIndex=" + addWorkerIndex) + var addWorkerHtml = $('#hidden_work_area').clone(); + // console.log(addWorkerHtml.html()); + var addW = ""; + // 최초 1번만 .html() 이 먹고 다음부터는 string으로 인식함. + addW = addWorkerHtml.html().replace('hidden_mcks_Worker_list', 'mcks_Worker_list_' + addWorkerIndex); + addW = addW.replace(/hidden_workerProvider/gi, 'workerProvider_' + addWorkerIndex); + addW = addW.replace(/hidden_workerConnectionName/gi, 'workerConnectionName_' + addWorkerIndex); + addW = addW.replace(/hidden_workerCount/gi, 'workerCount_' + addWorkerIndex); + addW = addW.replace(/hidden_workerSpecId/gi, 'workerSpecId_' + addWorkerIndex); + addW = addW.replace(/hidden_workerRemove/gi, 'workerRemove_' + addWorkerIndex); + addW = addW.replace(/hidden_workerAddCount/gi, 'workerAddCount_' + addWorkerIndex); + + + //$("#mcks_Worker_list").append(addW); + $("#mcksNodeArea").append(addW); + $("#mcks_Worker_list_" + addWorkerIndex).css("display", "block"); + //$("#aa").css("display", "block"); + // console.log($("#mcks_Worker_list").html()) + + $("#workerAddCount_" + addWorkerIndex).text((addWorkerIndex + 1)); + } catch (e) { console.log(e); } } -function removeWorkerNode(removeWorkerId){ +function removeWorkerNode(removeWorkerId) { console.log("removeWorkerId " + removeWorkerId) - + var workerArr = removeWorkerId.split("_"); console.log(workerArr) - var workerIndex = workerArr[workerArr.length-1]; + var workerIndex = workerArr[workerArr.length - 1]; console.log("removeWorkerNode " + workerIndex) $("#mcks_Worker_list_" + workerIndex).remove(); } \ No newline at end of file diff --git a/src/views/operation/manages/mcksmng/NodeConfigure.html b/src/views/operation/manages/mcksmng/NodeConfigure.html index 76a340df..be94ec9d 100644 --- a/src/views/operation/manages/mcksmng/NodeConfigure.html +++ b/src/views/operation/manages/mcksmng/NodeConfigure.html @@ -72,11 +72,14 @@
  • - - +
@@ -149,11 +152,13 @@
  • - - +
@@ -210,7 +215,7 @@ From d0a235f399fa2b1456a1d21c63dcba8678150478 Mon Sep 17 00:00:00 2001 From: choryang Date: Thu, 22 Dec 2022 14:45:58 +0900 Subject: [PATCH 2/2] Fix: Add Root Disk Config to Worker --- .../operation/manages/mcksmng/nodeconfigure.js | 4 ++-- .../operation/manages/mcksmng/NodeConfigure.html | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/static/assets/js/operation/manages/mcksmng/nodeconfigure.js b/src/static/assets/js/operation/manages/mcksmng/nodeconfigure.js index d4accf8f..6b84c864 100644 --- a/src/static/assets/js/operation/manages/mcksmng/nodeconfigure.js +++ b/src/static/assets/js/operation/manages/mcksmng/nodeconfigure.js @@ -17,8 +17,6 @@ function changeConnectionInfo(caller, configName, targetPrefix, objIndex) { var specObjId = targetPrefix + "SpecId_" + objIndex; var rootDiskTypeId = targetPrefix + "RootDiskType_" + objIndex; - console.log("mcks : " + provider, specObjId, rootDiskTypeId); - getSpecInfo(provider, configName, specObjId); getCommonLookupDiskInfo(rootDiskTypeId, provider, configName);// -> getCommonLookupDiskInfoSuccess @@ -258,6 +256,8 @@ function addWorkNode() { addW = addW.replace(/hidden_workerConnectionName/gi, 'workerConnectionName_' + addWorkerIndex); addW = addW.replace(/hidden_workerCount/gi, 'workerCount_' + addWorkerIndex); addW = addW.replace(/hidden_workerSpecId/gi, 'workerSpecId_' + addWorkerIndex); + addW = addW.replace(/hidden_workerRootDiskType/gi, 'workerRootDiskType_' + addWorkerIndex); + addW = addW.replace(/hidden_workerRootDiskSize/gi, 'workerRootDiskSize_' + addWorkerIndex); addW = addW.replace(/hidden_workerRemove/gi, 'workerRemove_' + addWorkerIndex); addW = addW.replace(/hidden_workerAddCount/gi, 'workerAddCount_' + addWorkerIndex); diff --git a/src/views/operation/manages/mcksmng/NodeConfigure.html b/src/views/operation/manages/mcksmng/NodeConfigure.html index be94ec9d..4e29eec0 100644 --- a/src/views/operation/manages/mcksmng/NodeConfigure.html +++ b/src/views/operation/manages/mcksmng/NodeConfigure.html @@ -215,7 +215,7 @@ @@ -241,6 +241,20 @@ +
+
    +
  • + + + +
  • +
+