| @@ -51,6 +51,7 @@ type Attachment struct { | |||||
| FileChunk *FileChunk `xorm:"-"` | FileChunk *FileChunk `xorm:"-"` | ||||
| CanDel bool `xorm:"-"` | CanDel bool `xorm:"-"` | ||||
| Uploader *User `xorm:"-"` | Uploader *User `xorm:"-"` | ||||
| Md5 string `xorm:"-"` | |||||
| } | } | ||||
| type AttachmentUsername struct { | type AttachmentUsername struct { | ||||
| @@ -1,6 +1,7 @@ | |||||
| package models | package models | ||||
| import ( | import ( | ||||
| "code.gitea.io/gitea/modules/log" | |||||
| "errors" | "errors" | ||||
| "fmt" | "fmt" | ||||
| "sort" | "sort" | ||||
| @@ -297,7 +298,13 @@ func getDatasetAttachments(e Engine, typeCloudBrain int, isSigned bool, user *Us | |||||
| if err != nil { | if err != nil { | ||||
| return err | return err | ||||
| } | } | ||||
| attachment.FileChunk = fileChunks[0] | |||||
| if len(fileChunks) > 0 { | |||||
| attachment.Md5 = fileChunks[0].Md5 | |||||
| } else { | |||||
| log.Error("has attachment record, but has no file_chunk record") | |||||
| attachment.Md5 = "no_record" | |||||
| } | |||||
| attachment.CanDel = CanDelAttachment(isSigned, user, attachment) | attachment.CanDel = CanDelAttachment(isSigned, user, attachment) | ||||
| sortedRels.Rel[currentIndex].Attachments = append(sortedRels.Rel[currentIndex].Attachments, attachment) | sortedRels.Rel[currentIndex].Attachments = append(sortedRels.Rel[currentIndex].Attachments, attachment) | ||||
| } | } | ||||
| @@ -249,7 +249,7 @@ func NotebookShow(ctx *context.Context) { | |||||
| debugListType := ctx.Query("debugListType") | debugListType := ctx.Query("debugListType") | ||||
| var ID = ctx.Params(":id") | var ID = ctx.Params(":id") | ||||
| task, err := models.GetCloudbrainByID(ID) | |||||
| task, err := models.GetCloudbrainByIDWithDeleted(ID) | |||||
| if err != nil { | if err != nil { | ||||
| ctx.Data["error"] = err.Error() | ctx.Data["error"] = err.Error() | ||||
| ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) | ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) | ||||
| @@ -264,16 +264,19 @@ func NotebookShow(ctx *context.Context) { | |||||
| } | } | ||||
| if result != nil { | if result != nil { | ||||
| task.Status = result.Status | |||||
| err = models.UpdateJob(task) | |||||
| if err != nil { | |||||
| ctx.Data["error"] = err.Error() | |||||
| ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) | |||||
| return | |||||
| } | |||||
| if task.DeletedAt.IsZero() { //normal record | |||||
| if task.Status != result.Status { | |||||
| task.Status = result.Status | |||||
| err = models.UpdateJob(task) | |||||
| if err != nil { | |||||
| ctx.Data["error"] = err.Error() | |||||
| ctx.RenderWithErr(err.Error(), tplModelArtsNotebookShow, nil) | |||||
| return | |||||
| } | |||||
| } | |||||
| } else { //deleted record | |||||
| result.CreateTime = time.Unix(int64(result.CreateAt/1000), 0).Format("2006-01-02 15:04:05") | |||||
| result.LatestUpdateTime = time.Unix(int64(result.UpdateAt/1000), 0).Format("2006-01-02 15:04:05") | |||||
| } | |||||
| } | } | ||||
| datasetDownloadLink := "-" | datasetDownloadLink := "-" | ||||
| @@ -319,7 +322,6 @@ func NotebookShow(ctx *context.Context) { | |||||
| ctx.Data["task"] = task | ctx.Data["task"] = task | ||||
| ctx.Data["ID"] = ID | ctx.Data["ID"] = ID | ||||
| ctx.Data["jobName"] = task.JobName | ctx.Data["jobName"] = task.JobName | ||||
| ctx.Data["result"] = result | |||||
| ctx.Data["debugListType"] = debugListType | ctx.Data["debugListType"] = debugListType | ||||
| ctx.HTML(200, tplModelArtsNotebookShow) | ctx.HTML(200, tplModelArtsNotebookShow) | ||||
| } | } | ||||
| @@ -199,7 +199,7 @@ | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| {{range $k, $v :=.Attachments}} | {{range $k, $v :=.Attachments}} | ||||
| <div class="ui grid stackable item" id="{{.FileChunk.UUID}}"> | |||||
| <div class="ui grid stackable item" id="{{.UUID}}"> | |||||
| <div class="row"> | <div class="row"> | ||||
| <!-- 数据集名称 --> | <!-- 数据集名称 --> | ||||
| @@ -266,8 +266,8 @@ | |||||
| <a class="ui basic blue button" href="datasets/dirs/{{.UUID}}?type={{$.Type}}" data-tooltip='{{$.i18n.Tr "dataset.directory"}}'>{{$.i18n.Tr "preview"}}</a> | <a class="ui basic blue button" href="datasets/dirs/{{.UUID}}?type={{$.Type}}" data-tooltip='{{$.i18n.Tr "dataset.directory"}}'>{{$.i18n.Tr "preview"}}</a> | ||||
| {{end}} | {{end}} | ||||
| {{if and (.CanDel) (not $.Repository.IsPrivate)}} | {{if and (.CanDel) (not $.Repository.IsPrivate)}} | ||||
| <span class="ui basic blue button" style="color: #13c28d !important;" @click="setPrivate('{{.FileChunk.UUID}}',false,{{$k}})" v-if="privates[{{$k}}]">{{$.i18n.Tr "dataset.set_public"}}</span> | |||||
| <span class="ui basic blue button" style="color: #fa8c16 !important;" @click="setPrivate('{{.FileChunk.UUID}}',true,{{$k}})" v-else="privates[{{$k}}]">{{$.i18n.Tr "dataset.set_private"}}</span> | |||||
| <span class="ui basic blue button" style="color: #13c28d !important;" @click="setPrivate('{{.UUID}}',false,{{$k}})" v-if="privates[{{$k}}]">{{$.i18n.Tr "dataset.set_public"}}</span> | |||||
| <span class="ui basic blue button" style="color: #fa8c16 !important;" @click="setPrivate('{{.UUID}}',true,{{$k}})" v-else="privates[{{$k}}]">{{$.i18n.Tr "dataset.set_private"}}</span> | |||||
| {{end}} | {{end}} | ||||
| <!-- {{if $.CanRead}} | <!-- {{if $.CanRead}} | ||||
| <a class="ui basic blue button" href="datasets/label/{{.UUID}}?type={{$.Type}}" data-tooltip='{{$.i18n.Tr "dataset.create_label_task"}}'>标注</a> | <a class="ui basic blue button" href="datasets/label/{{.UUID}}?type={{$.Type}}" data-tooltip='{{$.i18n.Tr "dataset.create_label_task"}}'>标注</a> | ||||
| @@ -281,13 +281,13 @@ | |||||
| </span> | </span> | ||||
| <el-dropdown-menu slot="dropdown"> | <el-dropdown-menu slot="dropdown"> | ||||
| <el-dropdown-item class="clipboard" data-clipboard-text="{{.DownloadURL}}" data-clipboard-action="copy">{{$.i18n.Tr "dataset.copy_url"}}</el-dropdown-item> | <el-dropdown-item class="clipboard" data-clipboard-text="{{.DownloadURL}}" data-clipboard-action="copy">{{$.i18n.Tr "dataset.copy_url"}}</el-dropdown-item> | ||||
| <el-dropdown-item class="clipboard" data-clipboard-text="{{.FileChunk.Md5}}" data-clipboard-action="copy">{{$.i18n.Tr "dataset.copy_md5"}}</el-dropdown-item> | |||||
| <el-dropdown-item class="clipboard" data-clipboard-text="{{.Md5}}" data-clipboard-action="copy">{{$.i18n.Tr "dataset.copy_md5"}}</el-dropdown-item> | |||||
| {{if and ($.CanWrite) (eq .DecompressState 1) }} | {{if and ($.CanWrite) (eq .DecompressState 1) }} | ||||
| <el-dropdown-item @click.native="gotoAnnotate('{{$.RepoLink}}','{{.UUID}}',{{.Type}})">{{$.i18n.Tr "dataset.annotation"}}</el-dropdown-item> | <el-dropdown-item @click.native="gotoAnnotate('{{$.RepoLink}}','{{.UUID}}',{{.Type}})">{{$.i18n.Tr "dataset.annotation"}}</el-dropdown-item> | ||||
| {{end}} | {{end}} | ||||
| {{if .CanDel}} | {{if .CanDel}} | ||||
| <el-dropdown-item @click.native="gotoDatasetEidt('{{$.RepoLink}}',{{.ID}})">{{$.i18n.Tr "dataset.modify_description"}}</el-dropdown-item> | <el-dropdown-item @click.native="gotoDatasetEidt('{{$.RepoLink}}',{{.ID}})">{{$.i18n.Tr "dataset.modify_description"}}</el-dropdown-item> | ||||
| <el-dropdown-item style="color: red;" @click.native="delDataset('{{.FileChunk.UUID}}')">{{$.i18n.Tr "dataset.delete"}}</el-dropdown-item> | |||||
| <el-dropdown-item style="color: red;" @click.native="delDataset('{{.UUID}}')">{{$.i18n.Tr "dataset.delete"}}</el-dropdown-item> | |||||
| {{end}} | {{end}} | ||||
| </el-dropdown-menu> | </el-dropdown-menu> | ||||
| </el-dropdown> | </el-dropdown> | ||||
| @@ -282,8 +282,11 @@ td, th { | |||||
| <td class="ti-text-form-content"> | <td class="ti-text-form-content"> | ||||
| <div class="text-span text-span-w" id="updateTime"> | <div class="text-span text-span-w" id="updateTime"> | ||||
| {{TimeSinceUnix1 .UpdatedUnix}} | |||||
| {{if not (eq .EndTime 0)}} | |||||
| {{TimeSinceUnix1 .EndTime}} | |||||
| {{else}} | |||||
| {{TimeSinceUnix1 .UpdatedUnix}} | |||||
| {{end}} | |||||
| </div> | </div> | ||||
| </td> | </td> | ||||