Browse Source

Added Update all geofiles button (#3318)

* added Update all geofiles button

* localized update all string
fgsfds 1 week ago
parent
commit
5e641ff9e8

+ 1 - 0
web/controller/server.go

@@ -45,6 +45,7 @@ func (a *ServerController) initRouter(g *gin.RouterGroup) {
 	g.POST("/stopXrayService", a.stopXrayService)
 	g.POST("/stopXrayService", a.stopXrayService)
 	g.POST("/restartXrayService", a.restartXrayService)
 	g.POST("/restartXrayService", a.restartXrayService)
 	g.POST("/installXray/:version", a.installXray)
 	g.POST("/installXray/:version", a.installXray)
+	g.POST("/updateGeofile", a.updateGeofile)
 	g.POST("/updateGeofile/:fileName", a.updateGeofile)
 	g.POST("/updateGeofile/:fileName", a.updateGeofile)
 	g.POST("/logs/:count", a.getLogs)
 	g.POST("/logs/:count", a.getLogs)
 	g.POST("/xraylogs/:count", a.getXrayLogs)
 	g.POST("/xraylogs/:count", a.getXrayLogs)

+ 11 - 2
web/html/index.html

@@ -383,6 +383,9 @@
             <a-icon type="reload" @click="updateGeofile(file)" :style="{ marginRight: '8px' }"/>
             <a-icon type="reload" @click="updateGeofile(file)" :style="{ marginRight: '8px' }"/>
           </a-list-item>
           </a-list-item>
         </a-list>
         </a-list>
+        <div style="margin-top: 5px; display: flex; justify-content: flex-end;">
+          <a-button @click="updateGeofile('')">{{ i18n "pages.index.geofilesUpdateAll" }}</a-button>
+        </div>
       </a-collapse-panel>
       </a-collapse-panel>
     </a-collapse>
     </a-collapse>
   </a-modal>
   </a-modal>
@@ -786,16 +789,22 @@ ${dateTime}
                 });
                 });
             },
             },
             updateGeofile(fileName) {
             updateGeofile(fileName) {
+                const isSingleFile = !!fileName;
                 this.$confirm({
                 this.$confirm({
                     title: '{{ i18n "pages.index.geofileUpdateDialog" }}',
                     title: '{{ i18n "pages.index.geofileUpdateDialog" }}',
-                    content: '{{ i18n "pages.index.geofileUpdateDialogDesc" }}'.replace("#filename#", fileName),
+                    content: isSingleFile
+                        ? '{{ i18n "pages.index.geofileUpdateDialogDesc" }}'.replace("#filename#", fileName)
+                        : '{{ i18n "pages.index.geofilesUpdateDialogDesc" }}',
                     okText: '{{ i18n "confirm"}}',
                     okText: '{{ i18n "confirm"}}',
                     class: themeSwitcher.currentTheme,
                     class: themeSwitcher.currentTheme,
                     cancelText: '{{ i18n "cancel"}}',
                     cancelText: '{{ i18n "cancel"}}',
                     onOk: async () => {
                     onOk: async () => {
                         versionModal.hide();
                         versionModal.hide();
                         this.loading(true, '{{ i18n "pages.index.dontRefresh"}}');
                         this.loading(true, '{{ i18n "pages.index.dontRefresh"}}');
-                        await HttpUtil.post(`/server/updateGeofile/${fileName}`);
+                        const url = isSingleFile 
+                            ? `/server/updateGeofile/${fileName}` 
+                            : `/server/updateGeofile`;
+                        await HttpUtil.post(url);
                         this.loading(false);
                         this.loading(false);
                     },
                     },
                 });
                 });

+ 30 - 14
web/service/server.go

@@ -511,7 +511,7 @@ func (s *ServerService) GetXrayLogs(
 		line := strings.TrimSpace(scanner.Text())
 		line := strings.TrimSpace(scanner.Text())
 
 
 		if line == "" || strings.Contains(line, "api -> api") {
 		if line == "" || strings.Contains(line, "api -> api") {
-			//skipping empty lines and api calls 
+			//skipping empty lines and api calls
 			continue
 			continue
 		}
 		}
 
 
@@ -742,27 +742,43 @@ func (s *ServerService) UpdateGeofile(fileName string) error {
 		return nil
 		return nil
 	}
 	}
 
 
-	var fileURL string
-	for _, file := range files {
-		if file.FileName == fileName {
-			fileURL = file.URL
-			break
+	var errorMessages []string
+
+	if fileName == "" {
+		for _, file := range files {
+			destPath := fmt.Sprintf("%s/%s", config.GetBinFolderPath(), file.FileName)
+
+			if err := downloadFile(file.URL, destPath); err != nil {
+				errorMessages = append(errorMessages, fmt.Sprintf("Error downloading Geofile '%s': %v", file.FileName, err))
+			}
 		}
 		}
-	}
+	} else {
+		destPath := fmt.Sprintf("%s/%s", config.GetBinFolderPath(), fileName)
 
 
-	if fileURL == "" {
-		return common.NewErrorf("File '%s' not found in the list of Geofiles", fileName)
-	}
+		var fileURL string
+		for _, file := range files {
+			if file.FileName == fileName {
+				fileURL = file.URL
+				break
+			}
+		}
 
 
-	destPath := fmt.Sprintf("%s/%s", config.GetBinFolderPath(), fileName)
+		if fileURL == "" {
+			errorMessages = append(errorMessages, fmt.Sprintf("File '%s' not found in the list of Geofiles", fileName))
+		}
 
 
-	if err := downloadFile(fileURL, destPath); err != nil {
-		return common.NewErrorf("Error downloading Geofile '%s': %v", fileName, err)
+		if err := downloadFile(fileURL, destPath); err != nil {
+			errorMessages = append(errorMessages, fmt.Sprintf("Error downloading Geofile '%s': %v", fileName, err))
+		}
 	}
 	}
 
 
 	err := s.RestartXrayService()
 	err := s.RestartXrayService()
 	if err != nil {
 	if err != nil {
-		return common.NewErrorf("Updated Geofile '%s' but Failed to start Xray: %v", fileName, err)
+		errorMessages = append(errorMessages, fmt.Sprintf("Updated Geofile '%s' but Failed to start Xray: %v", fileName, err))
+	}
+
+	if len(errorMessages) > 0 {
+		return common.NewErrorf("%s", strings.Join(errorMessages, "\r\n"))
 	}
 	}
 
 
 	return nil
 	return nil

+ 2 - 0
web/translation/translate.ar_EG.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "تم تحديث Xray بنجاح"
 "xraySwitchVersionPopover" = "تم تحديث Xray بنجاح"
 "geofileUpdateDialog" = "هل تريد حقًا تحديث ملف الجغرافيا؟"
 "geofileUpdateDialog" = "هل تريد حقًا تحديث ملف الجغرافيا؟"
 "geofileUpdateDialogDesc" = "سيؤدي هذا إلى تحديث ملف #filename#."
 "geofileUpdateDialogDesc" = "سيؤدي هذا إلى تحديث ملف #filename#."
+"geofilesUpdateDialogDesc" = "سيؤدي هذا إلى تحديث كافة الملفات."
+"geofilesUpdateAll" = "تحديث الكل"
 "geofileUpdatePopover" = "تم تحديث ملف الجغرافيا بنجاح"
 "geofileUpdatePopover" = "تم تحديث ملف الجغرافيا بنجاح"
 "dontRefresh" = "التثبيت شغال، متعملش Refresh للصفحة"
 "dontRefresh" = "التثبيت شغال، متعملش Refresh للصفحة"
 "logs" = "السجلات"
 "logs" = "السجلات"

+ 2 - 0
web/translation/translate.en_US.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray updated successfully"
 "xraySwitchVersionPopover" = "Xray updated successfully"
 "geofileUpdateDialog" = "Do you really want to update the geofile?"
 "geofileUpdateDialog" = "Do you really want to update the geofile?"
 "geofileUpdateDialogDesc" = "This will update the #filename# file."
 "geofileUpdateDialogDesc" = "This will update the #filename# file."
+"geofilesUpdateDialogDesc" = "This will update all geofiles."
+"geofilesUpdateAll" = "Update all"
 "geofileUpdatePopover" = "Geofile updated successfully"
 "geofileUpdatePopover" = "Geofile updated successfully"
 "dontRefresh" = "Installation is in progress, please do not refresh this page"
 "dontRefresh" = "Installation is in progress, please do not refresh this page"
 "logs" = "Logs"
 "logs" = "Logs"

+ 2 - 0
web/translation/translate.es_ES.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray se actualizó correctamente"
 "xraySwitchVersionPopover" = "Xray se actualizó correctamente"
 "geofileUpdateDialog" = "¿Realmente deseas actualizar el geofichero?"
 "geofileUpdateDialog" = "¿Realmente deseas actualizar el geofichero?"
 "geofileUpdateDialogDesc" = "Esto actualizará el archivo #filename#."
 "geofileUpdateDialogDesc" = "Esto actualizará el archivo #filename#."
+"geofilesUpdateDialogDesc" = "Esto actualizará todos los archivos."
+"geofilesUpdateAll" = "Actualizar todo"
 "geofileUpdatePopover" = "Geofichero actualizado correctamente"
 "geofileUpdatePopover" = "Geofichero actualizado correctamente"
 "dontRefresh" = "La instalación está en progreso, por favor no actualices esta página."
 "dontRefresh" = "La instalación está en progreso, por favor no actualices esta página."
 "logs" = "Registros"
 "logs" = "Registros"

+ 2 - 0
web/translation/translate.fa_IR.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray با موفقیت به‌روز شد"
 "xraySwitchVersionPopover" = "Xray با موفقیت به‌روز شد"
 "geofileUpdateDialog" = "آیا واقعاً می‌خواهید فایل جغرافیایی را به‌روز کنید؟"
 "geofileUpdateDialog" = "آیا واقعاً می‌خواهید فایل جغرافیایی را به‌روز کنید؟"
 "geofileUpdateDialogDesc" = "این عمل فایل #filename# را به‌روز می‌کند."
 "geofileUpdateDialogDesc" = "این عمل فایل #filename# را به‌روز می‌کند."
+"geofilesUpdateDialogDesc" = "با این کار همه فایل‌ها به‌روزرسانی می‌شوند."
+"geofilesUpdateAll" = "همه را به‌روزرسانی کنید"
 "geofileUpdatePopover" = "فایل جغرافیایی با موفقیت به‌روز شد"
 "geofileUpdatePopover" = "فایل جغرافیایی با موفقیت به‌روز شد"
 "dontRefresh" = "در حال نصب، لطفا صفحه را رفرش نکنید"
 "dontRefresh" = "در حال نصب، لطفا صفحه را رفرش نکنید"
 "logs" = "گزارش‌ها"
 "logs" = "گزارش‌ها"

+ 2 - 0
web/translation/translate.id_ID.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray berhasil diperbarui"
 "xraySwitchVersionPopover" = "Xray berhasil diperbarui"
 "geofileUpdateDialog" = "Apakah Anda yakin ingin memperbarui geofile?"
 "geofileUpdateDialog" = "Apakah Anda yakin ingin memperbarui geofile?"
 "geofileUpdateDialogDesc" = "Ini akan memperbarui file #filename#."
 "geofileUpdateDialogDesc" = "Ini akan memperbarui file #filename#."
+"geofilesUpdateDialogDesc" = "Ini akan memperbarui semua berkas."
+"geofilesUpdateAll" = "Perbarui semua"
 "geofileUpdatePopover" = "Geofile berhasil diperbarui"
 "geofileUpdatePopover" = "Geofile berhasil diperbarui"
 "dontRefresh" = "Instalasi sedang berlangsung, harap jangan menyegarkan halaman ini"
 "dontRefresh" = "Instalasi sedang berlangsung, harap jangan menyegarkan halaman ini"
 "logs" = "Log"
 "logs" = "Log"

+ 2 - 0
web/translation/translate.ja_JP.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xrayの更新が成功しました"
 "xraySwitchVersionPopover" = "Xrayの更新が成功しました"
 "geofileUpdateDialog" = "ジオファイルを本当に更新しますか?"
 "geofileUpdateDialog" = "ジオファイルを本当に更新しますか?"
 "geofileUpdateDialogDesc" = "これにより#filename#ファイルが更新されます。"
 "geofileUpdateDialogDesc" = "これにより#filename#ファイルが更新されます。"
+"geofilesUpdateDialogDesc" = "これにより、すべてのファイルが更新されます。"
+"geofilesUpdateAll" = "すべて更新"
 "geofileUpdatePopover" = "ジオファイルの更新が成功しました"
 "geofileUpdatePopover" = "ジオファイルの更新が成功しました"
 "dontRefresh" = "インストール中、このページをリロードしないでください"
 "dontRefresh" = "インストール中、このページをリロードしないでください"
 "logs" = "ログ"
 "logs" = "ログ"

+ 2 - 0
web/translation/translate.pt_BR.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray atualizado com sucesso"
 "xraySwitchVersionPopover" = "Xray atualizado com sucesso"
 "geofileUpdateDialog" = "Você realmente deseja atualizar o geofile?"
 "geofileUpdateDialog" = "Você realmente deseja atualizar o geofile?"
 "geofileUpdateDialogDesc" = "Isso atualizará o arquivo #filename#."
 "geofileUpdateDialogDesc" = "Isso atualizará o arquivo #filename#."
+"geofilesUpdateDialogDesc" = "Isso atualizará todos os arquivos."
+"geofilesUpdateAll" = "Atualizar tudo"
 "geofileUpdatePopover" = "Geofile atualizado com sucesso"
 "geofileUpdatePopover" = "Geofile atualizado com sucesso"
 "dontRefresh" = "Instalação em andamento, por favor não atualize a página"
 "dontRefresh" = "Instalação em andamento, por favor não atualize a página"
 "logs" = "Logs"
 "logs" = "Logs"

+ 2 - 0
web/translation/translate.ru_RU.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray успешно обновлён"
 "xraySwitchVersionPopover" = "Xray успешно обновлён"
 "geofileUpdateDialog" = "Вы действительно хотите обновить геофайл?"
 "geofileUpdateDialog" = "Вы действительно хотите обновить геофайл?"
 "geofileUpdateDialogDesc" = "Это обновит файл #filename#."
 "geofileUpdateDialogDesc" = "Это обновит файл #filename#."
+"geofilesUpdateDialogDesc" = "Это обновит все геофайлы."
+"geofilesUpdateAll" = "Обновить все"
 "geofileUpdatePopover" = "Геофайл успешно обновлён"
 "geofileUpdatePopover" = "Геофайл успешно обновлён"
 "dontRefresh" = "Установка в процессе. Не обновляйте страницу"
 "dontRefresh" = "Установка в процессе. Не обновляйте страницу"
 "logs" = "Журнал"
 "logs" = "Журнал"

+ 2 - 0
web/translation/translate.tr_TR.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray başarıyla güncellendi"
 "xraySwitchVersionPopover" = "Xray başarıyla güncellendi"
 "geofileUpdateDialog" = "Geofile'ı gerçekten güncellemek istiyor musunuz?"
 "geofileUpdateDialog" = "Geofile'ı gerçekten güncellemek istiyor musunuz?"
 "geofileUpdateDialogDesc" = "Bu işlem #filename# dosyasını güncelleyecektir."
 "geofileUpdateDialogDesc" = "Bu işlem #filename# dosyasını güncelleyecektir."
+"geofilesUpdateDialogDesc" = "Bu, tüm dosyaları güncelleyecektir."
+"geofilesUpdateAll" = "Tümünü güncelle"
 "geofileUpdatePopover" = "Geofile başarıyla güncellendi"
 "geofileUpdatePopover" = "Geofile başarıyla güncellendi"
 "dontRefresh" = "Kurulum devam ediyor, lütfen bu sayfayı yenilemeyin"
 "dontRefresh" = "Kurulum devam ediyor, lütfen bu sayfayı yenilemeyin"
 "logs" = "Günlükler"
 "logs" = "Günlükler"

+ 2 - 0
web/translation/translate.uk_UA.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray успішно оновлено"
 "xraySwitchVersionPopover" = "Xray успішно оновлено"
 "geofileUpdateDialog" = "Ви дійсно хочете оновити геофайл?"
 "geofileUpdateDialog" = "Ви дійсно хочете оновити геофайл?"
 "geofileUpdateDialogDesc" = "Це оновить файл #filename#."
 "geofileUpdateDialogDesc" = "Це оновить файл #filename#."
+"geofilesUpdateDialogDesc" = "Це оновить усі геофайли."
+"geofilesUpdateAll" = "Оновити все"
 "geofileUpdatePopover" = "Геофайл успішно оновлено"
 "geofileUpdatePopover" = "Геофайл успішно оновлено"
 "dontRefresh" = "Інсталяція триває, будь ласка, не оновлюйте цю сторінку"
 "dontRefresh" = "Інсталяція триває, будь ласка, не оновлюйте цю сторінку"
 "logs" = "Журнали"
 "logs" = "Журнали"

+ 2 - 0
web/translation/translate.vi_VN.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray đã được cập nhật thành công"
 "xraySwitchVersionPopover" = "Xray đã được cập nhật thành công"
 "geofileUpdateDialog" = "Bạn có chắc chắn muốn cập nhật geofile không?"
 "geofileUpdateDialog" = "Bạn có chắc chắn muốn cập nhật geofile không?"
 "geofileUpdateDialogDesc" = "Hành động này sẽ cập nhật tệp #filename#."
 "geofileUpdateDialogDesc" = "Hành động này sẽ cập nhật tệp #filename#."
+"geofilesUpdateDialogDesc" = "Thao tác này sẽ cập nhật tất cả các tập tin."
+"geofilesUpdateAll" = "Cập nhật tất cả"
 "geofileUpdatePopover" = "Geofile đã được cập nhật thành công"
 "geofileUpdatePopover" = "Geofile đã được cập nhật thành công"
 "dontRefresh" = "Đang tiến hành cài đặt, vui lòng không làm mới trang này."
 "dontRefresh" = "Đang tiến hành cài đặt, vui lòng không làm mới trang này."
 "logs" = "Nhật ký"
 "logs" = "Nhật ký"

+ 2 - 0
web/translation/translate.zh_CN.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray 更新成功"
 "xraySwitchVersionPopover" = "Xray 更新成功"
 "geofileUpdateDialog" = "您确定要更新地理文件吗?"
 "geofileUpdateDialog" = "您确定要更新地理文件吗?"
 "geofileUpdateDialogDesc" = "这将更新 #filename# 文件。"
 "geofileUpdateDialogDesc" = "这将更新 #filename# 文件。"
+"geofilesUpdateDialogDesc" = "这将更新所有文件。"
+"geofilesUpdateAll" = "全部更新"
 "geofileUpdatePopover" = "地理文件更新成功"
 "geofileUpdatePopover" = "地理文件更新成功"
 "dontRefresh" = "安装中,请勿刷新此页面"
 "dontRefresh" = "安装中,请勿刷新此页面"
 "logs" = "日志"
 "logs" = "日志"

+ 2 - 0
web/translation/translate.zh_TW.toml

@@ -132,6 +132,8 @@
 "xraySwitchVersionPopover" = "Xray 更新成功"
 "xraySwitchVersionPopover" = "Xray 更新成功"
 "geofileUpdateDialog" = "您確定要更新地理檔案嗎?"
 "geofileUpdateDialog" = "您確定要更新地理檔案嗎?"
 "geofileUpdateDialogDesc" = "這將更新 #filename# 檔案。"
 "geofileUpdateDialogDesc" = "這將更新 #filename# 檔案。"
+"geofilesUpdateDialogDesc" = "這將更新所有文件。"
+"geofilesUpdateAll" = "全部更新"
 "geofileUpdatePopover" = "地理檔案更新成功"
 "geofileUpdatePopover" = "地理檔案更新成功"
 "dontRefresh" = "安裝中,請勿重新整理此頁面"
 "dontRefresh" = "安裝中,請勿重新整理此頁面"
 "logs" = "日誌"
 "logs" = "日誌"