| @@ -44,6 +44,12 @@ | |||
| -webkit-line-clamp: 2; | |||
| -webkit-box-orient: vertical; | |||
| } | |||
| .ui.label{ | |||
| font-weight: normal; | |||
| } | |||
| .active { | |||
| color: #0366D6 !important; | |||
| } | |||
| .opacity5{ opacity:0.5;} | |||
| .radius15{ border-radius:1.5rem !important; } | |||
| @@ -250,9 +256,13 @@ | |||
| box-shadow: none !important; | |||
| } | |||
| .homeorg-list .card .ui.small.header .content{ | |||
| width: calc(100% - 3.25em); | |||
| width: calc(100% - 3.75em); | |||
| } | |||
| .homepro-list{ | |||
| .homepro-tit{ | |||
| z-index: 9; | |||
| position: relative; | |||
| } | |||
| .homepro-list, .homeorg-list{ | |||
| position: relative; | |||
| z-index: 9; | |||
| padding: 1.0em 1.0em 3.0em; | |||
| @@ -261,42 +271,156 @@ | |||
| .homepro-list .ui.card{ | |||
| border-radius: 15px; | |||
| background-color: #FFF; | |||
| box-shadow: 0px 5px 10px 0px rgba(105, 192, 255, 30); | |||
| border: 1px solid rgba(105, 192, 255, 40); | |||
| box-shadow: 0px 5px 10px 0px rgba(105, 192, 255, .3); | |||
| border: 1px solid rgba(105, 192, 255, .4); | |||
| min-height: 10.8em; | |||
| } | |||
| .homepro-list .ui.card>.content>.header{ | |||
| line-height: 40px !important; | |||
| } | |||
| .homepro-list .swiper-pagination-bullet-active{ | |||
| .homepro-list .swiper-pagination-bullet-active, .homeorg-list .swiper-pagination-bullet-active{ | |||
| width: 40px; | |||
| border-radius: 4px; | |||
| border-radius: 4px; | |||
| } | |||
| .i-env > div{ | |||
| position: relative; | |||
| } | |||
| /**seach**/ | |||
| /**搜索导航条适配窄屏**/ | |||
| .seachnav{ | |||
| overflow-x: auto; | |||
| overflow-y: hidden; | |||
| scrollbar-width: none; /* firefox */ | |||
| -ms-overflow-style: none; /* IE 10+ */ | |||
| } | |||
| .seachnav::-webkit-scrollbar { | |||
| display: none; /* Chrome Safari */ | |||
| } | |||
| .ui.green.button, .ui.green.buttons .button{ | |||
| background-color: #5BB973; | |||
| } | |||
| .seach .repos--seach{ | |||
| padding-bottom: 0; | |||
| border-bottom: none; | |||
| } | |||
| .seach .ui.secondary.pointing.menu{ | |||
| border-bottom: none; | |||
| } | |||
| .seach .ui.secondary.pointing.menu .item > i{ | |||
| margin-right: 5px; | |||
| } | |||
| .seach .ui.secondary.pointing.menu .active.item{ | |||
| border-bottom-width: 2px; | |||
| margin: 0 0 -1px; | |||
| } | |||
| .seach .ui.menu .active.item>.label { | |||
| background: #1684FC; | |||
| color: #FFF; | |||
| } | |||
| .seach .ui.menu .item>.label:not(.active.item>.label) { | |||
| background: #e8e8e8; | |||
| color: rgba(0,0,0,.6); | |||
| } | |||
| .highlight{ | |||
| color: red; | |||
| } | |||
| .ui.list .list>.item>img.image+.content, .ui.list>.item>img.image+.content { | |||
| width: calc(100% - 3.0em); | |||
| margin-left: 0; | |||
| } | |||
| .seach .ui.list .list>.item .header, .seach .ui.list>.item .header{ | |||
| margin-bottom: 0.5em; | |||
| font-size: 1.4rem !important; | |||
| font-weight: normal; | |||
| } | |||
| .seach .time, .seach .time a{ | |||
| font-size: 12px; | |||
| color: grey; | |||
| } | |||
| .seach .list .item.members .ui.avatar.image { | |||
| width: 3.2em; | |||
| height: 3.2em; | |||
| } | |||
| .ui.list .list>.item.members>img.image+.content, .ui.list>.item.members>img.image+.content { | |||
| width: calc(100% - 4.0em); | |||
| margin-left: 0; | |||
| } | |||
| @media only screen and (max-width: 767px) { | |||
| .am-mt-30{ margin-top: 1.5rem !important;} | |||
| .ui.secondary.hometop.segment{ | |||
| margin-bottom: 2.0rem; | |||
| margin-bottom: 5.0rem; | |||
| } | |||
| .bannerpic, .i-code-pic{ | |||
| .bannerpic{ | |||
| display: none; | |||
| } | |||
| .i-code h2::before { | |||
| left: calc(-5.0rem + 6px); | |||
| #homenews{ | |||
| bottom: -3em; | |||
| } | |||
| .i-code h2.am-bw::before{ | |||
| left: calc(-4.0rem + 6px); | |||
| #homenews > p { | |||
| margin-left: 1.0em; | |||
| } | |||
| .homenews{ | |||
| padding-left: 1.3em !important; | |||
| border-radius: 1.5em; | |||
| } | |||
| .homenews::before{ | |||
| left: 2em; | |||
| } | |||
| .homepro-tit > p{ | |||
| background: #FFF; | |||
| } | |||
| .homeorg{ | |||
| padding-left: 3.5em; | |||
| } | |||
| .homeorg-tit::after { | |||
| left: -2.3em; | |||
| } | |||
| .homeorg-list{ | |||
| margin: 0 0 2.0em !important; | |||
| } | |||
| .homeorg-list > .column{ | |||
| width: 3em !important; | |||
| margin-left: -0.5em; | |||
| padding: 0.5rem 0 0 !important; | |||
| } | |||
| .homeorg-list .card{ | |||
| background: none !important; | |||
| } | |||
| .homeorg-list .card > .content{ | |||
| padding: 0 !important; | |||
| } | |||
| .homeorg-list > .column .card .ui.header>img{ | |||
| width: 3.0em; | |||
| height: 3.0em; | |||
| border-radius: 2.0em; | |||
| border: 2px solid #FFF; | |||
| } | |||
| .homeorg-list > .column .card .ui.header > .content{ | |||
| display: none; | |||
| } | |||
| .leftline01{ | |||
| width: calc(50% - 4.0rem); | |||
| width: 4.0em; | |||
| bottom: 4em; | |||
| border-radius: 0 0 0 3.0em; | |||
| } | |||
| .leftline02{ | |||
| left: calc(50% - 1.0rem); | |||
| top: calc(-3.5rem - 2px); | |||
| .leftline02, .leftline02-2{ | |||
| left: 6.0em; | |||
| top: calc(-4.0em - 2px); | |||
| border-radius: 0 3.0em 3.0em 0; | |||
| width: calc(50% - 6.0em); | |||
| } | |||
| .leftline02-2 { | |||
| width: calc(50% - 8.0em); | |||
| } | |||
| .i-env .ui.cards>.card>.content .description{ | |||
| display: none; | |||
| } | |||
| } | |||
| @@ -88,12 +88,25 @@ func (a *Attachment) APIFormat() *api.Attachment { | |||
| Size: a.Size, | |||
| UUID: a.UUID, | |||
| DownloadURL: a.DownloadURL(), | |||
| S3DownloadURL: a.S3DownloadURL(), | |||
| } | |||
| } | |||
| // DownloadURL returns the download url of the attached file | |||
| func (a *Attachment) DownloadURL() string { | |||
| return fmt.Sprintf("%sattachments/%s", setting.AppURL, a.UUID) | |||
| return fmt.Sprintf("%sattachments/%s?type=%d", setting.AppURL, a.UUID, a.Type) | |||
| } | |||
| // S3DownloadURL returns the s3 download url of the attached file | |||
| func (a *Attachment) S3DownloadURL() string { | |||
| url := "" | |||
| if a.Type == TypeCloudBrainOne { | |||
| url, _ = storage.Attachments.PresignedGetURL(setting.Attachment.Minio.BasePath+AttachmentRelativePath(a.UUID), a.Name) | |||
| } else if a.Type == TypeCloudBrainTwo { | |||
| url, _ = storage.ObsGetPreSignedUrl(a.UUID, a.Name) | |||
| } | |||
| return url | |||
| } | |||
| // AttachmentRelativePath returns the relative path | |||
| @@ -12,6 +12,7 @@ type RepoStatistic struct { | |||
| ID int64 `xorm:"pk autoincr" json:"-"` | |||
| RepoID int64 `xorm:"unique(s) NOT NULL" json:"repo_id"` | |||
| Name string `xorm:"INDEX" json:"name"` | |||
| Alias string `xorm:"INDEX" json:"alias"` | |||
| OwnerName string `json:"ownerName"` | |||
| IsPrivate bool `json:"isPrivate"` | |||
| IsMirror bool `json:"isMirror"` | |||
| @@ -63,6 +64,13 @@ type RepoStatistic struct { | |||
| UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated" json:"-"` | |||
| } | |||
| func (repo *RepoStatistic) DisplayName() string { | |||
| if repo.Alias == "" { | |||
| return repo.Name | |||
| } | |||
| return repo.Alias | |||
| } | |||
| func DeleteRepoStatDaily(date string) error { | |||
| sess := xStatistic.NewSession() | |||
| defer sess.Close() | |||
| @@ -6,12 +6,14 @@ | |||
| package context | |||
| import ( | |||
| "encoding/base64" | |||
| "net/http" | |||
| "strings" | |||
| "code.gitea.io/gitea/models" | |||
| "code.gitea.io/gitea/modules/auth" | |||
| "code.gitea.io/gitea/modules/log" | |||
| "code.gitea.io/gitea/modules/setting" | |||
| "encoding/base64" | |||
| "net/http" | |||
| "gitea.com/macaron/csrf" | |||
| "gitea.com/macaron/macaron" | |||
| @@ -94,7 +96,14 @@ func Toggle(options *ToggleOptions) macaron.Handler { | |||
| return | |||
| } | |||
| ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) | |||
| tempUrl := ctx.Req.URL.RequestURI() | |||
| if strings.Contains(tempUrl, "action/star?") || strings.Contains(tempUrl, "action/watch?") { | |||
| redirectForStarAndWatch(ctx, tempUrl) | |||
| } else { | |||
| ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) | |||
| } | |||
| ctx.Redirect(setting.AppSubURL + "/user/login") | |||
| return | |||
| } else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm { | |||
| @@ -159,6 +168,17 @@ func Toggle(options *ToggleOptions) macaron.Handler { | |||
| } | |||
| } | |||
| func redirectForStarAndWatch(ctx *Context, tempUrl string) { | |||
| splits := strings.Split(tempUrl, "?") | |||
| if len(splits) > 1 { | |||
| redirectArguments := strings.Split(splits[1], "=") | |||
| if len(redirectArguments) > 0 && redirectArguments[0] == "redirect_to" { | |||
| ctx.SetCookie("redirect_to", setting.AppSubURL+strings.Replace(redirectArguments[1], "%2f", "/", -1), 0, setting.AppSubURL) | |||
| } | |||
| } | |||
| } | |||
| func basicAuth(ctx *Context) bool { | |||
| var siteAuth = base64.StdEncoding.EncodeToString([]byte(setting.CBAuthUser + ":" + setting.CBAuthPassword)) | |||
| auth := ctx.Req.Header.Get("Authorization") | |||
| @@ -16,9 +16,10 @@ type Attachment struct { | |||
| Size int64 `json:"size"` | |||
| DownloadCount int64 `json:"download_count"` | |||
| // swagger:strfmt date-time | |||
| Created time.Time `json:"created_at"` | |||
| UUID string `json:"uuid"` | |||
| DownloadURL string `json:"browser_download_url"` | |||
| Created time.Time `json:"created_at"` | |||
| UUID string `json:"uuid"` | |||
| DownloadURL string `json:"browser_download_url"` | |||
| S3DownloadURL string | |||
| } | |||
| // EditAttachmentOptions options for editing attachments | |||
| @@ -6,7 +6,6 @@ if(isEmpty(token)){ | |||
| token = meta.attr("content"); | |||
| } | |||
| } | |||
| var swiperNewMessage = new Swiper(".newslist", { | |||
| direction: "vertical", | |||
| slidesPerView: 10, | |||
| @@ -17,7 +16,7 @@ var swiperNewMessage = new Swiper(".newslist", { | |||
| }, | |||
| }); | |||
| var swiperRepo = new Swiper(".homepro-list", { | |||
| slidesPerView: 3, | |||
| slidesPerView: 1, | |||
| slidesPerColumn: 2, | |||
| slidesPerColumnFill:'row', | |||
| spaceBetween: 30, | |||
| @@ -29,6 +28,37 @@ var swiperRepo = new Swiper(".homepro-list", { | |||
| delay: 2500, | |||
| disableOnInteraction: false, | |||
| }, | |||
| breakpoints: { | |||
| 768: { | |||
| slidesPerView: 2, | |||
| }, | |||
| 1024: { | |||
| slidesPerView: 3, | |||
| }, | |||
| }, | |||
| }); | |||
| var swiperOrg = new Swiper(".homeorg-list", { | |||
| slidesPerView: 1, | |||
| slidesPerColumn: 4, | |||
| slidesPerColumnFill:'row', | |||
| spaceBetween: 15, | |||
| pagination: { | |||
| el: ".swiper-pagination", | |||
| clickable: true, | |||
| }, | |||
| autoplay: { | |||
| delay: 4500, | |||
| disableOnInteraction: false, | |||
| }, | |||
| breakpoints: { | |||
| 768: { | |||
| slidesPerView: 2, | |||
| }, | |||
| 1024: { | |||
| slidesPerView: 3, | |||
| }, | |||
| }, | |||
| }); | |||
| var output = document.getElementById("newmessage"); | |||
| @@ -392,7 +422,7 @@ function displayOrg(json){ | |||
| if (json != null && json.length > 0){ | |||
| for(var i = 0; i < json.length;i++){ | |||
| var record = json[i] | |||
| html += "<div class=\"column\">"; | |||
| html += "<div class=\"swiper-slide\">"; | |||
| html += " <a href=\"/" + record["Name"] + "\" class=\"ui fluid card\">"; | |||
| html += " <div class=\"content\">"; | |||
| html += " <div class=\"ui small header\">"; | |||
| @@ -408,4 +438,5 @@ function displayOrg(json){ | |||
| } | |||
| } | |||
| orgDiv.innerHTML = html; | |||
| swiperOrg.updateSlides(); | |||
| } | |||
| @@ -878,7 +878,8 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
| }, reqAdmin()) | |||
| }, reqAnyRepoReader()) | |||
| m.Group("/cloudbrain", func() { | |||
| m.Get("/:jobid", repo.GetCloudbrainTask) | |||
| // m.Get("/:jobid", repo.GetCloudbrainTask) | |||
| m.Get("/:jobname", repo.GetCloudbrainTask) | |||
| m.Get("/:jobid/log", repo.CloudbrainGetLog) | |||
| }, reqRepoReader(models.UnitTypeCloudBrain)) | |||
| m.Group("/modelarts", func() { | |||
| @@ -6,11 +6,12 @@ | |||
| package repo | |||
| import ( | |||
| "code.gitea.io/gitea/modules/log" | |||
| "net/http" | |||
| "sort" | |||
| "time" | |||
| "code.gitea.io/gitea/modules/log" | |||
| "code.gitea.io/gitea/models" | |||
| "code.gitea.io/gitea/modules/cloudbrain" | |||
| "code.gitea.io/gitea/modules/context" | |||
| @@ -48,14 +49,12 @@ func GetCloudbrainTask(ctx *context.APIContext) { | |||
| err error | |||
| ) | |||
| jobID := ctx.Params(":jobid") | |||
| repoID := ctx.Repo.Repository.ID | |||
| job, err := models.GetRepoCloudBrainByJobID(repoID, jobID) | |||
| jobName := ctx.Params(":jobname") | |||
| job, err := models.GetCloudbrainByName(jobName) | |||
| if err != nil { | |||
| ctx.NotFound(err) | |||
| return | |||
| ctx.Data["error"] = err.Error() | |||
| } | |||
| jobResult, err := cloudbrain.GetJob(jobID) | |||
| jobResult, err := cloudbrain.GetJob(job.JobID) | |||
| if err != nil { | |||
| ctx.NotFound(err) | |||
| return | |||
| @@ -84,7 +83,7 @@ func GetCloudbrainTask(ctx *context.APIContext) { | |||
| } | |||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | |||
| "JobID": result.Config.JobID, | |||
| "JobName": result.Config.JobName, | |||
| "JobStatus": result.JobStatus.State, | |||
| "SubState": result.JobStatus.SubState, | |||
| "CreatedTime": time.Unix(result.JobStatus.CreatedTime/1000, 0).Format("2006-01-02 15:04:05"), | |||
| @@ -104,7 +103,7 @@ func CloudbrainGetLog(ctx *context.Context) { | |||
| var hits []models.Hits | |||
| result, err := cloudbrain.GetJobLog(jobID) | |||
| if err != nil{ | |||
| if err != nil { | |||
| log.Error("GetJobLog failed: %v", err, ctx.Data["MsgID"]) | |||
| ctx.ServerError(err.Error(), err) | |||
| return | |||
| @@ -115,7 +114,7 @@ func CloudbrainGetLog(ctx *context.Context) { | |||
| if len(result.Hits.Hits) >= cloudbrain.LogPageSize { | |||
| for { | |||
| resultNext, err := cloudbrain.GetJobAllLog(result.ScrollID) | |||
| if err != nil{ | |||
| if err != nil { | |||
| log.Error("GetJobAllLog failed: %v", err, ctx.Data["MsgID"]) | |||
| } else { | |||
| for _, hit := range resultNext.Hits.Hits { | |||
| @@ -142,8 +141,8 @@ func CloudbrainGetLog(ctx *context.Context) { | |||
| } | |||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | |||
| "JobID": jobID, | |||
| "Content": content, | |||
| "JobID": jobID, | |||
| "Content": content, | |||
| }) | |||
| return | |||
| @@ -77,6 +77,7 @@ func GetModelArtsNotebook2(ctx *context.APIContext) { | |||
| ctx.JSON(http.StatusOK, map[string]interface{}{ | |||
| "JobID": jobID, | |||
| "JobName": job.JobName, | |||
| "JobStatus": result.Status, | |||
| }) | |||
| @@ -297,7 +297,7 @@ func allProjectsPeroidHeader(ctx *context.Context) map[string]string { | |||
| } | |||
| func allProjectsPeroidValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string { | |||
| return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.Name, getCellName("C", row): rs.OwnerName, getCellName("D", row): getIsPrivateDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), | |||
| return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getIsPrivateDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), | |||
| getCellName("F", row): strconv.FormatInt(rs.NumVisits, 10), getCellName("G", row): strconv.FormatInt(rs.NumDownloads, 10), getCellName("H", row): strconv.FormatInt(rs.NumPulls, 10), getCellName("I", row): strconv.FormatInt(rs.NumCommits, 10), | |||
| getCellName("J", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("K", row): strconv.FormatInt(rs.NumStars, 10), getCellName("L", row): strconv.FormatInt(rs.NumForks, 10), getCellName("M", row): strconv.FormatInt(rs.NumIssues, 10), | |||
| getCellName("N", row): strconv.FormatInt(rs.NumClosedIssues, 10), getCellName("O", row): strconv.FormatInt(rs.NumContributor, 10), | |||
| @@ -317,7 +317,7 @@ func allProjectsOpenIHeader() map[string]string { | |||
| func allProjectsOpenIValues(row int, rs *models.RepoStatistic, ctx *context.Context) map[string]string { | |||
| return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.Name, getCellName("C", row): rs.OwnerName, getCellName("D", row): getIsPrivateDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), | |||
| return map[string]string{getCellName("A", row): strconv.FormatInt(rs.RepoID, 10), getCellName("B", row): rs.DisplayName(), getCellName("C", row): rs.OwnerName, getCellName("D", row): getIsPrivateDisplay(rs.IsPrivate, ctx), getCellName("E", row): strconv.FormatFloat(rs.RadarTotal, 'f', 2, 64), | |||
| getCellName("F", row): strconv.FormatFloat(rs.Impact, 'f', 2, 64), getCellName("G", row): strconv.FormatFloat(rs.Completeness, 'f', 2, 64), getCellName("H", row): strconv.FormatFloat(rs.Liveness, 'f', 2, 64), getCellName("I", row): strconv.FormatFloat(rs.ProjectHealth, 'f', 2, 64), getCellName("J", row): strconv.FormatFloat(rs.TeamHealth, 'f', 2, 64), getCellName("K", row): strconv.FormatFloat(rs.Growth, 'f', 2, 64), | |||
| getCellName("L", row): strconv.FormatInt(rs.NumWatches, 10), getCellName("M", row): strconv.FormatInt(rs.NumStars, 10), getCellName("N", row): strconv.FormatInt(rs.NumForks, 10), getCellName("O", row): strconv.FormatInt(rs.NumDownloads, 10), | |||
| @@ -466,10 +466,10 @@ func generateCountSql(beginTime time.Time, endTime time.Time, latestDate string, | |||
| countSql := "SELECT count(*) FROM " + | |||
| "(SELECT repo_id FROM repo_statistic where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + | |||
| " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " group by repo_id) A," + | |||
| "(SELECT repo_id,name,is_private,radar_total from public.repo_statistic where date='" + latestDate + "') B" + | |||
| "(SELECT repo_id,name,alias,is_private,radar_total from public.repo_statistic where date='" + latestDate + "') B" + | |||
| " where A.repo_id=B.repo_id" | |||
| if q != "" { | |||
| countSql = countSql + " and LOWER(B.name) like '%" + strings.ToLower(q) + "%'" | |||
| countSql = countSql + " and LOWER(B.alias) like '%" + strings.ToLower(q) + "%'" | |||
| } | |||
| return countSql | |||
| } | |||
| @@ -482,22 +482,22 @@ func generateOpenICountSql(latestDate string) string { | |||
| } | |||
| func generateTypeAllSql(beginTime time.Time, endTime time.Time, latestDate string, q string, orderBy string, page int, pageSize int) string { | |||
| sql := "SELECT A.repo_id,name,owner_name,is_private,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " + | |||
| sql := "SELECT A.repo_id,name,alias,owner_name,is_private,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " + | |||
| "(SELECT repo_id,sum(num_visits) as num_visits " + | |||
| " FROM repo_statistic where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + | |||
| " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " group by repo_id) A," + | |||
| "(SELECT repo_id,name,owner_name,is_private,radar_total,num_watches,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor from public.repo_statistic where date='" + latestDate + "') B" + | |||
| "(SELECT repo_id,name,alias,owner_name,is_private,radar_total,num_watches,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor from public.repo_statistic where date='" + latestDate + "') B" + | |||
| " where A.repo_id=B.repo_id" | |||
| if q != "" { | |||
| sql = sql + " and LOWER(name) like '%" + strings.ToLower(q) + "%'" | |||
| sql = sql + " and LOWER(alias) like '%" + strings.ToLower(q) + "%'" | |||
| } | |||
| sql = sql + " order by " + orderBy + " desc,repo_id" + " limit " + strconv.Itoa(pageSize) + " offset " + strconv.Itoa((page-1)*pageSize) | |||
| return sql | |||
| } | |||
| func generateTypeAllOpenISql(latestDate string, page int, pageSize int) string { | |||
| sql := "SELECT id, repo_id, date, num_watches, num_stars, num_forks, num_downloads, num_comments, num_visits, num_closed_issues, num_versions, num_dev_months, repo_size, dataset_size, num_models, num_wiki_views, num_commits, num_issues, num_pulls, issue_fixed_rate, num_contributor, num_key_contributor, num_contributors_growth, num_commits_growth, num_commit_lines_growth, num_issues_growth, num_comments_growth, impact, completeness, liveness, project_health, team_health, growth, radar_total, name, is_private, owner_name FROM " + | |||
| sql := "SELECT id, repo_id, date, num_watches, num_stars, num_forks, num_downloads, num_comments, num_visits, num_closed_issues, num_versions, num_dev_months, repo_size, dataset_size, num_models, num_wiki_views, num_commits, num_issues, num_pulls, issue_fixed_rate, num_contributor, num_key_contributor, num_contributors_growth, num_commits_growth, num_commit_lines_growth, num_issues_growth, num_comments_growth, impact, completeness, liveness, project_health, team_health, growth, radar_total, name,alias, is_private, owner_name FROM " + | |||
| " public.repo_statistic where date='" + latestDate + "'" | |||
| sql = sql + " order by radar_total desc,repo_id" + " limit " + strconv.Itoa(pageSize) + " offset " + strconv.Itoa((page-1)*pageSize) | |||
| @@ -506,14 +506,14 @@ func generateTypeAllOpenISql(latestDate string, page int, pageSize int) string { | |||
| func generatePageSql(beginTime time.Time, endTime time.Time, latestDate string, q string, orderBy string, page int, pageSize int) string { | |||
| sql := "SELECT A.repo_id,name,owner_name,is_private,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " + | |||
| sql := "SELECT A.repo_id,name,alias,owner_name,is_private,radar_total,num_watches,num_visits,num_downloads,num_pulls,num_commits,num_stars,num_forks,num_issues,num_closed_issues,num_contributor FROM " + | |||
| "(SELECT repo_id,sum(num_watches_added) as num_watches,sum(num_visits) as num_visits, sum(num_downloads_added) as num_downloads,sum(num_pulls_added) as num_pulls,sum(num_commits_added) as num_commits,sum(num_stars_added) as num_stars,sum(num_forks_added) num_forks,sum(num_issues_added) as num_issues,sum(num_closed_issues_added) as num_closed_issues,sum(num_contributor_added) as num_contributor " + | |||
| " FROM repo_statistic where created_unix >=" + strconv.FormatInt(beginTime.Unix(), 10) + | |||
| " and created_unix<" + strconv.FormatInt(endTime.Unix(), 10) + " group by repo_id) A," + | |||
| "(SELECT repo_id,name,owner_name,is_private,radar_total from public.repo_statistic where date='" + latestDate + "') B" + | |||
| "(SELECT repo_id,name,alias,owner_name,is_private,radar_total from public.repo_statistic where date='" + latestDate + "') B" + | |||
| " where A.repo_id=B.repo_id" | |||
| if q != "" { | |||
| sql = sql + " and LOWER(B.name) like '%" + strings.ToLower(q) + "%'" | |||
| sql = sql + " and LOWER(B.alias) like '%" + strings.ToLower(q) + "%'" | |||
| } | |||
| sql = sql + " order by " + orderBy + " desc,A.repo_id" + " limit " + strconv.Itoa(pageSize) + " offset " + strconv.Itoa((page-1)*pageSize) | |||
| return sql | |||
| @@ -351,13 +351,13 @@ func CloudBrainShow(ctx *context.Context) { | |||
| func cloudBrainShow(ctx *context.Context, tpName base.TplName) { | |||
| ctx.Data["PageIsCloudBrain"] = true | |||
| var jobID = ctx.Params(":jobid") | |||
| task, err := models.GetCloudbrainByJobID(jobID) | |||
| var jobName = ctx.Params(":jobname") | |||
| task, err := models.GetCloudbrainByName(jobName) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| } | |||
| result, err := cloudbrain.GetJob(jobID) | |||
| result, err := cloudbrain.GetJob(task.JobID) | |||
| if err != nil { | |||
| ctx.Data["error"] = err.Error() | |||
| } | |||
| @@ -422,7 +422,7 @@ func cloudBrainShow(ctx *context.Context, tpName base.TplName) { | |||
| ctx.Data["duration"] = util.AddZero(duration/3600000) + ":" + util.AddZero(duration%3600000/60000) + ":" + util.AddZero(duration%60000/1000) | |||
| ctx.Data["task"] = task | |||
| ctx.Data["jobID"] = jobID | |||
| // ctx.Data["jobID"] = task.JobID | |||
| ctx.Data["jobName"] = task.JobName | |||
| version_list_task := make([]*models.Cloudbrain, 0) | |||
| version_list_task = append(version_list_task, task) | |||
| @@ -582,12 +582,13 @@ func logErrorAndUpdateJobStatus(err error, taskInfo *models.Cloudbrain) { | |||
| } | |||
| func CloudBrainDel(ctx *context.Context) { | |||
| var listType = ctx.Query("debugListType") | |||
| if err := deleteCloudbrainJob(ctx); err != nil { | |||
| log.Error("deleteCloudbrainJob failed: %v", err, ctx.Data["msgID"]) | |||
| ctx.ServerError(err.Error(), err) | |||
| return | |||
| } | |||
| ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all") | |||
| ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=" + listType) | |||
| } | |||
| func deleteCloudbrainJob(ctx *context.Context) error { | |||
| @@ -268,6 +268,7 @@ func NotebookShow(ctx *context.Context) { | |||
| ctx.Data["task"] = task | |||
| ctx.Data["jobID"] = jobID | |||
| ctx.Data["jobName"] = task.JobName | |||
| ctx.Data["result"] = result | |||
| ctx.HTML(200, tplModelArtsNotebookShow) | |||
| } | |||
| @@ -417,6 +418,7 @@ func NotebookManage(ctx *context.Context) { | |||
| func NotebookDel(ctx *context.Context) { | |||
| var jobID = ctx.Params(":jobid") | |||
| var listType = ctx.Query("debugListType") | |||
| task := ctx.Cloudbrain | |||
| if task.Status != string(models.ModelArtsCreateFailed) && task.Status != string(models.ModelArtsStartFailed) && task.Status != string(models.ModelArtsStopped) { | |||
| @@ -442,7 +444,7 @@ func NotebookDel(ctx *context.Context) { | |||
| return | |||
| } | |||
| ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=all") | |||
| ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/debugjob?debugListType=" + listType) | |||
| } | |||
| func TrainJobIndex(ctx *context.Context) { | |||
| @@ -106,7 +106,8 @@ func RepoStatisticDaily(date string) { | |||
| repoStat := models.RepoStatistic{ | |||
| RepoID: repo.ID, | |||
| Date: date, | |||
| Name: repo.Alias, | |||
| Name: repo.Name, | |||
| Alias: repo.Alias, | |||
| IsPrivate: repo.IsPrivate, | |||
| IsMirror: repo.IsMirror, | |||
| OwnerName: repo.OwnerName, | |||
| @@ -63,11 +63,13 @@ func queryUserDataPage(ctx *context.Context, tableName string, queryObj interfac | |||
| _, count := models.QueryUserStaticDataByTableName(1, 1, tableName, queryObj, userName) | |||
| var indexTotal int64 | |||
| indexTotal = 0 | |||
| row := 1 | |||
| for { | |||
| re, _ := models.QueryUserStaticDataByTableName(int(indexTotal), PAGE_SIZE, tableName, queryObj, "") | |||
| log.Info("return count=" + fmt.Sprint(count)) | |||
| for i, userRecord := range re { | |||
| rows := fmt.Sprint(i + 2) | |||
| for _, userRecord := range re { | |||
| row++ | |||
| rows := fmt.Sprint(row) | |||
| xlsx.SetCellValue(sheetName, "A"+rows, userRecord.ID) | |||
| xlsx.SetCellValue(sheetName, "B"+rows, userRecord.Name) | |||
| xlsx.SetCellValue(sheetName, "C"+rows, userRecord.CodeMergeCount) | |||
| @@ -974,8 +974,10 @@ func RegisterRoutes(m *macaron.Macaron) { | |||
| }, context.RepoRef()) | |||
| m.Group("/cloudbrain", func() { | |||
| m.Group("/:jobid", func() { | |||
| m.Group("/:jobname", func() { | |||
| m.Get("", reqRepoCloudBrainReader, repo.CloudBrainShow) | |||
| }) | |||
| m.Group("/:jobid", func() { | |||
| m.Get("/debug", cloudbrain.AdminOrJobCreaterRight, repo.CloudBrainDebug) | |||
| m.Post("/commit_image", cloudbrain.AdminOrJobCreaterRight, bindIgnErr(auth.CommitImageCloudBrainForm{}), repo.CloudBrainCommitImage) | |||
| m.Post("/stop", cloudbrain.AdminOrOwnerOrJobCreaterRight, repo.CloudBrainStop) | |||
| @@ -132,7 +132,7 @@ func getNotifications(c *context.Context) { | |||
| } | |||
| c.Data["Title"] = c.Tr("notifications") | |||
| c.Data["Keyword"] = keyword | |||
| //c.Data["Keyword"] = keyword | |||
| c.Data["Status"] = status | |||
| c.Data["Notifications"] = notifications | |||
| @@ -20,7 +20,7 @@ | |||
| <div id="homenews" class="ui container"> | |||
| <p>* {{.page_only_dynamic}}</p> | |||
| <div class="ui grid"> | |||
| <div class="twelve wide tablet ten wide computer column homenews"> | |||
| <div class="sixteen wide mobile twelve wide tablet ten wide computer column homenews"> | |||
| <div class="newslist"> | |||
| <div class="ui mini aligned list swiper-wrapper" id="newmessage"> | |||
| @@ -42,7 +42,11 @@ | |||
| <a href="{{AppSubUrl}}/explore/organizations" class="circular ui primary basic button">{{.page_recommend_org_more}} <i class="arrow circle right icon"></i></a> | |||
| </div> | |||
| <div class="sixteen wide tablet twelve wide computer column"> | |||
| <div class="ui stackable three column grid homeorg-list" id="recommendorg"> | |||
| <div class="homeorg-list"> | |||
| <div class="swiper-wrapper" id="recommendorg"> | |||
| </div> | |||
| <div class="swiper-pagination"></div> | |||
| </div> | |||
| </div> | |||
| @@ -78,7 +82,7 @@ | |||
| <h2>{{.page_dev_env}}</h2> | |||
| <p><span class="ui text grey">{{.page_dev_env_desc}}</p> | |||
| </div> | |||
| <div class="ui four stackable cards"> | |||
| <div class="ui four doubling cards"> | |||
| <div class="card"> | |||
| <div class="image"> | |||
| <img src="/img/i-pic-01.svg"> | |||
| @@ -158,4 +162,4 @@ | |||
| <script src="/home/home.js?v={{MD5 AppVer}}" type="text/javascript"></script> | |||
| {{template "base/footer" .}} | |||
| {{template "base/footer" .}} | |||
| @@ -14,7 +14,7 @@ | |||
| <div class="eight wide column right aligned"> | |||
| <div class="ui left mini icon buttons"> | |||
| <span class="ui basic button text left" data-tooltip='{{$.i18n.Tr "dataset.download_count"}}' data-position="bottom right" style="width: 60px; padding-left: 0;">{{svg "octicon-flame" 16}} {{(.DownloadCount | PrettyNumber)}}</span> | |||
| <span class="ui basic basic button clipboard" data-clipboard-text="{{.DownloadURL}}" data-tooltip='{{$.i18n.Tr "dataset.copy_url"}}' data-clipboard-action="copy"{{if ne $.Type 0}} style="display:none;"{{end}}>{{svg "octicon-file" 16}}</span> | |||
| <span class="ui basic basic button clipboard" data-clipboard-text="{{.DownloadURL}}" data-tooltip='{{$.i18n.Tr "dataset.copy_url"}}' data-clipboard-action="copy">{{svg "octicon-file" 16}}</span> | |||
| <span class="ui basic basic button clipboard" data-clipboard-text="{{.FileChunk.Md5}}" data-tooltip='{{$.i18n.Tr "dataset.copy_md5"}}' data-clipboard-action="copy">{{svg "octicon-file-binary" 16}}</span> | |||
| </div> | |||
| {{if eq .DecompressState 1}} | |||
| @@ -287,13 +287,13 @@ | |||
| <div class="row"> | |||
| <!-- 任务名 --> | |||
| <div class="four wide column"> | |||
| <a class="title" href='{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain{{else}}{{$.RepoLink}}/modelarts/notebook{{end}}/{{.JobID}}' title="{{.JobName}}" style="font-size: 14px;"> | |||
| <a class="title" href='{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain/{{.JobName}}{{else}}{{$.RepoLink}}/modelarts/notebook/{{.JobID}}{{end}}' title="{{.JobName}}" style="font-size: 14px;"> | |||
| <span class="fitted text_over" style="width: 90%;vertical-align: middle;">{{.JobName}}</span> | |||
| </a> | |||
| </div> | |||
| <div class="two wide column text center"> | |||
| <!--任务状态 --> | |||
| <span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}" data-resource="{{.ComputeResource}}"> | |||
| <span class="job-status" id="{{.JobID}}" data-repopath="{{$.RepoRelPath}}" data-jobid="{{.JobID}}" data-resource="{{.ComputeResource}}" data-jobname="{{.JobName}}"> | |||
| <span><i id="{{.JobID}}-icon" style="vertical-align: middle;" class="{{.Status}}"></i><span id="{{.JobID}}-text" style="margin-left: 0.4em;font-size: 12px;">{{.Status}}</span></span> | |||
| </span> | |||
| </div> | |||
| @@ -366,7 +366,7 @@ | |||
| </form> | |||
| <!-- 删除 --> | |||
| <form id="delForm-{{.JobID}}" action="{{if eq .ComputeResource "CPU/GPU"}}{{$.RepoLink}}/cloudbrain{{else}}{{$.RepoLink}}/modelarts/notebook{{end}}/{{.JobID}}/del" method="post"> | |||
| <input type="hidden" name="debugListType" value="all"> | |||
| <input type="hidden" name="debugListType" value="{{$.ListType}}"> | |||
| {{$.CsrfTokenHtml}} | |||
| {{if .CanDel}} | |||
| <a id="model-delete-{{.JobID}}" class='ui basic {{if eq .Status "STOPPED" "FAILED" "START_FAILED"}}blue {{else}}disabled {{end}}button' onclick="assertDelete(this)" style="border-radius: .28571429rem;"> | |||
| @@ -607,6 +607,7 @@ | |||
| function loadJobStatus() { | |||
| $(".job-status").each((index, job) => { | |||
| const jobID = job.dataset.jobid; | |||
| const jobName = job.dataset.jobname; | |||
| const repoPath = job.dataset.repopath; | |||
| const computeResource = job.dataset.resource | |||
| const initArray = ['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED','UNAVAILABLE','DELETED','RESIZE_FAILED'] | |||
| @@ -615,38 +616,39 @@ | |||
| return | |||
| } | |||
| const diffResource = computeResource == "NPU" ? 'modelarts/notebook' : 'cloudbrain' | |||
| $.get(`/api/v1/repos/${repoPath}/${diffResource}/${jobID}`, (data) => { | |||
| const jobID = data.JobID | |||
| const diffApi = computeResource == "NPU" ? jobID : jobName | |||
| $.get(`/api/v1/repos/${repoPath}/${diffResource}/${diffApi}`, (data) => { | |||
| const jobName = data.JobName | |||
| const status = data.JobStatus | |||
| if (status != job.textContent.trim()) { | |||
| $('#' + jobID+'-icon').removeClass().addClass(status) | |||
| $('#' + jobID+ '-text').text(status) | |||
| $('#' + jobName+'-icon').removeClass().addClass(status) | |||
| $('#' + jobName+ '-text').text(status) | |||
| } | |||
| if(status==="RUNNING"){ | |||
| $('#model-debug-'+jobID).removeClass('disabled').addClass('blue').text('调试').css("margin","0 1rem") | |||
| $('#model-image-'+jobID).removeClass('disabled').addClass('blue') | |||
| $('#model-debug-'+jobName).removeClass('disabled').addClass('blue').text('调试').css("margin","0 1rem") | |||
| $('#model-image-'+jobName).removeClass('disabled').addClass('blue') | |||
| } | |||
| if(status!=="RUNNING"){ | |||
| // $('#model-debug-'+jobID).removeClass('blue') | |||
| // $('#model-debug-'+jobID).addClass('disabled') | |||
| $('#model-image-'+jobID).removeClass('blue').addClass('disabled') | |||
| $('#model-image-'+jobName).removeClass('blue').addClass('disabled') | |||
| } | |||
| if(["CREATING","STOPPING","WAITING","STARTING"].includes(status)){ | |||
| $('#model-debug-'+jobID).removeClass('blue').addClass('disabled') | |||
| $('#model-debug-'+jobName).removeClass('blue').addClass('disabled') | |||
| } | |||
| if(['STOPPED','FAILED','START_FAILED','CREATE_FAILED','SUCCEEDED'].includes(status)){ | |||
| $('#model-debug-'+jobID).removeClass('disabled').addClass('blue').text('再次调试').css("margin","0") | |||
| $('#model-debug-'+jobName).removeClass('disabled').addClass('blue').text('再次调试').css("margin","0") | |||
| } | |||
| if(["RUNNING","WAITING"].includes(status)){ | |||
| $('#stop-model-debug-'+jobID).removeClass('disabled').addClass('blue') | |||
| $('#stop-model-debug-'+jobName).removeClass('disabled').addClass('blue') | |||
| } | |||
| if(["CREATING","STOPPING","STARTING","STOPPED","FAILED","START_FAILED","SUCCEEDED"].includes(status)){ | |||
| $('#stop-model-debug-'+jobID).removeClass('blue').addClass('disabled') | |||
| $('#stop-model-debug-'+jobName).removeClass('blue').addClass('disabled') | |||
| } | |||
| if(status==="STOPPED" || status==="FAILED"|| status==="START_FAILED"){ | |||
| $('#model-delete-'+jobID).removeClass('disabled').addClass('blue') | |||
| $('#model-delete-'+jobName).removeClass('disabled').addClass('blue') | |||
| }else{ | |||
| $('#model-delete-'+jobID).removeClass('blue').addClass('disabled') | |||
| $('#model-delete-'+jobName).removeClass('blue').addClass('disabled') | |||
| } | |||
| }).fail(function(err) { | |||
| console.log(err); | |||
| @@ -255,9 +255,9 @@ | |||
| {{end}} | |||
| </div> | |||
| <div class="ui six wide tablet four wide computer column"> | |||
| <div id="repo-desc"> | |||
| <h4 id="about-desc" class="ui header">简介</h4> | |||
| <input type="hidden" id="edit-alias" value="{{.Repository.Alias}}"> | |||
| <div id="repo-desc" data-IsSigned= "{{.IsSigned}}" > | |||
| <h4 id="about-desc" class="ui header">简介</h4> | |||
| <input type="hidden" id="edit-alias" value="{{.Repository.Alias}}"> | |||
| <p> | |||
| {{if .Repository.DescriptionHTML}} | |||
| <span class="description" style="word-break:break-all">{{.Repository.DescriptionHTML}}</span> | |||
| @@ -1,7 +1,7 @@ | |||
| <template> | |||
| <div> | |||
| <h4 id="about-desc" class="ui header desc-home">简介 | |||
| <a class="edit-icon" href="javascript:void(0)" @click="editClick"> | |||
| <a class="edit-icon" v-if="IsSigned" id ="editBtn" href="javascript:void(0)" @click="editClick" > | |||
| <i class="gray edit outline icon" style="margin-right: 0;"></i> | |||
| </a> | |||
| </h4> | |||
| @@ -52,7 +52,8 @@ export default { | |||
| desc: '', | |||
| index_web: '', | |||
| repo_name_name: '', | |||
| alias:'' | |||
| alias:'', | |||
| IsSigned:false | |||
| }, | |||
| // rule1:[{min:3,max:5,message:'1',trigger:"blur"}], | |||
| rule: { | |||
| @@ -63,8 +64,17 @@ export default { | |||
| }; | |||
| }, | |||
| methods: { | |||
| getIsSigned(){ | |||
| this.IsSigned = document.getElementById("repo-desc").dataset.issigned; | |||
| // console.log("IsSigned:",this.IsSigned) | |||
| if (this.IsSigned==true || this.IsSigned=="true"){ | |||
| this.IsSigned=true; | |||
| } | |||
| }, | |||
| editClick() { | |||
| this.editDataDialog = true; | |||
| if (this.IsSigned){ | |||
| this.editDataDialog = true; | |||
| } | |||
| }, | |||
| getDesc() { | |||
| const el = $('span.description').text(); | |||
| @@ -121,6 +131,7 @@ export default { | |||
| } | |||
| }, | |||
| mounted() { | |||
| this.getIsSigned(); | |||
| this.getUrl(); | |||
| this.getRepoName(); | |||
| this.getDesc(); | |||
| @@ -135,7 +146,7 @@ export default { | |||
| } | |||
| }, | |||
| created() { | |||
| this.getIsSigned(); | |||
| } | |||
| }; | |||