Browse Source

fix issue

tags/v1.22.8.2^2
zhoupzh 3 years ago
parent
commit
5a90cffcf9
2 changed files with 15 additions and 18 deletions
  1. +1
    -1
      templates/repo/datasets/reference.tmpl
  2. +14
    -17
      web_src/js/components/dataset/referenceDataset.vue

+ 1
- 1
templates/repo/datasets/reference.tmpl View File

@@ -2,7 +2,7 @@


<div class="repository"> <div class="repository">
{{template "repo/header" .}} {{template "repo/header" .}}
<div class="reference-dataset" data-repolink="{{.RepoLink}}"></div>
<div class="reference-dataset" data-repolink="{{.RepoLink}}" data-canwrite="{{.CanWrite}}" data-is-sign="{{$.IsSigned}}"></div>
<div id="reference-dataset"></div> <div id="reference-dataset"></div>
</div> </div>
{{template "base/footer" .}} {{template "base/footer" .}}

+ 14
- 17
web_src/js/components/dataset/referenceDataset.vue View File

@@ -18,6 +18,7 @@
<button <button
style="margin-right: 2rem" style="margin-right: 2rem"
class="ui green button" class="ui green button"
:class="{ disabled: !canWrite }"
@click="openDataset()" @click="openDataset()"
> >
{{ i18n.linked_datasets }} {{ i18n.linked_datasets }}
@@ -49,7 +50,7 @@
<div style="display: flex"> <div style="display: flex">
<button <button
class="ui mini basic button dataset-card-flavor" class="ui mini basic button dataset-card-flavor"
@click.stop="postStar(item)"
@click.stop="postStar(item, isSigned)"
> >
<i class="ri-heart-fill" style="color: #fa8c16"></i> <i class="ri-heart-fill" style="color: #fa8c16"></i>
<span style="margin-left: 0.3rem">{{ <span style="margin-left: 0.3rem">{{
@@ -65,7 +66,7 @@
<div style="display: flex"> <div style="display: flex">
<button <button
class="ui mini basic button dataset-card-flavor" class="ui mini basic button dataset-card-flavor"
@click.stop="postStar(item)"
@click.stop="postStar(item, isSigned)"
> >
<i class="ri-heart-line"></i> <i class="ri-heart-line"></i>
<span style="margin-left: 0.3rem">{{ <span style="margin-left: 0.3rem">{{
@@ -160,6 +161,7 @@
</span> </span>
<button <button
class="ui mini button" class="ui mini button"
:class="{ disabled: !canWrite }"
@click.stop="cancelReferData(item.ID, item.Title)" @click.stop="cancelReferData(item.ID, item.Title)"
> >
{{ i18n.disassociate }} {{ i18n.disassociate }}
@@ -380,6 +382,8 @@ export default {
currentPage: 1, currentPage: 1,
loadingLinkPage: false, loadingLinkPage: false,
loadingPublicPage: false, loadingPublicPage: false,
canWrite: true,
isSigned: false,
}; };
}, },
methods: { methods: {
@@ -388,7 +392,6 @@ export default {
this.selectDatasetArray.push({ ID: item.ID, Title: item.Title }); this.selectDatasetArray.push({ ID: item.ID, Title: item.Title });
return item.ID; return item.ID;
}); });
console.log("open");
this.dialogVisible = true; this.dialogVisible = true;
this.getDatasetList(); this.getDatasetList();
}, },
@@ -397,7 +400,6 @@ export default {
this.selectDatasetArray = []; this.selectDatasetArray = [];
}, },
gotoDataset(item) { gotoDataset(item) {
console.log(item);
location.href = `/${item.Repo.OwnerName}/${item.Repo.Name}/datasets`; location.href = `/${item.Repo.OwnerName}/${item.Repo.Name}/datasets`;
}, },
currentChange(page) { currentChange(page) {
@@ -414,16 +416,14 @@ export default {
this.$axios this.$axios
.delete(url) .delete(url)
.then((res) => { .then((res) => {
console.log(res);
if (res.data.Code === 0) { if (res.data.Code === 0) {
console.log("delete success");
this.$message.success(`取消${name}关联数据集成功!`); this.$message.success(`取消${name}关联数据集成功!`);
let index = this.datasetList.findIndex((item) => { let index = this.datasetList.findIndex((item) => {
return item.ID === id; return item.ID === id;
}); });
this.datasetList.splice(index, 1); this.datasetList.splice(index, 1);
} else { } else {
this.$message.error(`取消关联数据集失败!`);
this.$message.error(res.data.Message);
} }
}) })
.catch((err) => { .catch((err) => {
@@ -436,7 +436,6 @@ export default {
this.dialogVisible = false; this.dialogVisible = false;
}, },
changeCheckbox(checked, item) { changeCheckbox(checked, item) {
console.log(checked, item, this.checkList);
if (checked) { if (checked) {
this.selectDatasetArray.push({ ID: item.ID, Title: item.Title }); this.selectDatasetArray.push({ ID: item.ID, Title: item.Title });
} else { } else {
@@ -445,20 +444,19 @@ export default {
}); });
this.selectDatasetArray.splice(index, 1); this.selectDatasetArray.splice(index, 1);
} }
console.log(this.selectDatasetArray);
}, },
changeCheckSelected(checked, item) { changeCheckSelected(checked, item) {
console.log(checked, item);
if (!checked) { if (!checked) {
let index = this.selectDatasetArray.findIndex((element) => { let index = this.selectDatasetArray.findIndex((element) => {
return element.ID === item.ID; return element.ID === item.ID;
}); });
this.selectDatasetArray.splice(index, 1); this.selectDatasetArray.splice(index, 1);
} }
console.log(this.checkList, this.selectDatasetArray);
}, },
postStar(item) {
console.log(item);
postStar(item, isSigned) {
if (!isSigned) {
return;
}
if (item.IsStaring) { if (item.IsStaring) {
let url = `${this.repoLink}/datasets/${item.ID}/unstar`; let url = `${this.repoLink}/datasets/${item.ID}/unstar`;
this.$axios.put(url).then((res) => { this.$axios.put(url).then((res) => {
@@ -491,7 +489,6 @@ export default {
let url = `${this.repoLink}/datasets/reference_datasets_data`; let url = `${this.repoLink}/datasets/reference_datasets_data`;
this.$axios.get(url).then((res) => { this.$axios.get(url).then((res) => {
this.loadingLinkPage = false; this.loadingLinkPage = false;
console.log(res);
if (!res.data) { if (!res.data) {
this.showFlag = false; this.showFlag = false;
return; return;
@@ -501,7 +498,6 @@ export default {
? (this.showFlag = true) ? (this.showFlag = true)
: (this.showFlag = false); : (this.showFlag = false);
} }
console.log("this.getDatasetList:", this.datasetList, this.checkList);
}); });
}, },
getDatasetList() { getDatasetList() {
@@ -526,7 +522,6 @@ export default {
}, },
{ arrayFormat: "repeat" } { arrayFormat: "repeat" }
); );
console.log(data);
this.$axios this.$axios
.post(url, data) .post(url, data)
.then((res) => { .then((res) => {
@@ -534,7 +529,7 @@ export default {
this.$message.success(`关联数据集成功!`); this.$message.success(`关联数据集成功!`);
this.getSelectDatasetList(); this.getSelectDatasetList();
} else { } else {
this.$message.error(`关联数据集失败!`);
this.$message.error(res.data.Message);
} }
}) })
.catch((err) => { .catch((err) => {
@@ -571,6 +566,8 @@ export default {
}, },
created() { created() {
this.repoLink = $(".reference-dataset").data("repolink") || ""; this.repoLink = $(".reference-dataset").data("repolink") || "";
this.canWrite = $(".reference-dataset").data("canwrite");
this.isSigned = $(".reference-dataset").data("is-sign");
if (document.documentElement.attributes["lang"].nodeValue == "en-US") { if (document.documentElement.attributes["lang"].nodeValue == "en-US") {
this.i18n = this.$locale.US; this.i18n = this.$locale.US;
} else { } else {


Loading…
Cancel
Save