diff --git a/api/exporter/views.py b/api/exporter/views.py index d7b88d34..453da642 100644 --- a/api/exporter/views.py +++ b/api/exporter/views.py @@ -454,7 +454,8 @@ def check_starred(self, user, exporter, headers, repo_info): def get_csv(self, token): repo = f"{settings.ORGANIZATION}/exporterhub.io" - url = f"https://api.github.com/repos/{repo}/contents/contents/exporter_description.csv" + file = "exporter_description.csv" + url = f"https://api.github.com/repos/{repo}/contents/contents/{file}" result = requests.get(url, headers={'Content-Type':'application/json','Authorization': 'token ' + token}) data = result.json() csv_file = [] @@ -470,7 +471,7 @@ def get_csv(self, token): csv_file.append( [csv_detail[0], csv_detail[1], csv_detail[2]] ) - + content = { 'sha' : data['sha'], 'csv_file': csv_file @@ -479,21 +480,68 @@ def get_csv(self, token): return content elif result.status_code == 404: - return "GITHUB_URL_NON_EXISTED" - - def push_to_github(self, token, message, content, sha): - repo = f"{settings.ORGANIZATION}/exporterhub.io" - url = f"https://api.github.com/repos/{repo}/contents/contents/exporter_description.csv" + content = "" + return content + return "GITHUB_GET_REPO_ERROR" + + def push_to_github(self, token, message, exporter_id, name, description): + repo = f"{settings.ORGANIZATION}/exporterhub.io" + file = "exporter_description.csv" + url = f"https://api.github.com/repos/{repo}/contents/contents/{file}" + result = requests.get(url, headers={'Content-Type':'application/json','Authorization': 'token ' + token}) + data = result.json() + csv_file = [] + request_content = '' + count = 0 + + if result.status_code == 200: + content = base64.b64decode(data['content']).decode('utf-8') + details = [v for v in content.split('\n') if v] + for detail in details: + csv_detail = detail.split('"') + csv_detail = [v for v in csv_detail if v] + csv_detail = [v for v in csv_detail if ',' != v] + csv_detail = [v for v in csv_detail if ', ' != v] + csv_file.append( + [csv_detail[0], csv_detail[1], csv_detail[2]] + ) + for row in csv_file: + if row[0] == str(exporter_id): + if description: + request_content += f'"{row[0]}","{row[1]}","{description}"' + '\n' + count += 1 + else: + request_content += f'"{row[0]}","{row[1]}","{row[2]}"' + '\n' - contents = json.dumps({ - "message" : message, - "content" : content, - "sha" : sha - }) + if count == 0: + request_content += f'"{exporter_id}","{name}","{description}"' + '\n' + + content = base64.b64encode(request_content.encode('utf-8')).decode('utf-8') + contents = json.dumps({ + "message" : message, + "content" : content, + "sha" : data['sha'] + }) - requests.put(url, data=contents, headers={'Content-Type':'application/json','Authorization': 'token ' + token}) + result = requests.put(url, data=contents, headers={'Content-Type':'application/json','Authorization': 'token ' + token}) + return result + + elif result.status_code == 404: + request_content = '"exporter_id","exporter_name","description"' + '\n' + request_content += f'"{exporter_id}","{name}","{description}"' + '\n' + content = base64.b64encode(request_content.encode('utf-8')).decode('utf-8') + + contents = json.dumps({ + "message" : message, + "content" : content + }) + + result = requests.put(url, data=contents, headers={'Content-Type':'application/json','Authorization': 'token ' + token}) + + return result + @login_check def get(self, request, exporter_id): try: @@ -525,15 +573,18 @@ def get(self, request, exporter_id): else: forked_repository_url = None - get_csv = self.get_csv(github_token) - if get_csv == 'GITHUB_URL_NON_EXISTED': - return JsonResponse({'message': 'GITHUB_URL_NON_EXISTED'}, status=400) - - csv_file = get_csv['csv_file'] detail_description = '' - for row in csv_file: - if row[0] == str(exporter.id): - detail_description = row[2] + get_csv = self.get_csv(github_token) + + if get_csv == 'GITHUB_GET_REPO_ERROR': + return JsonResponse({'message': 'GITHUB_API_FAIL'}, status=400) + elif not get_csv: + detail_description = '' + else: + csv_file = get_csv['csv_file'] + for row in csv_file: + if row[0] == str(exporter.id): + detail_description = row[2] data = { 'exporter_id' : exporter.id, @@ -577,28 +628,28 @@ def post(self, request, exporter_id): return JsonResponse({'message':'FILL_THE_BLANK'}, status = 400) get_csv = self.get_csv(github_token) - if get_csv == 'GITHUB_URL_NON_EXISTED': - return JsonResponse({'message': 'GITHUB_URL_NON_EXISTED'}, status=400) + if get_csv == 'GITHUB_GET_REPO_ERROR': + return JsonResponse({'message': 'GITHUB_API_FAIL'}, status=400) + else: + result = self.push_to_github( + token = github_token, + message = message, + exporter_id = exporter.id, + name = exporter.name, + description = description, + ) + + if result.status_code == 201 or 200: + response = { + "exporter_id" : exporter.id, + "exporter_name" : exporter.name, + "description" : description + } + + return JsonResponse(response, status = 201) - request_content = '' - csv_file = get_csv['csv_file'] - for row in csv_file: - if row[0] == exporter.id: - return JsonResponse({'message':'EXIST_EXPORTER'}, status = 400) else: - request_content += f'"{row[0]}","{row[1]}","{row[2]}"' + '\n' - - request_content += f'"{exporter.id}","{exporter.name}","{description}"' - content = base64.b64encode(request_content.encode('utf-8')).decode('utf-8') - result = self.push_to_github(token=github_token, message=message, content=content, sha=get_csv['sha']) - - response = { - "exporter_id" : exporter.id, - "exporter_name" : exporter.name, - "description" : description - } - - return JsonResponse(response, status = 201) + return JsonResponse({'message':'GITHUB_API_ERROR'}, status=400) except KeyError: return JsonResponse({'message':'KEY_ERROR'}, status = 400) @@ -612,31 +663,27 @@ def patch(self, request, exporter_id): description = data["description"] message = f"{exporter.name} description update" - get_csv = self.get_csv(github_token) - if get_csv == 'GITHUB_URL_NON_EXISTED': - return JsonResponse({'message': 'GITHUB_URL_NON_EXISTED'}, status=400) - - request_content = '' - response_description = '' - csv_file = get_csv['csv_file'] - for row in csv_file: - if row[0] == str(exporter.id) and description: - row[2] = description - response_description = row[2] - request_content += f'"{row[0]}","{row[1]}","{row[2]}"' + '\n' - elif row[0] != str(exporter.id): - request_content += f'"{row[0]}","{row[1]}","{row[2]}"' + '\n' - - content = base64.b64encode(request_content.encode('utf-8')).decode('utf-8') - result = self.push_to_github(token=github_token, message=message, content=content, sha=get_csv['sha']) - - response = { - "exporter_id" : exporter.id, - "exporter_name" : exporter.name, - "description" : response_description, - } - - return JsonResponse(response, status = 200) + get_csv = self.get_csv(github_token) + if get_csv == 'GITHUB_GET_REPO_ERROR': + return JsonResponse({'message': 'GITHUB_API_FAIL'}, status=400) + else: + result = self.push_to_github( + token = github_token, + message = message, + exporter_id = exporter.id, + name = exporter.name, + description = description, + ) + if result.status_code == 200: + response = { + "exporter_id" : exporter.id, + "exporter_name" : exporter.name, + "description" : description + } + return JsonResponse(response, status = 200) + + else: + return JsonResponse({'message':'GITHUB_API_ERROR'}, status=400) except KeyError: return JsonResponse({'message':'KEY_ERROR'}, status = 400) @@ -711,7 +758,8 @@ def get(self, request, exporter_id): def code_to_github(self, app_name, file_name, token, content_type, content, file_type, sha, bf_file_name): repo = f"{settings.ORGANIZATION}/exporterhub.io" - url = f"https://api.github.com/repos/{repo}/contents/{bf_file_name}" + old_file_name = bf_file_name.strip('"') + url = f"https://api.github.com/repos/{repo}/contents/{old_file_name}" delete_content = json.dumps({'sha': sha, 'message': 'delete_old_file'}) delete = requests.delete(url, data=delete_content, headers={'Authorization': 'token ' + token, 'Content-Type':'application/vnd.github.v3+json'}) @@ -725,6 +773,11 @@ def code_to_github(self, app_name, file_name, token, content_type, content, file }) result = requests.put(create_url, data=contents, headers={'Authorization': 'token ' + token, 'Content-Type':'application/vnd.github.v3+json'}) + if result.status_code == 404: + return "GITHUB_REPO_API_ERROR" + + return result + else: create_url = f"https://api.github.com/repos/{repo}/contents/contents/{app_name}/{app_name}_{content_type}/{file_name}_{content_type}.{file_type}" contents = json.dumps({ @@ -769,14 +822,13 @@ def csv_to_github(self, app_name, file_name, token, content_type, content, file_ yaml_id = len(content_list) + 1 for i, detail in enumerate(content_list): - if detail[0] == file_id: + if detail[0] == f'"{file_id}"': bf_file_name = detail[2].strip() - content_list[i][1] = f"{content}" - content_list[i][2] = f'"./contents/{app_name}/{app_name}_{content_type}/{file_name}_{content_type}.{type[content_type]}", \n' + content_list[i][1] = f'"{content}"' + content_list[i][2] = f'"./contents/{app_name}/{app_name}_{content_type}/{file_name}_{content_type}.{type[content_type]}"' count += 1 if count == 0: - content_list.append([f'"0{yaml_id}","{content}", "./contents/{app_name}/{app_name}_{content_type}/{file_name}_{content_type}.{type[content_type]}", \n']) - + content_list.append([f'"0{yaml_id}","{content}", "./contents/{app_name}/{app_name}_{content_type}/{file_name}_{content_type}.{type[content_type]}",']) for each_content in content_list: response += ','.join(each_content) + '\n' contents = json.dumps( @@ -835,8 +887,8 @@ def post(self, request, exporter_id): file_sha = data['file_sha'] file_name = data["file_name"] - file_content = data["file_content"] - csv_desc = data["csv_desc"] + file_content = data["file_content"] + csv_desc = data["csv_desc"] if data["csv_desc"] else '-' csv_sha = data['csv_sha'] file_id = data.get('file_id') @@ -856,10 +908,12 @@ def post(self, request, exporter_id): return JsonResponse({'message': 'KEY_ERROR'}, status=400) def code_file_delete(self, app_name, content_type, file_type, token, yaml_url): - repo = f"{settings.ORGANIZATION}/exporterhub.io" - yaml_url = yaml_url.strip() - url = f"https://api.github.com/repos/{repo}/contents/{yaml_url}" - data = requests.get(url, headers={'Content-Type': 'application/json', 'Authorization': 'token ' + token}) + repo = f"{settings.ORGANIZATION}/exporterhub.io" + yaml_urls = yaml_url.replace('"','') + yaml_urls = yaml_urls.strip() + url = f"https://api.github.com/repos/{repo}/contents/{yaml_urls}" + data = requests.get(url, headers={'Content-Type': 'application/json', 'Authorization': 'token ' + token}) + if data.status_code == 404: return 'FILE_NOT_EXISTING' @@ -907,7 +961,7 @@ def csv_file_delete(self, app_name, content_type, file_type, token, file_id): content_list.append(csv_contents) for i, detail in enumerate(content_list): - if detail[0] == file_id: + if detail[0] == f'"{file_id}"': yaml_url = detail[2] else: results.append([detail[0], detail[1], detail[2], '\n']) @@ -921,8 +975,8 @@ def csv_file_delete(self, app_name, content_type, file_type, token, file_id): if csv_delete == 404: return "GITHUB_REPO_API_ERROR" - - return csv_delete + + return {'result' : csv_delete, 'yaml_url' : yaml_url} for content in results: response += ','.join(content) diff --git a/api/exporter_list.csv b/api/exporter_list.csv index 7c0984b2..d90350fb 100644 --- a/api/exporter_list.csv +++ b/api/exporter_list.csv @@ -2,15 +2,18 @@ title,project_name,github_url,offcial,category, eBPF,eBPF Exporter,https://github.com/cloudflare/ebpf_exporter,0,Miscellaneous, Ceph,Ceph Exporter,https://github.com/digitalocean/ceph_exporter,0,Storage, Grok,Grok Exporter,https://github.com/fstab/grok_exporter,0,Logging, +cAdvisor,cAdvisor Exporter,https://github.com/google/cadvisor,0,Miscellaneous, RabbitMQ,RabbitMQ Exporter,https://github.com/kbudde/rabbitmq_exporter,0,Messaging, Kong API Gateway,Kong Prometheus Plugin,https://github.com/Kong/kong-plugin-prometheus,0,Software, kube-state-metrics,kube-state-metrics,https://github.com/kubernetes/kube-state-metrics,0,Miscellaneous, System Process,Process Exporter,https://github.com/ncabatoff/process-exporter,0,Miscellaneous, NGINX,NGINX Exporter,https://github.com/nginxinc/nginx-prometheus-exporter,0,HTTP, +NVIDIA GPU Monitoring Tools,NVIDIA GPU Monitoring Tools,https://github.com/NVIDIA/gpu-monitoring-tools,0,Hardware, Redis,Redis Metrics Exporter,https://github.com/oliver006/redis_exporter,0,Database, OpenStack,OpenStack Exporter,https://github.com/openstack-exporter/openstack-exporter,0,Miscellaneous, JSON,JSON Exporter,https://github.com/prometheus-community/json_exporter,0,Miscellaneous, Google Stackdriver,Google Stackdriver Exporter,https://github.com/prometheus-community/stackdriver_exporter,0,Monitoring, +Windows system,Windows Exporter,https://github.com/prometheus-community/windows_exporter,0,Hardware, Blackbox,Blackbox Exporter,https://github.com/prometheus/blackbox_exporter,1,Miscellaneous, CloudWatch,CloudWatch Exporter,https://github.com/prometheus/cloudwatch_exporter,1,Monitoring, Collectd,Collectd Exporter,https://github.com/prometheus/collectd_exporter,1,Monitoring, @@ -21,6 +24,7 @@ InfluxDB,InfluxDB Exporter,https://github.com/prometheus/influxdb_exporter,1,Dat JMX,JMX Exporter,https://github.com/prometheus/jmx_exporter,1,Monitoring, Memcached,Memcached Exporter,https://github.com/prometheus/memcached_exporter,1,Database, MySQL,MySQL Server Exporter,https://github.com/prometheus/mysqld_exporter,1,Database, +Node Exporter,Node Exporter,https://github.com/prometheus/node_exporter,1,Hardware, SNMP,SNMP Exporter,https://github.com/prometheus/snmp_exporter,1,Monitoring, Statsd,Statsd Exporter,https://github.com/prometheus/statsd_exporter,1,Monitoring, Azure,Azure Metrics Exporter,https://github.com/RobustPerception/azure_metrics_exporter,0,Monitoring, diff --git a/contents/Go-Client/Go-Client_helm/Go-Client_helm.csv b/contents/Go-Client/Go-Client_helm/Go-Client_helm.csv deleted file mode 100644 index 6268368a..00000000 --- a/contents/Go-Client/Go-Client_helm/Go-Client_helm.csv +++ /dev/null @@ -1 +0,0 @@ -"01","aa", "./contents/Go-Client/Go-Client_helm/aaa_helm.yaml", diff --git a/contents/Go-Client/Go-Client_helm/aaa_helm.yaml b/contents/Go-Client/Go-Client_helm/aaa_helm.yaml deleted file mode 100644 index 7c4a013e..00000000 --- a/contents/Go-Client/Go-Client_helm/aaa_helm.yaml +++ /dev/null @@ -1 +0,0 @@ -aaa \ No newline at end of file diff --git a/contents/MongoDB/MongoDB_alert/MongoDB_alert.csv b/contents/MongoDB/MongoDB_alert/MongoDB_alert.csv new file mode 100644 index 00000000..979fd7bd --- /dev/null +++ b/contents/MongoDB/MongoDB_alert/MongoDB_alert.csv @@ -0,0 +1 @@ +"01","test", "./contents/MongoDB/MongoDB_alert/ddddddtest_alert.yaml", diff --git a/contents/MongoDB/MongoDB_alert/ddddddtest_alert.yaml b/contents/MongoDB/MongoDB_alert/ddddddtest_alert.yaml new file mode 100644 index 00000000..f22eedbe --- /dev/null +++ b/contents/MongoDB/MongoDB_alert/ddddddtest_alert.yaml @@ -0,0 +1 @@ +tsssss \ No newline at end of file diff --git a/contents/MongoDB/MongoDB_helm/MongoDB_helm.csv b/contents/MongoDB/MongoDB_helm/MongoDB_helm.csv new file mode 100644 index 00000000..bf421ca8 --- /dev/null +++ b/contents/MongoDB/MongoDB_helm/MongoDB_helm.csv @@ -0,0 +1,5 @@ +"01","helm for deployment", "./contents/MongoDB/MongoDB_helm/deployment_helm.yaml", +"02","asdfasdf","./contents/MongoDB/MongoDB_helm/config_helm.yaml", +"03","ㄴ", "./contents/MongoDB/MongoDB_helm/v0.11.2_helm.yaml", +"04","a", "./contents/MongoDB/MongoDB_helm/deploysment v0.11.2_helm.yaml", +"05","-", "./contents/MongoDB/MongoDB_helm/deploysment v0.11.3_helm.yaml", diff --git a/contents/MongoDB/MongoDB_helm/config_helm.yaml b/contents/MongoDB/MongoDB_helm/config_helm.yaml new file mode 100644 index 00000000..c1704f9c --- /dev/null +++ b/contents/MongoDB/MongoDB_helm/config_helm.yaml @@ -0,0 +1 @@ +asdfasdfss1111ssss \ No newline at end of file diff --git a/contents/MongoDB/MongoDB_helm/deployment_helm.yaml b/contents/MongoDB/MongoDB_helm/deployment_helm.yaml new file mode 100644 index 00000000..29e3879b --- /dev/null +++ b/contents/MongoDB/MongoDB_helm/deployment_helm.yaml @@ -0,0 +1,3 @@ +# test + sdfsdfsdf + sdfsdfsss111 \ No newline at end of file diff --git a/contents/MongoDB/MongoDB_helm/deploysment v0.11.2_helm.yaml b/contents/MongoDB/MongoDB_helm/deploysment v0.11.2_helm.yaml new file mode 100644 index 00000000..2e65efe2 --- /dev/null +++ b/contents/MongoDB/MongoDB_helm/deploysment v0.11.2_helm.yaml @@ -0,0 +1 @@ +a \ No newline at end of file diff --git a/contents/MongoDB/MongoDB_helm/deploysment v0.11.3_helm.yaml b/contents/MongoDB/MongoDB_helm/deploysment v0.11.3_helm.yaml new file mode 100644 index 00000000..e69de29b diff --git a/contents/MongoDB/MongoDB_helm/v0.11.2_helm.yaml b/contents/MongoDB/MongoDB_helm/v0.11.2_helm.yaml new file mode 100644 index 00000000..57528489 --- /dev/null +++ b/contents/MongoDB/MongoDB_helm/v0.11.2_helm.yaml @@ -0,0 +1 @@ +ㄴ \ No newline at end of file diff --git a/contents/exporter_description.csv b/contents/exporter_description.csv index fc96d6d2..249e1086 100644 --- a/contents/exporter_description.csv +++ b/contents/exporter_description.csv @@ -1 +1,3 @@ -exporter_id,exporter_name,description +"exporter_id","exporter_name","description" +"41","MongoDB Exporter","test" +"6","Kong Prometheus Plugin","ㅁㄴㅇㄹㅁㄴㅇㄹㅁㄴㅇㄹㅁㄴㅇㄹ" diff --git a/src/components/ContentDetail/ContentDetail.js b/src/components/ContentDetail/ContentDetail.js index 05e0300f..2b553206 100644 --- a/src/components/ContentDetail/ContentDetail.js +++ b/src/components/ContentDetail/ContentDetail.js @@ -30,6 +30,15 @@ const ContentDetail = () => { 2: , 3: , }; + + const descriptionDecode = (description) => { + let descriptionDecodeValue = description + .replace(/@>@/g, "\n") + .replace(/@\$#/g, '"'); + + return descriptionDecodeValue; + }; + const TOKEN = sessionStorage.getItem("access_token"); useEffect(() => { window.scrollTo(0, 0); @@ -51,7 +60,7 @@ const ContentDetail = () => { setForkState(res.data.data.is_bucket); setStarState(res.data.data.is_star); setStarNumber(res.data.data.stars); - setDesState(res.data.data.detail_description); + setDesState(descriptionDecode(res.data.data.detail_description)); }) .catch((err) => { console.log(err); diff --git a/src/components/ContentDetail/components/ExporterTabCodeEditor.js b/src/components/ContentDetail/components/ExporterTabCodeEditor.js index 97f2ef1c..16d88e6f 100644 --- a/src/components/ContentDetail/components/ExporterTabCodeEditor.js +++ b/src/components/ContentDetail/components/ExporterTabCodeEditor.js @@ -41,6 +41,20 @@ const ExporterTabCodeEditor = ({ ); const [sameFileName, setSameFileName] = useState(false); + const descriptionEncode = (description) => { + let descriptionEncodeValue = JSON.stringify(description) + .replace(/\\n/g, "@>@") + .replace(/\\"/g, "@$#"); + return descriptionEncodeValue.slice(1).slice(0, -1); + }; + + const descriptionDecode = (description) => { + let descriptionDecodeValue = description + .replace(/@>@/g, "\n") + .replace(/@\$#/g, '"'); + return descriptionDecodeValue; + }; + useEffect(() => { dispatch( beforeEdittingExporterTab( @@ -91,12 +105,14 @@ const ExporterTabCodeEditor = ({ isSame = exporterCsv.filter( (file) => edittingExporterFile.fileName.toLowerCase() === - file.file_url - .slice( - file.file_url.lastIndexOf("/") + 1, - file.file_url.lastIndexOf("_") - ) - .toLowerCase() + descriptionDecode( + file.file_url + .slice( + file.file_url.lastIndexOf("/") + 1, + file.file_url.lastIndexOf("_") + ) + .toLowerCase() + ) ); } if (edittingExporterFile.fileName === "") { @@ -121,10 +137,10 @@ const ExporterTabCodeEditor = ({ data: { file_id: fileId, file_content: edittingExporterFile.content, - file_name: edittingExporterFile.fileName, + file_name: descriptionEncode(edittingExporterFile.fileName), file_sha: fileSha, csv_sha: csvSha, - csv_desc: edittingExporterFile.description, + csv_desc: descriptionEncode(edittingExporterFile.description), }, }) .then((res) => { @@ -171,7 +187,7 @@ const ExporterTabCodeEditor = ({ placeholder="Description" value={edittingExporterFile.description} cols="150" - rows="3" + rows="5" dark={changeTheme} onChange={handleFileInfo} /> diff --git a/src/components/ContentDetail/components/ExporterTabDataviewer.js b/src/components/ContentDetail/components/ExporterTabDataviewer.js index 86521434..58b749ad 100644 --- a/src/components/ContentDetail/components/ExporterTabDataviewer.js +++ b/src/components/ContentDetail/components/ExporterTabDataviewer.js @@ -45,6 +45,14 @@ const ExporterTabDataviewer = ({ csv_desc: "", }, ]; + + const descriptionDecode = (description) => { + let descriptionDecodeValue = description + .replace(/@>@/g, "\n") + .replace(/@\$#/g, '"'); + return descriptionDecodeValue; + }; + return ( <>
@@ -80,13 +88,15 @@ const ExporterTabDataviewer = ({ {emty === false && selectFileInfo.length !== 0 ? (

- {selectFileInfo[0].file_url.slice( - selectFileInfo[0].file_url.lastIndexOf("/") + 1 + {descriptionDecode( + selectFileInfo[0].file_url.slice( + selectFileInfo[0].file_url.lastIndexOf("/") + 1 + ) )}

-
+

Description

-

{selectFileInfo[0].csv_desc}

+ {descriptionDecode(selectFileInfo[0].csv_desc)}
{selectFileInfo[0].file_content} @@ -102,12 +112,14 @@ const ExporterTabDataviewer = ({ store.darkThemeReducer); const { id } = useParams(); + const descriptionEncode = (description) => { + let descriptionEncodeValue = JSON.stringify(description) + .replace(/\\n/g, "@>@") + .replace(/\\"/g, "@$#"); + return descriptionEncodeValue.slice(1).slice(0, -1); + }; + + const descriptionDecode = (description) => { + let descriptionDecodeValue = description + .replace(/@>@/g, "\n") + .replace(/@\$#/g, '"'); + return descriptionDecodeValue; + }; + const handleSave = () => { if (desState === "") { axios({ @@ -47,11 +61,11 @@ const OpenSourceInfo = ({ Authorization: sessionStorage.getItem("access_token"), }, data: { - description: editState, + description: descriptionEncode(editState), }, }) .then((res) => { - setDesState(res.data.description); + setDesState(descriptionDecode(res.data.description)); handleEdit(); }) .catch((err) => { @@ -65,11 +79,11 @@ const OpenSourceInfo = ({ Authorization: sessionStorage.getItem("access_token"), }, data: { - description: editState, + description: descriptionEncode(editState), }, }) .then((res) => { - setDesState(res.data.description); + setDesState(descriptionDecode(res.data.description)); handleEdit(); }) .catch((err) => { diff --git a/src/components/Sider/ExporterDetailTabList.js b/src/components/Sider/ExporterDetailTabList.js index d78d59a5..faf5ddef 100644 --- a/src/components/Sider/ExporterDetailTabList.js +++ b/src/components/Sider/ExporterDetailTabList.js @@ -56,6 +56,13 @@ const ExporterDetailTabList = ({ } }; + const descriptionDecode = (description) => { + let descriptionDecodeValue = description + .replace(/@>@/g, "\n") + .replace(/@\$#/g, '"'); + return descriptionDecodeValue; + }; + const handleSaveModal = () => { if (dontSaved) { setSaveEdit(true); @@ -142,9 +149,11 @@ const ExporterDetailTabList = ({
{exporterCsv.length !== 0 ? exporterCsv.map((file) => { - let github = file.file_url.slice( - file.file_url.lastIndexOf("/") + 1, - file.file_url.lastIndexOf("_") + let github = descriptionDecode( + file.file_url.slice( + file.file_url.lastIndexOf("/") + 1, + file.file_url.lastIndexOf("_") + ) ); return (