Skip to content

Commit 387de52

Browse files
author
hyun123
committed
2 parents b7fa648 + d7d75c9 commit 387de52

File tree

2 files changed

+111
-53
lines changed

2 files changed

+111
-53
lines changed

applicationFE/src/views/softwareCatalog/SoftwareCatalogList.vue

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</div>
1212
<div class="col-auto ms-auto">
1313
<div class="btn-list">
14-
<a class="btn btn-primary d-none d-sm-inline-block" data-bs-toggle="modal" data-bs-target="#modal-form">
14+
<a class="btn btn-primary d-none d-sm-inline-block" @click="onClickCreate" data-bs-toggle="modal" data-bs-target="#modal-form">
1515
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-plus" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
1616
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
1717
<path d="M12 5l0 14"></path>
@@ -48,8 +48,8 @@
4848
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" /><path d="M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" /><path d="M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" /></svg>
4949
</a>
5050
<div class="dropdown-menu dropdown-menu-end">
51-
<a class="dropdown-item" href="#">temp action - 1</a>
52-
<a class="dropdown-item" href="#">temp action - 2</a>
51+
<a class="dropdown-item" @click="onClickUpdate(catalog.catalogIdx)" data-bs-toggle="modal" data-bs-target="#modal-form">Update</a>
52+
<!-- <a class="dropdown-item" href="#">temp action - 2</a> -->
5353
</div>
5454
</div>
5555
</div>
@@ -190,7 +190,7 @@
190190
</div>
191191
</div>
192192
</div>
193-
<SoftwareCatalogForm @get-list="_getSoftwareCatalogList"/>
193+
<SoftwareCatalogForm :mode="formMode" :catalog-idx="selectCatalogIdx" @get-list="_getSoftwareCatalogList"/>
194194
</div>
195195
</template>
196196
<script setup lang="ts">
@@ -216,6 +216,8 @@
216216
217217
const dockerHubSearchList = ref([] as any)
218218
const artifactHubSearch = ref([] as any)
219+
const selectCatalogIdx = ref(0 as number)
220+
const formMode = ref('new')
219221
220222
/**
221223
* @Title Life Cycle
@@ -243,8 +245,6 @@
243245
item.isShow = false;
244246
})
245247
catalogList.value = response.data;
246-
247-
console.log("catalogList.value : ", catalogList.value)
248248
} catch(error) {
249249
console.log(error)
250250
toast.error('데이터를 가져올 수 없습니다.')
@@ -253,7 +253,6 @@
253253
254254
const groupedData = (catalogRefData: any) => {
255255
return catalogRefData.reduce((acc:any, item:any) => {
256-
// item의 referenceType을 키로 사용
257256
if (!acc[item.referenceType]) {
258257
acc[item.referenceType] = [];
259258
}
@@ -321,7 +320,16 @@
321320
const goToPage = (url:string) => {
322321
window.open(url)
323322
}
324-
323+
324+
const onClickUpdate = (idx:number) => {
325+
formMode.value = "update";
326+
selectCatalogIdx.value = idx;
327+
}
328+
329+
const onClickCreate = () => {
330+
formMode.value = "new"
331+
selectCatalogIdx.value = 0;
332+
}
325333
326334
327335
</script>

applicationFE/src/views/softwareCatalog/components/softwareCatalogForm.vue

Lines changed: 95 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<h5 class="modal-title">Create New Software catalog</h5>
77
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
88
</div>
9-
<div class="modal-body">
9+
<div class="modal-body" style="max-height: calc(100vh - 200px);overflow-y: auto;">
1010
<div class="mb-3">
1111
<label class="form-label">Title</label>
1212
<input type="text" class="form-control" id="sc-title" name="title" placeholder="Application name" v-model="catalogDto.catalogTitle" />
@@ -22,11 +22,11 @@
2222
<div class="mb-3">
2323
<label class="form-label">Category</label>
2424
<select class="form-select" id="sc-category" v-model="catalogDto.catalogCategory">
25-
<option value="server" selected>SERVER</option>
26-
<option value="was">WAS</option>
27-
<option value="db">DB</option>
28-
<option value="util">UTIL</option>
29-
<option value="observability">OBSERVABILITY</option>
25+
<option value="SERVER" selected>SERVER</option>
26+
<option value="WAS">WAS</option>
27+
<option value="DB">DB</option>
28+
<option value="UTIL">UTIL</option>
29+
<option value="OBSERVABILITY">OBSERVABILITY</option>
3030
</select>
3131
</div>
3232
<div class="mb-3">
@@ -38,11 +38,13 @@
3838
<div class="mb-3">
3939
<label class="form-label">Reference</label>
4040
<select class="form-select" id="sc-reference-1" v-model="ref.referenceType">
41-
<option value="url" selected>URL</option>
42-
<option value="manifest">manifest</option>
43-
<option value="workflow">workflow</option>
44-
<option value="image">image</option>
45-
<option value="etc">etc</option>
41+
<option value="URL">URL</option>
42+
<option value="MANIFEST">MANIFEST</option>
43+
<option value="WORKFLOW">WORKFLOW</option>
44+
<option value="IMAGE">IMAGE</option>
45+
<option value="HOMEPAGE">HOMEPAGE</option>
46+
<option value="TAG">TAG</option>
47+
<option value="ETC">ETC</option>
4648
</select>
4749
</div>
4850
</div>
@@ -96,51 +98,84 @@
9698
import type { Repository } from '../../type/type';
9799
import { ref } from 'vue';
98100
import { useToast } from 'vue-toastification';
99-
import { createCatalog} from '@/api/softwareCatalog';
100-
import { onMounted } from 'vue';
101-
import { computed } from 'vue';
102-
import { watch } from 'vue';
101+
import { createCatalog } from '@/api/softwareCatalog';
102+
import { onMounted, watch, computed } from 'vue';
103+
import axios from 'axios'
104+
105+
/**
106+
* @Title Props / Emit
107+
*/
108+
interface Props {
109+
mode: String
110+
catalogIdx: Number
111+
}
103112
104113
const toast = useToast()
105114
const catalogDto = ref({} as any);
106115
const refData = ref([] as any)
107116
const files = ref([] as any)
108117
109-
const emit = defineEmits(['get-list'])
118+
const splitUrl = window.location.host.split(':');
119+
const baseUrl = window.location.protocol + '//' + splitUrl[0] + ':18084'
120+
// const baseUrl = "http://210.217.178.130:18084";
110121
122+
const emit = defineEmits(['get-list'])
123+
const props = defineProps<Props>()
124+
const catalogIdx = computed(() => props.catalogIdx);
125+
watch(catalogIdx, async () => {
126+
await setInit();
127+
});
111128
onMounted(async () => {
112129
await setInit()
113130
})
114131
115132
const setInit = async () => {
116-
console.log("setInit")
117-
catalogDto.value = {
118-
"catalogIdx": null,
119-
"catalogTitle": "",
120-
"catalogDescription": "",
121-
"catalogSummary": "",
122-
"catalogCategory": "",
123-
"catalogRefData": []
124-
}
125-
refData.value = [];
126-
refData.value.push(
127-
{
128-
"catalogRefIdx": null,
129-
"catalogIdx": null,
130-
"referncetIdx": null,
131-
"referenceValue": "",
132-
"referenceDescription": "",
133-
"referenceType": "url"
133+
console.log("setInit props.catalogIdx : ", props.catalogIdx)
134+
console.log("porps.mode : ", props.mode)
135+
if(props.mode == 'update') {
136+
await _getSoftwareCatalogDetail()
137+
} else {
138+
catalogDto.value = {
139+
"catalogIdx": null,
140+
"catalogTitle": "",
141+
"catalogDescription": "",
142+
"catalogSummary": "",
143+
"catalogCategory": "",
144+
"catalogRefData": []
134145
}
135-
)
146+
refData.value = [];
147+
refData.value.push(
148+
{
149+
"catalogRefIdx": null,
150+
"catalogIdx": null,
151+
"referncetIdx": 0,
152+
"referenceValue": "",
153+
"referenceDescription": "",
154+
"referenceType": "url"
155+
}
156+
)
157+
}
158+
}
159+
160+
const _getSoftwareCatalogDetail = async () => {
161+
try {
162+
const response = await axios.get(baseUrl + '/catalog/software/' + props.catalogIdx);
163+
console.log("response : ", response)
164+
165+
catalogDto.value = response.data
166+
refData.value = response.data.catalogRefData;
167+
} catch(error) {
168+
console.log(error)
169+
toast.error('데이터를 가져올 수 없습니다.')
170+
}
136171
}
137172
138173
const addRef = () => {
139174
console.log("addRef");
140175
refData.value.push({
141176
"catalogRefIdx": null,
142177
"catalogIdx": null,
143-
"referncetIdx": null,
178+
"referncetIdx": 0,
144179
"referenceValue": "",
145180
"referenceDescription": "",
146181
"referenceType": "url"
@@ -158,16 +193,31 @@ const handleFileChange = (event: any) => {
158193
}
159194
160195
const createSoftwareCatalog = async () => {
161-
const formData = new FormData();
162-
formData.append('iconFile', files.value);
163-
formData.append('catalogDto', catalogDto.value);
196+
if(props.mode == 'new') {
197+
const formData = new FormData();
198+
formData.append('iconFile', files.value);
199+
200+
catalogDto.value.catalogRefData = refData.value;
201+
formData.append('catalogDto', new Blob([JSON.stringify(catalogDto.value)], {
202+
type: 'application/json'
203+
}));
204+
205+
const response = await axios.post(baseUrl + '/catalog/software', formData, {
206+
headers: {
207+
'Content-Type': 'multipart/form-data'
208+
}
209+
});
210+
211+
if(response.data) {
212+
toast.success('등록되었습니다.')
213+
emit('get-list')
214+
} else {
215+
toast.error('등록 할 수 없습니다.')
216+
}
217+
} else {
218+
const response = await axios.put(baseUrl + '/catalog/software')
219+
}
164220
165-
const { data } = await createCatalog(formData);
166-
if (data)
167-
toast.success('등록되었습니다.')
168-
else
169-
toast.error('등록 할 수 없습니다.')
170-
emit('get-list')
171221
}
172222
173223
</script>

0 commit comments

Comments
 (0)