* DELETE /api/devcontainer?repoId=${repoId} 删除 DevContainer
* refactor
* GET /api/devcontainer?repoId=${repoId}&wait=true 阻塞式等待打开就绪的 DevContainer
* POST /api/devcontainer 创建 DevContainer
* refactored the code
* Updated context usage with cancel function
* 预留接口,适配单机版 DevStar DevContainer
* bugFix: context canceled while deleting k8s CRD DevcontainerApp
* 用户界面删除 k8s CRD DevContainer
* 用户界面创建 DevContainer 并更新 NodePort
* 完成用户界面创建 DevContainer
* transplant test code into DevStar Studio
* refactored API router to /routers/api
* 更改 DevContainer Doc
* 更改 DevContainer namespace
* 特殊仓库重定向
* [Doc] 更新 Kubernetes 部署 DevStar Studio 文档说明,特别是 namespace 管理
* [Doc] 更新 CI脚本说明
* Revert "optimized CI workflow"
* optimized CI workflow
* fix typo
* [feature test]: 测试 Pod 内使用 Kubernetes Operator 功能
* [Optimization] error msg for archived repo
* [Optimization]: display detailed err msg on creating devContainer for …
60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package setting
|
||
|
||
import (
|
||
"code.gitea.io/gitea/models/db"
|
||
"code.gitea.io/gitea/modules/base"
|
||
"code.gitea.io/gitea/modules/setting"
|
||
DevcontainersVO "code.gitea.io/gitea/routers/api/devcontainer/vo"
|
||
gitea_context "code.gitea.io/gitea/services/context"
|
||
devstar_devcontainer_service "code.gitea.io/gitea/services/devstar_devcontainer"
|
||
"net/http"
|
||
)
|
||
|
||
const (
|
||
tplSettingsDevContainers base.TplName = "user/settings/dev_containers_list"
|
||
)
|
||
|
||
// ListDevContainers 展示用户所有开发容器
|
||
func ListDevContainers(ctx *gitea_context.Context) {
|
||
|
||
// 1. 检查页面是否登录,若未登录则重定向到登录页
|
||
ctxUser := ctx.Doer
|
||
if ctxUser == nil {
|
||
ctx.Redirect(setting.AppSubURL + string(setting.LandingPageLogin))
|
||
return
|
||
}
|
||
|
||
// 2. 设置前端展示元数据数据
|
||
ctx.Data["Title"] = ctx.Tr("settings.dev_containers_list")
|
||
ctx.Data["PageIsSettingsDevContainersList"] = true
|
||
|
||
// 3. 分页查询
|
||
paginationOptions := db.ListOptions{
|
||
PageSize: setting.UI.Admin.DevContainersPagingNum, // 参考 app.ini 配置文件 ui.admin.DEV_CONTAINERS_PAGING_NUM,默认50
|
||
Page: ctx.FormInt("page"), // URL参数起始页码
|
||
}
|
||
if paginationOptions.Page <= 0 {
|
||
paginationOptions.Page = 1
|
||
}
|
||
opts := &DevcontainersVO.SearchUserDevcontainerListItemVoOptions{
|
||
PaginationOptions: paginationOptions,
|
||
Actor: ctxUser,
|
||
}
|
||
userDevcontainersListVO, err := devstar_devcontainer_service.GetUserDevcontainersList(ctx, opts)
|
||
if err != nil {
|
||
ctx.ServerError("ListDevContainers", err)
|
||
return
|
||
}
|
||
ctx.Data["DevContainers"] = userDevcontainersListVO.DevContainers
|
||
ctx.Data["ContextUser"] = ctxUser
|
||
itemTotalNum := userDevcontainersListVO.ItemTotalNum
|
||
pageTotalNum := userDevcontainersListVO.PageTotalNum
|
||
pageSize := userDevcontainersListVO.PageSize
|
||
currentPage := userDevcontainersListVO.Page
|
||
pager := gitea_context.NewPagination(int(itemTotalNum), pageSize, currentPage, pageTotalNum)
|
||
pager.SetDefaultParams(ctx)
|
||
ctx.Data["Page"] = pager
|
||
ctx.HTML(http.StatusOK, tplSettingsDevContainers)
|
||
return
|
||
}
|