| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
8910bfa617 | fix issue | 2 years ago |
|
|
55bcd99d3d |
提交代码。增加置顶功能。
Signed-off-by: zouap <zouap@pcl.ac.cn> |
2 years ago |
|
|
4174e094a5 |
智算网络相关接口修改。
Signed-off-by: zouap <zouap@pcl.ac.cn> |
2 years ago |
|
|
f3a817bc19 | Merge remote-tracking branch 'origin/V20230215' into zouap | 2 years ago |
|
|
fa5e71fc54 |
智算任务监控接口变动
Signed-off-by: zouap <zouap@pcl.ac.cn> |
2 years ago |
|
|
c95c0dd748 |
智算任务监控接口变动
Signed-off-by: zouap <zouap@pcl.ac.cn> |
2 years ago |
|
|
9a262a20c4 |
issue中增加置顶属性
Signed-off-by: zouap <zouap@pcl.ac.cn> |
2 years ago |
| @@ -1661,6 +1661,15 @@ type Metrics struct { | |||||
| Value []string `json:"value"` //获取的监控值的序列,元素为String类型 | Value []string `json:"value"` //获取的监控值的序列,元素为String类型 | ||||
| } | } | ||||
| type NewModelArtsMetricStatisticResult struct { | |||||
| MetricsInfo []NewModelArtsMetrics `json:"metrics"` //监控详情 | |||||
| } | |||||
| type NewModelArtsMetrics struct { | |||||
| Metric string `json:"metric"` //监控指标项 | |||||
| Value []float32 `json:"value"` //获取的监控值的序列,元素为float类型 | |||||
| } | |||||
| func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { | func Cloudbrains(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { | ||||
| sess := x.NewSession() | sess := x.NewSession() | ||||
| defer sess.Close() | defer sess.Close() | ||||
| @@ -69,7 +69,8 @@ type Issue struct { | |||||
| //block_chain | //block_chain | ||||
| Amount int64 | Amount int64 | ||||
| IsTransformed bool `xorm:"INDEX NOT NULL DEFAULT false"` | |||||
| IsTransformed bool `xorm:"INDEX NOT NULL DEFAULT false"` | |||||
| StayTop int64 `xorm:"NOT NULL DEFAULT 0"` | |||||
| } | } | ||||
| var ( | var ( | ||||
| @@ -775,6 +776,19 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) { | |||||
| return sess.Commit() | return sess.Commit() | ||||
| } | } | ||||
| func (issue *Issue) ChangeStayTop(doer *User, stayTop int64) (err error) { | |||||
| issue.StayTop = stayTop | |||||
| sess := x.NewSession() | |||||
| defer sess.Close() | |||||
| if err = sess.Begin(); err != nil { | |||||
| return err | |||||
| } | |||||
| if err = updateIssueCols(sess, issue, "stay_top"); err != nil { | |||||
| return fmt.Errorf("UpdateIssueCols,stayTop: %v", err) | |||||
| } | |||||
| return sess.Commit() | |||||
| } | |||||
| // ChangeRef changes issue ref, as the given user. | // ChangeRef changes issue ref, as the given user. | ||||
| func (issue *Issue) ChangeRef(doer *User, newRef string) (err error) { | func (issue *Issue) ChangeRef(doer *User, newRef string) (err error) { | ||||
| oldRef := issue.Ref | oldRef := issue.Ref | ||||
| @@ -1116,6 +1130,7 @@ type IssuesOptions struct { | |||||
| // sortIssuesSession sort an issues-related session based on the provided | // sortIssuesSession sort an issues-related session based on the provided | ||||
| // sortType string | // sortType string | ||||
| func sortIssuesSession(sess *xorm.Session, sortType string, priorityRepoID int64) { | func sortIssuesSession(sess *xorm.Session, sortType string, priorityRepoID int64) { | ||||
| sess.Desc("issue.stay_top") | |||||
| switch sortType { | switch sortType { | ||||
| case "oldest": | case "oldest": | ||||
| sess.Asc("issue.created_unix") | sess.Asc("issue.created_unix") | ||||
| @@ -1966,3 +1981,14 @@ func UpdateReactionsMigrationsByType(gitServiceType structs.GitServiceType, orig | |||||
| }) | }) | ||||
| return err | return err | ||||
| } | } | ||||
| func GetMaxStayTop(repoId int64) int64 { | |||||
| re := new(Issue) | |||||
| isExist, err := x.Table(new(Issue)).Where("repo_id="+fmt.Sprint(repoId)).Desc("stay_top").Limit(1, 0).Get(re) | |||||
| if err == nil { | |||||
| if isExist { | |||||
| return re.StayTop + 1 | |||||
| } | |||||
| } | |||||
| return 1 | |||||
| } | |||||
| @@ -315,10 +315,10 @@ func GetTrainJobLog(jobID string) (string, error) { | |||||
| return logContent, nil | return logContent, nil | ||||
| } | } | ||||
| func GetGrampusMetrics(jobID string) (models.GetTrainJobMetricStatisticResult, error) { | |||||
| func GetGrampusMetrics(jobID string) (models.NewModelArtsMetricStatisticResult, error) { | |||||
| checkSetting() | checkSetting() | ||||
| client := getRestyClient() | client := getRestyClient() | ||||
| var result models.GetTrainJobMetricStatisticResult | |||||
| var result models.NewModelArtsMetricStatisticResult | |||||
| res, err := client.R(). | res, err := client.R(). | ||||
| SetAuthToken(TOKEN). | SetAuthToken(TOKEN). | ||||
| Get(HOST + urlTrainJob + "/" + jobID + "/task/0/replica/0/metrics") | Get(HOST + urlTrainJob + "/" + jobID + "/task/0/replica/0/metrics") | ||||
| @@ -331,12 +331,7 @@ func GetGrampusMetrics(jobID string) (models.GetTrainJobMetricStatisticResult, e | |||||
| return result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error()) | return result, fmt.Errorf("json.Unmarshal failed(%s): %v", res.String(), err.Error()) | ||||
| } | } | ||||
| if res.StatusCode() != http.StatusOK { | if res.StatusCode() != http.StatusOK { | ||||
| log.Error("Call GrampusMetrics failed(%d):%s(%s)", res.StatusCode(), result.ErrorCode, result.ErrorMsg) | |||||
| return result, fmt.Errorf("Call GrampusMetrics failed(%d):%d(%s)", res.StatusCode(), result.ErrorCode, result.ErrorMsg) | |||||
| } | |||||
| if !result.IsSuccess { | |||||
| log.Error("GetGrampusMetrics(%s) failed", jobID) | |||||
| return result, fmt.Errorf("GetGrampusMetrics failed:%s", result.ErrorMsg) | |||||
| return result, fmt.Errorf("Call GrampusMetrics failed(%d)", res.StatusCode()) | |||||
| } | } | ||||
| return result, nil | return result, nil | ||||
| } | } | ||||
| @@ -1732,6 +1732,9 @@ issues.attachment.open_tab = `Click to see "%s" in a new tab` | |||||
| issues.attachment.download = `Click to download "%s"` | issues.attachment.download = `Click to download "%s"` | ||||
| issues.subscribe = Subscribe | issues.subscribe = Subscribe | ||||
| issues.unsubscribe = Unsubscribe | issues.unsubscribe = Unsubscribe | ||||
| issues.top_task=Top issue | |||||
| issues.top = Top | |||||
| issues.cancel_topping = Cancel topping | |||||
| issues.lock = Lock conversation | issues.lock = Lock conversation | ||||
| issues.unlock = Unlock conversation | issues.unlock = Unlock conversation | ||||
| issues.lock.unknown_reason = Cannot lock an issue with an unknown reason. | issues.lock.unknown_reason = Cannot lock an issue with an unknown reason. | ||||
| @@ -1749,6 +1749,9 @@ issues.attachment.open_tab=`在新的标签页中查看 '%s'` | |||||
| issues.attachment.download=`点击下载 '%s'` | issues.attachment.download=`点击下载 '%s'` | ||||
| issues.subscribe=订阅 | issues.subscribe=订阅 | ||||
| issues.unsubscribe=取消订阅 | issues.unsubscribe=取消订阅 | ||||
| issues.top_task=置顶任务 | |||||
| issues.top=置顶 | |||||
| issues.cancel_topping=取消置顶 | |||||
| issues.lock=锁定对话 | issues.lock=锁定对话 | ||||
| issues.unlock=解锁对话 | issues.unlock=解锁对话 | ||||
| issues.lock.unknown_reason=由于未知原因无法锁定。 | issues.lock.unknown_reason=由于未知原因无法锁定。 | ||||
| @@ -1,7 +1,6 @@ | |||||
| package repo | package repo | ||||
| import ( | import ( | ||||
| "code.gitea.io/gitea/services/lock" | |||||
| "encoding/json" | "encoding/json" | ||||
| "errors" | "errors" | ||||
| "fmt" | "fmt" | ||||
| @@ -12,6 +11,8 @@ import ( | |||||
| "strconv" | "strconv" | ||||
| "strings" | "strings" | ||||
| "code.gitea.io/gitea/services/lock" | |||||
| "code.gitea.io/gitea/modules/urfs_client/urchin" | "code.gitea.io/gitea/modules/urfs_client/urchin" | ||||
| "code.gitea.io/gitea/routers/response" | "code.gitea.io/gitea/routers/response" | ||||
| @@ -1456,7 +1457,7 @@ func GrampusMetrics(ctx *context.Context) { | |||||
| } | } | ||||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | ctx.JSON(http.StatusOK, map[string]interface{}{ | ||||
| "JobID": jobID, | "JobID": jobID, | ||||
| "Interval": result.Interval, | |||||
| "Interval": 0, | |||||
| "MetricsInfo": result.MetricsInfo, | "MetricsInfo": result.MetricsInfo, | ||||
| }) | }) | ||||
| @@ -2079,3 +2079,27 @@ func attachmentsHTML(ctx *context.Context, attachments []*models.Attachment) str | |||||
| } | } | ||||
| return attachHTML | return attachHTML | ||||
| } | } | ||||
| func SetIssueStayTop(ctx *context.Context) { | |||||
| issue := GetActionIssue(ctx) | |||||
| if ctx.Written() { | |||||
| return | |||||
| } | |||||
| isStayTop := ctx.QueryBool("isStayTop") | |||||
| if !ctx.IsSigned || (!issue.IsPoster(ctx.User.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) { | |||||
| ctx.Error(403) | |||||
| return | |||||
| } | |||||
| var stayTop int64 | |||||
| stayTop = 0 | |||||
| if isStayTop { | |||||
| stayTop = models.GetMaxStayTop(ctx.Repo.Repository.ID) | |||||
| } | |||||
| err := issue.ChangeStayTop(ctx.User, stayTop) | |||||
| if err != nil { | |||||
| log.Info("update stay top error," + err.Error()) | |||||
| } | |||||
| ctx.JSON(200, map[string]interface{}{ | |||||
| "code": 0, | |||||
| }) | |||||
| } | |||||
| @@ -1006,6 +1006,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| m.Post("/title", repo.UpdateIssueTitle) | m.Post("/title", repo.UpdateIssueTitle) | ||||
| m.Post("/content", repo.UpdateIssueContent) | m.Post("/content", repo.UpdateIssueContent) | ||||
| m.Post("/watch", repo.IssueWatch) | m.Post("/watch", repo.IssueWatch) | ||||
| m.Post("/setstaytop", repo.SetIssueStayTop) | |||||
| m.Group("/dependency", func() { | m.Group("/dependency", func() { | ||||
| m.Post("/add", repo.AddDependency) | m.Post("/add", repo.AddDependency) | ||||
| m.Post("/delete", repo.RemoveDependency) | m.Post("/delete", repo.RemoveDependency) | ||||
| @@ -246,7 +246,9 @@ | |||||
| {{end}} | {{end}} | ||||
| <div class="ui {{if .IsClosed}}{{if .IsPull}}{{if .PullRequest.HasMerged}}purple{{else}}red{{end}}{{else}}red{{end}}{{else}}{{if .IsRead}}white{{else}}green{{end}}{{end}} label">#{{.Index}}</div> | <div class="ui {{if .IsClosed}}{{if .IsPull}}{{if .PullRequest.HasMerged}}purple{{else}}red{{end}}{{else}}red{{end}}{{else}}{{if .IsRead}}white{{else}}green{{end}}{{end}} label">#{{.Index}}</div> | ||||
| <a class="title" href="{{$.Link}}/{{.Index}}">{{RenderEmoji .Title}}</a> | <a class="title" href="{{$.Link}}/{{.Index}}">{{RenderEmoji .Title}}</a> | ||||
| {{if eq .StayTop 1}} | |||||
| <div class="ui label green" data="{{.StayTop}}">{{$.i18n.Tr "repo.issues.top"}}</div> | |||||
| {{end}} | |||||
| {{if .IsPull }} | {{if .IsPull }} | ||||
| {{if (index $.CommitStatus .PullRequest.ID)}} | {{if (index $.CommitStatus .PullRequest.ID)}} | ||||
| {{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}} | {{template "repo/commit_status" (index $.CommitStatus .PullRequest.ID)}} | ||||
| @@ -264,7 +266,7 @@ | |||||
| {{if .TotalTrackedTime}} | {{if .TotalTrackedTime}} | ||||
| <span class="comment ui right">{{svg "octicon-clock" 16}} {{.TotalTrackedTime | Sec2Time}}</span> | <span class="comment ui right">{{svg "octicon-clock" 16}} {{.TotalTrackedTime | Sec2Time}}</span> | ||||
| {{end}} | {{end}} | ||||
| <p class="desc"> | <p class="desc"> | ||||
| {{ $timeStr := TimeSinceUnix .GetLastEventTimestamp $.Lang }} | {{ $timeStr := TimeSinceUnix .GetLastEventTimestamp $.Lang }} | ||||
| {{if .OriginalAuthor }} | {{if .OriginalAuthor }} | ||||
| @@ -325,6 +325,25 @@ | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| {{end}} | {{end}} | ||||
| {{if and $.IssueWatch (not .Repository.IsArchived)}} | |||||
| <div class="ui divider"></div> | |||||
| <div class="ui isToping"> | |||||
| <span class="text"><strong>{{.i18n.Tr "repo.issues.top_task"}}</strong></span> | |||||
| <div id="stayTopIssue" data-issue-top="{{if .Issue.StayTop}}false{{else}}true{{end}}" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/setstaytop"> | |||||
| <button class="fluid ui button"> | |||||
| {{if .Issue.StayTop}} | |||||
| {{.i18n.Tr "repo.issues.cancel_topping"}} | |||||
| {{else}} | |||||
| {{.i18n.Tr "repo.issues.top"}} | |||||
| {{end}} | |||||
| </button> | |||||
| </form> | |||||
| </div> | |||||
| </div> | |||||
| {{end}} | |||||
| {{if .Repository.IsTimetrackerEnabled }} | {{if .Repository.IsTimetrackerEnabled }} | ||||
| {{if and .CanUseTimetracker (not .Repository.IsArchived)}} | {{if and .CanUseTimetracker (not .Repository.IsArchived)}} | ||||
| <div class="ui divider"></div> | <div class="ui divider"></div> | ||||
| @@ -646,4 +665,3 @@ | |||||
| </div> | </div> | ||||
| {{end}} | {{end}} | ||||
| {{end}} | {{end}} | ||||
| @@ -56,6 +56,7 @@ import { Message } from "element-ui"; | |||||
| import { i18nVue } from "./features/i18nVue.js"; | import { i18nVue } from "./features/i18nVue.js"; | ||||
| import './features/ad.js'; | import './features/ad.js'; | ||||
| import { Fancybox } from "./vendor/fancybox.esm.js"; | import { Fancybox } from "./vendor/fancybox.esm.js"; | ||||
| import { resolveProjectReferencePath } from "typescript"; | |||||
| Vue.prototype.$axios = axios; | Vue.prototype.$axios = axios; | ||||
| @@ -263,7 +264,20 @@ function updateIssuesMeta(url, action, issueIds, elementId, isAdd) { | |||||
| }); | }); | ||||
| }); | }); | ||||
| } | } | ||||
| function updateIssueTop(url,param) { | |||||
| return new Promise((resolve,reject) => { | |||||
| $.ajax({ | |||||
| type: "POST", | |||||
| url, | |||||
| data: { | |||||
| _csrf: csrf, | |||||
| isStayTop:param, | |||||
| }, | |||||
| success: resolve, | |||||
| error:reject, | |||||
| }); | |||||
| }); | |||||
| } | |||||
| function initRepoStatusChecker() { | function initRepoStatusChecker() { | ||||
| const migrating = $("#repo_migrating"); | const migrating = $("#repo_migrating"); | ||||
| $("#repo_migrating_failed").hide(); | $("#repo_migrating_failed").hide(); | ||||
| @@ -824,7 +838,19 @@ function initIssueComments() { | |||||
| event.preventDefault(); | event.preventDefault(); | ||||
| updateIssuesMeta(url, "", issueId, id, isChecked).then(reload); | updateIssuesMeta(url, "", issueId, id, isChecked).then(reload); | ||||
| }); | }); | ||||
| $("#stayTopIssue").on("click", function (event){ | |||||
| const url = $(this).data("update-url"); | |||||
| const isIssueTop = $(this).data("issue-top"); | |||||
| updateIssueTop(url, isIssueTop).then((res, rej) => { | |||||
| console.log(res) | |||||
| if (res.code === 0){ | |||||
| reload() | |||||
| } | |||||
| }).catch((err) => { | |||||
| console.log(err) | |||||
| }) | |||||
| event.preventDefault(); | |||||
| }) | |||||
| $(document).on("click", (event) => { | $(document).on("click", (event) => { | ||||
| const urlTarget = $(":target"); | const urlTarget = $(":target"); | ||||
| if (urlTarget.length === 0) return; | if (urlTarget.length === 0) return; | ||||