Bladeren bron

enhance: removed the ability to modify nginx log path settings online

Jacky 9 maanden geleden
bovenliggende
commit
27f751671b
4 gewijzigde bestanden met toevoegingen van 9 en 8 verwijderingen
  1. 3 0
      api/settings/settings.go
  2. 2 2
      app/src/views/preference/NginxSettings.vue
  3. 2 4
      internal/nginx/config_args.go
  4. 2 2
      settings/nginx.go

+ 3 - 0
api/settings/settings.go

@@ -3,6 +3,7 @@ package settings
 import (
 	"github.com/0xJacky/Nginx-UI/api"
 	"github.com/0xJacky/Nginx-UI/internal/cron"
+	"github.com/0xJacky/Nginx-UI/internal/nginx"
 	"github.com/0xJacky/Nginx-UI/settings"
 	"github.com/gin-gonic/gin"
 	"net/http"
@@ -15,6 +16,8 @@ func GetServerName(c *gin.Context) {
 }
 
 func GetSettings(c *gin.Context) {
+	settings.NginxSettings.AccessLogPath = nginx.GetAccessLogPath()
+	settings.NginxSettings.ErrorLogPath = nginx.GetErrorLogPath()
 	c.JSON(http.StatusOK, gin.H{
 		"server":    settings.ServerSettings,
 		"nginx":     settings.NginxSettings,

+ 2 - 2
app/src/views/preference/NginxSettings.vue

@@ -14,7 +14,7 @@ const errors: Record<string, Record<string, string>> = inject('errors') as Recor
         ? $gettext('File not found')
         : ''"
     >
-      <AInput v-model:value="data.nginx.access_log_path" />
+      {{ data.nginx.access_log_path }}
     </AFormItem>
     <AFormItem
       :label="$gettext('Nginx Error Log Path')"
@@ -23,7 +23,7 @@ const errors: Record<string, Record<string, string>> = inject('errors') as Recor
         ? $gettext('File not found')
         : ''"
     >
-      <AInput v-model:value="data.nginx.error_log_path" />
+      {{ data.nginx.error_log_path }}
     </AFormItem>
   </AForm>
 </template>

+ 2 - 4
internal/nginx/config_args.go

@@ -33,12 +33,10 @@ func GetConfPath(dir ...string) (confPath string) {
 	}
 
 	joined := filepath.Clean(filepath.Join(confPath, filepath.Join(dir...)))
-
-	if !helper.IsUnderDirectory(confPath, joined) {
+	if !helper.IsUnderDirectory(joined, confPath) {
 		return confPath
 	}
-
-	return
+	return joined
 }
 
 func GetPIDPath() (path string) {

+ 2 - 2
settings/nginx.go

@@ -1,8 +1,8 @@
 package settings
 
 type Nginx struct {
-	AccessLogPath string `json:"access_log_path" binding:"omitempty,file"`
-	ErrorLogPath  string `json:"error_log_path" binding:"omitempty,file"`
+	AccessLogPath string `json:"access_log_path" protected:"true"`
+	ErrorLogPath  string `json:"error_log_path" protected:"true"`
 	ConfigDir     string `json:"config_dir" protected:"true"`
 	PIDPath       string `json:"pid_path" protected:"true"`
 	TestConfigCmd string `json:"test_config_cmd" protected:"true"`