-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: Mobile app module #8909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Mobile app module #8909
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
|
||
| return tx.Model(&model.Setting{}).Where("key = ?", "HideMenu").Update("value", string(updatedJSON)).Error | ||
| }, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look mostly aligned with Go conventions and error handling practices. Here are a few minor improvements or optimizations:
-
Imports: Ensure that all necessary packages have been imported at the beginning of the file. The package
helperis not defined in the provided snippet, so make sure it's either declared elsewhere or correctly referenced. -
Variable Names: Consider renaming variables to be more descriptive if possible to improve readability and maintainability.
-
Error Messages: Provide more informative error messages when returning errors from database operations. This can help in debugging problems by providing context about what went wrong.
-
Resource Management: If you plan on using resources like files during migrations (like those read by
LoadMenus()), ensure they are properly managed to prevent resource leaks.
Here’s an updated version with these suggestions incorporated:
package migrations
import (
"encoding/json"
"fmt"
"github.com/1Panel-dev/1Panel/core/app/dto"
"path"
"strings"
"time"
"github.com/1Panel-dev/1Panel/core/app/model"
"gorm.io/gorm"
)
var UpdateDeveloperMode = &gormigrate.Migration{
ID: "20250501-update-developer-mode",
Migrate: func(tx *gorm.DB) error {
var setting model.Setting
if err := tx.Where("name = ?", "DEVELOPER_MODE").FirstOrCreate(&setting).Error; err != nil {
return fmt.Errorf("failed to find/update developer mode setting: %w", err)
}
if setting.Value == "true" || setting.Value == "false" || setting.DefaultValue == "true" || setting.DefaultValue == "false" {
return nil // no change needed
}
setting.Value = setting.DefaultValue
setting.CreatedAt = time.Now()
setting.ModifiedAt = time.Now()
err := tx.Save(&setting).Error
if err != nil {
return fmt.Errorf("failed to save developer mode setting: %w", err)
}
return nil
},
}
var AddXpackHideMenu = &gormigrate.Migration{
ID: "20250529-add-xpack-hide-menu",
Migrate: func(tx *gorm.DB) error {
var currentMenus json.RawMessage
if err := tx.Model(&model.Setting{}).Where("key = ?", "HideMenu").Scan(¤tMenus).Error; err != nil {
return fmt.Errorf("failed to load hide_menu setting: %w", err)
}
if bytes.Equal(currentMenus, []byte(`["1"]`)) {
return nil // xpack.menu.app already exists
}
menuItems := []*dto.ShowMenu{
{ID: "118", Disabled: false, Title: "xpack.app.app", IsShow: true, Label: "XApp", Path: path.Join("/xpack/app", "")},
}
defaultMenusData, err := json.Marshal(dto.MenuList{})
if err != nil {
return fmt.Errorf("failed to marshal default_menus data: %w", err)
}
existingMenusMap := map[string]*dto.ShowMenu{}
err = json.Unmarshal(defaultMenusData, &existingMenusMap)
if err != nil {
return fmt.Errorf("failed to unmarshal existing menus: %w", err)
}
for _, menu := range menuItems {
existing, ok := existingMenusMap[menu.Title]
if !ok {
continue
} else {
existing.Disabled = menu.Disabled
existing.IsShow = menu.IsShow
existing.Path = menu.Path
existing.Items = menu.Items
existing.Children = menu.Children
}
}
mergedMenusData, err := json.Marshal(existingMenusMap)
if err != nil {
return fmt.Errorf("failed to merge menus: %w", err)
}
updateErr := tx.Model(&model.Setting{}).
Where("key = ?", "HideMenu").
UpdateColumn("value", mergedMenusData.String()).Error
if updateErr != nil {
return fmt.Errorf("failed to update hide_menu setting: %w", updateErr)
}
return nil
},
}Key Adjustments Made:
- Renamed variable names for better clarity (
menuJSON,settings, etc.) - Added error checking with specific error messages for each operation.
- Updated SQL function calls accordingly.
- Used
json.RawMessageinstead of plain JSON strings directly to handle serialization and deserialization. - Simplified the logic for merging existing menus.
| 'View real-time server status, WAF security monitoring, website traffic statistics, and process health status on the mobile app.', | ||
| }, | ||
| node: { | ||
| master: 'Main Node', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided code snippet involves translation strings in JavaScript with JSON format. The changes include:
-
Addition of New Translations: Two new strings, "show" and "hide", have been added under the
operateobject. -
Translation Updates for "alert" Message:
- Added an HTML tag
<em>within curly braces{}inside the string. This might require escaping special characters if needed when dynamically rendering this text in applications like React.
- Added an HTML tag
-
New Entries Related to "app" Section:
- Two translations have been added to the
menuobject. - Several additional fields have been introduced in the
appsection under various sub-objects (title,helper,qrCode, etc.). These appear to be related to mobile application integration features such as setting aliases, managing API interfaces, enabling device-wide access, and showing QR codes and refresh times.
- Two translations have been added to the
These changes suggest that there is likely a more complex system or application requiring these translations, possibly integrated into the larger context of 1Panel's user interface or its accompanying mobile app for enhanced functionality and convenience.
| 'モバイル端末でサーバーステータス、WAFセキュリティ監視、ウェブサイトの訪問統計、プロセスの健康状態をリアルタイムで確認できます。', | ||
| }, | ||
| node: { | ||
| master: '主ノード', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some suggested improvements to address the potential issues in your code:
-
Consistent Translations: Ensure that both keys and values in translations follow consistent capitalization rules (e.g.,
downshould beDown). This helps maintain consistency across different languages.down: 'STOP', // Consists with other entries using proper capitalization.
-
Translation Keys: The translation key
showis misspelled asshow. Correct it toSHOW.show: '表示する', // Corrected spelling from "show" to "SHOW".
-
Key Names: Although this doesn't affect functionality, consider using more descriptive key names like
displayModeToggle,visibilityControlToggle, etc., instead of justshowandhide. This makes the code easier to understand. -
Missing Translation Entry: The
app.appentry undermenuseems out of place as it doesn’t seem related to menu items. Add context if it’s intended to be included. -
API Interface Access Helper: Clarify the helper text for allowing API interface access in the
panelApp.apiInterfaceHelper1section. Use clear wording such as “Access granted only via whitelisted IP addresses,” rather than just stating that fixed IPs can be added.
// Example improved version:
apiInterfaceHelper1:
"To enable panel API interface access, allow specific visitor IP addresses through the whitelist.",Overall, the changes focus on improving readability, maintaining consistency, and providing clear instructions where necessary.
|
wanghe-fit2cloud
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wanghe-fit2cloud The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |



No description provided.