261028_01_ENH: 새로운 KART 연동
This commit is contained in:
@@ -113,91 +113,29 @@ kon.prj = (function () {
|
||||
return { "element": "button", "text": element.name, "attr": { "data-code": code, "onClick": element.fn,"class":element.class , "data_type":element.data_type, "style":element.style} }
|
||||
})
|
||||
}
|
||||
/* 2023-02-01 서성완 Analysis 버튼에 Kart 연동 */
|
||||
|
||||
/* 2026-10-27 Analysis 버튼 → KART 사내 연동 API(URL Copy)로 변경 */
|
||||
function fnAnalysis() { /* 프로젝트 기능 버튼 반환 함수 */
|
||||
var isKiwi = "1"; //KIWI 프로젝트는 "1"
|
||||
var reportToken = getReportToken();/////인증 - Report API로 부터 인증 키를 받아야만 다른 기능을 사용 가능
|
||||
kon.prj.code = event.target.getAttribute("data-code");
|
||||
var skey = getSkey(reportToken.Token, kon.prj.code, "1");
|
||||
var shortUrl = getShortUrl(reportToken.Token, skey);
|
||||
kon.prj.code = $(event.target).closest("[data-code]").attr("data-code");
|
||||
var win = window.open("about:blank", "_blank"); // 비동기 호출 전에 열어 팝업 차단 방지
|
||||
|
||||
window.open(shortUrl, '_blank');
|
||||
}
|
||||
|
||||
/* 2023-02-01 서성완 Kart 특졍값을 전송해 External Token 가져오는 함수 */
|
||||
function getReportToken(){
|
||||
var reportToken = "";
|
||||
$.ajax({
|
||||
url: 'https://rapi.kric.com/api/v1/encrypt/external',
|
||||
url: KART_BASE_URL + "/project/" + KART_PROJECT_TYPE + "/" + encodeURIComponent(kon.prj.code) + "/share",
|
||||
type: "POST",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: JSON.stringify({ "external": "KON"}),
|
||||
data: JSON.stringify({ realUrl: "/Report/Current", mode: "U" }),
|
||||
cache: false,
|
||||
async: false,
|
||||
success: function (data) {
|
||||
reportToken = JSON.parse(data);
|
||||
},
|
||||
error: function (x, h, r) {
|
||||
console.log(x);
|
||||
console.log(h);
|
||||
console.log(r);
|
||||
}
|
||||
});
|
||||
return reportToken;
|
||||
}
|
||||
|
||||
/* 2023-02-01 서성완 Kart Skey Token 가져오는 함수 */
|
||||
function getSkey(token,pkey,iskiwi){
|
||||
var skey = "";
|
||||
$.ajax({
|
||||
url: 'https://rapi.kric.com/api/v1/encrypt/pkey',
|
||||
type: "GET",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
cache: false,
|
||||
async: false,
|
||||
beforeSend : function(xhr){
|
||||
xhr.setRequestHeader("token", token);
|
||||
xhr.setRequestHeader("pkey",pkey);
|
||||
xhr.setRequestHeader("iskiwi",iskiwi);
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader("X-API-Key", KON_KIWI_API_KEY);
|
||||
},
|
||||
success: function (data) {
|
||||
skey = data;
|
||||
win.location.href = data.url;
|
||||
},
|
||||
error: function (x, h, r) {
|
||||
console.log(x);
|
||||
console.log(h);
|
||||
console.log(r);
|
||||
error: function (x) {
|
||||
win.close();
|
||||
alert((x.responseJSON && x.responseJSON.message) || "공유 링크 생성에 실패했습니다.");
|
||||
}
|
||||
});
|
||||
return skey;
|
||||
}
|
||||
|
||||
/* 2023-02-01 서성완 Kart ShortUrl로 변경하는 함수 */
|
||||
function getShortUrl(token, skey){
|
||||
$.ajax({
|
||||
url: 'https://rapi.kric.com/api/v1/uri/short',
|
||||
type: "POST",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data:JSON.stringify({
|
||||
"realURI": "/Report/Current",
|
||||
"mode": "U"
|
||||
}),
|
||||
cache: false,
|
||||
async: false,
|
||||
beforeSend : function(xhr){
|
||||
xhr.setRequestHeader("token", token);
|
||||
xhr.setRequestHeader("skey",skey);
|
||||
},
|
||||
success: function (data) {
|
||||
shortUrl = data;
|
||||
},
|
||||
error: function (x, h, r) {
|
||||
console.log(x);
|
||||
console.log(h);
|
||||
console.log(r);
|
||||
}
|
||||
});
|
||||
return shortUrl;
|
||||
}
|
||||
|
||||
function fn_makeFrame() { /* 프로젝트 만든 프레임 틀에 넣는 함수 */
|
||||
|
||||
28
js/kfunc.js
28
js/kfunc.js
@@ -1,3 +1,10 @@
|
||||
var CONTACT_TEST_URL = "https://test-contact.kric.com/api";
|
||||
var CONTACT_BASE_URL = "https://contact.kric.com/api";
|
||||
var KART_BASE_URL = "https://kart.kric.com/api/kric-internal";
|
||||
var KART_PROJECT_TYPE = "1";
|
||||
var KON_KIWI_API_KEY = "4B495749-537572766579-466F72-4B4F4E-4953-4B4F4E4B495749";
|
||||
|
||||
|
||||
/******************************************* 2023-09-21 14:35 서지원 상무님 요청 드래그와 우클릭을 막아라**********************************************************/
|
||||
if(window.location.href.toLowerCase().match(/(project\/){1}[A-Z|0-9|a-z|\_]+(\/index.asp){1}/g) || window.location.href.toLowerCase().match(/(project\/){1}[A-Z|0-9|a-z|\_]+(\/question.asp){1}/g)){
|
||||
$("html").attr("oncontextmenu","return false").attr("ondragstart","return false").attr("onselectstart","return false");
|
||||
@@ -243,17 +250,20 @@ function ajax_returnData(urlx, datax, other) {
|
||||
return data;
|
||||
}
|
||||
|
||||
var CONTACT_BASE_URL = "https://contact.kric.com/api";
|
||||
var KON_KIWI_API_KEY = "4B495749-537572766579-466F72-4B4F4E-4953-4B4F4E4B495749";
|
||||
function getContactUrl(isTest = false) {
|
||||
return isTest ? CONTACT_TEST_URL : CONTACT_BASE_URL;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @Explain 리스트 헤더명 목록 조회
|
||||
* @param {string} prjctCd
|
||||
* @param {boolean} [isTest=false] 기본값 false
|
||||
* @returns {string[]} 헤더명 배열
|
||||
*/
|
||||
function getContactListHeader(prjctCd) {
|
||||
function getContactListHeader(prjctCd, isTest = false) {
|
||||
return ajax_returnData(
|
||||
CONTACT_BASE_URL + "/list-external/header?prjctCd=" + encodeURIComponent(prjctCd),
|
||||
getContactUrl(isTest) + "/list-external/header?prjctCd=" + encodeURIComponent(prjctCd),
|
||||
{},
|
||||
{ headers: { "X-API-Key": KON_KIWI_API_KEY } }
|
||||
);
|
||||
@@ -263,11 +273,12 @@ function getContactListHeader(prjctCd) {
|
||||
* @Explain sid 기준 리스트 정보 조회
|
||||
* @param {string} prjctCd
|
||||
* @param {string} sid
|
||||
* @param {boolean} [isTest=false] 기본값 false
|
||||
* @returns {Object} { prjctCd, sid, itemList }
|
||||
*/
|
||||
function getContactListWithSid(prjctCd, sid) {
|
||||
function getContactListWithSid(prjctCd, sid, isTest = false) {
|
||||
return ajax_returnData(
|
||||
CONTACT_BASE_URL + "/list-external/search?prjctCd=" + encodeURIComponent(prjctCd) + "&sid=" + encodeURIComponent(sid),
|
||||
getContactUrl(isTest) + "/list-external/search?prjctCd=" + encodeURIComponent(prjctCd) + "&sid=" + encodeURIComponent(sid),
|
||||
{},
|
||||
{ headers: { "X-API-Key": KON_KIWI_API_KEY } }
|
||||
);
|
||||
@@ -279,9 +290,10 @@ function getContactListWithSid(prjctCd, sid) {
|
||||
* @param {string} prjctCd
|
||||
* @param {string} sid
|
||||
* @param {Object} itemMap 예: {"중요메모":"KON-TEST", "주소":"TTTTTTTT"}
|
||||
* @param {boolean} [isTest=false] 기본값 false
|
||||
* @returns {number|undefined} backend 응답(수정 건수)
|
||||
*/
|
||||
function setContactListWithSid(prjctCd, sid, itemMap) {
|
||||
function setContactListWithSid(prjctCd, sid, itemMap, isTest = false) {
|
||||
var headerList = getContactListHeader(prjctCd) || [];
|
||||
var refinedMap = {};
|
||||
if (itemMap && typeof itemMap === "object") {
|
||||
@@ -299,7 +311,7 @@ function setContactListWithSid(prjctCd, sid, itemMap) {
|
||||
}
|
||||
|
||||
return ajax_returnData(
|
||||
CONTACT_BASE_URL + "/list-external/update?prjctCd=" + encodeURIComponent(prjctCd) + "&sid=" + encodeURIComponent(sid),
|
||||
getContactUrl(isTest) + "/list-external/update?prjctCd=" + encodeURIComponent(prjctCd) + "&sid=" + encodeURIComponent(sid),
|
||||
JSON.stringify(refinedMap),
|
||||
{
|
||||
contentType: "application/json",
|
||||
|
||||
@@ -101,9 +101,7 @@ kon.survey = (function () {
|
||||
|
||||
var apiWaits = [];
|
||||
if (nextinput.val() === "END") {
|
||||
var isKiwi = 1;
|
||||
var kartRequestUrl = "https://rapi.kric.com/api/v1/project/derived/"+isKiwi+"/"+kon.survey.PKEY+"/"+kon.survey.IDKEY;
|
||||
apiWaits.push(callLoggedApi(kartRequestUrl, "DERIVED", kon.survey.IDKEY, "", ""));
|
||||
apiWaits.push(callKartDerived(kon.survey.PKEY, kon.survey.IDKEY));
|
||||
}
|
||||
|
||||
if (surveyType === "LIST") {
|
||||
@@ -193,6 +191,41 @@ kon.survey = (function () {
|
||||
});
|
||||
}
|
||||
|
||||
function callKartDerived(pkey, idkey) {
|
||||
var url = KART_BASE_URL
|
||||
+ "/project/" + KART_PROJECT_TYPE
|
||||
+ "/" + encodeURIComponent(pkey)
|
||||
+ "/derived/respondent/" + encodeURIComponent(idkey)
|
||||
+ "/recalculate";
|
||||
|
||||
logExternalApi("DERIVED", idkey, "", "REQUEST", "");
|
||||
|
||||
return $.ajax({
|
||||
url: url,
|
||||
type: "POST",
|
||||
headers: {
|
||||
"X-API-Key": KON_KIWI_API_KEY
|
||||
},
|
||||
dataType: "json",
|
||||
cache: false,
|
||||
timeout: 60000,
|
||||
|
||||
success: function (data, status, xhr) {
|
||||
logExternalApi(
|
||||
"DERIVED", idkey, "", "SUCCESS",
|
||||
"HTTP " + xhr.status
|
||||
);
|
||||
},
|
||||
|
||||
error: function (xhr, status) {
|
||||
logExternalApi(
|
||||
"DERIVED", idkey, "", "FAIL",
|
||||
"HTTP " + xhr.status + " / " + status
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function callContactStatusApi(contactMappingList, idkey, statuses) {
|
||||
var allRequestsDone = $.Deferred();
|
||||
var mappingsLeft = contactMappingList.length;
|
||||
|
||||
Reference in New Issue
Block a user