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.

referenceDataset.vue 12 kB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <div>
  3. <template v-if="showFlag">
  4. <div class="ui container">
  5. <div class="ui mobile reversed stackable grid">
  6. <div class="row" style="justify-content: space-between">
  7. <div class="ui blue small menu compact selectcloudbrain">
  8. <a class="item" :href="`${repoLink}/datasets`">当前数据集</a>
  9. <a
  10. class="active item"
  11. :href="`${repoLink}/datasets/reference_datasets`"
  12. >关联数据集</a
  13. >
  14. </div>
  15. <button
  16. style="margin-right: 3rem"
  17. class="ui green button"
  18. @click="openDataset()"
  19. >
  20. 关联数据集
  21. </button>
  22. </div>
  23. <div class="row">
  24. <div class="ui two cards" style="width: 100%">
  25. <div
  26. class="ui card refer-dataset-card"
  27. v-for="(item, index) in datasetList"
  28. :key="index"
  29. >
  30. <div class="content" style="border-bottom: none">
  31. <div class="refer-dataset-card-content">
  32. <div class="refer-dataset-card-title">
  33. <span
  34. :title="item.Title"
  35. class="nowrap"
  36. style="display: inline-block; max-width: 90%"
  37. >{{ item.Title }}</span
  38. ><img
  39. v-if="item.Recommend"
  40. src="/img/jian.svg"
  41. style="margin-left: 0.5rem"
  42. />
  43. </div>
  44. <template v-if="item.IsStaring">
  45. <div style="display: flex">
  46. <button
  47. class="ui mini basic button dataset-card-flavor"
  48. >
  49. <i class="ri-heart-fill" style="color: #fa8c16"></i>
  50. <span style="margin-left: 0.3rem">取消收藏</span>
  51. </button>
  52. <a class="ui mini basic button card-flavor-num">
  53. {{ item.NumStars }}
  54. </a>
  55. </div>
  56. </template>
  57. <template v-else>
  58. <div style="display: flex">
  59. <button
  60. class="ui mini basic button dataset-card-flavor"
  61. >
  62. <i class="ri-heart-line"></i>
  63. <span style="margin-left: 0.3rem">收藏</span>
  64. </button>
  65. <a class="ui mini basic button card-flavor-num">
  66. {{ item.NumStars }}
  67. </a>
  68. </div>
  69. </template>
  70. </div>
  71. <div style="font-size: 12px; margin-top: 5px">
  72. <a
  73. v-if="item.Category"
  74. :href="'/explore/datasets?category=' + item.Category"
  75. class="ui repo-topic label topic"
  76. >{{ item.Category }}</a
  77. >
  78. <a
  79. v-if="item.Task"
  80. :href="'/explore/datasets?task=' + item.Task"
  81. class="ui repo-topic label topic"
  82. >{{ item.Task }}</a
  83. >
  84. <a
  85. v-if="item.License"
  86. :href="'/explore/datasets?license=' + item.License"
  87. class="ui repo-topic label topic"
  88. >{{ item.License }}</a
  89. >
  90. </div>
  91. <div class="description card-flavor-desc">
  92. <p>{{ item.Description }}</p>
  93. </div>
  94. </div>
  95. <div class="extra content" style="border-top: none !important">
  96. <div style="display: flex; align-items: center">
  97. <a
  98. :href="'/' + item.Repo.OwnerName"
  99. :title="item.Repo.OwnerName"
  100. >
  101. <img
  102. class="ui avatar image"
  103. style="width: 22px; height: 22px"
  104. :src="'/user/avatar/' + item.Repo.OwnerName + '/-1'"
  105. />
  106. </a>
  107. <span
  108. style="
  109. color: #999999;
  110. font-size: 12px;
  111. margin-left: 0.5rem;
  112. "
  113. >{{ item.CreatedUnix | transformTimestamp }}</span
  114. >
  115. <span
  116. style="
  117. display: flex;
  118. align-items: center;
  119. justify-content: center;
  120. margin: 0 1rem;
  121. "
  122. title="引用次数"
  123. >
  124. <i class="ri-link"></i>
  125. <span
  126. style="
  127. color: #101010;
  128. font-size: 12px;
  129. margin-left: 0.2rem;
  130. "
  131. >{{ item.UseCount }}</span
  132. >
  133. </span>
  134. <span
  135. style="display: flex; align-items: center; flex: 1"
  136. title="下载次数"
  137. >
  138. <i class="ri-download-line"></i>
  139. <span
  140. style="
  141. color: #101010;
  142. font-size: 12px;
  143. margin-left: 0.2rem;
  144. "
  145. >{{ item.DownloadTimes }}</span
  146. >
  147. </span>
  148. <button class="ui mini button">取消关联</button>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </template>
  157. <template v-else>
  158. <div class="ui container">
  159. <div class="ui mobile reversed stackable grid">
  160. <div class="row" style="justify-content: space-between">
  161. <div class="ui blue small menu compact selectcloudbrain">
  162. <a class="item" :href="`${repoLink}/datasets`">当前数据集</a>
  163. <a
  164. class="active item"
  165. :href="`${repoLink}/datasets/reference_datasets`"
  166. >关联数据集</a
  167. >
  168. </div>
  169. <button class="ui green button" @click="openDataset()">
  170. 关联数据集
  171. </button>
  172. </div>
  173. </div>
  174. <div class="ui placeholder segment bgtask-none">
  175. <div class="ui icon header bgtask-header-pic"></div>
  176. <div class="bgtask-content-header">还未关联过数据集</div>
  177. <div class="bgtask-content">
  178. <div class="bgtask-content-txt">
  179. 您可以通过单击新建关联数据集按钮,将平台上公开数据集展示在这里。
  180. </div>
  181. <div class="bgtask-content-txt">
  182. 使用说明可以参考启智AI协作平台<a
  183. href="https://git.openi.org.cn/zeizei/OpenI_Learning"
  184. >小白训练营课程</a
  185. >
  186. </div>
  187. </div>
  188. </div>
  189. </div>
  190. </template>
  191. <el-dialog
  192. title="关联数据集"
  193. :visible.sync="dialogVisible"
  194. :width="dialogWidth"
  195. >
  196. <div class="ui icon input dataset-search-vue">
  197. <i
  198. class="search icon"
  199. style="cursor: pointer; pointer-events: auto"
  200. @click="searchName"
  201. ></i>
  202. <input
  203. type="text"
  204. placeholder="搜数据集名称/描述..."
  205. v-model="search"
  206. @keydown.enter.stop.prevent="searchName"
  207. />
  208. </div>
  209. <el-row>
  210. <el-col
  211. :span="17"
  212. style="
  213. padding-right: 1rem;
  214. border-right: 1px solid #f5f5f6;
  215. position: relative;
  216. "
  217. >
  218. <el-tabs v-model="activeName">
  219. <el-tab-pane label="公开数据集" name="first">
  220. <el-row>
  221. <el-checkbox-group v-model="checkList">
  222. <el-checkbox
  223. class="checkbox-list"
  224. label="复选框 A"
  225. ></el-checkbox>
  226. <el-checkbox label="复选框 B"></el-checkbox>
  227. <el-checkbox label="复选框 C"></el-checkbox>
  228. <el-checkbox label="禁用" disabled></el-checkbox>
  229. <el-checkbox label="选中且禁用" disabled></el-checkbox>
  230. </el-checkbox-group>
  231. </el-row>
  232. </el-tab-pane>
  233. </el-tabs>
  234. </el-col>
  235. </el-row>
  236. </el-dialog>
  237. </div>
  238. </template>
  239. <script>
  240. const { _AppSubUrl, _StaticUrlPrefix, csrf } = window.config;
  241. export default {
  242. components: {},
  243. data() {
  244. return {
  245. dialogWidth: "65%",
  246. dialogVisible: false,
  247. activeName: "first",
  248. repoLink: "",
  249. datasetList: [],
  250. test: false,
  251. checkList: [],
  252. publicDatasetList: [],
  253. showFlag: true,
  254. search: "",
  255. };
  256. },
  257. methods: {
  258. openDataset() {
  259. console.log("open");
  260. this.dialogVisible = true;
  261. },
  262. searchName() {},
  263. getDatasetList() {
  264. let url = `${this.repoLink}/datasets/reference_datasets_data`;
  265. this.$axios.get(url).then((res) => {
  266. this.datasetList = res.data;
  267. this.datasetList.length
  268. ? (this.showFlag = true)
  269. : (this.showFlag = false);
  270. console.log("this.getDatasetList:", this.datasetList);
  271. });
  272. },
  273. getSelectDatasetList() {
  274. let url = `${this.repoLink}/datasets/reference_datasets_available`;
  275. this.$axios.get(url).then((res) => {
  276. this.publicDatasetList = JSON.parse(res.data.data);
  277. console.log("this.publicDatasetList", this.publicDatasetList);
  278. });
  279. },
  280. },
  281. filters: {
  282. transformTimestamp(timestamp) {
  283. const date = new Date(parseInt(timestamp) * 1000);
  284. const Y = date.getFullYear() + "-";
  285. const M =
  286. (date.getMonth() + 1 < 10
  287. ? "0" + (date.getMonth() + 1)
  288. : date.getMonth() + 1) + "-";
  289. const D =
  290. (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
  291. const dateString = Y + M + D;
  292. return dateString;
  293. },
  294. },
  295. watch: {},
  296. mounted() {
  297. this.getDatasetList();
  298. this.getSelectDatasetList();
  299. },
  300. created() {
  301. this.repoLink = $(".reference-dataset").data("repolink") || "";
  302. },
  303. beforeDestroy() {},
  304. };
  305. </script>
  306. <style scoped>
  307. .dataset-search-vue {
  308. z-index: 9999;
  309. position: absolute;
  310. right: 31%;
  311. height: 30px;
  312. top: 60px;
  313. }
  314. .checkbox-list {
  315. display: flex;
  316. }
  317. .refer-dataset-card {
  318. cursor: pointer;
  319. box-shadow: 0px 4px 4px 0px rgba(232, 232, 232, 0.6);
  320. border: 1px solid rgba(232, 232, 232, 1);
  321. }
  322. .refer-dataset-card .refer-dataset-card-content {
  323. font-size: 16px;
  324. color: #0366d6;
  325. font-family: SourceHanSansSC-medium;
  326. height: 34px;
  327. font-weight: bold;
  328. display: flex;
  329. align-items: center;
  330. justify-content: space-between;
  331. }
  332. .refer-dataset-card-title {
  333. display: flex;
  334. align-items: center;
  335. max-width: 80%;
  336. width: 100%;
  337. }
  338. .dataset-card-flavor {
  339. display: flex;
  340. align-items: center;
  341. padding: 0.3rem 0.5rem;
  342. border: #888888;
  343. border-top-right-radius: 0 !important;
  344. border-bottom-right-radius: 0 !important;
  345. margin-right: -1px;
  346. }
  347. .card-flavor-num {
  348. padding: 0.5rem;
  349. border: #888888;
  350. border-top-left-radius: 0 !important;
  351. border-bottom-left-radius: 0 !important;
  352. }
  353. .card-flavor-desc {
  354. -webkit-box-orient: vertical;
  355. -webkit-line-clamp: 2;
  356. display: -webkit-box;
  357. overflow: hidden;
  358. color: #999999;
  359. font-size: 14px;
  360. margin-top: 10px;
  361. }
  362. </style>