You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

selectDataset.vue 39 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224
  1. <template>
  2. <div
  3. class="inline field"
  4. :class="{
  5. dataset_flex: confirmDatasetList && confirmFlag,
  6. required: required,
  7. margin_b_0: benchmarkNew,
  8. }"
  9. >
  10. <label
  11. v-if="benchmarkNew"
  12. class="label-fix-width"
  13. style="font-weight: normal"
  14. >{{ i18n.dataset_label }}</label
  15. >
  16. <label v-else>{{ i18n.dataset_label }}</label>
  17. <span
  18. :class="
  19. benchmarkNew === true ? 'dataset-train-span' : 'dataset-debug-span'
  20. "
  21. v-if="confirmDatasetList && confirmFlag"
  22. >
  23. <input type="hidden" name="attachment" :value="confirmDatasetList" />
  24. <input
  25. type="hidden"
  26. name="dataset_name"
  27. :value="confirmDatasetNameList"
  28. />
  29. <div class="multi-dataset-box">
  30. <span
  31. v-for="(item, index) in confirmChecklist"
  32. :key="index"
  33. class="select-dataset-label"
  34. :title="item"
  35. style="padding: 0.2rem 0"
  36. >{{ item }};
  37. </span>
  38. </div>
  39. </span>
  40. <span v-else>
  41. <input
  42. v-if="benchmarkNew"
  43. type="text"
  44. class="disabled"
  45. style="width: 48.5%"
  46. :placeholder="i18n.dataset_select_placeholder"
  47. required
  48. />
  49. <input
  50. v-else
  51. type="text"
  52. class="disabled"
  53. :required="required"
  54. :placeholder="i18n.dataset_select_placeholder"
  55. />
  56. </span>
  57. <el-button
  58. type="text"
  59. @click="openDataset"
  60. icon="el-icon-plus"
  61. :class="
  62. confirmFlag && confirmDatasetList
  63. ? 'select-dataset-button'
  64. : 'select-dataset-button-color'
  65. "
  66. >{{ i18n.dataset_select }}
  67. </el-button>
  68. <el-dialog
  69. :title="i18n.dataset_select"
  70. :visible.sync="dialogVisible"
  71. :width="dialogWidth"
  72. >
  73. <div class="ui icon input dataset-search-vue">
  74. <i
  75. class="search icon"
  76. style="cursor: pointer; pointer-events: auto"
  77. @click="searchName"
  78. ></i>
  79. <input
  80. type="text"
  81. :placeholder="i18n.dataset_search_placeholder"
  82. v-model="search"
  83. @keydown.enter.stop.prevent="searchName"
  84. />
  85. </div>
  86. <el-row>
  87. <el-col
  88. :span="17"
  89. style="
  90. padding-right: 1rem;
  91. border-right: 1px solid #f5f5f6;
  92. position: relative;
  93. "
  94. >
  95. <el-tabs v-model="activeName" @tab-click="handleClick">
  96. <!-- 当前项目的数据集 -->
  97. <el-tab-pane
  98. :label="i18n.dataset_current_repo"
  99. name="first"
  100. v-loading="loadingCurrent"
  101. >
  102. <el-row>
  103. <el-tree
  104. :data="currentDatasetList"
  105. ref="currentTree"
  106. highlight-current
  107. show-checkbox
  108. node-key="id"
  109. :default-expanded-keys="initCurrentTreeNode"
  110. :props="defaultProps"
  111. :index="20"
  112. accordion
  113. @check="onCheck"
  114. >
  115. <span slot-scope="{ node, data }" class="slot-wrap">
  116. <span v-if="data.parent" class="custom-tree-node">
  117. <el-tooltip v-if="data.Description" placement="top-start">
  118. <div slot="content" class="multiple-wrap">
  119. {{ data.Description }}
  120. </div>
  121. <span class="dataset-title dataset-nowrap"
  122. ><div class="dataset_flex">
  123. <span
  124. style="flex: inherit"
  125. class="dataset-nowrap"
  126. >{{ node.label }}</span
  127. >
  128. <img
  129. v-if="data.Recommend"
  130. style="margin-left: 0.4rem"
  131. src="/img/jian.svg"
  132. />
  133. </div>
  134. </span>
  135. </el-tooltip>
  136. <span v-else class="dataset-title dataset-nowrap"
  137. ><div class="dataset_flex">
  138. <span style="flex: inherit" class="dataset-nowrap">{{
  139. node.label
  140. }}</span>
  141. <img
  142. v-if="data.Recommend"
  143. style="margin-left: 0.4rem"
  144. src="/img/jian.svg"
  145. />
  146. </div>
  147. </span>
  148. <span
  149. class="dataset-repolink dataset-nowrap"
  150. @click.stop="return false;"
  151. >
  152. <i
  153. class="ri-links-line"
  154. style="color: #21ba45; margin-right: 0.3rem"
  155. :title="i18n.dataset_relate"
  156. v-if="
  157. '/' + data.Repo.OwnerName + '/' + data.Repo.Name !==
  158. repoLink
  159. "
  160. ></i>
  161. <a
  162. :href="
  163. '/' +
  164. data.Repo.OwnerName +
  165. '/' +
  166. data.Repo.Name +
  167. '/datasets'
  168. "
  169. target="_blank"
  170. :title="data.Repo.OwnerName + '/' + data.Repo.Alias"
  171. >{{ data.Repo.OwnerName }}/{{ data.Repo.Alias }}</a
  172. >
  173. </span>
  174. </span>
  175. <span v-else style="display: flex">
  176. <span class="dataset-nowrap" :title="node.label">
  177. {{ node.label }}
  178. </span>
  179. <span
  180. class="zip-loading"
  181. v-if="data.DecompressState === 2"
  182. >
  183. {{ i18n.dataset_unziping }}
  184. </span>
  185. <span
  186. class="unzip-failed"
  187. v-if="data.DecompressState === 3"
  188. >
  189. {{ i18n.dataset_unzip_failed }}
  190. </span>
  191. </span>
  192. </span>
  193. </el-tree>
  194. <div></div>
  195. </el-row>
  196. <div
  197. class="ui container"
  198. style="margin-top: 25px; text-align: center"
  199. >
  200. <el-pagination
  201. background
  202. @current-change="currentChangePage"
  203. :current-page="initCurrentPage"
  204. :page-size="5"
  205. layout="total, prev, pager, next"
  206. :total="totalNumCurrent"
  207. >
  208. </el-pagination>
  209. </div>
  210. </el-tab-pane>
  211. <!-- 我上传的数据集 -->
  212. <el-tab-pane
  213. :label="i18n.dataset_my_upload"
  214. name="second"
  215. v-loading="loadingMy"
  216. >
  217. <el-row>
  218. <el-tree
  219. :data="myDatasetList"
  220. ref="myTree"
  221. highlight-current
  222. show-checkbox
  223. node-key="id"
  224. :default-expanded-keys="initMyTreeNode"
  225. :props="defaultProps"
  226. :index="20"
  227. accordion
  228. @check="onCheck"
  229. >
  230. <span slot-scope="{ node, data }" class="slot-wrap">
  231. <span v-if="data.parent" class="custom-tree-node">
  232. <el-tooltip v-if="data.Description" placement="top-start">
  233. <div slot="content" class="multiple-wrap">
  234. {{ data.Description }}
  235. </div>
  236. <span class="dataset-title dataset-nowrap"
  237. ><div class="dataset_flex">
  238. <span
  239. style="flex: inherit"
  240. class="dataset-nowrap"
  241. >{{ node.label }}</span
  242. >
  243. <img
  244. v-if="data.Recommend"
  245. style="margin-left: 0.4rem"
  246. src="/img/jian.svg"
  247. />
  248. </div>
  249. </span>
  250. </el-tooltip>
  251. <span v-else class="dataset-title dataset-nowrap"
  252. ><div class="dataset_flex">
  253. <span style="flex: inherit" class="dataset-nowrap">{{
  254. node.label
  255. }}</span>
  256. <img
  257. v-if="data.Recommend"
  258. style="margin-left: 0.4rem"
  259. src="/img/jian.svg"
  260. />
  261. </div>
  262. </span>
  263. <span
  264. class="dataset-repolink dataset-nowrap"
  265. @click.stop="return false;"
  266. >
  267. <a
  268. :href="
  269. '/' +
  270. data.Repo.OwnerName +
  271. '/' +
  272. data.Repo.Name +
  273. '/datasets'
  274. "
  275. target="_blank"
  276. :title="data.Repo.OwnerName + '/' + data.Repo.Alias"
  277. >{{ data.Repo.OwnerName }}/{{ data.Repo.Alias }}</a
  278. >
  279. </span>
  280. </span>
  281. <span v-else style="display: flex">
  282. <span class="dataset-nowrap" :title="node.label">
  283. {{ node.label }}
  284. </span>
  285. <span
  286. class="zip-loading"
  287. v-if="data.DecompressState === 2"
  288. >
  289. {{ i18n.dataset_unziping }}
  290. </span>
  291. <span
  292. class="unzip-failed"
  293. v-if="data.DecompressState === 3"
  294. >
  295. {{ i18n.dataset_unzip_failed }}
  296. </span>
  297. </span>
  298. </span>
  299. </el-tree>
  300. <div></div>
  301. </el-row>
  302. <div
  303. class="ui container"
  304. style="margin-top: 25px; text-align: center"
  305. >
  306. <el-pagination
  307. background
  308. @current-change="myChangePage"
  309. :current-page="initMyPage"
  310. :page-size="5"
  311. layout="total, prev, pager, next"
  312. :total="totalNumMy"
  313. >
  314. </el-pagination>
  315. </div>
  316. </el-tab-pane>
  317. <!-- 公开的数据集 -->
  318. <el-tab-pane
  319. :label="i18n.dataset_public"
  320. name="third"
  321. v-loading="loadingPublic"
  322. >
  323. <el-row>
  324. <el-tree
  325. :data="publicDatasetList"
  326. ref="publicTree"
  327. highlight-current
  328. show-checkbox
  329. node-key="id"
  330. :default-expanded-keys="initPublicTreeNode"
  331. :props="defaultProps"
  332. :index="20"
  333. accordion
  334. @check="onCheck"
  335. >
  336. <span slot-scope="{ node, data }" class="slot-wrap">
  337. <span v-if="data.parent" class="custom-tree-node">
  338. <el-tooltip v-if="data.Description" placement="top-start">
  339. <div slot="content" class="multiple-wrap">
  340. {{ data.Description }}
  341. </div>
  342. <span class="dataset-title dataset-nowrap"
  343. ><div class="dataset_flex">
  344. <span
  345. style="flex: inherit"
  346. class="dataset-nowrap"
  347. >{{ node.label }}</span
  348. >
  349. <img
  350. v-if="data.Recommend"
  351. style="margin-left: 0.4rem"
  352. src="/img/jian.svg"
  353. />
  354. </div>
  355. </span>
  356. </el-tooltip>
  357. <span v-else class="dataset-title dataset-nowrap"
  358. ><div class="dataset_flex">
  359. <span style="flex: inherit" class="dataset-nowrap">{{
  360. node.label
  361. }}</span>
  362. <img
  363. v-if="data.Recommend"
  364. style="margin-left: 0.4rem"
  365. src="/img/jian.svg"
  366. />
  367. </div>
  368. </span>
  369. <span
  370. class="dataset-repolink dataset-nowrap"
  371. @click.stop="return false;"
  372. >
  373. <a
  374. :href="
  375. '/' +
  376. data.Repo.OwnerName +
  377. '/' +
  378. data.Repo.Name +
  379. '/datasets'
  380. "
  381. target="_blank"
  382. :title="data.Repo.OwnerName + '/' + data.Repo.Alias"
  383. >{{ data.Repo.OwnerName }}/{{ data.Repo.Alias }}</a
  384. >
  385. </span>
  386. </span>
  387. <span v-else style="display: flex">
  388. <span class="dataset-nowrap" :title="node.label">
  389. {{ node.label }}
  390. </span>
  391. <span
  392. class="zip-loading"
  393. v-if="data.DecompressState === 2"
  394. >
  395. {{ i18n.dataset_unziping }}
  396. </span>
  397. <span
  398. class="unzip-failed"
  399. v-if="data.DecompressState === 3"
  400. >
  401. {{ i18n.dataset_unzip_failed }}
  402. </span>
  403. </span>
  404. </span>
  405. </el-tree>
  406. <div></div>
  407. </el-row>
  408. <div
  409. class="ui container"
  410. style="margin-top: 25px; text-align: center"
  411. >
  412. <el-pagination
  413. background
  414. @current-change="publicChangePage"
  415. :current-page="initPublicPage"
  416. :page-size="5"
  417. layout="total, prev, pager, next"
  418. :total="totalNumPublic"
  419. >
  420. </el-pagination>
  421. </div>
  422. </el-tab-pane>
  423. <!-- 我点赞的数据集 -->
  424. <el-tab-pane
  425. :label="i18n.dataset_collected"
  426. name="four"
  427. v-loading="loadingFavorite"
  428. >
  429. <el-row>
  430. <el-tree
  431. :data="MyFavoriteDatasetList"
  432. ref="favoriteTree"
  433. highlight-current
  434. show-checkbox
  435. node-key="id"
  436. :default-expanded-keys="initFavoriteTreeNode"
  437. :props="defaultProps"
  438. :index="20"
  439. accordion
  440. @check="onCheck"
  441. >
  442. <span slot-scope="{ node, data }" class="slot-wrap">
  443. <span v-if="data.parent" class="custom-tree-node">
  444. <el-tooltip v-if="data.Description" placement="top-start">
  445. <div slot="content" class="multiple-wrap">
  446. {{ data.Description }}
  447. </div>
  448. <span class="dataset-title dataset-nowrap"
  449. ><div class="dataset_flex">
  450. <span
  451. style="flex: inherit"
  452. class="dataset-nowrap"
  453. >{{ node.label }}</span
  454. >
  455. <img
  456. v-if="data.Recommend"
  457. style="margin-left: 0.4rem"
  458. src="/img/jian.svg"
  459. />
  460. </div>
  461. </span>
  462. </el-tooltip>
  463. <span v-else class="dataset-title dataset-nowrap"
  464. ><div class="dataset_flex">
  465. <span style="flex: inherit" class="dataset-nowrap">{{
  466. node.label
  467. }}</span>
  468. <img
  469. v-if="data.Recommend"
  470. style="margin-left: 0.4rem"
  471. src="/img/jian.svg"
  472. />
  473. </div>
  474. </span>
  475. <span
  476. class="dataset-repolink dataset-nowrap"
  477. @click.stop="return false;"
  478. >
  479. <a
  480. :href="
  481. '/' +
  482. data.Repo.OwnerName +
  483. '/' +
  484. data.Repo.Name +
  485. '/datasets'
  486. "
  487. target="_blank"
  488. :title="data.Repo.OwnerName + '/' + data.Repo.Alias"
  489. >{{ data.Repo.OwnerName }}/{{ data.Repo.Alias }}</a
  490. >
  491. </span>
  492. </span>
  493. <span v-else style="display: flex">
  494. <span class="dataset-nowrap" :title="node.label">
  495. {{ node.label }}
  496. </span>
  497. <span
  498. class="zip-loading"
  499. v-if="data.DecompressState === 2"
  500. >
  501. {{ i18n.dataset_unziping }}
  502. </span>
  503. <span
  504. class="unzip-failed"
  505. v-if="data.DecompressState === 3"
  506. >
  507. {{ i18n.dataset_unzip_failed }}
  508. </span>
  509. </span>
  510. </span>
  511. </el-tree>
  512. <div></div>
  513. </el-row>
  514. <div
  515. class="ui container"
  516. style="margin-top: 25px; text-align: center"
  517. >
  518. <el-pagination
  519. background
  520. @current-change="favoriteChangePage"
  521. :current-page="initFavoritePage"
  522. :page-size="5"
  523. layout="total, prev, pager, next"
  524. :total="totalNumFavorite"
  525. >
  526. </el-pagination>
  527. </div>
  528. </el-tab-pane>
  529. </el-tabs>
  530. </el-col>
  531. <el-col
  532. :span="7"
  533. style="
  534. display: flex;
  535. flex-direction: column;
  536. height: 100%;
  537. right: 0;
  538. position: absolute;
  539. padding: 0 1.5rem;
  540. "
  541. >
  542. <div
  543. style="
  544. font-size: 14px;
  545. height: 40px;
  546. text-align: left;
  547. color: #0066ff;
  548. line-height: 40px;
  549. "
  550. >
  551. {{ i18n.dataset_selected }}
  552. </div>
  553. <div style="flex: 1; margin: 1.5rem 0; overflow-y: auto">
  554. <el-checkbox-group v-model="checkList">
  555. <el-checkbox
  556. v-for="(item, index) in selectDatasetArray"
  557. :key="index"
  558. :label="item.label"
  559. :title="item.label"
  560. @change="(checked) => changeCheckbox(checked, item)"
  561. ></el-checkbox>
  562. </el-checkbox-group>
  563. </div>
  564. <div style="text-align: end">
  565. <el-button
  566. @click.native="confirmDataset"
  567. size="small"
  568. style="
  569. background: #389e0d;
  570. color: #fff;
  571. border: 1px solid #389e0d;
  572. "
  573. >{{ i18n.dataset_ok }}</el-button
  574. >
  575. </div>
  576. </el-col>
  577. </el-row>
  578. </el-dialog>
  579. </div>
  580. </template>
  581. <script>
  582. const { _AppSubUrl, _StaticUrlPrefix, csrf } = window.config;
  583. export default {
  584. components: {},
  585. data() {
  586. return {
  587. defaultProps: {
  588. children: "Attachments",
  589. label: "label",
  590. },
  591. dialogWidth: "65%",
  592. dialogVisible: false,
  593. benchmarkNew: false,
  594. imageAddress: "",
  595. activeName: "first",
  596. search: "",
  597. required: true,
  598. i18n: {},
  599. type: 0,
  600. repoLink: "",
  601. selectDatasetArray: [],
  602. checkList: [],
  603. confirmChecklist: [],
  604. confirmDatasetList: "",
  605. confirmDatasetNameList: "",
  606. confirmFlag: false,
  607. saveStatusList: [],
  608. // 初始化已选择的数据集列表
  609. hasSelectDatasetList: [],
  610. //当前项目数据集页面配置的初始化
  611. initCurrentPage: 1,
  612. totalNumCurrent: 0,
  613. paramsCurrent: { page: 1, q: "" },
  614. currentDatasetList: [],
  615. loadingCurrent: false,
  616. initCurrentTreeNode: [],
  617. //我上传的数据集页面配置的初始化
  618. initMyPage: 1,
  619. totalNumMy: 0,
  620. paramsMy: { page: 1, q: "" },
  621. myDatasetList: [],
  622. loadingMy: false,
  623. initMyTreeNode: [],
  624. //公开的数据集页面配置的初始化
  625. initPublicPage: 1,
  626. totalNumPublic: 0,
  627. paramsPublics: { page: 1, q: "" },
  628. publicDatasetList: [],
  629. loadingPublic: false,
  630. initPublicTreeNode: [],
  631. //我点赞的数据集页面配置的初始化
  632. initFavoritePage: 1,
  633. totalNumFavorite: 0,
  634. MyFavoriteDatasetList: [],
  635. paramsFavorite: { page: 1, q: "" },
  636. loadingFavorite: false,
  637. initFavoriteTreeNode: [],
  638. };
  639. },
  640. methods: {
  641. openDataset() {
  642. this.dialogVisible = true;
  643. if (!this.confirmDatasetList) {
  644. this.confirmFlag = false;
  645. }
  646. this.getCurrentRepoDataset();
  647. },
  648. handleClick(tab, event) {
  649. this.search = "";
  650. if (tab.name == "first") {
  651. // this.paramsPublic.q = "";
  652. this.getCurrentRepoDataset();
  653. }
  654. if (tab.name == "second") {
  655. this.getMyUploadDataset();
  656. }
  657. if (tab.name == "third") {
  658. this.getPublicDataset();
  659. }
  660. if (tab.name == "four") {
  661. this.getMyFavoriteDataset();
  662. }
  663. },
  664. //tree 勾选触发事件
  665. onCheck(data, checkedInfo) {
  666. this.hasSelectDatasetList = [];
  667. if (
  668. this.selectDatasetArray.length === 0 ||
  669. this.selectDatasetArray.every((item) => item.id !== data.id)
  670. ) {
  671. if (
  672. this.selectDatasetArray.some((item) => {
  673. return item.label.split(".")[0] === data.label.split(".")[0];
  674. })
  675. ) {
  676. this.$refs[data.ref].setChecked(data.id, false, false);
  677. this.$message.warning(this.i18n.dataset_not_equal_file);
  678. } else if (this.selectDatasetArray.length === 5) {
  679. this.$refs[data.ref].setChecked(data.id, false, false);
  680. this.$message.error(this.i18n.dataset_most);
  681. } else {
  682. this.selectDatasetArray.push(data);
  683. }
  684. } else {
  685. let index = this.selectDatasetArray.findIndex((item) => {
  686. return item.id === data.id;
  687. });
  688. this.selectDatasetArray.splice(index, 1);
  689. }
  690. this.checkList = this.selectDatasetArray.map((item) => {
  691. return item.label;
  692. });
  693. this.saveStatusList = this.selectDatasetArray.map((item) => {
  694. return item.id;
  695. });
  696. },
  697. //已选择数据集checkbox group 勾选事件
  698. changeCheckbox(checked, data) {
  699. this.$refs.currentTree.setChecked(data.id, false, false);
  700. this.$refs.myTree.setChecked(data.id, false, false);
  701. this.$refs.publicTree.setChecked(data.id, false, false);
  702. this.$refs.favoriteTree.setChecked(data.id, false, false);
  703. let index = this.selectDatasetArray.findIndex((item) => {
  704. return item.id === data.id;
  705. });
  706. this.selectDatasetArray.splice(index, 1);
  707. this.saveStatusList.splice(index, 1);
  708. },
  709. tableHeaderStyle({ row, column, rowIndex, columnIndex }) {
  710. if (rowIndex === 0) {
  711. return "background:#f5f5f6;color:#606266";
  712. }
  713. },
  714. currentChangePage(val) {
  715. this.paramsCurrent.page = val;
  716. this.getCurrentRepoDataset();
  717. },
  718. myChangePage(val) {
  719. this.paramsMy.page = val;
  720. this.getMyUploadDataset();
  721. },
  722. publicChangePage(val) {
  723. this.paramsPublics.page = val;
  724. this.getPublicDataset();
  725. },
  726. favoriteChangePage(val) {
  727. this.paramsFavorite.page = val;
  728. this.getMyFavoriteDataset();
  729. },
  730. getCurrentRepoDataset() {
  731. this.loadingCurrent = true;
  732. let url = this.repoLink + "/datasets/current_repo_m";
  733. this.paramsCurrent.type = this.type;
  734. this.$axios
  735. .get(url, {
  736. params: this.paramsCurrent,
  737. })
  738. .then((res) => {
  739. this.loadingCurrent = false;
  740. let data = JSON.parse(res.data.data);
  741. this.currentDatasetList = this.transformeTreeData(
  742. data,
  743. "currentTree",
  744. this.paramsCurrent.page
  745. );
  746. this.initCurrentTreeNode = this.currentDatasetList[0]?.id
  747. ? [this.currentDatasetList[0].id]
  748. : [];
  749. this.totalNumCurrent = parseInt(res.data.count);
  750. let setCheckedKeysList = this.currentDatasetList.reduce(
  751. (pre, cur) => {
  752. cur.Attachments.forEach((item) => {
  753. if (
  754. this.saveStatusList.includes(item.id) ||
  755. this.hasSelectDatasetList.includes(item.id)
  756. ) {
  757. pre.push(item.id);
  758. }
  759. });
  760. return pre;
  761. },
  762. []
  763. );
  764. this.$refs.currentTree.setCheckedKeys(setCheckedKeysList);
  765. })
  766. .catch((error) => {
  767. this.loadingCurrent = false;
  768. console.log(error);
  769. });
  770. },
  771. getMyUploadDataset() {
  772. this.loadingMy = true;
  773. let url = this.repoLink + "/datasets/my_datasets_m";
  774. this.paramsMy.type = this.type;
  775. this.$axios
  776. .get(url, {
  777. params: this.paramsMy,
  778. })
  779. .then((res) => {
  780. this.loadingMy = false;
  781. let data = JSON.parse(res.data.data);
  782. this.myDatasetList = this.transformeTreeData(
  783. data,
  784. "myTree",
  785. this.paramsMy.page
  786. );
  787. this.initMyTreeNode = this.myDatasetList[0]?.id
  788. ? [this.myDatasetList[0].id]
  789. : [];
  790. this.totalNumMy = parseInt(res.data.count);
  791. let setCheckedKeysList = this.myDatasetList.reduce((pre, cur) => {
  792. cur.Attachments.forEach((item) => {
  793. if (this.saveStatusList.includes(item.id)) {
  794. pre.push(item.id);
  795. }
  796. });
  797. return pre;
  798. }, []);
  799. this.$refs.myTree.setCheckedKeys(setCheckedKeysList);
  800. })
  801. .catch((error) => {
  802. console.log(error);
  803. });
  804. },
  805. getPublicDataset() {
  806. this.loadingPublic = true;
  807. let url = this.repoLink + "/datasets/public_datasets_m";
  808. this.paramsPublics.type = this.type;
  809. this.$axios
  810. .get(url, {
  811. params: this.paramsPublics,
  812. })
  813. .then((res) => {
  814. this.loadingPublic = false;
  815. let data = JSON.parse(res.data.data);
  816. this.publicDatasetList = this.transformeTreeData(
  817. data,
  818. "publicTree",
  819. this.paramsPublics.page
  820. );
  821. this.initPublicTreeNode = this.publicDatasetList[0]?.id
  822. ? [this.publicDatasetList[0].id]
  823. : [];
  824. this.totalNumPublic = parseInt(res.data.count);
  825. let setCheckedKeysList = this.publicDatasetList.reduce((pre, cur) => {
  826. cur.Attachments.forEach((item) => {
  827. if (this.saveStatusList.includes(item.id)) {
  828. pre.push(item.id);
  829. }
  830. });
  831. return pre;
  832. }, []);
  833. this.$refs.publicTree.setCheckedKeys(setCheckedKeysList);
  834. })
  835. .catch((error) => {
  836. this.loadingPublic = false;
  837. console.log(error);
  838. });
  839. },
  840. getMyFavoriteDataset() {
  841. this.loadingFavorite = true;
  842. let url = this.repoLink + "/datasets/my_favorite_m";
  843. this.paramsFavorite.type = this.type;
  844. this.$axios
  845. .get(url, {
  846. params: this.paramsFavorite,
  847. })
  848. .then((res) => {
  849. this.loadingFavorite = false;
  850. let data = JSON.parse(res.data.data);
  851. this.MyFavoriteDatasetList = this.transformeTreeData(
  852. data,
  853. "favoriteTree",
  854. this.paramsFavorite.page
  855. );
  856. this.initFavoriteTreeNode = this.MyFavoriteDatasetList[0]?.id
  857. ? [this.MyFavoriteDatasetList[0].id]
  858. : [];
  859. this.totalNumFavorite = parseInt(res.data.count);
  860. let setCheckedKeysList = this.MyFavoriteDatasetList.reduce(
  861. (pre, cur) => {
  862. cur.Attachments.forEach((item) => {
  863. if (this.saveStatusList.includes(item.id)) {
  864. pre.push(item.id);
  865. }
  866. });
  867. return pre;
  868. },
  869. []
  870. );
  871. this.$refs.favoriteTree.setCheckedKeys(setCheckedKeysList);
  872. })
  873. .catch((error) => {
  874. this.loadingFavorite = false;
  875. console.log(error);
  876. });
  877. },
  878. transformeTreeData(data, ref, page) {
  879. return data.reduce((preParent, curParent) => {
  880. curParent.id = curParent.ID;
  881. curParent.disabled = true;
  882. curParent.parent = true;
  883. curParent.label = curParent.Title;
  884. let childrenData = curParent.Attachments.reduce(
  885. (preChild, curchild) => {
  886. curchild.id = curchild.UUID;
  887. if (curchild.DecompressState !== 1) {
  888. curchild.disabled = true;
  889. }
  890. curchild.ref = ref;
  891. curchild.label = curchild.Name;
  892. preChild.push(curchild);
  893. return preChild;
  894. },
  895. []
  896. );
  897. preParent.push(curParent);
  898. return preParent;
  899. }, []);
  900. },
  901. searchName() {
  902. if (this.activeName == "first") {
  903. this.paramsCurrent.q = this.search;
  904. this.paramsCurrent.page = 1;
  905. this.getCurrentRepoDataset();
  906. }
  907. if (this.activeName == "second") {
  908. this.paramsMy.q = this.search;
  909. this.paramsMy.page = 1;
  910. this.getMyUploadDataset();
  911. }
  912. if (this.activeName == "third") {
  913. this.paramsPublics.q = this.search;
  914. this.paramsPublics.page = 1;
  915. this.getPublicDataset();
  916. }
  917. if (this.activeName == "four") {
  918. this.paramsFavorite.q = this.search;
  919. this.paramsFavorite.page = 1;
  920. this.getMyFavoriteDataset();
  921. }
  922. return false;
  923. },
  924. confirmDataset() {
  925. this.confirmDatasetList = this.saveStatusList.join(";");
  926. this.confirmDatasetNameList = this.checkList.join(";");
  927. this.confirmChecklist = this.checkList;
  928. this.dialogVisible = false;
  929. this.confirmFlag = true;
  930. },
  931. setDialogWidth() {
  932. const cWidth = document.body.clientWidth;
  933. if (cWidth > 1600) {
  934. this.dialogWidth = "1200px";
  935. } else if (cWidth < 1600 && 1200 < cWidth) {
  936. this.dialogWidth = "1127px";
  937. } else if (992 < cWidth && cWidth < 1200) {
  938. this.dialogWidth = "993px";
  939. } else {
  940. this.dialogWidth = "723px";
  941. }
  942. },
  943. },
  944. watch: {
  945. search(val) {
  946. if (!val) {
  947. switch (this.activeName) {
  948. case "first": {
  949. this.paramsCurrent.q = val;
  950. this.getCurrentRepoDataset();
  951. break;
  952. }
  953. case "second": {
  954. this.paramsMy.q = val;
  955. this.getMyUploadDataset();
  956. break;
  957. }
  958. case "third": {
  959. this.paramsPublics.q = val;
  960. this.getPublicDataset();
  961. break;
  962. }
  963. case "four": {
  964. this.paramsFavorite.q = val;
  965. this.getMyFavoriteDataset();
  966. break;
  967. }
  968. default:
  969. console.log("error");
  970. }
  971. }
  972. },
  973. },
  974. mounted() {
  975. this.type = $(".cloudbrain-type").data("cloudbrain-type");
  976. this.repoLink = $(".cloudbrain-type").data("repo-link");
  977. if ($(".cloudbrain-type").data("dataset-uuid")) {
  978. this.hasSelectDatasetList = $(".cloudbrain-type")
  979. .data("dataset-uuid")
  980. .split(";");
  981. let hasSelectDatasetName = $(".cloudbrain-type")
  982. .data("dataset-name")
  983. .split(";");
  984. if (
  985. this.hasSelectDatasetList.length !== 0 &&
  986. hasSelectDatasetName[0] !== ""
  987. ) {
  988. this.saveStatusList = this.hasSelectDatasetList;
  989. this.checkList = hasSelectDatasetName;
  990. this.hasSelectDatasetList.forEach((item, index) => {
  991. this.selectDatasetArray.push({
  992. id: item,
  993. label: hasSelectDatasetName[index],
  994. });
  995. });
  996. }
  997. this.confirmDataset();
  998. }
  999. if (
  1000. location.href.indexOf("benchmark") !== -1 ||
  1001. location.href.indexOf("train-job") !== -1 ||
  1002. location.href.indexOf("inference") !== -1 ||
  1003. location.href.indexOf("modelsafety") !== -1
  1004. ) {
  1005. this.benchmarkNew = true;
  1006. }
  1007. if (
  1008. location.href.indexOf("modelarts/notebook/create") !== -1 ||
  1009. location.href.indexOf("/cloudbrain/create") !== -1
  1010. ) {
  1011. this.required = false;
  1012. }
  1013. window.onresize = () => {
  1014. return (() => {
  1015. this.setDialogWidth();
  1016. })();
  1017. };
  1018. },
  1019. created() {
  1020. this.setDialogWidth();
  1021. if (document.documentElement.attributes["lang"].nodeValue == "en-US") {
  1022. this.i18n = this.$locale.US;
  1023. } else {
  1024. this.i18n = this.$locale.CN;
  1025. }
  1026. },
  1027. };
  1028. </script>
  1029. <style scoped>
  1030. .header-wrapper {
  1031. background-color: #f5f5f6;
  1032. padding-top: 15px;
  1033. }
  1034. .image_text {
  1035. padding: 25px 0 55px 0;
  1036. }
  1037. #header {
  1038. position: relative;
  1039. top: -40px;
  1040. }
  1041. #success {
  1042. background-color: #5bb973;
  1043. color: white;
  1044. }
  1045. .text-over {
  1046. overflow: hidden;
  1047. text-overflow: ellipsis;
  1048. vertical-align: middle;
  1049. white-space: nowrap;
  1050. }
  1051. .image_title {
  1052. display: inline-block;
  1053. width: 80%;
  1054. cursor: default;
  1055. color: rgb(66, 98, 144);
  1056. }
  1057. .image_desc {
  1058. -webkit-line-clamp: 2;
  1059. -webkit-box-orient: vertical;
  1060. display: -webkit-box;
  1061. text-overflow: ellipsis;
  1062. overflow: hidden;
  1063. }
  1064. .heart-stroke {
  1065. stroke: #666;
  1066. stroke-width: 2;
  1067. fill: #fff;
  1068. }
  1069. .stars_active {
  1070. fill: #fa8c16 !important;
  1071. stroke: #fa8c16 !important;
  1072. }
  1073. /deep/ .el-dialog__body {
  1074. position: relative;
  1075. }
  1076. .el-tree {
  1077. max-height: 400px;
  1078. overflow-y: auto;
  1079. overflow-x: hidden;
  1080. position: relative;
  1081. cursor: default;
  1082. background: #fff;
  1083. color: #606266;
  1084. font-family: SourceHanSansSC-medium;
  1085. }
  1086. .custom-tree-node {
  1087. display: flex;
  1088. align-items: center;
  1089. justify-content: space-between;
  1090. }
  1091. .custom-tree-node .dataset-title {
  1092. font-size: 14px;
  1093. color: #101010;
  1094. font-weight: 600;
  1095. flex: 1;
  1096. }
  1097. .custom-tree-node .dataset-repolink {
  1098. flex: 1;
  1099. text-align: right;
  1100. font-size: 12px;
  1101. }
  1102. .el-tree /deep/ .el-tree-node__content {
  1103. height: 40px;
  1104. background-color: #f5f5f6;
  1105. }
  1106. .el-tree /deep/ .el-tree-node__children .el-tree-node__content {
  1107. height: 30px;
  1108. background-color: #fff;
  1109. line-height: 20px;
  1110. font-size: 12px;
  1111. }
  1112. /deep/ .el-checkbox-group .el-checkbox {
  1113. max-width: 100%;
  1114. min-width: 80%;
  1115. }
  1116. /deep/ .el-checkbox-group .el-checkbox .el-checkbox__label {
  1117. max-width: 100%;
  1118. overflow: hidden;
  1119. vertical-align: middle;
  1120. text-overflow: ellipsis;
  1121. }
  1122. .dataset-nowrap {
  1123. overflow: hidden;
  1124. text-overflow: ellipsis;
  1125. }
  1126. .slot-wrap {
  1127. flex: 1;
  1128. padding-right: 2rem;
  1129. max-width: 93%;
  1130. }
  1131. .multiple-wrap {
  1132. -webkit-line-clamp: 3;
  1133. -webkit-box-orient: vertical;
  1134. display: -webkit-box;
  1135. max-width: 400px;
  1136. overflow: hidden;
  1137. }
  1138. .unzip-failed {
  1139. margin-left: 1rem;
  1140. color: red;
  1141. }
  1142. .zip-loading {
  1143. margin-left: 1rem;
  1144. color: #fcca00;
  1145. }
  1146. .dataset-search-vue {
  1147. z-index: 9999;
  1148. position: absolute;
  1149. right: 31%;
  1150. height: 30px;
  1151. top: 6px;
  1152. }
  1153. .select-dataset-label {
  1154. max-width: 100%;
  1155. overflow: hidden;
  1156. text-overflow: ellipsis;
  1157. margin-right: 1rem;
  1158. white-space: nowrap;
  1159. }
  1160. .dataset_flex {
  1161. display: flex;
  1162. align-items: center;
  1163. }
  1164. .dataset-debug-span {
  1165. display: inline-block;
  1166. width: 50%;
  1167. margin-left: 0.3rem;
  1168. }
  1169. .dataset-train-span {
  1170. display: inline-block;
  1171. width: 48.5%;
  1172. margin-left: 0.3rem;
  1173. }
  1174. .margin_b_0 {
  1175. margin-bottom: 0 !important;
  1176. }
  1177. .select-dataset-button {
  1178. margin-left: 0.3rem;
  1179. color: #0366d6;
  1180. }
  1181. .select-dataset-button-color {
  1182. color: #0366d6;
  1183. }
  1184. .multi-dataset-box {
  1185. border: 1px solid rgba(34, 36, 38, 0.15);
  1186. padding: 0.678571em 1em;
  1187. border-radius: 0.285714rem;
  1188. background: rgb(255, 255, 255);
  1189. display: flex;
  1190. flex-direction: column;
  1191. }
  1192. @media screen and (min-width: 1200px) and (max-width: 1600px) {
  1193. .dataset-search-vue {
  1194. top: -36px;
  1195. }
  1196. }
  1197. @media screen and (min-width: 1200px) and (max-width: 1400px) {
  1198. .multiple-wrap {
  1199. max-width: 200px;
  1200. }
  1201. }
  1202. </style>