Browse Source

update

tags/v1.22.6.1^2
liuzx 3 years ago
parent
commit
56bc38dc4b
3 changed files with 14 additions and 32 deletions
  1. +6
    -0
      models/cloudbrain.go
  2. +8
    -24
      routers/api/v1/repo/cloudbrain_dashboard.go
  3. +0
    -8
      routers/user/auth.go

+ 6
- 0
models/cloudbrain.go View File

@@ -330,6 +330,7 @@ type CloudbrainsOptions struct {
RepoIDList []int64
BeginTime time.Time
EndTime time.Time
ComputeResource string
}

type TaskPod struct {
@@ -1174,6 +1175,11 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) {
builder.Eq{"cloudbrain.job_id": opts.JobID},
)
}
if (opts.ComputeResource) != "" {
cond = cond.And(
builder.Eq{"cloudbrain.compute_resource": opts.ComputeResource},
)
}

if (opts.Type) >= 0 {
cond = cond.And(


+ 8
- 24
routers/api/v1/repo/cloudbrain_dashboard.go View File

@@ -280,21 +280,12 @@ func GetAllCloudbrainsTrend(ctx *context.Context) {
}

func GetAllCloudbrainsTrendDetail(ctx *context.Context) {
// brainRecordBeginTime, err := getBrainRecordBeginTime()
// if err != nil {
// log.Error("Can not get brain record begin time", err)
// ctx.Error(http.StatusBadRequest, ctx.Tr("repo.brain_record_begintime_get_err"))
// return
// }
// queryType := ctx.QueryTrim("type")
now := time.Now()
var beginTime time.Time
var endTime time.Time
var endTimeTemp time.Time
// dateCloudbrainNum := make([]DateCloudbrainNum, 0)

beginTime = now.AddDate(0, 0, -30) //
// beginTime = brainRecordBeginTime
beginTime = now.AddDate(0, 0, -30)
beginTime = time.Date(beginTime.Year(), beginTime.Month(), beginTime.Day(), 0, 0, 0, 0, now.Location())
endTime = now
endTimeTemp = endTime.AddDate(0, 0, -1)
@@ -313,16 +304,9 @@ func GetAllCloudbrainsTrendDetail(ctx *context.Context) {
if pagesize <= 0 {
pagesize = 5
}
// pager := context.NewPagination(len(dateCloudbrainNum), pagesize, page, 5)

pageDateCloudbrainNum := getPageDateCloudbrainNum(dayCloudbrainInfo, page, pagesize)

//load attachment creator
// for _, attachment := range pageAttachments {
// uploader, _ := models.GetUserByID(attachment.UploaderID)
// attachment.Uploader = uploader
// }

cloudbrainsPeriodData := TimeCloudbrainsNum{
TotalCount: 30,
TimeCloudbrainNum: pageDateCloudbrainNum,
@@ -465,16 +449,15 @@ func GetCloudbrainsDetailData(ctx *context.Context) {
listType := ctx.Query("listType")
jobType := ctx.Query("jobType")
jobStatus := ctx.Query("jobStatus")
cloudBrainType := ctx.QueryInt("Type")

page := ctx.QueryInt("page")
pageSize := ctx.QueryInt("pageSize")
if page <= 0 {
page = 1
}
debugType := models.TypeCloudBrainAll
if listType == models.GPUResource {
debugType = models.TypeCloudBrainOne
} else if listType == models.NPUResource {
debugType = models.TypeCloudBrainTwo
if pageSize <= 0 {
pageSize = 10
}

var jobTypes []string
@@ -501,10 +484,11 @@ func GetCloudbrainsDetailData(ctx *context.Context) {
ciTasks, count, err := models.Cloudbrains(&models.CloudbrainsOptions{
ListOptions: models.ListOptions{
Page: page,
PageSize: setting.UI.IssuePagingNum,
PageSize: pageSize,
},
Keyword: keyword,
Type: debugType,
Type: cloudBrainType,
ComputeResource: listType,
JobTypeNot: jobTypeNot,
JobStatusNot: jobStatusNot,
JobStatus: jobStatuses,


+ 0
- 8
routers/user/auth.go View File

@@ -176,9 +176,6 @@ func SignInCloudBrain(ctx *context.Context) {
ctx.HTML(200, tplSignInCloudBrain)
}




func SignInPostAPI(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("sign_in")
UserName := ctx.Query("UserName")
@@ -202,14 +199,11 @@ func SignInPostAPI(ctx *context.Context) {
ctx.HTML(200, tplSignIn)
return
}
log.Info("1111111")
u, err := models.UserSignIn(UserName, Password)
log.Info("22222")
if err != nil {
ctx.ServerError("UserSignIn", err)
return
}
log.Info("3333")
models.SaveLoginInfoToDb(ctx.Req.Request, u)
// If this user is enrolled in 2FA, we can't sign the user in just yet.
// Instead, redirect them to the 2FA authentication page.
@@ -217,7 +211,6 @@ func SignInPostAPI(ctx *context.Context) {
handleSignInFullNotRedirect(ctx, u, true, false)
}


// SignInPost response for sign in request
func SignInPost(ctx *context.Context, form auth.SignInForm) {
ctx.Data["Title"] = ctx.Tr("sign_in")
@@ -619,7 +612,6 @@ func handleSignInFullNotRedirect(ctx *context.Context, u *models.User, remember
return setting.AppSubURL + "/dashboard"
}


return setting.AppSubURL + "/dashboard"
}



Loading…
Cancel
Save