Skip to content

Commit d4dc150

Browse files
authored
Merge branch 'dev-v2' into pr@dev-v2@feat_container_pinned
2 parents c7d93f5 + 7c33dd9 commit d4dc150

File tree

119 files changed

+2949
-1117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+2949
-1117
lines changed

agent/app/api/v2/app.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"github.com/1Panel-dev/1Panel/agent/app/dto/request"
77
"github.com/1Panel-dev/1Panel/agent/i18n"
88
"github.com/gin-gonic/gin"
9+
"net/http"
10+
"time"
911
)
1012

1113
// @Tags App
@@ -192,3 +194,28 @@ func (b *BaseApi) GetAppListUpdate(c *gin.Context) {
192194
}
193195
helper.SuccessWithData(c, res)
194196
}
197+
198+
// @Tags App
199+
// @Summary Get app icon by app_id
200+
// @Accept json
201+
// @Param appId path integer true "app id"
202+
// @Success 200 {file} file "app icon"
203+
// @Security ApiKeyAuth
204+
// @Security Timestamp
205+
// @Router /apps/icon/:appId [get]
206+
func (b *BaseApi) GetAppIcon(c *gin.Context) {
207+
appID, err := helper.GetIntParamByKey(c, "appID")
208+
if err != nil {
209+
helper.BadRequest(c, err)
210+
return
211+
}
212+
iconBytes, err := appService.GetAppIcon(appID)
213+
if err != nil {
214+
helper.InternalServer(c, err)
215+
return
216+
}
217+
c.Header("Content-Type", "image/png")
218+
c.Header("Cache-Control", "public, max-age=31536000, immutable")
219+
c.Header("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
220+
c.Data(http.StatusOK, "image/png", iconBytes)
221+
}

agent/app/api/v2/website_ssl.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ func (b *BaseApi) UploadWebsiteSSL(c *gin.Context) {
235235
func (b *BaseApi) UploadSSLFile(c *gin.Context) {
236236
var req request.WebsiteSSLFileUpload
237237

238-
req.Type = c.PostForm("type")
239238
req.Description = c.PostForm("description")
240239
sslID := c.PostForm("sslID")
241240
if sslID != "" {
@@ -279,7 +278,7 @@ func (b *BaseApi) UploadSSLFile(c *gin.Context) {
279278
return
280279
}
281280

282-
helper.SuccessWithData(c, nil)
281+
helper.Success(c)
283282
}
284283

285284
func readUploadedFile(fileHeader *multipart.FileHeader) ([]byte, error) {

agent/app/dto/app.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ type AppProperty struct {
9191
Key string `json:"key"`
9292
Required []string `json:"Required"`
9393
CrossVersionUpdate bool `json:"crossVersionUpdate"`
94-
Limit int `json:"limit"`
95-
Recommend int `json:"recommend"`
94+
Limit int `json:"limit" yaml:"limit"`
95+
Recommend int `json:"recommend" yaml:"recommend"`
9696
Website string `json:"website"`
9797
Github string `json:"github"`
9898
Document string `json:"document"`
9999
Architectures []string `json:"architectures"`
100-
MemoryRequired int `json:"memoryRequired"`
100+
MemoryRequired int `json:"memoryRequired" yaml:"memoryRequired"`
101101
GpuSupport bool `json:"gpuSupport"`
102102
Version float64 `json:"version"`
103103
Deprecated float64 `json:"deprecated"`

agent/app/dto/container.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,16 @@ type ResourceLimit struct {
8282
}
8383

8484
type ContainerOperate struct {
85-
TaskID string `json:"taskID"`
86-
ForcePull bool `json:"forcePull"`
87-
Name string `json:"name" validate:"required"`
88-
Image string `json:"image" validate:"required"`
89-
Network string `json:"network"`
90-
Hostname string `json:"hostname"`
91-
DomainName string `json:"domainName"`
92-
MacAddr string `json:"macAddr"`
93-
DNS []string `json:"dns"`
94-
Ipv4 string `json:"ipv4"`
95-
Ipv6 string `json:"ipv6"`
85+
TaskID string `json:"taskID"`
86+
ForcePull bool `json:"forcePull"`
87+
Name string `json:"name" validate:"required"`
88+
Image string `json:"image" validate:"required"`
89+
90+
Hostname string `json:"hostname"`
91+
DomainName string `json:"domainName"`
92+
DNS []string `json:"dns"`
93+
Networks []ContainerNetwork `json:"networks"`
94+
9695
PublishAllPorts bool `json:"publishAllPorts"`
9796
ExposedPorts []PortHelper `json:"exposedPorts"`
9897
Tty bool `json:"tty"`
@@ -111,6 +110,12 @@ type ContainerOperate struct {
111110
Env []string `json:"env"`
112111
RestartPolicy string `json:"restartPolicy"`
113112
}
113+
type ContainerNetwork struct {
114+
Network string `json:"network"`
115+
Ipv4 string `json:"ipv4"`
116+
Ipv6 string `json:"ipv6"`
117+
MacAddr string `json:"macAddr"`
118+
}
114119

115120
type ContainerCreateByCommand struct {
116121
TaskID string `json:"taskID"`

agent/app/dto/database.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,15 @@ type DatabaseItem struct {
281281
}
282282

283283
type DatabaseCreate struct {
284-
Name string `json:"name" validate:"required,max=256"`
285-
Type string `json:"type" validate:"required"`
286-
From string `json:"from" validate:"required,oneof=local remote"`
287-
Version string `json:"version" validate:"required"`
288-
Address string `json:"address"`
289-
Port uint `json:"port"`
290-
Username string `json:"username" validate:"required"`
291-
Password string `json:"password"`
284+
Name string `json:"name" validate:"required,max=256"`
285+
Type string `json:"type" validate:"required"`
286+
From string `json:"from" validate:"required,oneof=local remote"`
287+
Version string `json:"version" validate:"required"`
288+
Address string `json:"address"`
289+
Port uint `json:"port"`
290+
InitialDB string `json:"initialDB"`
291+
Username string `json:"username" validate:"required"`
292+
Password string `json:"password"`
292293

293294
SSL bool `json:"ssl"`
294295
RootCert string `json:"rootCert"`

agent/app/dto/response/app.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,10 @@ type AppItem struct {
3333
Key string `json:"key"`
3434
ID uint `json:"id"`
3535
Description string `json:"description"`
36-
Icon string `json:"icon"`
37-
Type string `json:"type"`
3836
Status string `json:"status"`
39-
Resource string `json:"resource"`
4037
Installed bool `json:"installed"`
41-
Versions []string `json:"versions"`
4238
Limit int `json:"limit"`
43-
Tags []TagDTO `json:"tags"`
44-
Github string `json:"github"`
45-
Website string `json:"website"`
39+
Tags []string `json:"tags"`
4640
GpuSupport bool `json:"gpuSupport"`
4741
Recommend int `json:"recommend"`
4842
}

agent/app/dto/response/disk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type DiskBasicInfo struct {
2424
type CompleteDiskInfo struct {
2525
Disks []DiskInfo `json:"disks"`
2626
UnpartitionedDisks []DiskBasicInfo `json:"unpartitionedDisks"`
27-
SystemDisk *DiskInfo `json:"systemDisk"`
27+
SystemDisks []DiskInfo `json:"systemDisks"`
2828
TotalDisks int `json:"totalDisks"`
2929
TotalCapacity int64 `json:"totalCapacity"`
3030
}

agent/app/model/database.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type Database struct {
99
From string `json:"from" gorm:"not null"`
1010
Address string `json:"address" gorm:"not null"`
1111
Port uint `json:"port" gorm:"not null"`
12+
InitialDB string `json:"initialDB"`
1213
Username string `json:"username"`
1314
Password string `json:"password"`
1415

agent/app/service/app.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type AppService struct {
3737
}
3838

3939
type IAppService interface {
40-
PageApp(ctx *gin.Context, req request.AppSearch) (interface{}, error)
40+
PageApp(ctx *gin.Context, req request.AppSearch) (*response.AppRes, error)
4141
GetAppTags(ctx *gin.Context) ([]response.TagDTO, error)
4242
GetApp(ctx *gin.Context, key string) (*response.AppDTO, error)
4343
GetAppDetail(appId uint, version, appType string) (response.AppDetailDTO, error)
@@ -46,13 +46,14 @@ type IAppService interface {
4646
GetAppUpdate() (*response.AppUpdateRes, error)
4747
GetAppDetailByID(id uint) (*response.AppDetailDTO, error)
4848
SyncAppListFromLocal(taskID string)
49+
GetAppIcon(appID uint) ([]byte, error)
4950
}
5051

5152
func NewIAppService() IAppService {
5253
return &AppService{}
5354
}
5455

55-
func (a AppService) PageApp(ctx *gin.Context, req request.AppSearch) (interface{}, error) {
56+
func (a AppService) PageApp(ctx *gin.Context, req request.AppSearch) (*response.AppRes, error) {
5657
var opts []repo.DBOption
5758
opts = append(opts, appRepo.OrderByRecommend())
5859
if req.Name != "" {
@@ -98,7 +99,7 @@ func (a AppService) PageApp(ctx *gin.Context, req request.AppSearch) (interface{
9899
}
99100
opts = append(opts, repo.WithByIDs(appIds))
100101
}
101-
var res response.AppRes
102+
res := &response.AppRes{}
102103

103104
total, apps, err := appRepo.Page(req.Page, req.PageSize, opts...)
104105
if err != nil {
@@ -120,12 +121,7 @@ func (a AppService) PageApp(ctx *gin.Context, req request.AppSearch) (interface{
120121
ID: ap.ID,
121122
Name: ap.Name,
122123
Key: ap.Key,
123-
Type: ap.Type,
124-
Icon: ap.Icon,
125-
Resource: ap.Resource,
126124
Limit: ap.Limit,
127-
Website: ap.Website,
128-
Github: ap.Github,
129125
GpuSupport: ap.GpuSupport,
130126
Recommend: ap.Recommend,
131127
Description: ap.GetDescription(ctx),
@@ -135,7 +131,9 @@ func (a AppService) PageApp(ctx *gin.Context, req request.AppSearch) (interface{
135131
if err != nil {
136132
continue
137133
}
138-
appDTO.Tags = tags
134+
for _, tag := range tags {
135+
appDTO.Tags = append(appDTO.Tags, tag.Name)
136+
}
139137
if ap.Type == constant.RuntimePHP || ap.Type == constant.RuntimeGo || ap.Type == constant.RuntimeNode || ap.Type == constant.RuntimePython || ap.Type == constant.RuntimeJava || ap.Type == constant.RuntimeDotNet {
140138
details, _ := appDetailRepo.GetBy(appDetailRepo.WithAppId(ap.ID))
141139
var ids []uint
@@ -1161,3 +1159,15 @@ func (a AppService) SyncAppListFromRemote(taskID string) (err error) {
11611159

11621160
return nil
11631161
}
1162+
1163+
func (a AppService) GetAppIcon(appID uint) ([]byte, error) {
1164+
app, err := appRepo.GetFirst(repo.WithByID(appID))
1165+
if err != nil {
1166+
return nil, err
1167+
}
1168+
iconBytes, err := base64.StdEncoding.DecodeString(app.Icon)
1169+
if err != nil {
1170+
return nil, err
1171+
}
1172+
return iconBytes, nil
1173+
}

agent/app/service/app_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,7 @@ func handleLocalApp(appDir string) (app *model.App, err error) {
14141414
app.Key = "local" + appDefine.Key
14151415
app.Architectures = strings.Join(appDefine.Architectures, ",")
14161416
app.GpuSupport = appDefine.GpuSupport
1417+
app.MemoryRequired = appDefine.MemoryRequired
14171418

14181419
app.Resource = constant.AppResourceLocal
14191420
app.Status = constant.AppNormal
@@ -1555,7 +1556,6 @@ func handleInstalled(appInstallList []model.AppInstall, updated bool, sync bool)
15551556
Message: installed.Message,
15561557
HttpPort: installed.HttpPort,
15571558
HttpsPort: installed.HttpsPort,
1558-
Icon: installed.App.Icon,
15591559
AppName: installed.App.Name,
15601560
AppKey: installed.App.Key,
15611561
AppType: installed.App.Type,

0 commit comments

Comments
 (0)