Pārlūkot izejas kodu

feat(upgrade): add in_docker flag to RuntimeInfo and adjust upgrade interval based on Docker environment

Jacky 1 dienu atpakaļ
vecāks
revīzija
406d9113e7
3 mainītis faili ar 17 papildinājumiem un 9 dzēšanām
  1. 1 0
      app/src/api/upgrade.ts
  2. 14 9
      app/src/views/system/Upgrade.vue
  3. 2 0
      internal/version/info.go

+ 1 - 0
app/src/api/upgrade.ts

@@ -8,6 +8,7 @@ export interface RuntimeInfo {
   body: string
   published_at: string
   cur_version: Info
+  in_docker: boolean
 }
 
 interface Info {

+ 14 - 9
app/src/views/system/Upgrade.vue

@@ -123,16 +123,18 @@ async function performUpgrade() {
       return
 
     const t = setInterval(() => {
+      const interval = data.value.in_docker ? 10000 : 1000
       upgrade.current_version().then(() => {
         clearInterval(t)
-        progressStatus.value = 'success'
-        progressPercent.value = 100
-        modalClosable.value = true
-        log('Upgraded successfully')
-
-        setInterval(() => {
-          location.reload()
-        }, 1000)
+        setTimeout(() => {
+          progressStatus.value = 'success'
+          progressPercent.value = 100
+          modalClosable.value = true
+          log('Upgraded successfully')
+          setTimeout(() => {
+            location.reload()
+          }, 1000)
+        }, interval)
       })
     }, 2000)
   }
@@ -171,7 +173,10 @@ const performUpgradeBtnText = computed(() => {
     </AModal>
     <div class="upgrade-container">
       <p>{{ $gettext('You can check Nginx UI upgrade at this page.') }}</p>
-      <h3>{{ $gettext('Current Version') }}: v{{ version.version }} <span class="short-hash">({{ data?.cur_version?.short_hash }})</span></h3>
+      <h3>
+        {{ $gettext('Current Version') }}: v{{ version.version }}
+        <span v-if="data?.cur_version?.short_hash" class="short-hash">({{ data?.cur_version?.short_hash }})</span>
+      </h3>
       <template v-if="getReleaseError">
         <AAlert
           type="error"

+ 2 - 0
internal/version/info.go

@@ -13,6 +13,7 @@ type RuntimeInfo struct {
 	Arch       string `json:"arch"`
 	ExPath     string `json:"ex_path"`
 	CurVersion *Info  `json:"cur_version"`
+	InDocker   bool   `json:"in_docker"`
 }
 
 func GetRuntimeInfo() (r RuntimeInfo, err error) {
@@ -32,6 +33,7 @@ func GetRuntimeInfo() (r RuntimeInfo, err error) {
 		Arch:       runtime.GOARCH,
 		ExPath:     realPath,
 		CurVersion: GetVersionInfo(),
+		InDocker:   os.Getenv("NGINX_UI_IN_DOCKER") == "true",
 	}
 
 	return