From 41be075ceb09dfb72e559cb47156056c54ae0945 Mon Sep 17 00:00:00 2001 From: dkjang Date: Wed, 4 Dec 2024 17:03:27 -0500 Subject: [PATCH 1/9] temp save --- .../researchPortal/ResearchSection.vue | 65 ++++ src/views/Debug/Template.vue | 342 +----------------- 2 files changed, 66 insertions(+), 341 deletions(-) diff --git a/src/components/researchPortal/ResearchSection.vue b/src/components/researchPortal/ResearchSection.vue index 4ec1c61c7..529231ca7 100644 --- a/src/components/researchPortal/ResearchSection.vue +++ b/src/components/researchPortal/ResearchSection.vue @@ -951,6 +951,9 @@ export default Vue.component("research-section", { this.queryGraphQl(query, this.dataPoint["url"], paramsString, paramsType, params) break; + case "openApi": + this.queryOpenApi(); + break; case "component": this.loadingDataFlag = "down"; break; @@ -991,6 +994,68 @@ export default Vue.component("research-section", { .catch(error => console.error('Error fetching GraphQL:', error)); }, + queryOpenApi() { + + async function fetchGraphQL(query) { + const response = await fetch('https://search.motrpac-data.org/search/api', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb3RycGFjX2RhdGFfaHViIiwiZXhwIjoxNzMxNzA4MjQ5fQ.eh7Htyt-Lj7SsXVqY5SyugIjIv9OT_XR6bjsHqAdCg8' + }, + body: JSON.stringify( query ), + }); + + if (!response.ok) { + throw new Error(`GraphQL request failed with status ${response.status}`); + } + + return response.json(); + } + + let Query = { + "ktype": "gene", + "keys": "TP53", + "omics": [ + "transcriptomics", + "proteomics" + ], + "filters": { + "assay": [], + "tissue": [] + }, + "fields": [ + "gene_symbol", + "feature_ID", + "tissue", + "assay", + "sex", + "comparison_group", + "logFC", + "logFC_se", + "p_value", + "adj_p_value", + "p_value_male", + "p_value_female" + ], + "unique_fields": [ + "tissue", + "assay" + ], + "size": 10000, + "start": 0, + "save": false + } + + fetchGraphQL(Query) + .then(data => { + + console.log(data) + //this.processLoadedApi(data, PARAM, TYPE, PARAMS); + }) + .catch(error => console.error('Error fetching GraphQL:', error)); + }, + async queryBioindex(QUERY, TYPE, PARAMS) { //console.log("PARAMS", PARAMS); diff --git a/src/views/Debug/Template.vue b/src/views/Debug/Template.vue index f1c5a3d03..ccaafd8e7 100644 --- a/src/views/Debug/Template.vue +++ b/src/views/Debug/Template.vue @@ -1,345 +1,5 @@ - From 5c810dfedce152ee1e2d3b7bdccb93272aea500a Mon Sep 17 00:00:00 2001 From: dkjang Date: Thu, 5 Dec 2024 16:16:42 -0500 Subject: [PATCH 2/9] temp save --- .../researchPortal/ResearchSection.vue | 72 +++++++++++++++++-- 1 file changed, 66 insertions(+), 6 deletions(-) diff --git a/src/components/researchPortal/ResearchSection.vue b/src/components/researchPortal/ResearchSection.vue index 529231ca7..3c89da449 100644 --- a/src/components/researchPortal/ResearchSection.vue +++ b/src/components/researchPortal/ResearchSection.vue @@ -914,6 +914,7 @@ export default Vue.component("research-section", { if (document.getElementById('tabUi' + this.sectionID)) { document.getElementById('tabUi' + this.sectionID).classList.add("loading"); } + let urlString, query, autoToken; switch (queryType) { case "bioindex": // Parameters type for BI is always 'array,' it doesn't need to pass paramsType and params @@ -928,7 +929,7 @@ export default Vue.component("research-section", { break; case "graphQl": // first added for CFDE project, to query data from IDG(pharos) - let urlString; + if (paramsType == "array") { urlString = this.dataPoint["query string"].replace("$parameter", paramsString) @@ -947,12 +948,43 @@ export default Vue.component("research-section", { }) } - let query = `${urlString}`; + query = `${urlString}`; this.queryGraphQl(query, this.dataPoint["url"], paramsString, paramsType, params) break; case "openApi": - this.queryOpenApi(); + + /*if (paramsType == "array") { + urlString = this.dataPoint["body"].replace("$parameter", paramsString) + } else if (paramsType == "replace to field") { + + urlString = this.dataPoint["body"] + + params.map((param, pIndex) => { + let paramList = this.customList[param] + let replaceFrom = this.dataPoint["replace from"]; + let replaceTo = this.dataPoint["replace to"]; + + let paramValue = paramList.filter(item => item[replaceFrom] == paramsString.split(",")[pIndex])[0][replaceTo]; + + urlString = urlString.replace("$" + param, paramValue); + }) + }*/ + + //console.log(this.dataPoint["header"]); + + let header = this.dataPoint["header"]; + let body = this.dataPoint["body"]; + + console.log("params",params,paramsString); + body["keys"] = "TP53"; + + let paramStrArr = paramsString.split(","); + + /*params.map((param, pIndex) => { + }*/ + + this.queryOpenApi(header, body, this.dataPoint["url"], paramsString, paramsType, params); break; case "component": this.loadingDataFlag = "down"; @@ -994,14 +1026,42 @@ export default Vue.component("research-section", { .catch(error => console.error('Error fetching GraphQL:', error)); }, - queryOpenApi() { + queryOpenApi(HEADER,BODY, URL, PARAM, TYPE, PARAMS) { + + console.log(URL, PARAM, TYPE, PARAMS) + + //const query = QUERY; + + async function fetchApi(header,body) { + const response = await fetch(URL, { + method: 'POST', + headers: header, + body: JSON.stringify(body), + }); + + if (!response.ok) { + throw new Error(`Request failed with status ${response.status}`); + } + + return response.json(); + } + + fetchApi(HEADER,BODY) + .then(data => { + console.log(data); + this.processLoadedApi(data, PARAM, TYPE, PARAMS); + }) + .catch(error => console.error('Error fetching GraphQL:', error)); + }, + + /*queryOpenApi() { async function fetchGraphQL(query) { const response = await fetch('https://search.motrpac-data.org/search/api', { method: 'POST', headers: { 'Content-Type': 'application/json', - 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb3RycGFjX2RhdGFfaHViIiwiZXhwIjoxNzMxNzA4MjQ5fQ.eh7Htyt-Lj7SsXVqY5SyugIjIv9OT_XR6bjsHqAdCg8' + 'Authorization': 'bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb3RycGFjX2RhdGFfaHViIiwiZXhwIjoxNzM5NTc4MDY3fQ.ezIAP3qa_FGg0ZI5uoC79ay0xWwg6rmHrgEnxa6bvaU' }, body: JSON.stringify( query ), }); @@ -1055,7 +1115,7 @@ export default Vue.component("research-section", { }) .catch(error => console.error('Error fetching GraphQL:', error)); }, - +*/ async queryBioindex(QUERY, TYPE, PARAMS) { //console.log("PARAMS", PARAMS); From 3f90a01a4f8435d22945698eab2a1931fe70f077 Mon Sep 17 00:00:00 2001 From: dkjang Date: Fri, 6 Dec 2024 11:02:14 -0500 Subject: [PATCH 3/9] temp save --- .../researchPortal/ResearchSection.vue | 279 ++++++++++-------- 1 file changed, 154 insertions(+), 125 deletions(-) diff --git a/src/components/researchPortal/ResearchSection.vue b/src/components/researchPortal/ResearchSection.vue index 3c89da449..b717f3942 100644 --- a/src/components/researchPortal/ResearchSection.vue +++ b/src/components/researchPortal/ResearchSection.vue @@ -237,30 +237,51 @@ :regionZoom="regionZoom" :regionViewArea="regionViewArea" :region="regionParam" :starItems="starItems" @on-star="starColumn"> - - - - + + +
{ - let paramList = this.customList[param] - let replaceFrom = this.dataPoint["replace from"]; - let replaceTo = this.dataPoint["replace to"]; - - let paramValue = paramList.filter(item => item[replaceFrom] == paramsString.split(",")[pIndex])[0][replaceTo]; - - urlString = urlString.replace("$" + param, paramValue); - }) - }*/ - - //console.log(this.dataPoint["header"]); - let header = this.dataPoint["header"]; let body = this.dataPoint["body"]; - console.log("params",params,paramsString); - body["keys"] = "TP53"; - let paramStrArr = paramsString.split(","); - /*params.map((param, pIndex) => { - }*/ + params.map((param, pIndex) => { + for (const [key, value] of Object.entries(body)) { + if(value == '$'+param) { + body[key] = paramStrArr[pIndex]; + } + } + }) this.queryOpenApi(header, body, this.dataPoint["url"], paramsString, paramsType, params); break; @@ -1028,10 +1030,6 @@ export default Vue.component("research-section", { queryOpenApi(HEADER,BODY, URL, PARAM, TYPE, PARAMS) { - console.log(URL, PARAM, TYPE, PARAMS) - - //const query = QUERY; - async function fetchApi(header,body) { const response = await fetch(URL, { method: 'POST', @@ -1048,79 +1046,12 @@ export default Vue.component("research-section", { fetchApi(HEADER,BODY) .then(data => { - console.log(data); this.processLoadedApi(data, PARAM, TYPE, PARAMS); }) .catch(error => console.error('Error fetching GraphQL:', error)); }, - - /*queryOpenApi() { - - async function fetchGraphQL(query) { - const response = await fetch('https://search.motrpac-data.org/search/api', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'Authorization': 'bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJtb3RycGFjX2RhdGFfaHViIiwiZXhwIjoxNzM5NTc4MDY3fQ.ezIAP3qa_FGg0ZI5uoC79ay0xWwg6rmHrgEnxa6bvaU' - }, - body: JSON.stringify( query ), - }); - - if (!response.ok) { - throw new Error(`GraphQL request failed with status ${response.status}`); - } - - return response.json(); - } - - let Query = { - "ktype": "gene", - "keys": "TP53", - "omics": [ - "transcriptomics", - "proteomics" - ], - "filters": { - "assay": [], - "tissue": [] - }, - "fields": [ - "gene_symbol", - "feature_ID", - "tissue", - "assay", - "sex", - "comparison_group", - "logFC", - "logFC_se", - "p_value", - "adj_p_value", - "p_value_male", - "p_value_female" - ], - "unique_fields": [ - "tissue", - "assay" - ], - "size": 10000, - "start": 0, - "save": false - } - - fetchGraphQL(Query) - .then(data => { - - console.log(data) - //this.processLoadedApi(data, PARAM, TYPE, PARAMS); - }) - .catch(error => console.error('Error fetching GraphQL:', error)); - }, -*/ async queryBioindex(QUERY, TYPE, PARAMS) { - //console.log("PARAMS", PARAMS); - //console.log("QUERY", QUERY); - this.searched.push(QUERY); let dataUrl = this.dataPoint.url; @@ -1140,8 +1071,6 @@ export default Vue.component("research-section", { dataUrl = dataUrl + "query/" + this.dataPoint.index + "?q=" + QUERY; } - //console.log("dataUrl replaced", dataUrl); - let contentJson = await fetch(dataUrl).then((resp) => resp.json()); if (contentJson.error == null && !!Array.isArray(contentJson.data) && contentJson.data.length > 0) { @@ -1448,6 +1377,7 @@ export default Vue.component("research-section", { // often data is wrapped by multiple layers of wrappers let dataWrapper = this.dataPoint["data wrapper"]; + let dataWrappers = this.dataPoint["data wrappers"]; // process data by data type switch (this.dataPoint["data type"]) { @@ -1480,6 +1410,107 @@ export default Vue.component("research-section", { case "line json": data = CONTENT; + break; + case "json lines": + if (!!dataWrapper) { + + let tempData = [] + + let dataEntity = CONTENT; + dataWrapper["headers"].map(w => { + dataEntity = dataEntity[w]; + }) + + let headers = dataEntity; + + dataEntity = CONTENT; + + dataWrapper["data"].map(w => { + dataEntity = dataEntity[w]; + }) + + dataEntity.map(item,itemIndex => { + let tempObj = {} + + item.map((column, columnIndex) => { + tempObj[headers[columnIndex]] = column; + }) + + tempData.push(tempObj); + }) + + data = tempData; + + } else if (!!dataWrappers){ + + let tempData = [] + let headers = []; + + + dataWrappers.map(dataWrapper => { + + let dataEntity = CONTENT; + + dataWrapper["headers"].map(w => { + dataEntity = dataEntity[w]; + }) + + headers = headers.concat(dataEntity); + + }) + + let uniqHeaders = [...new Set(headers)]; + + uniqHeaders.push("stamp") + + + dataWrappers.map(dataWrapper => { + + let dataEntity = CONTENT; + dataWrapper["headers"].map(w => { + + dataEntity = dataEntity[w]; + }) + + let tempHeaders = dataEntity; + + dataEntity = CONTENT; + + dataWrapper["data"].map(w => { + dataEntity = dataEntity[w]; + }) + + dataEntity.map((item,itemIndex) => { + let tempObj = {} + + item.map((column, columnIndex) => { + tempObj[headers[columnIndex]] = column; + }) + + tempObj["stamp"] = dataWrapper["stamp"]; + + tempData.push(tempObj); + }) + + }) + + let mergedData = []; + + tempData.map(d => { + let tempObj = {} + uniqHeaders.map(header => { + tempObj[header] = (!!d[header])? d[header]:""; + }) + + mergedData.push(tempObj); + }) + + data = mergedData; + + } else { + data = CONTENT; + } + break; case "csv": @@ -1629,7 +1660,6 @@ export default Vue.component("research-section", { /// 'checkbox' filter 'uncheck' filter gets applied here if(!!this.sectionConfig && !!this.sectionConfig.filters) { let chkboxFilters = this.sectionConfig.filters.filter( f => f.type == 'checkbox'); - console.log('chkboxFilters', chkboxFilters); let tempArr = [...new Set(this.sectionData)]; chkboxFilters.map( f =>{ @@ -1657,7 +1687,6 @@ export default Vue.component("research-section", { } if (!!this.sectionConfig["after data load"]) { - //console.log('this.sectionConfig["after data load"]', this.sectionConfig["after data load"]) this.sectionConfig["after data load"].map(act => { switch (act.type) { From bbeacad12b394204c4eaa180049936ae7d4524eb Mon Sep 17 00:00:00 2001 From: dkjang Date: Mon, 9 Dec 2024 16:51:17 -0500 Subject: [PATCH 4/9] tabs with multiple datatables implemented --- .../researchPortal/ResearchSection.vue | 81 ++++++++++++++++--- 1 file changed, 68 insertions(+), 13 deletions(-) diff --git a/src/components/researchPortal/ResearchSection.vue b/src/components/researchPortal/ResearchSection.vue index b717f3942..c78b5f3b5 100644 --- a/src/components/researchPortal/ResearchSection.vue +++ b/src/components/researchPortal/ResearchSection.vue @@ -267,19 +267,35 @@
@@ -544,6 +560,45 @@ export default Vue.component("research-section", { }, }, methods: { + buildTabData(DATA,TAB) { + + let tabData = []; + + switch (TAB["group type"]) { + case "search": + + tabData = DATA.filter(d => d[TAB["group by"]] == TAB["group value"]) + break; + + case "search other than": + + tabData = DATA.filter(d => d[TAB["group by"]] != TAB["group value"]) + break; + + } + + return tabData; + }, + buildTabFormat(TABLE,TAB) { + + let tabFormat ={}; + + tabFormat["top rows"] = TAB["top rows"]; + + if(TABLE["column formatting"]) { + tabFormat["column formatting"] = TABLE["column formatting"]; + } + + if(TAB["features"]) { + tabFormat["features"] = TABLE["features"]; + + TABLE["features"].map(feature => { + tabFormat[feature] = TAB[feature] + }) + } + + return tabFormat; + }, meetRequirements() { let required = this.sectionConfig['required parameters to display']; let meetRequired = true; From 62ca97d8fdf07398ed82a7cb4303c40e514f3269 Mon Sep 17 00:00:00 2001 From: dkjang Date: Tue, 10 Dec 2024 09:09:45 -0500 Subject: [PATCH 5/9] multi tab data tables completed --- src/components/researchPortal/ResearchSection.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/researchPortal/ResearchSection.vue b/src/components/researchPortal/ResearchSection.vue index c78b5f3b5..e6342d224 100644 --- a/src/components/researchPortal/ResearchSection.vue +++ b/src/components/researchPortal/ResearchSection.vue @@ -271,8 +271,9 @@
- {{ utils.Formatters.replaceWithParams(tab['header'], pageParams) }} + 'tableContent' + sectionID + tab['id'], 'tableContentGroup' + sectionID, false)" + v-html="utils.Formatters.replaceWithParams(tab['header'], pageParams)" + >
From a3eb93772325ebdee6648e8ea192c43553004413 Mon Sep 17 00:00:00 2001 From: dkjang Date: Tue, 10 Dec 2024 14:41:38 -0500 Subject: [PATCH 6/9] Subsection type "api" added. --- .../researchPortal/ResearchDataTable.vue | 117 +++++++++++++++++- src/utils/dataConvert.js | 9 +- 2 files changed, 122 insertions(+), 4 deletions(-) diff --git a/src/components/researchPortal/ResearchDataTable.vue b/src/components/researchPortal/ResearchDataTable.vue index 2510b90af..c7c5d8384 100644 --- a/src/components/researchPortal/ResearchDataTable.vue +++ b/src/components/researchPortal/ResearchDataTable.vue @@ -812,10 +812,12 @@ export default Vue.component("research-data-table", { // Parameters type for BI is always 'array,' it doesn't need to pass paramsType and params this.queryBioindex(paramsString, paramsType, params, dataPoint, tableFormat,INDEX, KEY); break; - /*case "api": - this.queryApi(paramsString, paramsType, params); + case "api": + + console.log(paramsString, paramsType, params, dataPoint, tableFormat,KEY) + this.queryApi(paramsString, paramsType, params, dataPoint, tableFormat,INDEX, KEY); break; - case "file": + /*case "file": let parameter = this.dataPoint["parameter"] this.queryFile(parameter); break;*/ @@ -937,6 +939,115 @@ export default Vue.component("research-data-table", { //data = this.checkPreFilters(data) }, + async queryApi(QUERY, TYPE, PARAMS, DATA_POINT, TABLE_FORMAT, INDEX, KEY) { + + console.log(QUERY, TYPE, PARAMS, DATA_POINT, TABLE_FORMAT, INDEX, KEY); + + let dataUrl = DATA_POINT.url; + let fKEY = this.getRowID(KEY + QUERY + INDEX); + + if (TYPE == "replace") { + PARAMS.map((param, pIndex) => { + if (!!QUERY.split(",")[pIndex]) { + dataUrl = dataUrl.replace("$" + param, QUERY.split(",")[pIndex]); + } else { + dataUrl = dataUrl.replace("$" + param + ",", ''); + dataUrl = dataUrl.replace(",$" + param, ''); + dataUrl = dataUrl.replace("$" + param, ''); + } + }) + + } + + this.subSectionLoading.push(fKEY); //start loading + try { + + let contentJson = await fetch(dataUrl).then((resp) => resp.json()); + + this.subSectionLoading.splice(this.subSectionLoading.indexOf(fKEY), 1); //finish loading + + if (contentJson) { + + let data = {} + if(!!DATA_POINT["data wrapper"]) { + + let dataEntity = contentJson; + + DATA_POINT["data wrapper"].map(w => { + + dataEntity = dataEntity[w]; + }) + + if (!Array.isArray(dataEntity)) { + dataEntity = [dataEntity]; + } + + data["data"] = dataEntity; + + } else { + data["data"] = CONTENT + } + + this.processLoadedApi(data, QUERY, DATA_POINT, TABLE_FORMAT, INDEX, KEY); + } + + } catch (error) { + console.log(error); + } + + }, + + processLoadedApi(CONTENT, QUERY, DATA_POINT, TABLE_FORMAT, INDEX, KEY) { + + let data = CONTENT.data; + + console.log("data",data); + + // if loaded data is processed + let tableFormat = TABLE_FORMAT; + + if (!!tableFormat && !!tableFormat["data convert"]) { + let convertConfig = tableFormat["data convert"]; + data = this.utils.dataConvert.convertData(convertConfig, data, this.phenotypeMap); /// convert raw data + } + + // Apply pre-filters + + if(!!tableFormat["pre filters"]) { + + let tempArr = [...new Set(data)]; + + tableFormat["pre filters"].map(filter =>{ + + switch (filter.type) { + case 'filter out': + filter.values.map(v => { + tempArr = tempArr.filter(f => f[filter.field] != v); + }) + + break; + } + }) + + data = tempArr; + } + + // + + let tempObj = { + key: this.getRowID(KEY+QUERY+INDEX), + data: data + } + + this.subSectionData.push(tempObj); + + if (!!CONTENT.continuation) { + this.queryBiContinue(CONTENT.continuation, QUERY, DATA_POINT, TABLE_FORMAT, INDEX, KEY); + } + /* implement pre filters later */ + //data = this.checkPreFilters(data) + }, + ifSetParameterColumn(KEY){ if(!!this.tableFormat['column formatting'] && !!this.tableFormat['column formatting'][KEY] && !!this.tableFormat['column formatting'][KEY]['type'].includes('set parameter')) { diff --git a/src/utils/dataConvert.js b/src/utils/dataConvert.js index 84bc62118..d03d0b467 100644 --- a/src/utils/dataConvert.js +++ b/src/utils/dataConvert.js @@ -167,7 +167,6 @@ let convertData = function (CONVERT, DATA, PHENOTYPE_MAP) { break; case "raw": - let rawValue = (!!d[c["raw field"]]) ? d[c["raw field"]] : (!!c["if no value"]) ? c["if no value"] : null; if (d[c["raw field"]] === 0) { @@ -236,6 +235,14 @@ let convertData = function (CONVERT, DATA, PHENOTYPE_MAP) { d[c["field name"]] = tempObj[c["field name"]]; break; + case "boolean to string": + let value = d[c["raw field"]] === true || d[c["raw field"]] == 1 ? "true" : + d[c["raw field"]] === false || d[c["raw field"]] === 0 ? "false" : "" + + tempObj[c["field name"]] = value; + + break; + } }) return tempObj; From 4bfcebcbdd9369168f20e540d3b40d66c1bb7c0d Mon Sep 17 00:00:00 2001 From: dkjang Date: Thu, 12 Dec 2024 10:27:47 -0500 Subject: [PATCH 7/9] field_page_mode issue resolved. --- src/modules/hugeampkpncms.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/hugeampkpncms.js b/src/modules/hugeampkpncms.js index 6a5a2e72d..0c635013e 100644 --- a/src/modules/hugeampkpncms.js +++ b/src/modules/hugeampkpncms.js @@ -67,10 +67,10 @@ export default { "https://hugeampkpncms.org/view/rest/get_research_page_access?pageid=" + param.pageID ).then(resp => resp.json()); //check for cookie if dev mode - if(json[0].field_page_mode==='dev'){ + if (!!json[0].field_page_mode && json[0].field_page_mode === 'dev') { const cookieCheck = Vue.$cookies.get(`KPN_${param.pageID}`); //login if cookie exists - if(cookieCheck) context.dispatch("getResearchDevPage", {pageID: param.pageID, devID: cookieCheck.u, devPW: cookieCheck.p}); + if (cookieCheck) context.dispatch("getResearchDevPage", { pageID: param.pageID, devID: cookieCheck.u, devPW: cookieCheck.p }); } // set the data context.commit("setResearchMode", json); @@ -96,9 +96,9 @@ export default { "https://hugeampkpncms.org/view/rest/get_research_page_dev?pageid=" + param.pageID + "&&devid=" + param.devID + "&&devpw=" + param.devPW ).then(resp => resp.json()); //if login successful, and user wants to be remembered - if(json.length>0 && param.devCK){ + if (json.length > 0 && param.devCK) { //set cookie for 14 days - const cookieValues = {u: param.devID, p: param.devPW}; + const cookieValues = { u: param.devID, p: param.devPW }; Vue.$cookies.set(`KPN_${param.pageID}`, cookieValues, "14d");//14 days //30MIN } // set the data From 8b0df20d74d019004e94842e716f0c62f6e973c4 Mon Sep 17 00:00:00 2001 From: dkjang Date: Mon, 16 Dec 2024 09:09:33 -0500 Subject: [PATCH 8/9] BYOR a new option "sub to top" is added to "data convert" option --- src/utils/dataConvert.js | 45 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/utils/dataConvert.js b/src/utils/dataConvert.js index d03d0b467..e307a2d4b 100644 --- a/src/utils/dataConvert.js +++ b/src/utils/dataConvert.js @@ -80,6 +80,45 @@ let convertData = function (CONVERT, DATA, PHENOTYPE_MAP) { let cType = c.type; switch (cType) { + case "sub to top": + + let subList = d; + + if (!!c["sub path"]) { + c["sub path"].map(path => { + subList = subList[path]; + }) + } + + if (!!subList) { + let subRow; + + if (!!c["copy by"]) { + + switch (c["copy by"]) { + + case "condition": + + if (c["condition"]["type"] == "equal to") { + + subList.map(row => { + //console.log("field", row[c["condition"]["field"]], c["condition"]["value"]) + + if (row[c["condition"]["field"]] == c["condition"]["value"]) { + subRow = row + } + }) + } + + break; + } + } + + tempObj[c["field name"]] = subRow[c["raw field"]]; + } + + break; + case "join": tempObj[c["field name"]] = joinValues(c["fields to join"], c["join by"], d); d[c["field name"]] = tempObj[c["field name"]]; @@ -126,7 +165,6 @@ let convertData = function (CONVERT, DATA, PHENOTYPE_MAP) { case "calculate": - let calType = c["calculation type"]; switch (calType) { @@ -140,7 +178,8 @@ let convertData = function (CONVERT, DATA, PHENOTYPE_MAP) { let calcString = ""; c["expression"].map(e => { - let eValue = !!["+", "-", "*", "/", "(", ")"].includes(e) ? e : (typeof e === 'number') ? e : d[e]; + let eValue = !!["+", "-", "*", "/", "(", ")"].includes(e) ? e : (typeof e === 'number') ? e : + (!!tempObj[e] || tempObj[e] === 0) ? (tempObj[e] === 0) ? 0 : tempObj[e] : (d[e] === 0) ? 0 : d[e]; calcString += eValue; }); @@ -243,6 +282,8 @@ let convertData = function (CONVERT, DATA, PHENOTYPE_MAP) { break; + + } }) return tempObj; From 44273cdcde9fcf406b7011ff74d9801bb96b7557 Mon Sep 17 00:00:00 2001 From: dkjang Date: Mon, 16 Dec 2024 10:57:52 -0500 Subject: [PATCH 9/9] Data convert "split" updated --- src/utils/dataConvert.js | 56 +++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/utils/dataConvert.js b/src/utils/dataConvert.js index 4093b4250..22b730fe5 100644 --- a/src/utils/dataConvert.js +++ b/src/utils/dataConvert.js @@ -133,28 +133,42 @@ let convertData = function (CONVERT, DATA, PHENOTYPE_MAP) { let newFields = c["field name"]; let newFieldValues = []; - let string2Split = d[c["field to split"]]; - let loopIndex = 1; - c["split by"].map(s => { - - let [key, ...rest] = string2Split.split(s); - string2Split = rest.join(s) - - if (loopIndex < c["split by"].length) { - newFieldValues.push(key) - } else if (loopIndex = c["split by"].length) { - newFieldValues.push(key) - newFieldValues.push(rest.join(s)) - } - loopIndex++; - }) + let string2Split = (!!tempObj[c["field to split"]]) ? tempObj[c["field to split"]] : d[c["field to split"]]; + + //console.log('c["field name"]', c["field name"]); + + if (!!string2Split) { + let loopIndex = 1; + c["split by"].map(s => { + + let [key, ...rest] = string2Split.split(s); + string2Split = rest.join(s) + + if (loopIndex < c["split by"].length) { + newFieldValues.push(key) + } else if (loopIndex = c["split by"].length) { + newFieldValues.push(key) + newFieldValues.push(rest.join(s)) + } + loopIndex++; + }) + + //console.log("newFieldValues", newFieldValues); + + loopIndex = 0; + newFields.map(f => { + tempObj[f] = newFieldValues[loopIndex]; + d[f] = tempObj[f]; + + + + loopIndex++; + }) + + console.log(tempObj); + } + - loopIndex = 0; - newFields.map(f => { - tempObj[f] = newFieldValues[loopIndex]; - d[f] = tempObj[f]; - loopIndex++; - }) break;