From f108202f65e922bccc7a3fe3aef6f51857108a51 Mon Sep 17 00:00:00 2001
From: lewis <747342561@qq.com>
Date: Mon, 11 Oct 2021 11:42:03 +0800
Subject: [PATCH 1/2] add creator-name
---
models/cloudbrain.go | 13 ++++++++++---
routers/repo/cloudbrain.go | 3 ++-
templates/repo/cloudbrain/index.tmpl | 2 +-
templates/repo/modelarts/index.tmpl | 2 +-
4 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/models/cloudbrain.go b/models/cloudbrain.go
index 5be07f741..4f615ed00 100755
--- a/models/cloudbrain.go
+++ b/models/cloudbrain.go
@@ -65,6 +65,11 @@ type Cloudbrain struct {
Repo *Repository `xorm:"-"`
}
+type CloudbrainInfo struct {
+ Cloudbrain `xorm:"extends"`
+ User `xorm:"extends"`
+}
+
type CloudBrainLoginResult struct {
Code string
Msg string
@@ -523,7 +528,7 @@ type NotebookDelResult struct {
InstanceID string `json:"instance_id"`
}
-func Cloudbrains(opts *CloudbrainsOptions) ([]*Cloudbrain, int64, error) {
+func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) {
sess := x.NewSession()
defer sess.Close()
@@ -583,8 +588,10 @@ func Cloudbrains(opts *CloudbrainsOptions) ([]*Cloudbrain, int64, error) {
}
sess.OrderBy("cloudbrain.created_unix DESC")
- cloudbrains := make([]*Cloudbrain, 0, setting.UI.IssuePagingNum)
- if err := sess.Where(cond).Find(&cloudbrains); err != nil {
+ cloudbrains := make([]*CloudbrainInfo, 0, setting.UI.IssuePagingNum)
+ if err := sess.Table(&Cloudbrain{}).Where(cond).
+ Join("left", "`user`", "cloudbrain.user_id = `user`.id").
+ Find(&cloudbrains); err != nil {
return nil, 0, fmt.Errorf("Find: %v", err)
}
sess.Close()
diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go
index c30906af4..ccd51a89f 100755
--- a/routers/repo/cloudbrain.go
+++ b/routers/repo/cloudbrain.go
@@ -69,7 +69,8 @@ func CloudBrainIndex(ctx *context.Context) {
timestamp := time.Now().Unix()
for i, task := range ciTasks {
- if task.Status == string(models.JobRunning) && (timestamp-int64(task.CreatedUnix) > 10) {
+ log.Info("", task.User.Name)
+ if task.Status == string(models.JobRunning) && (timestamp-int64(task.Cloudbrain.CreatedUnix) > 10) {
ciTasks[i].CanDebug = true
} else {
ciTasks[i].CanDebug = false
diff --git a/templates/repo/cloudbrain/index.tmpl b/templates/repo/cloudbrain/index.tmpl
index 532a8f4ff..1130c23d0 100755
--- a/templates/repo/cloudbrain/index.tmpl
+++ b/templates/repo/cloudbrain/index.tmpl
@@ -269,7 +269,7 @@
{{.Status}}
- {{TimeSinceUnix .CreatedUnix $.Lang}}
+ {{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}
diff --git a/templates/repo/modelarts/index.tmpl b/templates/repo/modelarts/index.tmpl
index a42f502d8..a81e47827 100755
--- a/templates/repo/modelarts/index.tmpl
+++ b/templates/repo/modelarts/index.tmpl
@@ -262,7 +262,7 @@
{{.Status}}
- {{TimeSinceUnix .CreatedUnix $.Lang}}
+ {{TimeSinceUnix .Cloudbrain.CreatedUnix $.Lang}}
From dfa7a6fd918b0454d31265fea462a38e48fc4bed Mon Sep 17 00:00:00 2001
From: zhoupzh
Date: Mon, 11 Oct 2021 15:13:49 +0800
Subject: [PATCH 2/2] fix issue 455
---
options/locale/locale_en-US.ini | 3 ++-
options/locale/locale_zh-CN.ini | 1 +
templates/repo/cloudbrain/index.tmpl | 12 ++++++++----
web_src/less/openi.less | 9 +++++++++
4 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 50e85ba27..acaf9bbb2 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -573,7 +573,7 @@ authorized_oauth2_applications_description = You've granted access to your perso
revoke_key = Revoke
revoke_oauth2_grant = Revoke Access
revoke_oauth2_grant_description = Revoking access for this third party application will prevent this application from accessing your data. Are you sure?
-revoke_oauth2_grant_success = You've revoked access successfully.
+revoke_oauth2_grant_success = You have revoked access successfully.
twofa_desc = Two-factor authentication enhances the security of your account.
twofa_is_enrolled = Your account is currently enrolled in two-factor authentication.
@@ -770,6 +770,7 @@ cloudbrain_selection = select cloudbrain
cloudbrain_platform_selection = Select the cloudbrain platform you want to use:
confirm_choice = confirm
cloudbran1_tips = Only data in zip format can create cloudbrain tasks
+cloudbrain_creator=Creator
template.items = Template Items
template.git_content = Git Content (Default Branch)
diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini
index 89a6282e5..b4c198c99 100755
--- a/options/locale/locale_zh-CN.ini
+++ b/options/locale/locale_zh-CN.ini
@@ -772,6 +772,7 @@ cloudbrain_selection=云脑选择
cloudbrain_platform_selection=选择您准备使用的云脑平台:
confirm_choice=确定
cloudbran1_tips=只有zip格式的数据集才能发起云脑任务
+cloudbrain_creator=创建者
template.items=模板选项
template.git_content=Git数据(默认分支)
diff --git a/templates/repo/cloudbrain/index.tmpl b/templates/repo/cloudbrain/index.tmpl
index 1130c23d0..e9e5c6bbf 100755
--- a/templates/repo/cloudbrain/index.tmpl
+++ b/templates/repo/cloudbrain/index.tmpl
@@ -256,10 +256,10 @@
-
-
+
+ {{$.i18n.Tr "repo.cloudbrain_creator"}}{{.User.Name}}
+
+
+