Browse Source

Merge branch 'V20220630' into fix-2225

tags/v1.22.6.2^2
chenyifan01 3 years ago
parent
commit
a422a5ba7c
3 changed files with 34 additions and 17 deletions
  1. +8
    -0
      models/dataset.go
  2. +23
    -16
      public/home/home.js
  3. +3
    -1
      routers/home.go

+ 8
- 0
models/dataset.go View File

@@ -181,6 +181,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond {
if len(opts.DatasetIDs) > 0 {
subCon := builder.NewCond()
subCon = subCon.And(builder.In("dataset.id", opts.DatasetIDs))
subCon = generateFilterCond(opts, subCon)
cond = cond.Or(subCon)
}

@@ -460,5 +461,12 @@ func GetCollaboratorDatasetIdsByUserID(userID int64) []int64 {
_ = x.Table("dataset").Join("INNER", "collaboration", "dataset.repo_id = collaboration.repo_id and collaboration.mode>0 and collaboration.user_id=?", userID).
Cols("dataset.id").Find(&datasets)
return datasets
}

func GetTeamDatasetIdsByUserID(userID int64) []int64 {
var datasets []int64
_ = x.Table("dataset").Join("INNER", "team_repo", "dataset.repo_id = team_repo.repo_id").
Join("INNER", "team_user", "team_repo.team_id=team_user.team_id and team_user.uid=?", userID).
Cols("dataset.id").Find(&datasets)
return datasets
}

+ 23
- 16
public/home/home.js View File

@@ -74,28 +74,30 @@ var swiperOrg = new Swiper(".homeorg-list", {
},
});

var output = document.getElementById("newmessage");
var url = "ws://" + document.location.host + "/action/notification";
if(document.location.host == "git.openi.org.cn" || document.URL.startsWith("https")){
url = "wss://" + document.location.host + "/action/notification"
}
var socket = new WebSocket(url);

socket.onopen = function () {
messageQueue = [];
console.log("message has connected.");
};

var maxSize = 20;
var html =document.documentElement;
var lang = html.attributes["lang"]
var isZh = true;
if(lang != null && lang.nodeValue =="en-US" ){
isZh=false;
}else{
}

socket.onmessage = function (e) {
document.onreadystatechange = function () {
queryRecommendData();

var output = document.getElementById("newmessage");
var url = "ws://" + document.location.host + "/action/notification";
if(document.location.host == "git.openi.org.cn" || document.URL.startsWith("https")){
url = "wss://" + document.location.host + "/action/notification"
}
var socket = new WebSocket(url);
socket.onopen = function () {
messageQueue = [];
console.log("message has connected.");
};

socket.onmessage = function (e) {
var data =JSON.parse(e.data)
var html = "";
if (data != null){
@@ -176,7 +178,10 @@ socket.onmessage = function (e) {
output.innerHTML = html;
swiperNewMessage.updateSlides();
swiperNewMessage.updateProgress();
};
};
}



function getTaskLink(record){
var re = getRepoLink(record);
@@ -437,7 +442,9 @@ function getAction(opType,isZh){
}
}

queryRecommendData();




function queryRecommendData(){
$.ajax({


+ 3
- 1
routers/home.go View File

@@ -345,7 +345,9 @@ func ExploreDatasets(ctx *context.Context) {
var datasetsIds []int64
if ownerID > 0 {

datasetsIds = models.GetCollaboratorDatasetIdsByUserID(ownerID)
collaboratorDatasetsIds := models.GetCollaboratorDatasetIdsByUserID(ownerID)
teamDatasetsIds := models.GetTeamDatasetIdsByUserID(ownerID)
datasetsIds = append(collaboratorDatasetsIds, teamDatasetsIds...)
}

opts := &models.SearchDatasetOptions{


Loading…
Cancel
Save