@@ -42,7 +42,7 @@ import {
42
42
Popup ,
43
43
Message ,
44
44
} from "semantic-ui-react" ;
45
- import { formatDataset } from "../../../../utils/formatter" ;
45
+ import { formatDataset , formatDatasetOuter } from "../../../../utils/formatter" ;
46
46
47
47
const DatasetCard = ( { dataset, recommender, toggleAI } ) => {
48
48
const datasetLink = `/#/datasets/${ dataset . _id } ` ;
@@ -100,9 +100,45 @@ const DatasetCard = ({ dataset, recommender, toggleAI }) => {
100
100
// api call to remove dataset
101
101
}
102
102
103
- function removeDatasetCard ( e ) {
103
+ // // ==================== chat api ====================
104
+ // async function postChats(experimentId) {
105
+ // // POST http://localhost:5080/chatapi/v1/chats
106
+ // // Content-Type: application/json
107
+
108
+ // // {
109
+ // // "title" : "Chat with experiment id 2",
110
+ // // "_experiment_id": "63f6e4987c5f93004a3e3ca8",
111
+ // // "_dataset_id": "63f6e4947c5f93004a3e3ca7"
112
+ // // }
113
+
114
+ // let data = await fetch("/chatapi/v1/chats", {
115
+ // method: "POST",
116
+ // headers: {
117
+ // "Content-Type": "application/json",
118
+ // },
119
+ // body: JSON.stringify({
120
+ // title: "ChatBox",
121
+ // _experiment_id: experimentId,
122
+ // _dataset_id: experiment.data._dataset_id,
123
+ // }),
124
+ // })
125
+ // .then((res) => res.json())
126
+ // .then((data) => {
127
+ // // console.log("postChats", data);
128
+ // return data;
129
+ // })
130
+ // .catch((err) => {
131
+ // // console.log("err--postChats",err);
132
+ // return err;
133
+ // });
134
+
135
+ // return data;
136
+ // }
137
+
138
+ // Removes a dataset card element from the DOM upon an event
139
+ async function removeDatasetCard ( e ) {
104
140
let parent = e . target . closest ( ".dataset-card" ) ;
105
- console . log ( parent ) ;
141
+ // console.log(parent);
106
142
parent . style . cssText += ";display:none!important;" ;
107
143
108
144
// find child which has <a> tag from the parent
@@ -115,17 +151,41 @@ const DatasetCard = ({ dataset, recommender, toggleAI }) => {
115
151
// and the last element is the dataset id
116
152
let dataset_id = href . split ( "/" ) . pop ( ) ;
117
153
154
+ await removeDatasetFiles ( dataset_id ) ;
155
+
118
156
console . log ( dataset_id ) ;
119
157
120
158
// api call to remove dataset
121
159
}
122
160
161
+ // api call to remove all files related to the data id
162
+ async function removeDatasetFiles ( dataset_id ) {
163
+ // api call to remove dataset files example
164
+ // /api/v1/datasets/63f6e4947c5f93004a3e3ca7
165
+
166
+ await fetch ( "/api/v1/datasets/" + dataset_id , {
167
+ method : "DELETE" ,
168
+ headers : {
169
+ "Content-Type" : "application/json" ,
170
+ } ,
171
+ } )
172
+ . then ( ( res ) => res . json ( ) )
173
+ . then ( ( data ) => {
174
+ console . log ( "removeDatasetFiles" , data ) ;
175
+ return data ;
176
+ } )
177
+ . catch ( ( err ) => {
178
+ console . log ( "err--removeDatasetFiles" , err ) ;
179
+ return err ;
180
+ } ) ;
181
+ }
182
+
123
183
function mouseEnterCardDelectButton ( e ) {
124
184
console . log ( "mouseoverCardDelectButton" ) ;
125
185
console . log ( e . target ) ;
126
186
127
187
// make the red boundary in the trash can emoji
128
- e . target . style . cssText += ";border: 0.5px solid red;" ;
188
+ e . target . style . cssText += ";border: 0.1px solid red;" ;
129
189
}
130
190
131
191
function mouseLeaveCardDelectButton ( e ) {
@@ -188,25 +248,26 @@ const DatasetCard = ({ dataset, recommender, toggleAI }) => {
188
248
< Header
189
249
as = "a"
190
250
inverted
191
- size = "large"
251
+ // size="large"
252
+ size = "medium"
192
253
icon = { icon_type }
193
- content = { formatDataset ( dataset . name ) }
254
+ content = { formatDatasetOuter ( dataset . name ) }
194
255
href = { datasetLink }
195
256
className = "title"
196
257
/>
197
258
}
198
259
/>
199
-
260
+ { /* <div style={{ display: "flex", justifyContent: "flex-end" }}> */ }
200
261
{ /* trash emoji */ }
201
- { /* <span
262
+ < span
202
263
className = "float-right"
203
264
onClick = { clickDatasetCardDelButton }
204
265
onMouseEnter = { mouseEnterCardDelectButton }
205
266
onMouseLeave = { mouseLeaveCardDelectButton }
206
267
style = { { cursor : "pointer" } }
207
268
>
208
269
🗑
209
- </span> */ }
270
+ </ span >
210
271
211
272
< span className = "float-right" >
212
273
< DatasetActions
@@ -215,6 +276,7 @@ const DatasetCard = ({ dataset, recommender, toggleAI }) => {
215
276
toggleAI = { toggleAI }
216
277
/>
217
278
</ span >
279
+ { /* </div> */ }
218
280
</ Segment >
219
281
}
220
282
position = "bottom right"
@@ -344,24 +406,25 @@ const DatasetCard = ({ dataset, recommender, toggleAI }) => {
344
406
< Header
345
407
as = "a"
346
408
inverted
347
- size = "large"
409
+ // size="large"
410
+ size = "medium"
348
411
icon = { icon_type }
349
- content = { formatDataset ( dataset . name ) }
412
+ content = { formatDatasetOuter ( dataset . name ) }
350
413
href = { datasetLink }
351
414
className = "title"
352
415
/>
353
416
}
354
417
/>
355
418
{ /* trash emoji */ }
356
- { /* <span
419
+ < span
357
420
className = "float-right"
358
421
onClick = { clickDatasetCardDelButton }
359
422
onMouseEnter = { mouseEnterCardDelectButton }
360
423
onMouseLeave = { mouseLeaveCardDelectButton }
361
424
style = { { cursor : "pointer" } }
362
425
>
363
426
🗑
364
- </span> */ }
427
+ </ span >
365
428
< span className = "float-right" >
366
429
< DatasetActions
367
430
dataset = { dataset }
0 commit comments