Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/router/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ func setupTenant(r chi.Router,
r.Route(fmt.Sprintf("/{%s}", request.PathParamTenantUID), func(r chi.Router) {
r.Use(middlewareinject.InjectTenant(tenantCtrl))
r.Get("/", handlertenant.HandleGet(tenantCtrl, projectCtrl))
setupProject(r, appCtx, tenantCtrl, projectCtrl, envCtrl, ghAppCtrl, gitPublicCtrl, appCtrl, varCtrl, deploymentCtrl, logsCtrl, volumeCtrl, templCtrl, favCtrl)
r.Get("/favorites", handlerfavorite.HandleListFavorites(favCtrl))
setupProject(r, appCtx, tenantCtrl, projectCtrl, envCtrl, ghAppCtrl, gitPublicCtrl, appCtrl, varCtrl, deploymentCtrl, logsCtrl, volumeCtrl, templCtrl, favCtrl)

// Admin routes
r.Route("/", func(r chi.Router) {
Expand Down Expand Up @@ -292,6 +292,7 @@ func setupProject(r chi.Router,
r.Use(middlewarerestrict.ToTeamAdmin())
r.Post("/", handlerproject.HandleAdd(projectCtrl))
})
r.Get("/nav", handlerproject.HandleListNavigation(projectCtrl))
r.Route(fmt.Sprintf("/{%s}", request.PathParamProjectUID), func(r chi.Router) {
r.Use(middlewareinject.InjectProject(projectCtrl))
r.Use(middlewarerestrict.ToProjectRole())
Expand Down Expand Up @@ -332,6 +333,7 @@ func setupEnvionment(r chi.Router,
r.Route("/environment", func(r chi.Router) {
r.Get("/", handlerenvironment.HandleList(envCtrl))
r.Post("/create", handlerenvironment.HandleAdd(envCtrl))
r.Get("/nav", handlerenvironment.HandleListNavigation(envCtrl))
r.Route(fmt.Sprintf("/{%s}", request.PathParamEnvironmentUID), func(r chi.Router) {
r.Use(middlewareinject.InjectEnvironment(envCtrl))
r.Route("/", func(r chi.Router) {
Expand All @@ -354,6 +356,7 @@ func setupEnvionment(r chi.Router,
func setupApplication(r chi.Router, appCtx context.Context, envCtrl *environment.Controller, appCtrl *application.Controller, varCtrl *variable.Controller, ghAppCtrl *githubapp.Controller, gitPublicCtrl *gitpublic.Controller, deploymentCtrl *deployment.Controller, logsCtrl *logs.Controller, volumeCtrl *volume.Controller, templCtrl *template.Controller, favCtrl *favorite.Controller) {
r.Route("/application", func(r chi.Router) {
r.Get("/", handlerapplication.HandleList(envCtrl, appCtrl))
r.Get("/nav", handlerapplication.HandleListNavigation(appCtrl))
r.Route(fmt.Sprintf("/{%s}", request.PathParamApplicationUID), func(r chi.Router) {
//Inject application here
r.Use(middlewareinject.InjectApplication(appCtrl))
Expand Down
6 changes: 6 additions & 0 deletions app/utils/routes/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const (
AppNetworkTCP = "network/tcp"
AppFavorite = "favorite"

AppNav = "/nav"

AppSourceGithub = "source/github"
AppSourceGitPublic = "source/git-public"
AppSourceRegistry = "source/registry"
Expand All @@ -53,6 +55,10 @@ func ApplicationCtx(ctx context.Context) string {
return fmt.Sprintf("%s/application/%d", EnvironmentCtx(ctx), app.UID)
}

func ApplicationCtxUID(ctx context.Context, appUID int64) string {
return fmt.Sprintf("%s/application/%d", EnvironmentCtx(ctx), appUID)
}

func ApplicationProject(projectUID, envUID, appUID int64) string {
return fmt.Sprintf("%s/%s", Project(projectUID), Application(envUID, appUID))
}
5 changes: 5 additions & 0 deletions app/utils/routes/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
EnvironmentSettings = "/settings"
EnvironmentDelete = "/delete"
EnvironmentVolumes = "/volumes"
EnvironmentNav = "/nav"
)

func Environment(uid int64) string {
Expand All @@ -30,6 +31,10 @@ func EnvironmentCtx(ctx context.Context) string {
return fmt.Sprintf("%s/environment/%d", ProjectCtx(ctx), environment.UID)
}

func EnvironmentCtxUID(ctx context.Context, envUID int64) string {
return fmt.Sprintf("%s/environment/%d", ProjectCtx(ctx), envUID)
}

func EnvironmentApplicationCtx(ctx context.Context) string {
return fmt.Sprintf("%s/%s%s", EnvironmentCtx(ctx), EnvironmentApplication, TargetMainQuery)
}
Expand Down
5 changes: 5 additions & 0 deletions app/utils/routes/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
ProjectMembers = "members"
ProjectSettings = "settings"
ProjectDelete = "delete"
ProjectNav = "/nav"

ProjectSourceGithub = "source/github"
)
Expand All @@ -34,6 +35,10 @@ func ProjectCtx(ctx context.Context) string {
return fmt.Sprintf("%s/project/%d", TenantCtx(ctx), project.UID)
}

func ProjectCtxUID(ctx context.Context, projectUID int64) string {
return fmt.Sprintf("%s/project/%d", TenantCtx(ctx), projectUID)
}

func ProjectGithubCtx(ctx context.Context, ghApp *types.GithubApp) string {
base := fmt.Sprintf("%s/%s", ProjectCtx(ctx), ProjectSourceGithub)
if ghApp != nil {
Expand Down
28 changes: 28 additions & 0 deletions app/web/handler/application/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/cloudness-io/cloudness/app/web/render"
"github.com/cloudness-io/cloudness/app/web/views/components/vapplication"
"github.com/cloudness-io/cloudness/app/web/views/components/vproject"
"github.com/cloudness-io/cloudness/app/web/views/dto"
"github.com/cloudness-io/cloudness/app/web/views/shared"
"github.com/cloudness-io/cloudness/types"

"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -51,3 +53,29 @@ func RenderAppList(ctx context.Context, w http.ResponseWriter, r *http.Request,
}
render.Page(ctx, w, vproject.Overview(project, envs, env, apps))
}

func HandleListNavigation(appctrl *application.Controller) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
tenant, _ := request.TenantFrom(ctx)
project, _ := request.ProjectFrom(ctx)
env, _ := request.EnvironmentFrom(ctx)

apps, err := appctrl.List(ctx, tenant.ID, project.ID, env.ID)
if err != nil {
log.Ctx(ctx).Error().Err(err).Msg("Error listing application")
render.ToastError(ctx, w, err)
return
}

listItems := make([]*dto.BreadCrumbListItem, 0)
for _, app := range apps {
listItems = append(listItems, &dto.BreadCrumbListItem{
Name: app.Name,
Link: routes.ApplicationCtxUID(ctx, app.UID),
})
}

render.HTML(ctx, w, shared.BreadCrumbDropdownList(listItems))
}
}
28 changes: 28 additions & 0 deletions app/web/handler/environment/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import (

"github.com/cloudness-io/cloudness/app/controller/environment"
"github.com/cloudness-io/cloudness/app/request"
"github.com/cloudness-io/cloudness/app/utils/routes"
"github.com/cloudness-io/cloudness/app/web/render"
"github.com/cloudness-io/cloudness/app/web/views/components/vproject"
"github.com/cloudness-io/cloudness/app/web/views/dto"
"github.com/cloudness-io/cloudness/app/web/views/shared"

"github.com/rs/zerolog/log"
)
Expand All @@ -27,3 +30,28 @@ func HandleList(envCtrl *environment.Controller) http.HandlerFunc {
render.Page(ctx, w, vproject.ListEnvs(project, envs, nil))
}
}

func HandleListNavigation(envCtrl *environment.Controller) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
tenant, _ := request.TenantFrom(ctx)
project, _ := request.ProjectFrom(ctx)

envs, err := envCtrl.List(ctx, tenant.ID, project.ID)
if err != nil {
log.Ctx(ctx).Error().Err(err).Msg("Error listing environments")
render.ToastError(ctx, w, err)
return
}

listItems := make([]*dto.BreadCrumbListItem, 0)
for _, env := range envs {
listItems = append(listItems, &dto.BreadCrumbListItem{
Name: env.Name,
Link: routes.EnvironmentCtxUID(ctx, env.UID) + routes.EnvironmentApplication + routes.TargetMainQuery,
})
}

render.HTML(ctx, w, shared.BreadCrumbDropdownList(listItems))
}
}
39 changes: 39 additions & 0 deletions app/web/handler/project/list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package project

import (
"net/http"

"github.com/cloudness-io/cloudness/app/controller/project"
"github.com/cloudness-io/cloudness/app/request"
"github.com/cloudness-io/cloudness/app/utils/routes"
"github.com/cloudness-io/cloudness/app/web/render"
"github.com/cloudness-io/cloudness/app/web/views/dto"
"github.com/cloudness-io/cloudness/app/web/views/shared"

"github.com/rs/zerolog/log"
)

func HandleListNavigation(projectCtrl *project.Controller) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
session, _ := request.AuthSessionFrom(ctx)
tenant, _ := request.TenantFrom(ctx)

projects, err := projectCtrl.List(ctx, tenant.ID, session.Principal.ID)
if err != nil {
log.Ctx(ctx).Error().Err(err).Msg("Error listing projects")
render.ToastError(ctx, w, err)
return
}

listItems := make([]*dto.BreadCrumbListItem, 0)
for _, project := range projects {
listItems = append(listItems, &dto.BreadCrumbListItem{
Name: project.Name,
Link: routes.ProjectCtxUID(ctx, project.UID),
})
}

render.HTML(ctx, w, shared.BreadCrumbDropdownList(listItems))
}
}
2 changes: 1 addition & 1 deletion app/web/views/components/vinstance/registry.templ
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ templ Registry(instance *types.Instance) {
<form
class="flex flex-col gap-5 w-full mt-2"
x-data={ xdata.ToFormData(instance) }
x-clock
x-cloak
>
@shared.CheckBox(&shared.CheckBoxProps{
Name: "registry_enabled",
Expand Down
2 changes: 1 addition & 1 deletion app/web/views/components/vinstance/settings.templ
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ templ Settings(instance *types.Instance, server *types.Server) {
AdditionalScripts: instance.AdditionalScripts,
}) }
x-data={ xdata.ToFormData(instance) }
x-clock
x-cloak
>
@shared.Input(&shared.InputProps{
Name: "fqdn",
Expand Down
2 changes: 1 addition & 1 deletion app/web/views/components/vproject/settings.templ
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ templ projectGeneralSettings(project *types.Project) {
<form
class="flex flex-col place-items-baseline mt-2 gap-2"
x-data={ xdata.ToFormData(&projectGeneralForm{project.Name, project.Description}) }
x-clock
x-cloak
>
@shared.Input(&shared.InputProps{
Name: "name",
Expand Down
2 changes: 1 addition & 1 deletion app/web/views/components/vserver/general.templ
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ templ generalSetting(server *types.Server) {
Name: server.Name,
Description: server.Description,
}) }
x-clock
x-cloak
>
@shared.Input(&shared.InputProps{
Name: "name",
Expand Down
2 changes: 1 addition & 1 deletion app/web/views/components/vserver/limits.templ
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ templ limits(server *types.Server) {
SupportsOnlineExpansion: server.VolumeSupportsOnlineExpansion,
MinVolumeSize: server.VolumeMinSize,
}) }
x-clock
x-cloak
hx-push-url="false"
>
<h4>Volume Limits</h4>
Expand Down
2 changes: 1 addition & 1 deletion app/web/views/components/vserver/network.templ
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ templ networkSetting(server *types.Server) {
DNSProvider: server.DNSProvider,
DNSProviderAuth: server.DNSProviderAuth,
}) }
x-clock
x-cloak
hx-push-url="false"
>
@shared.Input(&shared.InputProps{
Expand Down
2 changes: 1 addition & 1 deletion app/web/views/components/vserver/runner.templ
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ templ runnerSettings(server *types.Server) {
MaxCPUPerBuild: server.MaxCPUPerBuild,
MaxMemoryPerBuild: server.MaxMemoryPerBuild,
}) }
x-clock
x-cloak
hx-push-url="false"
>
@shared.CheckBox(&shared.CheckBoxProps{
Expand Down
2 changes: 1 addition & 1 deletion app/web/views/components/vtenant/settings.templ
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ templ Settings(tenant *types.Tenant) {
<form
class="flex flex-col place-items-baseline my-2 gap-2"
x-data={ xdata.ToFormData(&tenantGeneralForm{tenant.Name, tenant.Description}) }
x-clock
x-cloak
>
@shared.Input(&shared.InputProps{
Name: "name",
Expand Down
6 changes: 6 additions & 0 deletions app/web/views/dto/breadcrumb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package dto

type BreadCrumbListItem struct {
Name string
Link string
}
Loading
Loading