From fa09af8d32281d0ca7ef5ee2910e8f35c7625cfe Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 11:59:33 -0300 Subject: [PATCH 01/42] fix: rename read to transform --- src/presentation/ui/page/runtimes.templ | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/presentation/ui/page/runtimes.templ b/src/presentation/ui/page/runtimes.templ index 9caa0f997..535180bba 100644 --- a/src/presentation/ui/page/runtimes.templ +++ b/src/presentation/ui/page/runtimes.templ @@ -64,7 +64,7 @@ templ RuntimesIndex( } -func readRuntimesTabHeaderItems( +func transformRuntimeTypesIntoTabHeaderItems( selectedRuntimeType valueObject.RuntimeType, ) []componentStructural.HorizontalTabHeaderItem { tabHeaderItems := []componentStructural.HorizontalTabHeaderItem{ @@ -89,7 +89,7 @@ templ RuntimesTabs( vhostsHostnames []string, ) { @componentStructural.HorizontalTabHeader( - readRuntimesTabHeaderItems(runtimeOverview.Type), "updateSelectedRuntimeType", + transformRuntimeTypesIntoTabHeaderItems(runtimeOverview.Type), "updateSelectedRuntimeType", ) if runtimeOverview.Type.String() == "php" { @pageRuntimes.PhpRuntimeHorizontalTabContent(runtimeOverview, vhostsHostnames) From c670f7287a61ef6643dd83c8b6e0e4899a92920e Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 11:59:51 -0300 Subject: [PATCH 02/42] fix: re-order components for better readability --- .../phpRuntimeHorizontalTabContent.templ | 269 +++++++++--------- 1 file changed, 128 insertions(+), 141 deletions(-) diff --git a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ index 87f310960..0c5fc6ae7 100644 --- a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ +++ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ @@ -80,72 +80,38 @@ script PhpRuntimeHorizontalTabContentLocalState(defaultVhostHostname string) { }); } -templ CreatePhpMappingForm(selectedVhostHostname valueObject.Fqdn) { - -
-

The Selected Virtual Host Doesn't Map to PHP Yet

-

- In order to control PHP settings and modules, the selected virtual host needs to proxy traffic to the PHP Web Server. -
- Just click on "Create Mapping" and the system will do this for you. If you want to map a specific sub-directory of your virtual host to the PHP Web Server, go to the Advanced Settings and change the Sub-directory from "/" (root) to the desired location. -

-
-
- - - Advanced Settings - - -
-
- @componentForm.InputField("text", "path", "Subdirectory", "", false) -
-

Subdirectories are used to access different applications within the same domain. For example, if you have a website at { selectedVhostHostname.String() } and want to create a blog, you can create a subdirectory called blog and access it at { selectedVhostHostname.String() }/blog.

-
-
-
-
- - - -
- @componentForm.SubmitButton( - "create-php-mapping-button", "create mapping", "ph-plus-square", - "", false, - ) -
+templ PhpRuntimeHorizontalTabContent( + runtimeOverview presenterDto.RuntimeOverview, + vhostsHostnames []string, +) { + + @PhpRuntimeHorizontalTabContentLocalState(runtimeOverview.VirtualHostHostname.String()) + +
+
+ if runtimeOverview.IsInstalled { + if runtimeOverview.CanVirtualHostHostnameAccessRuntime { + @FunctionalPhpRuntimeContent(runtimeOverview, vhostsHostnames) + } else { + @CreatePhpMappingForm(runtimeOverview.VirtualHostHostname) + } + } else { + @componentStructural.ServiceNotInstalledWarningForm("php") + }
- -} - -func transformPhpVersionOptionsIntoStringSlice( - versionOptions []valueObject.PhpVersion, -) []string { - versionOptionsStrSlice := []string{} - for _, versionOption := range versionOptions { - versionOptionsStrSlice = append(versionOptionsStrSlice, versionOption.String()) - } - - return versionOptionsStrSlice + @UpdatePhpVersionModal() +
} -templ PhpModulesCheckboxInputsSwitchToggles( - selectedPhpVersion entity.PhpVersion, - modules []entity.PhpModule, -) { +templ PhpModulesCheckboxInputsSwitchToggles(phpConfigs *entity.PhpConfigs) { - @templ.JSONScript("phpModulesCheckInputsSwitchToggles", modules) + @templ.JSONScript("phpModulesCheckInputsSwitchToggles", phpConfigs.Modules)
- for _, module := range modules { + for _, module := range phpConfigs.Modules { @componentForm.CheckboxInputSwitchToggle( "", module.Name.String(), "phpConfigs.modules['"+module.Name.String()+"']", "", @@ -166,22 +132,18 @@ func transformPhpSettingsOptionsIntoStringSlice( return optionsStrSlice } -templ PhpSettingsInputs( - selectedPhpVersion entity.PhpVersion, - settings []entity.PhpSetting, -) { +templ PhpSettingsInputs(phpConfigs *entity.PhpConfigs) { - @templ.JSONScript("phpSettingsInputs", settings) + @templ.JSONScript("phpSettingsInputs", phpConfigs.Settings)
- for _, setting := range settings { + for _, setting := range phpConfigs.Settings { if setting.Type.String() == "text" { @componentForm.InputField( - setting.Value.GetType(), "", - setting.Name.String(), + setting.Value.GetType(), "", setting.Name.String(), "phpConfigs.settings['"+setting.Name.String()+"']", false, ) @@ -198,26 +160,18 @@ templ PhpSettingsInputs( } -templ UpdatePhpVersionWarningContent() { -

- Do you really want to change the PHP version? -

- Before changing, make sure your application is compatible with PHP version . -

Remember to then enable/disable the desired modules and adjust the settings in the new version, since the modules/settings of the previous version may be different.

-} - -templ UpdatePhpVersionModal() { - - @componentStructural.WarningModal( - "isUpdatePhpVersionModalOpen", "closeUpdatePhpVersionModal()", - "Cancel", "updateVersion()", - "update-version-button", "ph-swap", "Yes, change version", - ) { - @UpdatePhpVersionWarningContent() +func transformPhpVersionOptionsIntoStringSlice( + versionOptions []valueObject.PhpVersion, +) []string { + versionOptionsStrSlice := []string{} + for _, versionOption := range versionOptions { + versionOptionsStrSlice = append(versionOptionsStrSlice, versionOption.String()) } + + return versionOptionsStrSlice } -templ InstalledPhpRuntimeContent( +templ FunctionalPhpRuntimeContent( runtimeOverview presenterDto.RuntimeOverview, vhostsHostnames []string, ) { @@ -230,70 +184,103 @@ templ InstalledPhpRuntimeContent( vhostsHostnames, false, )
- if runtimeOverview.CanVirtualHostHostnameAccessRuntime { -
-
- - @componentForm.SelectInput( - "version", "Version", "phpConfigs.version", - "const phpVersion = $event.target.value; openUpdatePhpVersionModal(phpVersion)", - transformPhpVersionOptionsIntoStringSlice(runtimeOverview.PhpConfigs.Version.Options), - false, - ) + +
+ + @componentForm.SelectInput( + "version", "Version", "phpConfigs.version", + "const phpVersion = $event.target.value; openUpdatePhpVersionModal(phpVersion)", + transformPhpVersionOptionsIntoStringSlice(runtimeOverview.PhpConfigs.Version.Options), + false, + ) +
+
+ @componentStructural.VerticalTabHeader( + []componentStructural.VerticalTabHeaderItem{ + {Label: "Modules", Icon: "ph-puzzle-piece", ComponentValue: "modules"}, + {Label: "Settings", Icon: "ph-gear", ComponentValue: "settings"}, + }, "updateSelectedPhpVerticalTab", + ) +
+ @PhpModulesCheckboxInputsSwitchToggles(runtimeOverview.PhpConfigs) + @PhpSettingsInputs(runtimeOverview.PhpConfigs)
-
- @componentStructural.VerticalTabHeader( - []componentStructural.VerticalTabHeaderItem{ - {Label: "Modules", Icon: "ph-puzzle-piece", ComponentValue: "modules"}, - {Label: "Settings", Icon: "ph-gear", ComponentValue: "settings"}, - }, "updateSelectedPhpVerticalTab", +
+
+
+ @componentForm.SubmitButton( + "apply-php-runtime-configs-changes", "Apply changes", + "ph-check-fat", "", false, ) -
- @PhpModulesCheckboxInputsSwitchToggles( - runtimeOverview.PhpConfigs.Version, - runtimeOverview.PhpConfigs.Modules, - ) - @PhpSettingsInputs( - runtimeOverview.PhpConfigs.Version, - runtimeOverview.PhpConfigs.Settings, - ) -
-
-
-
- @componentForm.SubmitButton( - "apply-php-runtime-configs-changes", "Apply changes", - "ph-check-fat", "", false, - ) -
- - } else { -
- @CreatePhpMappingForm(runtimeOverview.VirtualHostHostname) - } +
+
} -templ PhpRuntimeHorizontalTabContent( - runtimeOverview presenterDto.RuntimeOverview, - vhostsHostnames []string, -) { - - @PhpRuntimeHorizontalTabContentLocalState(runtimeOverview.VirtualHostHostname.String()) -
-
- if runtimeOverview.IsInstalled { - @InstalledPhpRuntimeContent(runtimeOverview, vhostsHostnames) - } else { - @componentStructural.ServiceNotInstalledWarningForm("php") - } +templ CreatePhpMappingForm(selectedVhostHostname valueObject.Fqdn) { + +
+

The Selected Virtual Host Doesn't Map to PHP Yet

+

+ In order to control PHP settings and modules, the selected virtual host needs to proxy traffic to the PHP Web Server. +
+ Just click on "Create Mapping" and the system will do this for you. If you want to map a specific sub-directory of your virtual host to the PHP Web Server, go to the Advanced Settings and change the Sub-directory from "/" (root) to the desired location. +

+
+
+ + + Advanced Settings + + +
+
+ @componentForm.InputField("text", "path", "Subdirectory", "", false) +
+

Subdirectories are used to access different applications within the same domain. For example, if you have a website at { selectedVhostHostname.String() } and want to create a blog, you can create a subdirectory called blog and access it at { selectedVhostHostname.String() }/blog.

+
+
+
+
+ + + +
+ @componentForm.SubmitButton( + "create-php-mapping-button", "create mapping", "ph-plus-square", + "", false, + ) +
- @UpdatePhpVersionModal() -
+ +} + +templ UpdatePhpVersionWarningContent() { +

+ Do you really want to change the PHP version? +

+ Before changing, make sure your application is compatible with PHP version . +

Remember to then enable/disable the desired modules and adjust the settings in the new version, since the modules/settings of the previous version may be different.

} + +templ UpdatePhpVersionModal() { + + @componentStructural.WarningModal( + "isUpdatePhpVersionModalOpen", "closeUpdatePhpVersionModal()", + "Cancel", "updateVersion()", + "update-version-button", "ph-swap", "Yes, change version", + ) { + @UpdatePhpVersionWarningContent() + } +} \ No newline at end of file From 3b83a2ae67659b08ae866ce177c064e78793e62c Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 12:17:43 -0300 Subject: [PATCH 03/42] fix: simplify bool for using runtime --- .../ui/presenter/dto/runtimeOverview.go | 22 +++++++++---------- src/presentation/ui/presenter/runtimes.go | 8 +++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/presentation/ui/presenter/dto/runtimeOverview.go b/src/presentation/ui/presenter/dto/runtimeOverview.go index d0bb2ac38..40eaf9978 100644 --- a/src/presentation/ui/presenter/dto/runtimeOverview.go +++ b/src/presentation/ui/presenter/dto/runtimeOverview.go @@ -6,24 +6,24 @@ import ( ) type RuntimeOverview struct { - VirtualHostHostname valueObject.Fqdn `json:"vhostHostname"` - Type valueObject.RuntimeType `json:"type"` - IsInstalled bool `json:"-"` - CanVirtualHostHostnameAccessRuntime bool `json:"-"` - PhpConfigs *entity.PhpConfigs `json:"phpConfigs"` + VirtualHostHostname valueObject.Fqdn `json:"vhostHostname"` + Type valueObject.RuntimeType `json:"type"` + IsInstalled bool `json:"-"` + IsVirtualHostUsingRuntime bool `json:"-"` + PhpConfigs *entity.PhpConfigs `json:"phpConfigs"` } func NewRuntimeOverview( virtualHostHostname valueObject.Fqdn, runtimeType valueObject.RuntimeType, - isInstalled, canVirtualHostHostnameAccessRuntime bool, + isInstalled, isVirtualHostUsingRuntime bool, phpConfigs *entity.PhpConfigs, ) RuntimeOverview { return RuntimeOverview{ - VirtualHostHostname: virtualHostHostname, - Type: runtimeType, - IsInstalled: isInstalled, - CanVirtualHostHostnameAccessRuntime: canVirtualHostHostnameAccessRuntime, - PhpConfigs: phpConfigs, + VirtualHostHostname: virtualHostHostname, + Type: runtimeType, + IsInstalled: isInstalled, + IsVirtualHostUsingRuntime: isVirtualHostUsingRuntime, + PhpConfigs: phpConfigs, } } diff --git a/src/presentation/ui/presenter/runtimes.go b/src/presentation/ui/presenter/runtimes.go index 2fdd05aaf..2b255d0e3 100644 --- a/src/presentation/ui/presenter/runtimes.go +++ b/src/presentation/ui/presenter/runtimes.go @@ -58,7 +58,7 @@ func (presenter *RuntimesPresenter) runtimeOverviewFactory( selectedVhostHostname valueObject.Fqdn, ) (runtimeOverview presenterDto.RuntimeOverview, err error) { isInstalled := false - canVirtualHostHostnameAccessRuntime := false + isVirtualHostUsingRuntime := false var phpConfigsPtr *entity.PhpConfigs if runtimeType.String() == "php" { @@ -66,9 +66,9 @@ func (presenter *RuntimesPresenter) runtimeOverviewFactory( responseOutput := presenter.runtimeService.ReadPhpConfigs(requestBody) isInstalled = true - canVirtualHostHostnameAccessRuntime = true + isVirtualHostUsingRuntime = true if responseOutput.Status != service.Success { - canVirtualHostHostnameAccessRuntime = false + isVirtualHostUsingRuntime = false responseOutputBodyStr, assertOk := responseOutput.Body.(string) if assertOk { isInstalled = responseOutputBodyStr != "ServiceUnavailable" @@ -85,7 +85,7 @@ func (presenter *RuntimesPresenter) runtimeOverviewFactory( return presenterDto.NewRuntimeOverview( selectedVhostHostname, runtimeType, isInstalled, - canVirtualHostHostnameAccessRuntime, phpConfigsPtr, + isVirtualHostUsingRuntime, phpConfigsPtr, ), nil } From 6b473f922f28e901dd6f9c3c6ac55986877e1a0c Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 12:22:15 -0300 Subject: [PATCH 04/42] fix: use reset primary state --- .../phpRuntimeHorizontalTabContent.templ | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ index 0c5fc6ae7..9cde86d79 100644 --- a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ +++ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ @@ -8,11 +8,31 @@ import ( presenterDto "github.com/speedianet/os/src/presentation/ui/presenter/dto" ) -script PhpRuntimeHorizontalTabContentLocalState(defaultVhostHostname string) { +script PhpRuntimeHorizontalTabContentLocalState(selectedVirtualHostHostname string) { document.addEventListener('alpine:init', () => { Alpine.data('php', () => ({ - // Primary states + // Primary States phpConfigs: {}, + resetPrimaryStates() { + this.phpConfigs = { + hostname: selectedVirtualHostHostname, + version: document.getElementById('phpVersion').textContent, + modules: Object.fromEntries( + JSON.parse( + document.getElementById('phpModulesCheckInputsSwitchToggles').textContent + ).map(item => [item.name, item.status]) + ), + settings: Object.fromEntries( + JSON.parse( + document.getElementById('phpSettingsInputs').textContent + ).map(item => [item.name, item.value]) + ), + }; + }, + init() { + this.resetPrimaryStates(); + }, + get phpModulesAsApiFormat() { const modulesAsObjectsArray = [] for (const moduleName of Object.keys(this.phpConfigs.modules)) { @@ -33,22 +53,6 @@ script PhpRuntimeHorizontalTabContentLocalState(defaultVhostHostname string) { } return settingsAsObjectsArray; }, - init() { - this.phpConfigs = { - vhostHostname: defaultVhostHostname, - version: document.getElementById('phpVersion').textContent, - modules: Object.fromEntries( - JSON.parse( - document.getElementById('phpModulesCheckInputsSwitchToggles').textContent - ).map(item => [item.name, item.status]) - ), - settings: Object.fromEntries( - JSON.parse( - document.getElementById('phpSettingsInputs').textContent - ).map(item => [item.name, item.value]) - ), - }; - }, // Auxiliary states selectedPhpVerticalTab: 'modules', @@ -65,10 +69,10 @@ script PhpRuntimeHorizontalTabContentLocalState(defaultVhostHostname string) { closeUpdatePhpVersionModal() { this.isUpdatePhpVersionModalOpen = false; }, - updateVersion() { + updatePhpVersion() { htmx.ajax( 'PUT', - '/api/v1/runtime/php/' + this.phpConfigs.vhostHostname + '/', + '/api/v1/runtime/php/' + this.phpConfigs.hostname + '/', { swap: 'none', values: { version: this.phpConfigs.version }, @@ -90,7 +94,7 @@ templ PhpRuntimeHorizontalTabContent(
if runtimeOverview.IsInstalled { - if runtimeOverview.CanVirtualHostHostnameAccessRuntime { + if runtimeOverview.IsVirtualHostUsingRuntime { @FunctionalPhpRuntimeContent(runtimeOverview, vhostsHostnames) } else { @CreatePhpMappingForm(runtimeOverview.VirtualHostHostname) @@ -179,7 +183,7 @@ templ FunctionalPhpRuntimeContent(
@componentForm.SelectInput( "virtualHost", "Virtual Host Hostname", - "phpConfigs.vhostHostname", + "phpConfigs.hostname", "const vhostHostname = $event.target.value; updateSelectedVhostHostname(vhostHostname)", vhostsHostnames, false, ) @@ -278,7 +282,7 @@ templ UpdatePhpVersionModal() { @componentStructural.WarningModal( "isUpdatePhpVersionModalOpen", "closeUpdatePhpVersionModal()", - "Cancel", "updateVersion()", + "Cancel", "updatePhpVersion()", "update-version-button", "ph-swap", "Yes, change version", ) { @UpdatePhpVersionWarningContent() From 2e069fa4ef106508d25bd78e051b56a2a9b124bb Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 12:40:50 -0300 Subject: [PATCH 05/42] fix: remove redundant php version input --- .../runtimes/phpRuntimeHorizontalTabContent.templ | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ index 9cde86d79..a67c8a31c 100644 --- a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ +++ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ @@ -62,8 +62,7 @@ script PhpRuntimeHorizontalTabContentLocalState(selectedVirtualHostHostname stri // Modal states isUpdatePhpVersionModalOpen: false, - openUpdatePhpVersionModal(phpVersion) { - this.phpConfigs.version = phpVersion; + openUpdatePhpVersionModal() { this.isUpdatePhpVersionModalOpen = true; }, closeUpdatePhpVersionModal() { @@ -89,7 +88,9 @@ templ PhpRuntimeHorizontalTabContent( vhostsHostnames []string, ) { - @PhpRuntimeHorizontalTabContentLocalState(runtimeOverview.VirtualHostHostname.String()) + @PhpRuntimeHorizontalTabContentLocalState( + runtimeOverview.VirtualHostHostname.String(), + )
@@ -179,6 +180,9 @@ templ FunctionalPhpRuntimeContent( runtimeOverview presenterDto.RuntimeOverview, vhostsHostnames []string, ) { + + @templ.JSONScript("phpConfigs", runtimeOverview.PhpConfigs) +
@componentForm.SelectInput( @@ -198,7 +202,7 @@ templ FunctionalPhpRuntimeContent( @componentForm.SelectInput( "version", "Version", "phpConfigs.version", - "const phpVersion = $event.target.value; openUpdatePhpVersionModal(phpVersion)", + "openUpdatePhpVersionModal()", transformPhpVersionOptionsIntoStringSlice(runtimeOverview.PhpConfigs.Version.Options), false, ) From 5cd3bce82842d4599f971ddaff47219df4da9893 Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 15:53:54 -0300 Subject: [PATCH 06/42] chore: add and use make file --- .air.toml | 2 +- Makefile | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 Makefile diff --git a/.air.toml b/.air.toml index f705f3cdb..3e006bec8 100644 --- a/.air.toml +++ b/.air.toml @@ -4,7 +4,7 @@ tmp_dir = "tmp" [build] bin = "bin/os" -cmd = "CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/os ./os.go" +cmd = "make build" delay = 1000 exclude_dir = [".git", "bin", "logs", "tmp", "vendor", "src/devUtils"] exclude_regex = [".*_templ.go"] diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..77a7afb5a --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +SHELL=/bin/bash +UI_DIR=src/presentation/ui + +dev: + air serve + +build: + templ generate -path $(UI_DIR) + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/os ./os.go + +run: + /var/infinite/os serve \ No newline at end of file From 130e3af4cb26c04466fb58978222800a4b30a7a2 Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 15:54:22 -0300 Subject: [PATCH 07/42] refactor: phpConfigs state logic --- .../phpRuntimeHorizontalTabContent.templ | 99 ++++++------------- 1 file changed, 32 insertions(+), 67 deletions(-) diff --git a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ index a67c8a31c..d13873afb 100644 --- a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ +++ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ @@ -6,61 +6,32 @@ import ( componentForm "github.com/speedianet/os/src/presentation/ui/component/form" componentStructural "github.com/speedianet/os/src/presentation/ui/component/structural" presenterDto "github.com/speedianet/os/src/presentation/ui/presenter/dto" + "strconv" ) -script PhpRuntimeHorizontalTabContentLocalState(selectedVirtualHostHostname string) { +script PhpRuntimeHorizontalTabContentLocalState() { document.addEventListener('alpine:init', () => { Alpine.data('php', () => ({ // Primary States phpConfigs: {}, resetPrimaryStates() { - this.phpConfigs = { - hostname: selectedVirtualHostHostname, - version: document.getElementById('phpVersion').textContent, - modules: Object.fromEntries( - JSON.parse( - document.getElementById('phpModulesCheckInputsSwitchToggles').textContent - ).map(item => [item.name, item.status]) - ), - settings: Object.fromEntries( - JSON.parse( - document.getElementById('phpSettingsInputs').textContent - ).map(item => [item.name, item.value]) - ), - }; + phpConfigsElement = document.getElementById('phpConfigs'); + if (!phpConfigsElement) { + return; + } + this.phpConfigs = JSON.parse(phpConfigsElement.textContent); }, init() { this.resetPrimaryStates(); }, - get phpModulesAsApiFormat() { - const modulesAsObjectsArray = [] - for (const moduleName of Object.keys(this.phpConfigs.modules)) { - modulesAsObjectsArray.push({ - name: moduleName, - status: this.phpConfigs.modules[moduleName] - }); - } - return modulesAsObjectsArray; - }, - get phpSettingsAsApiFormat() { - const settingsAsObjectsArray = [] - for (const settingName of Object.keys(this.phpConfigs.settings)) { - settingsAsObjectsArray.push({ - name: settingName, - value: this.phpConfigs.settings[settingName] - }); - } - return settingsAsObjectsArray; - }, - - // Auxiliary states + // Auxiliary States selectedPhpVerticalTab: 'modules', updateSelectedPhpVerticalTab(tabName) { this.selectedPhpVerticalTab = tabName; }, - // Modal states + // Modal States isUpdatePhpVersionModalOpen: false, openUpdatePhpVersionModal() { this.isUpdatePhpVersionModalOpen = true; @@ -70,8 +41,7 @@ script PhpRuntimeHorizontalTabContentLocalState(selectedVirtualHostHostname stri }, updatePhpVersion() { htmx.ajax( - 'PUT', - '/api/v1/runtime/php/' + this.phpConfigs.hostname + '/', + 'PUT', '/api/v1/runtime/php/' + this.phpConfigs.hostname + '/', { swap: 'none', values: { version: this.phpConfigs.version }, @@ -88,9 +58,7 @@ templ PhpRuntimeHorizontalTabContent( vhostsHostnames []string, ) { - @PhpRuntimeHorizontalTabContentLocalState( - runtimeOverview.VirtualHostHostname.String(), - ) + @PhpRuntimeHorizontalTabContentLocalState()
@@ -109,21 +77,23 @@ templ PhpRuntimeHorizontalTabContent( } templ PhpModulesCheckboxInputsSwitchToggles(phpConfigs *entity.PhpConfigs) { - - @templ.JSONScript("phpModulesCheckInputsSwitchToggles", phpConfigs.Modules) - +
- for _, module := range phpConfigs.Modules { + // Using the index as the key is not recommended, but in this case, the entities + // list used here is the exact same as the one that will be on Alpine.js, so + // the position of the entities will also be the same. Since we need Alpine to + // control the state of the checkboxes, we have to use the index as the key. + for moduleIndex, moduleEntity := range phpConfigs.Modules { @componentForm.CheckboxInputSwitchToggle( - "", module.Name.String(), - "phpConfigs.modules['"+module.Name.String()+"']", "", + "", moduleEntity.Name.String(), + "phpConfigs.modules["+strconv.FormatInt(int64(moduleIndex), 10)+"].status", + "", ) }
- } func transformPhpSettingsOptionsIntoStringSlice( @@ -138,31 +108,27 @@ func transformPhpSettingsOptionsIntoStringSlice( } templ PhpSettingsInputs(phpConfigs *entity.PhpConfigs) { - - @templ.JSONScript("phpSettingsInputs", phpConfigs.Settings) - +
- for _, setting := range phpConfigs.Settings { - if setting.Type.String() == "text" { + for settingIndex, settingEntity := range phpConfigs.Settings { + if settingEntity.Type.String() == "text" { @componentForm.InputField( - setting.Value.GetType(), "", setting.Name.String(), - "phpConfigs.settings['"+setting.Name.String()+"']", + settingEntity.Value.GetType(), "", settingEntity.Name.String(), + "phpConfigs.settings["+strconv.FormatInt(int64(settingIndex), 10)+"].value", false, ) } else { @componentForm.SelectInput( - "", setting.Name.String(), - "phpConfigs.settings['"+setting.Name.String()+"']", "", - transformPhpSettingsOptionsIntoStringSlice(setting.Options), - false, + "", settingEntity.Name.String(), + "phpConfigs.settings["+strconv.FormatInt(int64(settingIndex), 10)+"].value", + "", transformPhpSettingsOptionsIntoStringSlice(settingEntity.Options), false, ) } }
- } func transformPhpVersionOptionsIntoStringSlice( @@ -199,9 +165,8 @@ templ FunctionalPhpRuntimeContent( hx-swap="none" >
- @componentForm.SelectInput( - "version", "Version", "phpConfigs.version", + "version", "Version", "phpConfigs.version.value", "openUpdatePhpVersionModal()", transformPhpVersionOptionsIntoStringSlice(runtimeOverview.PhpConfigs.Version.Options), false, @@ -291,4 +256,4 @@ templ UpdatePhpVersionModal() { ) { @UpdatePhpVersionWarningContent() } -} \ No newline at end of file +} From f990136e3d16ef11db97e5605eea9300b8080e8d Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 16:06:16 -0300 Subject: [PATCH 08/42] chore: enable format on save --- .vscode/settings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e5157bfc4..c472957e7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -83,5 +83,6 @@ "webserver", "zerolog", "Zerolog" - ] + ], + "editor.formatOnSave": true } From 060f4af076a0cfe44008c89a8ff9a4c9c42e50c2 Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 16:06:28 -0300 Subject: [PATCH 09/42] fix: version selector position --- .../phpRuntimeHorizontalTabContent.templ | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ index d13873afb..535475a64 100644 --- a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ +++ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ @@ -82,10 +82,10 @@ templ PhpModulesCheckboxInputsSwitchToggles(phpConfigs *entity.PhpConfigs) { x-show="selectedPhpVerticalTab == 'modules'" class="gap-7.5 grid grid-cols-5 lg:grid-cols-6" > - // Using the index as the key is not recommended, but in this case, the entities - // list used here is the exact same as the one that will be on Alpine.js, so - // the position of the entities will also be the same. Since we need Alpine to - // control the state of the checkboxes, we have to use the index as the key. + // Using the index as the key is not recommended, but in this case, the entities + // list used here is the exact same as the one that will be on Alpine.js, so + // the position of the entities will also be the same. Since we need Alpine to + // control the state of the checkboxes, we have to use the index as the key. for moduleIndex, moduleEntity := range phpConfigs.Modules { @componentForm.CheckboxInputSwitchToggle( "", moduleEntity.Name.String(), @@ -150,13 +150,19 @@ templ FunctionalPhpRuntimeContent( @templ.JSONScript("phpConfigs", runtimeOverview.PhpConfigs)
-
+
@componentForm.SelectInput( "virtualHost", "Virtual Host Hostname", "phpConfigs.hostname", "const vhostHostname = $event.target.value; updateSelectedVhostHostname(vhostHostname)", vhostsHostnames, false, ) + @componentForm.SelectInput( + "version", "Version", "phpConfigs.version.value", + "openUpdatePhpVersionModal()", + transformPhpVersionOptionsIntoStringSlice(runtimeOverview.PhpConfigs.Version.Options), + false, + )
-
- @componentForm.SelectInput( - "version", "Version", "phpConfigs.version.value", - "openUpdatePhpVersionModal()", - transformPhpVersionOptionsIntoStringSlice(runtimeOverview.PhpConfigs.Version.Options), - false, - ) -
@componentStructural.VerticalTabHeader( []componentStructural.VerticalTabHeaderItem{ From ce3357106d521182152dcb10f335b3c9fb9be5b4 Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 16:22:47 -0300 Subject: [PATCH 10/42] fix: refresh runtime content after php change --- src/presentation/ui/page/runtimes.templ | 2 +- .../runtimes/phpRuntimeHorizontalTabContent.templ | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/presentation/ui/page/runtimes.templ b/src/presentation/ui/page/runtimes.templ index 535180bba..3e1b6ba09 100644 --- a/src/presentation/ui/page/runtimes.templ +++ b/src/presentation/ui/page/runtimes.templ @@ -47,7 +47,7 @@ templ RuntimesIndex(
{ + this.$dispatch('refresh:runtimes-page-content'); + }); }, })); }); @@ -241,8 +243,8 @@ templ UpdatePhpVersionWarningContent() {

Do you really want to change the PHP version?

- Before changing, make sure your application is compatible with PHP version . -

Remember to then enable/disable the desired modules and adjust the settings in the new version, since the modules/settings of the previous version may be different.

+

Make sure your application is compatible with PHP before proceeding.

+

You must also remember to enable/disable any modules and adjust the settings in the new version, as the modules/settings of the previous version will not be automatically transferred.

} templ UpdatePhpVersionModal() { From 78336f729fd976f218efaa6004cac9b1adcd2306 Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 18:10:04 -0300 Subject: [PATCH 11/42] fix: lint on style --- src/presentation/ui/layout/main.templ | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/presentation/ui/layout/main.templ b/src/presentation/ui/layout/main.templ index b23c5c592..2110c426d 100644 --- a/src/presentation/ui/layout/main.templ +++ b/src/presentation/ui/layout/main.templ @@ -42,12 +42,7 @@ templ MainLayout(pageContent templ.Component, currentUrl string) { rel="stylesheet" href="/assets/additional.css" /> - + if isDevMode, _ := voHelper.InterfaceToBool(os.Getenv("DEV_MODE")); isDevMode { @DevWsHotReload() @@ -107,7 +102,7 @@ templ MainLayout(pageContent templ.Component, currentUrl string) { @componentUtil.LoadingOverlay() @Sidebar(currentUrl) -
+
@pageContent
@componentUtil.Toast() From e816e59440a699f101686917aacf62e9d0146024 Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 18:10:21 -0300 Subject: [PATCH 12/42] fix: move state to the top --- src/presentation/ui/page/runtimes.templ | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/presentation/ui/page/runtimes.templ b/src/presentation/ui/page/runtimes.templ index 3e1b6ba09..ef36b4ffe 100644 --- a/src/presentation/ui/page/runtimes.templ +++ b/src/presentation/ui/page/runtimes.templ @@ -7,9 +7,10 @@ import ( presenterDto "github.com/speedianet/os/src/presentation/ui/presenter/dto" ) -script RuntimesIndexLocalState(defaultVhostHostname, defaultRuntimeType string) { +script RuntimesIndexLocalState(selectedVhostHostname, selectedRuntimeType string) { document.addEventListener('alpine:init', () => { Alpine.data('runtimes', () => ({ + runtimeVhostHostname: selectedVhostHostname, reloadRuntimePageContent(vhostHostname, runtimeType) { htmx.ajax( 'GET', @@ -22,11 +23,11 @@ script RuntimesIndexLocalState(defaultVhostHostname, defaultRuntimeType string) }, ); }, - updateSelectedVhostHostname(selectedVhostHostname) { - this.reloadRuntimePageContent(selectedVhostHostname, defaultRuntimeType); + updateSelectedVhostHostname(vhostHostname) { + this.reloadRuntimePageContent(vhostHostname, selectedRuntimeType); }, - updateSelectedRuntimeType(selectedRuntimeType) { - this.reloadRuntimePageContent(defaultVhostHostname, selectedRuntimeType); + updateSelectedRuntimeType(runtimeType) { + this.reloadRuntimePageContent(selectedVhostHostname, runtimeType); }, })); }); @@ -36,6 +37,10 @@ templ RuntimesIndex( runtimeOverview presenterDto.RuntimeOverview, vhostsHostnames []string, ) { + @RuntimesIndexLocalState( + runtimeOverview.VirtualHostHostname.String(), + runtimeOverview.Type.String(), + )
@componentStructural.PageTitle( @@ -53,10 +58,6 @@ templ RuntimesIndex( hx-swap="outerHTML transition:true" class="card w-full" > - @RuntimesIndexLocalState( - runtimeOverview.VirtualHostHostname.String(), - runtimeOverview.Type.String(), - )
@RuntimesTabs(runtimeOverview, vhostsHostnames)
From 98ea33524ccb736809786ba38b701083b977aa35 Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 18:10:44 -0300 Subject: [PATCH 13/42] fix: move vhost selector to tab content --- .../phpRuntimeHorizontalTabContent.templ | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ index d7680c3ae..25ba5f27f 100644 --- a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ +++ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ @@ -42,7 +42,7 @@ script PhpRuntimeHorizontalTabContentLocalState() { updatePhpVersion() { this.closeUpdatePhpVersionModal(); htmx.ajax( - 'PUT', '/api/v1/runtime/php/' + this.phpConfigs.hostname + '/', + 'PUT', '/api/v1/runtime/php/' + this.runtimeVhostHostname + '/', { swap: 'none', values: { version: this.phpConfigs.version.value }, @@ -63,10 +63,18 @@ templ PhpRuntimeHorizontalTabContent( @PhpRuntimeHorizontalTabContentLocalState()
-
+
if runtimeOverview.IsInstalled { +
+ @componentForm.SelectInput( + "virtualHost", "Virtual Host Hostname", "runtimeVhostHostname", + "updateSelectedVhostHostname(runtimeVhostHostname)", + vhostsHostnames, false, + ) +
if runtimeOverview.IsVirtualHostUsingRuntime { @FunctionalPhpRuntimeContent(runtimeOverview, vhostsHostnames) + @UpdatePhpVersionModal() } else { @CreatePhpMappingForm(runtimeOverview.VirtualHostHostname) } @@ -74,7 +82,6 @@ templ PhpRuntimeHorizontalTabContent( @componentStructural.ServiceNotInstalledWarningForm("php") }
- @UpdatePhpVersionModal()
} @@ -151,14 +158,8 @@ templ FunctionalPhpRuntimeContent( @templ.JSONScript("phpConfigs", runtimeOverview.PhpConfigs) -
-
- @componentForm.SelectInput( - "virtualHost", "Virtual Host Hostname", - "phpConfigs.hostname", - "const vhostHostname = $event.target.value; updateSelectedVhostHostname(vhostHostname)", - vhostsHostnames, false, - ) +
+
@componentForm.SelectInput( "version", "Version", "phpConfigs.version.value", "openUpdatePhpVersionModal()", @@ -172,14 +173,14 @@ templ FunctionalPhpRuntimeContent( hx-ext="encoding-request-as-json" hx-swap="none" > -
+
@componentStructural.VerticalTabHeader( []componentStructural.VerticalTabHeaderItem{ {Label: "Modules", Icon: "ph-puzzle-piece", ComponentValue: "modules"}, {Label: "Settings", Icon: "ph-gear", ComponentValue: "settings"}, }, "updateSelectedPhpVerticalTab", ) -
+
@PhpModulesCheckboxInputsSwitchToggles(runtimeOverview.PhpConfigs) @PhpSettingsInputs(runtimeOverview.PhpConfigs)
@@ -203,6 +204,7 @@ templ CreatePhpMappingForm(selectedVhostHostname valueObject.Fqdn) { hx-post="/api/v1/vhosts/mapping/" hx-indicator="#loading-overlay" hx-swap="none" + class="mt-4 p-4" >

The Selected Virtual Host Doesn't Map to PHP Yet

From 6c58f8a09be6c9a3869fb415a856952ba7b3236d Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 18:11:03 -0300 Subject: [PATCH 14/42] fix: return err if selected hostname is invalid --- src/presentation/ui/presenter/runtimes.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/presentation/ui/presenter/runtimes.go b/src/presentation/ui/presenter/runtimes.go index 2b255d0e3..8b7b3d838 100644 --- a/src/presentation/ui/presenter/runtimes.go +++ b/src/presentation/ui/presenter/runtimes.go @@ -96,16 +96,22 @@ func (presenter *RuntimesPresenter) Handler(c echo.Context) error { } runtimeType, err := valueObject.NewRuntimeType(rawRuntimeType) if err != nil { + slog.Error("InvalidRuntimeType", slog.Any("err", err)) return nil } - selectedVhostHostname, err := valueObject.NewFqdn(c.QueryParam("vhostHostname")) + primaryVhostHostname, err := infraHelper.GetPrimaryVirtualHost() if err != nil { - primaryVhostHostname, err := infraHelper.GetPrimaryVirtualHost() + slog.Error("ReadPrimaryVirtualHost", slog.Any("err", err)) + return nil + } + selectedVhostHostname := primaryVhostHostname + if c.QueryParam("vhostHostname") != "" { + selectedVhostHostname, err = valueObject.NewFqdn(c.QueryParam("vhostHostname")) if err != nil { + slog.Error("InvalidVhostHostname", slog.Any("err", err)) return nil } - selectedVhostHostname = primaryVhostHostname } runtimeOverview, err := presenter.runtimeOverviewFactory( From a5c13a493721b0e4ea777b8d8f676bc5845384d7 Mon Sep 17 00:00:00 2001 From: ntorga Date: Thu, 3 Oct 2024 18:14:47 -0300 Subject: [PATCH 15/42] fix: simplify naming for vhost hostname --- src/presentation/ui/page/runtimes.templ | 2 +- .../ui/page/runtimes/phpRuntimeHorizontalTabContent.templ | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/presentation/ui/page/runtimes.templ b/src/presentation/ui/page/runtimes.templ index ef36b4ffe..acc49741c 100644 --- a/src/presentation/ui/page/runtimes.templ +++ b/src/presentation/ui/page/runtimes.templ @@ -10,7 +10,7 @@ import ( script RuntimesIndexLocalState(selectedVhostHostname, selectedRuntimeType string) { document.addEventListener('alpine:init', () => { Alpine.data('runtimes', () => ({ - runtimeVhostHostname: selectedVhostHostname, + vhostHostname: selectedVhostHostname, reloadRuntimePageContent(vhostHostname, runtimeType) { htmx.ajax( 'GET', diff --git a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ index 25ba5f27f..4a1810831 100644 --- a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ +++ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ @@ -42,7 +42,7 @@ script PhpRuntimeHorizontalTabContentLocalState() { updatePhpVersion() { this.closeUpdatePhpVersionModal(); htmx.ajax( - 'PUT', '/api/v1/runtime/php/' + this.runtimeVhostHostname + '/', + 'PUT', '/api/v1/runtime/php/' + this.vhostHostname + '/', { swap: 'none', values: { version: this.phpConfigs.version.value }, @@ -67,8 +67,8 @@ templ PhpRuntimeHorizontalTabContent( if runtimeOverview.IsInstalled {

@componentForm.SelectInput( - "virtualHost", "Virtual Host Hostname", "runtimeVhostHostname", - "updateSelectedVhostHostname(runtimeVhostHostname)", + "virtualHost", "Virtual Host Hostname", "vhostHostname", + "updateSelectedVhostHostname(vhostHostname)", vhostsHostnames, false, )
From 5022ceaf5a4f9b59d95bce77561ae7bc00e795c4 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 10:57:57 -0300 Subject: [PATCH 16/42] chore: update cspell --- .vscode/settings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index c472957e7..4bb46826a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -24,6 +24,7 @@ "grpcs", "gsub", "Hostnames", + "htmx", "installables", "Installables", "ioncube", From b81822818c9f7f4ac89580357ab148fef55e2d43 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 10:58:09 -0300 Subject: [PATCH 17/42] feat: add jsonAjax --- src/presentation/ui/assets/additional.js | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/presentation/ui/assets/additional.js diff --git a/src/presentation/ui/assets/additional.js b/src/presentation/ui/assets/additional.js new file mode 100644 index 000000000..dfb8bcc70 --- /dev/null +++ b/src/presentation/ui/assets/additional.js @@ -0,0 +1,29 @@ +"use strict"; + +document.addEventListener("alpine:initializing", () => { + async function jsonAjax(method, url, data) { + loadingOverlayElement = document.getElementById("loading-overlay"); + loadingOverlayElement.classList.add("htmx-request"); + + await fetch(url, { + method: method, + headers: { + Accept: "application/json", + "Content-Type": "application/json", + }, + body: JSON.stringify(data), + }) + .then((response) => { + loadingOverlayElement.classList.remove("htmx-request"); + return response.json(); + }) + .then((parsedResponse) => { + Alpine.store("toast").displayToast(parsedResponse.body, "success"); + }) + .catch((parsedResponse) => { + Alpine.store("toast").displayToast(parsedResponse.body, "danger"); + }); + } + + window.jsonAjax = jsonAjax; +}); From ced7d2c91548b4fc6292a340d69f7882c19aa1f0 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 10:58:20 -0300 Subject: [PATCH 18/42] feat: add additional.js --- src/presentation/ui/layout/main.templ | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/presentation/ui/layout/main.templ b/src/presentation/ui/layout/main.templ index 2110c426d..80e4eafbc 100644 --- a/src/presentation/ui/layout/main.templ +++ b/src/presentation/ui/layout/main.templ @@ -81,19 +81,7 @@ templ MainLayout(pageContent templ.Component, currentUrl string) { - + if isDevMode, _ := voHelper.InterfaceToBool(os.Getenv("DEV_MODE")); isDevMode { @DevWsHotReload() } From 7bc5e0d2948cc8b68827a617c54ec44554c3ceb0 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 10:58:41 -0300 Subject: [PATCH 19/42] fix: remove unnecessary space --- src/presentation/ui/component/util/toast.templ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/presentation/ui/component/util/toast.templ b/src/presentation/ui/component/util/toast.templ index 0e8153c05..f6ffd76b3 100644 --- a/src/presentation/ui/component/util/toast.templ +++ b/src/presentation/ui/component/util/toast.templ @@ -27,7 +27,7 @@ script ToastGlobalState() { return; } - const responseData = event.detail.xhr.responseText; + const responseData = event.detail.xhr.responseText; if (responseData === '') { return; } From e3c9fc3524f2105595d822a9a331028a4a9e4432 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 10:59:02 -0300 Subject: [PATCH 20/42] feat: add updatePhpConfigs() --- .../phpRuntimeHorizontalTabContent.templ | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ index 4a1810831..2cb4563c3 100644 --- a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ +++ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ @@ -24,6 +24,16 @@ script PhpRuntimeHorizontalTabContentLocalState() { init() { this.resetPrimaryStates(); }, + async updatePhpConfigs() { + await window.jsonAjax( + 'PUT', '/api/v1/runtime/php/' + this.vhostHostname + '/', + { + version: this.phpConfigs.version.value, + modules: this.phpConfigs.modules, + settings: this.phpConfigs.settings, + }, + ); + }, // Auxiliary States selectedPhpVerticalTab: 'modules', @@ -167,33 +177,24 @@ templ FunctionalPhpRuntimeContent( false, )
- -
- @componentStructural.VerticalTabHeader( - []componentStructural.VerticalTabHeaderItem{ - {Label: "Modules", Icon: "ph-puzzle-piece", ComponentValue: "modules"}, - {Label: "Settings", Icon: "ph-gear", ComponentValue: "settings"}, - }, "updateSelectedPhpVerticalTab", - ) -
- @PhpModulesCheckboxInputsSwitchToggles(runtimeOverview.PhpConfigs) - @PhpSettingsInputs(runtimeOverview.PhpConfigs) -
-
-
-
+
+ @componentStructural.VerticalTabHeader( + []componentStructural.VerticalTabHeaderItem{ + {Label: "Modules", Icon: "ph-puzzle-piece", ComponentValue: "modules"}, + {Label: "Settings", Icon: "ph-gear", ComponentValue: "settings"}, + }, "updateSelectedPhpVerticalTab", + ) +
+ @PhpModulesCheckboxInputsSwitchToggles(runtimeOverview.PhpConfigs) + @PhpSettingsInputs(runtimeOverview.PhpConfigs) +
@componentForm.SubmitButton( "apply-php-runtime-configs-changes", "Apply changes", - "ph-check-fat", "", false, + "ph-check-fat", "updatePhpConfigs()", false, )
- +
} From 72eec711ef3518a5c6bc7a30b3f860a3e16c1e73 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 14:37:33 -0300 Subject: [PATCH 21/42] fix: ignore ui auth on /dev --- src/presentation/ui/middleware/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/presentation/ui/middleware/auth.go b/src/presentation/ui/middleware/auth.go index 1808ad95b..549e172e0 100644 --- a/src/presentation/ui/middleware/auth.go +++ b/src/presentation/ui/middleware/auth.go @@ -39,7 +39,7 @@ func getAccountIdFromAccessToken( } func shouldSkipUiAuthentication(req *http.Request) bool { - urlSkipRegex := regexp.MustCompile(`^/(api|\_|login)/`) + urlSkipRegex := regexp.MustCompile(`^/(api|\_|login|dev)/`) return urlSkipRegex.MatchString(req.URL.Path) } From 188be54bce209324967f5b598f0e9ab3897b0c56 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 14:37:43 -0300 Subject: [PATCH 22/42] chore: add js and css to include_ext --- .air.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.air.toml b/.air.toml index 3e006bec8..f17d27d89 100644 --- a/.air.toml +++ b/.air.toml @@ -10,4 +10,4 @@ exclude_dir = [".git", "bin", "logs", "tmp", "vendor", "src/devUtils"] exclude_regex = [".*_templ.go"] follow_symlink = false ignore = ["*_test.go", "testHelpers.go"] -include_ext = ["go", "tpl", "tmpl", "templ", "html"] +include_ext = ["go", "tpl", "tmpl", "templ", "html", "js", "css"] From 4bede6a3ee4bef8002fe832992543c80c28f5a0d Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 14:40:15 -0300 Subject: [PATCH 23/42] chore: restart os-api if running --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 77a7afb5a..6f88e7ba8 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ dev: build: templ generate -path $(UI_DIR) CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/os ./os.go + if podman ps | grep -q "os"; then podman exec os /bin/bash -c "supervisorctl restart os-api"; fi run: /var/infinite/os serve \ No newline at end of file From bdefc283951a194403c0c5dcb6b710a70ab40346 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 14:40:35 -0300 Subject: [PATCH 24/42] fix: update icon on schedule --- .../component/structural/serviceNotInstalledWarningForm.templ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/presentation/ui/component/structural/serviceNotInstalledWarningForm.templ b/src/presentation/ui/component/structural/serviceNotInstalledWarningForm.templ index 5dffe8197..63b017992 100644 --- a/src/presentation/ui/component/structural/serviceNotInstalledWarningForm.templ +++ b/src/presentation/ui/component/structural/serviceNotInstalledWarningForm.templ @@ -14,7 +14,7 @@ templ ServiceNotInstalledWarningForm(serviceName string) { The { serviceName } service is not installed yet. @componentForm.SubmitButton( "schedule-service-installation", - "Schedule "+serviceName+" service installation", "ph-caret-line-down", + "Schedule "+serviceName+" service installation", "ph-queue", "", true, ) From 9be0dac6abe1b6eb9ea81828ab580f13e223b7f8 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 14:40:51 -0300 Subject: [PATCH 25/42] fix: add localhost as aliases --- src/presentation/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/presentation/http.go b/src/presentation/http.go index 0f501d1fd..9a71f7628 100644 --- a/src/presentation/http.go +++ b/src/presentation/http.go @@ -47,7 +47,7 @@ func HttpServerInit( os.Exit(1) } - aliases := []string{} + aliases := []string{"localhost", "127.0.0.1"} err = infraHelper.CreateSelfSignedSsl(pkiDir, "os", aliases) if err != nil { slog.Error("GenerateSelfSignedCertFailed", slog.Any("error", err)) From f6af39e83545a6a6a29a95ef372c95326769fee0 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 14:44:10 -0300 Subject: [PATCH 26/42] docs: add build dev steps --- README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5ab0c5dd5..06cc55430 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,8 @@ When running in production, the `/speedia/.env` file is only used if the environ Speedia OS commands can harm your system, so it's important to run the unit tests in a proper container: ``` -podman build -t sos-unit-test:latest -f Containerfile.test . -podman run --rm -it sos-unit-test:latest +podman build -t os-unit-test:latest -f Containerfile.test . +podman run --rm -it os-unit-test:latest ``` Make sure you have the `.env` file in the root of the git directory before running the tests. @@ -87,20 +87,74 @@ For instance there you'll find a `testHelpers.go` file that is used to read the ### Building +#### Simple Build + To build the project, run the command below. It takes two minutes to build the project at first. After that, it takes less than 10 seconds to build. ``` -podman build -t sos:latest . +podman build -t os:latest . ``` To run the project you may use the following command: ``` -podman run --name sos --env 'PRIMARY_VHOST=speedia.net' --rm -p 1618:1618 -it sos:latest +podman run --name os --env 'PRIMARY_VHOST=speedia.net' --rm -p 1618:1618 -it os:latest ``` When testing, consider publishing port 80 and 443 to the host so that you don't need to use a reverse proxy. You should also consider using `--env 'LOG_LEVEL=debug'` to increase the log verbosity. +#### Development Build + +When developing the project, you may want to use the following steps for the best experience: + +1. Add this to your `.bashrc` (or equivalent) file if you don't have it yet: + +```bash +function os-build() { + ports=(-p 1618:1618 -p 7080:7080) + case ${1} in + http) + sudo sysctl net.ipv4.ip_unprivileged_port_start=80 + ports+=(-p 80:80 -p 443:443) + ;; + no-cache) + podman image prune -a + podman rmi localhost/os -f + ;; + esac + + make build + podman build -t os:latest . + podman run --name os \ + --env 'LOG_LEVEL=debug' --env 'DEV_MODE=true' --env 'PRIMARY_VHOST=speedia.cloud' \ + --hostname=speedia.cloud --cpus=2 --memory=2g --rm \ + --volume "$(pwd)/bin:/speedia/bin:Z,ro,bind,slave" \ + "${ports[@]}" -it os:latest +} +``` + +Read the script above and understand what it does. The `os-build` function will build the project, run the container, and expose the ports 1618 and 7080. + +If you pass the `http` argument, it will also expose the ports 80 and 443 to the host. If you pass the `no-cache` argument, it will remove the image cache and rebuild the image from scratch. + +Port 1618 is used for the dashboard and port 7080 is used for the OpenLiteSpeed admin panel which may come in handy during development related to the PHP features, but isn't necessary, so you can remove it if you want. + +2. Run `source ~/.bashrc` (or equivalent) to reload the terminal or close and open the terminal; + +3. Open a new terminal and run `os-build` to build and run the container on that window. You could add the `-d` flag to run the container in the background on the `os-build` script, but to easily stop the container with CTRL+C instead of using `podman stop os`, it's better to run in a second terminal, but you can do it as you prefer; + +4. Back on the first terminal, run `air` to monitor any changes in the project and recompile it automatically. Since we're using the `DEV_MODE=true` environment variable, the frontend will also automatically reload when the `os-api` service is restarted by Air (check the Makefile to understand how it works); + +5. On the very first time you build the container, you must run the following command to symlink the binary Air will generate to the one used by the container entrypoint: + +``` +podman exec os /bin/bash -c 'rm -f os && ln -s bin/os os && supervisorctl restart os-api' +``` + +If you look closely at the `os-build` function, you'll see that it mounts the `bin` directory to the container. This is necessary because Air will generate the binary in the `bin` directory and the container will look for the binary in the root of the container. The symlink command above will make sure the container is using the binary you're altering during development. + +Note: all the commands above are meant to be run in the root of the project (before src/). + ### Web UIs This project has two web UIs, the previous Vue.js frontend and the new [Templ](https://templ.guide/) + [Alpine.js](https://alpinejs.dev/) + [HTMX](https://htmx.org/docs/) frontend. The Vue.js frontend is deprecated and will be removed in the future. It's available at `/_/` and the [Templ](https://templ.guide/) + [Alpine.js](https://alpinejs.dev/) + [HTMX](https://htmx.org/docs/) frontend is available at `/`. From 9be2c7be8d2e7242be28f1b5f797f9a6439c68aa Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 15:55:58 -0300 Subject: [PATCH 27/42] chore: reduce air verbosity --- .air.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.air.toml b/.air.toml index f17d27d89..6d0345c80 100644 --- a/.air.toml +++ b/.air.toml @@ -11,3 +11,9 @@ exclude_regex = [".*_templ.go"] follow_symlink = false ignore = ["*_test.go", "testHelpers.go"] include_ext = ["go", "tpl", "tmpl", "templ", "html", "js", "css"] + +[log] +main_only = true + +[screen] +clear_on_rebuild = true From bf74514789e26622d001784a51055affdae400e3 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 15:56:30 -0300 Subject: [PATCH 28/42] feat: add dev-build.sh --- dev-build.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 dev-build.sh diff --git a/dev-build.sh b/dev-build.sh new file mode 100644 index 000000000..5b118b1c3 --- /dev/null +++ b/dev-build.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Define the execution arguments. +ports=(-p 1618:1618) +case ${1} in +http) + sudo sysctl net.ipv4.ip_unprivileged_port_start=80 + ports+=(-p 80:80 -p 443:443) + ;; +ols) + ports+=(-p 7080:7080) + ;; +no-cache) + podman image prune -a + podman rmi localhost/os -f + ;; +esac + +echo "=> Building the container..." +make build +podman build -t os:latest . +podman run --name os -d \ + --env 'LOG_LEVEL=debug' --env 'DEV_MODE=true' --env 'PRIMARY_VHOST=speedia.cloud' \ + --hostname=speedia.cloud --cpus=2 --memory=2g --rm \ + --volume "$(pwd)/bin:/speedia/bin:Z,ro,bind,slave" \ + "${ports[@]}" -it os:latest + +echo "=> Waiting for the container to start..." +sleep 5 + +echo "=> Replacing the standard binary with the development binary..." +podman exec os /bin/bash -c 'rm -f os && ln -s bin/os os && supervisorctl restart os-api' + +echo +echo "<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>" +echo +echo "=> Starting the development build..." +echo "Any changes to the code will trigger a rebuild automatically." +echo "Please, ignore the 'Only root can run SOS' message." +echo +echo "<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>" +echo +sleep 3 + +stopDevBuild() { + kill $airPid + kill $podmanPid + echo + echo "=> Development build stopped." + echo + exit +} + +trap stopDevBuild SIGINT + +air & +airPid=$! +podman attach os & +podmanPid=$! + +wait $airPid +wait $podmanPid From 64447958ec90a0f2b750339061b981843780a0e1 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 15:56:39 -0300 Subject: [PATCH 29/42] docs: improve dev build with new script --- README.md | 52 +++++++++------------------------------------------- 1 file changed, 9 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 06cc55430..d25ddf3eb 100644 --- a/README.md +++ b/README.md @@ -105,55 +105,21 @@ When testing, consider publishing port 80 and 443 to the host so that you don't #### Development Build -When developing the project, you may want to use the following steps for the best experience: +When developing the project, you may want to use a script to automate the build process. The `dev-build.sh` script is available in the root of the project and it will take care of all the steps needed to build and run the container. -1. Add this to your `.bashrc` (or equivalent) file if you don't have it yet: +To run the script you can simply use `bash dev-build.sh` (bash may be replaced by zsh or similar). By default, the script will expose the port 1618 to the host which is used by the API and the dashboard. -```bash -function os-build() { - ports=(-p 1618:1618 -p 7080:7080) - case ${1} in - http) - sudo sysctl net.ipv4.ip_unprivileged_port_start=80 - ports+=(-p 80:80 -p 443:443) - ;; - no-cache) - podman image prune -a - podman rmi localhost/os -f - ;; - esac +- If you pass the `http` argument, it will also expose the ports 80 and 443 to the host; +- If you pass the `ols` argument, it will expose port 7080 (used by OpenLiteSpeed admin); +- If you pass the `no-cache` argument, it will remove the image cache and rebuild the image from scratch; - make build - podman build -t os:latest . - podman run --name os \ - --env 'LOG_LEVEL=debug' --env 'DEV_MODE=true' --env 'PRIMARY_VHOST=speedia.cloud' \ - --hostname=speedia.cloud --cpus=2 --memory=2g --rm \ - --volume "$(pwd)/bin:/speedia/bin:Z,ro,bind,slave" \ - "${ports[@]}" -it os:latest -} -``` - -Read the script above and understand what it does. The `os-build` function will build the project, run the container, and expose the ports 1618 and 7080. - -If you pass the `http` argument, it will also expose the ports 80 and 443 to the host. If you pass the `no-cache` argument, it will remove the image cache and rebuild the image from scratch. - -Port 1618 is used for the dashboard and port 7080 is used for the OpenLiteSpeed admin panel which may come in handy during development related to the PHP features, but isn't necessary, so you can remove it if you want. - -2. Run `source ~/.bashrc` (or equivalent) to reload the terminal or close and open the terminal; +When you need to stop the container, just CTRL+C to stop and remove it. If you don't want to remove it, just ditch the `--rm` flag from the `podman run` command in the script. -3. Open a new terminal and run `os-build` to build and run the container on that window. You could add the `-d` flag to run the container in the background on the `os-build` script, but to easily stop the container with CTRL+C instead of using `podman stop os`, it's better to run in a second terminal, but you can do it as you prefer; - -4. Back on the first terminal, run `air` to monitor any changes in the project and recompile it automatically. Since we're using the `DEV_MODE=true` environment variable, the frontend will also automatically reload when the `os-api` service is restarted by Air (check the Makefile to understand how it works); - -5. On the very first time you build the container, you must run the following command to symlink the binary Air will generate to the one used by the container entrypoint: - -``` -podman exec os /bin/bash -c 'rm -f os && ln -s bin/os os && supervisorctl restart os-api' -``` +If you look closely at the script, you'll see that it mounts the project's `bin` directory to the container `/speedia/bin` path. This is done to allow the container to access the binary file generated by Air on the host. The script then replace the binary file that comes with the container with the one on the `/bin` directory. -If you look closely at the `os-build` function, you'll see that it mounts the `bin` directory to the container. This is necessary because Air will generate the binary in the `bin` directory and the container will look for the binary in the root of the container. The symlink command above will make sure the container is using the binary you're altering during development. +With this approach you don't need to rebuild the container every time you change the code. Although sometimes you may want to restart the container to apply some changes, specially when changing the dependencies or system configurations. In this case, just hit CTRL+C to stop the container and run the script again. -Note: all the commands above are meant to be run in the root of the project (before src/). +Note: you must run the script from the project's root directory. ### Web UIs From 7c9c40d64cd843192aefdcf61458f5e5243770ab Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 16:14:31 -0300 Subject: [PATCH 30/42] feat: create dev acc --- dev-build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev-build.sh b/dev-build.sh index 5b118b1c3..6f9b083e1 100644 --- a/dev-build.sh +++ b/dev-build.sh @@ -31,6 +31,9 @@ sleep 5 echo "=> Replacing the standard binary with the development binary..." podman exec os /bin/bash -c 'rm -f os && ln -s bin/os os && supervisorctl restart os-api' +echo "=> Creating a development account..." +podman exec os /bin/bash -c 'os account create -u dev -p 123456' + echo echo "<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>" echo From e583b850dd6ff25b21ebff17a8d0b76f9fefc89a Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 16:14:45 -0300 Subject: [PATCH 31/42] docs: mention dev acc --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d25ddf3eb..2f14f3acd 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,8 @@ To run the script you can simply use `bash dev-build.sh` (bash may be replaced b - If you pass the `ols` argument, it will expose port 7080 (used by OpenLiteSpeed admin); - If you pass the `no-cache` argument, it will remove the image cache and rebuild the image from scratch; +The script will also create a `dev` account with the password `123456` so you can access the dashboard. + When you need to stop the container, just CTRL+C to stop and remove it. If you don't want to remove it, just ditch the `--rm` flag from the `podman run` command in the script. If you look closely at the script, you'll see that it mounts the project's `bin` directory to the container `/speedia/bin` path. This is done to allow the container to access the binary file generated by Air on the host. The script then replace the binary file that comes with the container with the one on the `/bin` directory. @@ -133,9 +135,9 @@ For the interface code to be read and rendered by Go, we need to convert all `.t templ generate -path src/presentation/api ``` -With this, Go will be able to provide the entire application interface at the previously indicated route (`/`). +It is important that this is done before using Air to create the binary; otherwise, the Web UI will not be embedded, and you will not be able to use it. -**NOTE:** It is important that this is done before using Air to create the binary; otherwise, the Web UI will not be embedded, and you will not be able to use it. +**NOTE:** If you are using the `dev-build.sh` script, you don't need to run the `templ generate` command (or Air for that matter) since the script will take care of everything for you. ### VSCode Extensions From 173a0f6a36c5be3172f787dbce9fa3614ab5740d Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 17:22:59 -0300 Subject: [PATCH 32/42] chore: update deps --- go.mod | 46 ++++++++++++------------ go.sum | 112 +++++++++++++++++++++++++++------------------------------ 2 files changed, 74 insertions(+), 84 deletions(-) diff --git a/go.mod b/go.mod index 7da6c9f98..a9f0787f4 100644 --- a/go.mod +++ b/go.mod @@ -1,36 +1,36 @@ module github.com/speedianet/os -go 1.22 +go 1.23 require ( github.com/alecthomas/chroma v0.10.0 github.com/alessio/shellescape v1.4.2 - github.com/dgraph-io/badger/v4 v4.2.0 + github.com/dgraph-io/badger/v4 v4.3.0 github.com/glebarez/sqlite v1.11.0 github.com/golang-jwt/jwt v3.2.2+incompatible github.com/google/uuid v1.6.0 github.com/joho/godotenv v1.5.1 github.com/labstack/echo/v4 v4.12.0 github.com/rs/zerolog v1.33.0 - github.com/samber/slog-zerolog/v2 v2.6.0 + github.com/samber/slog-zerolog/v2 v2.7.0 github.com/shirou/gopsutil v3.21.11+incompatible github.com/spf13/cobra v1.8.1 github.com/swaggo/echo-swagger v1.4.1 github.com/swaggo/swag v1.16.3 - golang.org/x/crypto v0.25.0 - golang.org/x/exp v0.0.0-20240707233637-46b078467d37 - golang.org/x/net v0.27.0 - golang.org/x/term v0.22.0 + golang.org/x/crypto v0.28.0 + golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 + golang.org/x/net v0.30.0 + golang.org/x/term v0.25.0 gopkg.in/yaml.v3 v3.0.1 - gorm.io/gorm v1.25.10 + gorm.io/gorm v1.25.12 ) require ( github.com/KyleBanks/depth v1.2.1 // indirect - github.com/a-h/templ v0.2.747 + github.com/a-h/templ v0.2.778 github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/dgraph-io/ristretto v0.1.1 // indirect - github.com/dlclark/regexp2 v1.4.0 // indirect + github.com/dgraph-io/ristretto v1.0.0 // indirect + github.com/dlclark/regexp2 v1.11.4 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/glebarez/go-sqlite v1.22.0 // indirect @@ -40,16 +40,14 @@ require ( github.com/go-openapi/spec v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect - github.com/golang/snappy v0.0.4 // indirect github.com/google/flatbuffers v24.3.25+incompatible // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/compress v1.17.10 // indirect github.com/labstack/gommon v0.4.2 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -57,24 +55,24 @@ require ( github.com/ncruces/go-strftime v0.1.9 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/samber/lo v1.44.0 // indirect - github.com/samber/slog-common v0.17.0 // indirect + github.com/samber/lo v1.47.0 // indirect + github.com/samber/slog-common v0.17.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/swaggo/files/v2 v2.0.0 // indirect + github.com/swaggo/files/v2 v2.0.1 // indirect github.com/tklauser/go-sysconf v0.3.14 // indirect - github.com/tklauser/numcpus v0.8.0 // indirect + github.com/tklauser/numcpus v0.9.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 - golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.23.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 + golang.org/x/time v0.7.0 // indirect + golang.org/x/tools v0.26.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - modernc.org/libc v1.54.2 // indirect + modernc.org/libc v1.61.0 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.8.0 // indirect - modernc.org/sqlite v1.30.1 // indirect + modernc.org/sqlite v1.33.1 // indirect ) diff --git a/go.sum b/go.sum index ff205b079..a51e1d89e 100644 --- a/go.sum +++ b/go.sum @@ -2,14 +2,13 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/a-h/templ v0.2.747 h1:D0dQ2lxC3W7Dxl6fxQ/1zZHBQslSkTSvl5FxP/CfdKg= -github.com/a-h/templ v0.2.747/go.mod h1:69ObQIbrcuwPCU32ohNaWce3Cb7qM5GMiqN1K+2yop4= +github.com/a-h/templ v0.2.778 h1:VzhOuvWECrwOec4790lcLlZpP4Iptt5Q4K9aFxQmtaM= +github.com/a-h/templ v0.2.778/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= github.com/alessio/shellescape v1.4.2 h1:MHPfaU+ddJ0/bYWpgIeUnQUqKrlJ1S7BfEYPM4uEoM0= github.com/alessio/shellescape v1.4.2/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -19,15 +18,15 @@ github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= -github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= -github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= -github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= +github.com/dgraph-io/badger/v4 v4.3.0 h1:lcsCE1/1qrRhqP+zYx6xDZb8n7U+QlwNicpc676Ub40= +github.com/dgraph-io/badger/v4 v4.3.0/go.mod h1:Sc0T595g8zqAQRDf44n+z3wG4BOqLwceaFntt8KPxUM= +github.com/dgraph-io/ristretto v1.0.0 h1:SYG07bONKMlFDUYu5pEu3DGAh8c2OFNzKm6G9J4Si84= +github.com/dgraph-io/ristretto v1.0.0/go.mod h1:jTi2FiYEhQ1NsMmA7DeBykizjOuY88NhKBkepyu1jPc= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yAo= +github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -57,8 +56,6 @@ github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69 github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4= -github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -74,8 +71,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/flatbuffers v24.3.25+incompatible h1:CX395cjN9Kke9mmalRoL3d81AtFUxJM+yDthflgJGkI= github.com/google/flatbuffers v24.3.25+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -103,8 +98,8 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0= +github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -136,12 +131,12 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/samber/lo v1.44.0 h1:5il56KxRE+GHsm1IR+sZ/6J42NODigFiqCWpSc2dybA= -github.com/samber/lo v1.44.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU= -github.com/samber/slog-common v0.17.0 h1:HdRnk7QQTa9ByHlLPK3llCBo8ZSX3F/ZyeqVI5dfMtI= -github.com/samber/slog-common v0.17.0/go.mod h1:mZSJhinB4aqHziR0SKPqpVZjJ0JO35JfH+dDIWqaCBk= -github.com/samber/slog-zerolog/v2 v2.6.0 h1:S7Q7fvV6HB7NSa7WnI/7ymuVkQZg5XhNXM1ltmAOvGc= -github.com/samber/slog-zerolog/v2 v2.6.0/go.mod h1:vGzG7VhveVOnyHEpr7LpIuw28QxEOfV/dQxphJRB4iY= +github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc= +github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU= +github.com/samber/slog-common v0.17.1 h1:jTqqLBgoJshpoxlPSGiypyOanjH6tY+i9bwyYmIbjhI= +github.com/samber/slog-common v0.17.1/go.mod h1:mZSJhinB4aqHziR0SKPqpVZjJ0JO35JfH+dDIWqaCBk= +github.com/samber/slog-zerolog/v2 v2.7.0 h1:VWJNhvoR3bf+SDEO89BmahAnz6w5l+NGbPBcnMUqO2g= +github.com/samber/slog-zerolog/v2 v2.7.0/go.mod h1:vGzG7VhveVOnyHEpr7LpIuw28QxEOfV/dQxphJRB4iY= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= @@ -151,7 +146,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -160,14 +154,14 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/swaggo/echo-swagger v1.4.1 h1:Yf0uPaJWp1uRtDloZALyLnvdBeoEL5Kc7DtnjzO/TUk= github.com/swaggo/echo-swagger v1.4.1/go.mod h1:C8bSi+9yH2FLZsnhqMZLIZddpUxZdBYuNHbtaS1Hljc= -github.com/swaggo/files/v2 v2.0.0 h1:hmAt8Dkynw7Ssz46F6pn8ok6YmGZqHSVLZ+HQM7i0kw= -github.com/swaggo/files/v2 v2.0.0/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM= +github.com/swaggo/files/v2 v2.0.1 h1:XCVJO/i/VosCDsJu1YLpdejGsGnBE9deRMpjN4pJLHk= +github.com/swaggo/files/v2 v2.0.1/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM= github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg= github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk= github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= -github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY= -github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= +github.com/tklauser/numcpus v0.9.0 h1:lmyCHtANi8aRUgkckBgoDk1nHCux3n2cgkJLXdQGPDo= +github.com/tklauser/numcpus v0.9.0/go.mod h1:SN6Nq1O3VychhC1npsWostA+oW+VOQTxZrS604NSRyI= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= @@ -181,18 +175,18 @@ go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20240707233637-46b078467d37 h1:uLDX+AfeFCct3a2C7uIWBKMJIR3CJMhcgfrUAqjRK6w= -golang.org/x/exp v0.0.0-20240707233637-46b078467d37/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= +golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 h1:1wqE9dj9NpSm04INVsJhhEUzhuDVjbcyKH91sVyPATw= +golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= -golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -202,36 +196,35 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= +golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -240,8 +233,8 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= -golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -270,26 +263,25 @@ google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWn gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s= -gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= +gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= modernc.org/cc/v4 v4.21.4 h1:3Be/Rdo1fpr8GrQ7IVw9OHtplU4gWbb+wNgeoBMmGLQ= modernc.org/cc/v4 v4.21.4/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= -modernc.org/ccgo/v4 v4.19.0 h1:f9K5VdC0nVhHKTFMvhjtZ8TbRgFQbASvE5yO1zs8eC0= -modernc.org/ccgo/v4 v4.19.0/go.mod h1:CfpAl+673iXNwMG/aqcQn+vDcu4Es/YLya7+9RHjTa4= +modernc.org/ccgo/v4 v4.21.0 h1:kKPI3dF7RIag8YcToh5ZwDcVMIv6VGa0ED5cvh0LMW4= +modernc.org/ccgo/v4 v4.21.0/go.mod h1:h6kt6H/A2+ew/3MW/p6KEoQmrq/i3pr0J/SiwiaF/g0= modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= -modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw= -modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU= -modernc.org/libc v1.54.2 h1:9ymAodb+3v85YfBIZqn62BGgO4L9zF2Hx4LNb6dSU/Q= -modernc.org/libc v1.54.2/go.mod h1:B0D6klDmSmnq26T1iocn9kzyX6NtbzjuI3+oX/xfvng= +modernc.org/gc/v2 v2.5.0 h1:bJ9ChznK1L1mUtAQtxi0wi5AtAs5jQuw4PrPHO5pb6M= +modernc.org/gc/v2 v2.5.0/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU= +modernc.org/libc v1.61.0 h1:eGFcvWpqlnoGwzZeZe3PWJkkKbM/3SUGyk1DVZQ0TpE= +modernc.org/libc v1.61.0/go.mod h1:DvxVX89wtGTu+r72MLGhygpfi3aUGgZRdAYGCAVVud0= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= @@ -298,8 +290,8 @@ modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc= modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss= -modernc.org/sqlite v1.30.1 h1:YFhPVfu2iIgUf9kuA1CR7iiHdcEEsI2i+yjRYHscyxk= -modernc.org/sqlite v1.30.1/go.mod h1:DUmsiWQDaAvU4abhc/N+djlom/L2o8f7gZ95RCvyoLU= +modernc.org/sqlite v1.33.1 h1:trb6Z3YYoeM9eDL1O8do81kP+0ejv+YzgyFo+Gwy0nM= +modernc.org/sqlite v1.33.1/go.mod h1:pXV2xHxhzXZsgT/RtTFAPY6JJDEvOTcTdwADQCCWD4k= modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= From 455beb4731ce6c0c80745ba08761525d3a7aff96 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 17:27:39 -0300 Subject: [PATCH 33/42] chore: add disclaimer for echo v4.13 --- README.md | 5 ++++- dev-build.sh | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f14f3acd..848f1ea75 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,10 @@ If you look closely at the script, you'll see that it mounts the project's `bin` With this approach you don't need to rebuild the container every time you change the code. Although sometimes you may want to restart the container to apply some changes, specially when changing the dependencies or system configurations. In this case, just hit CTRL+C to stop the container and run the script again. -Note: you must run the script from the project's root directory. +**Notes:** + +1. You must run the script from the project's root directory; +2. Until Echo v4.13.0 is released, you'll need to refresh the browser page during development to see the changes in the dashboard as we're not able to use the `DEV_MODE` auto refresh websocket trick for now. To understand how this trick used to work, check the UI router and main layout files. ### Web UIs diff --git a/dev-build.sh b/dev-build.sh index 6f9b083e1..52cf4bc77 100644 --- a/dev-build.sh +++ b/dev-build.sh @@ -19,8 +19,9 @@ esac echo "=> Building the container..." make build podman build -t os:latest . +# TODO: Re-add --env 'DEV_MODE=true' after Echo v4.13.0 release. podman run --name os -d \ - --env 'LOG_LEVEL=debug' --env 'DEV_MODE=true' --env 'PRIMARY_VHOST=speedia.cloud' \ + --env 'LOG_LEVEL=debug' --env 'PRIMARY_VHOST=speedia.cloud' \ --hostname=speedia.cloud --cpus=2 --memory=2g --rm \ --volume "$(pwd)/bin:/speedia/bin:Z,ro,bind,slave" \ "${ports[@]}" -it os:latest From ded20b5f4f0baf2dd8b08367cfebfcdfabeeb5e9 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 17:47:47 -0300 Subject: [PATCH 34/42] fix: move additional.js before alpine --- src/presentation/ui/layout/main.templ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/presentation/ui/layout/main.templ b/src/presentation/ui/layout/main.templ index 80e4eafbc..69b39080b 100644 --- a/src/presentation/ui/layout/main.templ +++ b/src/presentation/ui/layout/main.templ @@ -79,9 +79,9 @@ templ MainLayout(pageContent templ.Component, currentUrl string) { + - if isDevMode, _ := voHelper.InterfaceToBool(os.Getenv("DEV_MODE")); isDevMode { @DevWsHotReload() } From ddb52200e8172ac59617d64ddc6460f89b7dac19 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 17:48:01 -0300 Subject: [PATCH 35/42] fix: rename data to payload --- src/presentation/ui/assets/additional.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/presentation/ui/assets/additional.js b/src/presentation/ui/assets/additional.js index dfb8bcc70..8a43c1f21 100644 --- a/src/presentation/ui/assets/additional.js +++ b/src/presentation/ui/assets/additional.js @@ -1,8 +1,8 @@ "use strict"; -document.addEventListener("alpine:initializing", () => { - async function jsonAjax(method, url, data) { - loadingOverlayElement = document.getElementById("loading-overlay"); +document.addEventListener("alpine:init", () => { + async function jsonAjax(method, url, payload) { + const loadingOverlayElement = document.getElementById("loading-overlay"); loadingOverlayElement.classList.add("htmx-request"); await fetch(url, { @@ -11,7 +11,7 @@ document.addEventListener("alpine:initializing", () => { Accept: "application/json", "Content-Type": "application/json", }, - body: JSON.stringify(data), + body: JSON.stringify(payload), }) .then((response) => { loadingOverlayElement.classList.remove("htmx-request"); From 1eb73030753f62caaf4fda02a88d894b91a8eedd Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 17:48:12 -0300 Subject: [PATCH 36/42] fix: do not use window prefix on json ajax --- .../ui/page/runtimes/phpRuntimeHorizontalTabContent.templ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ index 2cb4563c3..887e976cc 100644 --- a/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ +++ b/src/presentation/ui/page/runtimes/phpRuntimeHorizontalTabContent.templ @@ -25,7 +25,7 @@ script PhpRuntimeHorizontalTabContentLocalState() { this.resetPrimaryStates(); }, async updatePhpConfigs() { - await window.jsonAjax( + await jsonAjax( 'PUT', '/api/v1/runtime/php/' + this.vhostHostname + '/', { version: this.phpConfigs.version.value, From e9ed1b977e6ec797919a6a9de0174f445210c4d6 Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 17:58:44 -0300 Subject: [PATCH 37/42] fix: use | instead of / for sed --- src/infra/runtime/runtimeCmdRepo.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/infra/runtime/runtimeCmdRepo.go b/src/infra/runtime/runtimeCmdRepo.go index f87f0d373..ab678aa1e 100644 --- a/src/infra/runtime/runtimeCmdRepo.go +++ b/src/infra/runtime/runtimeCmdRepo.go @@ -2,7 +2,7 @@ package runtimeInfra import ( "errors" - "log" + "log/slog" "os" "strings" @@ -76,19 +76,26 @@ func (repo *RuntimeCmdRepo) UpdatePhpSettings( if err != nil { return err } + phpConfigFilePathStr := phpConfFilePath.String() for _, setting := range settings { - name := setting.Name.String() - value := setting.Value.String() + settingName := setting.Name.String() + settingValue := setting.Value.String() if setting.Value.GetType() == "string" { - value = "\"" + value + "\"" + settingValue = "\"" + settingValue + "\"" + settingValue = strings.Replace(settingValue, "|", "\\|", -1) } _, err := infraHelper.RunCmd( - "sed", "-i", "s/"+name+" .*/"+name+" "+value+"/g", phpConfFilePath.String(), + "sed", "-i", "s|"+settingName+" .*|"+settingName+" "+settingValue+"|g", phpConfigFilePathStr, ) if err != nil { - log.Printf("(%s) UpdatePhpSettingFailed: %s", name, err.Error()) + slog.Debug( + "UpdatePhpSettingFailed", + slog.String("settingName", settingName), + slog.String("settingValue", settingValue), + slog.Any("error", err), + ) continue } } From 20867e9d5ce878d733b310df13d407f57848eefa Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 18:13:19 -0300 Subject: [PATCH 38/42] fix: improve nginx validation and use full path --- src/infra/helper/reloadWebServer.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/infra/helper/reloadWebServer.go b/src/infra/helper/reloadWebServer.go index c1ee4c448..5956fad43 100644 --- a/src/infra/helper/reloadWebServer.go +++ b/src/infra/helper/reloadWebServer.go @@ -1,14 +1,29 @@ package infraHelper -import "errors" +import ( + "errors" + "strings" + "time" +) func ReloadWebServer() error { - _, err := RunCmdWithSubShell( - "nginx -t && nginx -s reload && sleep 2", - ) + wsConfigTestResult, err := RunCmd("/usr/sbin/nginx", "-t") + if err != nil { + if wsConfigTestResult != "" { + return errors.New("NginxConfigTestFailed: " + err.Error()) + } + + if !strings.Contains(wsConfigTestResult, "test is successful") { + return errors.New("NginxConfigTestFailed: " + wsConfigTestResult) + } + } + + _, err = RunCmd("/usr/sbin/nginx", "-s", "reload", "-c", "/etc/nginx/nginx.conf") if err != nil { return errors.New("NginxReloadFailed: " + err.Error()) } + time.Sleep(2 * time.Second) + return nil } From 77cf9f76833ec037a08b712ec25e2d023c277cad Mon Sep 17 00:00:00 2001 From: ntorga Date: Fri, 4 Oct 2024 18:13:41 -0300 Subject: [PATCH 39/42] fix: define default type and match patterns --- .../component/mappings/matchPatternSelectInput.templ | 2 +- src/presentation/ui/page/mappings.templ | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/presentation/ui/component/mappings/matchPatternSelectInput.templ b/src/presentation/ui/component/mappings/matchPatternSelectInput.templ index 54e59a8aa..bc3ebcd7c 100644 --- a/src/presentation/ui/component/mappings/matchPatternSelectInput.templ +++ b/src/presentation/ui/component/mappings/matchPatternSelectInput.templ @@ -11,6 +11,6 @@ templ MatchPatternSelectInput(id, label, bindValuePath string) { {Label: "Contains", Value: "contains"}, {Label: "Equals", Value: "equals"}, {Label: "Ends With", Value: "ends-with"}, - }, true, + }, false, ) } diff --git a/src/presentation/ui/page/mappings.templ b/src/presentation/ui/page/mappings.templ index ab0fdef8f..5e36cba7e 100644 --- a/src/presentation/ui/page/mappings.templ +++ b/src/presentation/ui/page/mappings.templ @@ -20,14 +20,14 @@ script MappingsIndexLocalState() { resetPrimaryStates() { this.virtualHost = { 'hostname': '', - 'type': '', + 'type': 'top-level', 'rootDirectory': '', 'parentHostname': '' } this.mapping = { 'id': 0, 'path': '', - 'matchPattern': '', + 'matchPattern': 'begins-with', 'targetType': 'url', 'targetValue': '', 'targetHttpResponseCode': '' @@ -238,7 +238,7 @@ templ CreateVhostForm() {
@componentForm.SelectInput( "type", "Type", "virtualHost.type", "", - valueObject.AvailableVirtualHostsTypes, true, + valueObject.AvailableVirtualHostsTypes, false, )