7
7
"strconv"
8
8
9
9
"github.com/IceWhaleTech/CasaOS/model"
10
- "github.com/IceWhaleTech/CasaOS/pkg/docker"
11
- "github.com/IceWhaleTech/CasaOS/pkg/utils/env_helper"
12
10
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
13
11
oasis_err2 "github.com/IceWhaleTech/CasaOS/pkg/utils/oasis_err"
14
12
port2 "github.com/IceWhaleTech/CasaOS/pkg/utils/port"
@@ -33,20 +31,33 @@ func AppList(c *gin.Context) {
33
31
//service.MyService.Docker().DockerContainerCommit("test2")
34
32
35
33
index := c .DefaultQuery ("index" , "1" )
36
- size := c .DefaultQuery ("size" , "10 " )
34
+ size := c .DefaultQuery ("size" , "10000 " )
37
35
t := c .DefaultQuery ("type" , "rank" )
38
36
categoryId := c .DefaultQuery ("category_id" , "0" )
39
37
key := c .DefaultQuery ("key" , "" )
40
- list , count := service .MyService .OAPI ().GetServerList (index , size , t , categoryId , key )
38
+ recommend , list , community := service .MyService .OAPI ().GetServerList (index , size , t , categoryId , key )
39
+ for i := 0 ; i < len (recommend ); i ++ {
40
+ ct , _ := service .MyService .Docker ().DockerListByImage (recommend [i ].Image , recommend [i ].ImageVersion )
41
+ if ct != nil {
42
+ list [i ].State = ct .State
43
+ }
44
+ }
41
45
for i := 0 ; i < len (list ); i ++ {
42
46
ct , _ := service .MyService .Docker ().DockerListByImage (list [i ].Image , list [i ].ImageVersion )
43
47
if ct != nil {
44
48
list [i ].State = ct .State
45
49
}
46
50
}
47
- data := make (map [string ]interface {}, 2 )
48
- data ["count" ] = count
49
- data ["items" ] = list
51
+ for i := 0 ; i < len (community ); i ++ {
52
+ ct , _ := service .MyService .Docker ().DockerListByImage (community [i ].Image , community [i ].ImageVersion )
53
+ if ct != nil {
54
+ list [i ].State = ct .State
55
+ }
56
+ }
57
+ data := make (map [string ]interface {}, 3 )
58
+ data ["recommend" ] = recommend
59
+ data ["list" ] = list
60
+ data ["community" ] = community
50
61
51
62
c .JSON (http .StatusOK , & model.Result {Success : oasis_err2 .SUCCESS , Message : oasis_err2 .GetMsg (oasis_err2 .SUCCESS ), Data : data })
52
63
}
@@ -147,20 +158,24 @@ func AppInfo(c *gin.Context) {
147
158
info .PortMap = info .Ports [i ].CommendPort
148
159
}
149
160
}
161
+ } else {
162
+ for i := 0 ; i < len (info .Ports ); i ++ {
163
+ if info .Ports [i ].Type == 0 {
164
+ info .PortMap = info .Ports [i ].ContainerPort
165
+ break
166
+ }
167
+ }
150
168
}
151
169
152
170
for i := 0 ; i < len (info .Devices ); i ++ {
153
171
if ! file .CheckNotExist (info .Devices [i ].ContainerPath ) {
154
172
info .Devices [i ].Path = info .Devices [i ].ContainerPath
155
173
}
156
174
}
157
- if len (info .Tip ) > 0 {
158
- info .Tip = env_helper .ReplaceStringDefaultENV (info .Tip )
159
- }
175
+ // if len(info.Tip) > 0 {
176
+ // info.Tip = env_helper.ReplaceStringDefaultENV(info.Tip)
177
+ // }
160
178
161
- for i := 0 ; i < len (info .Volumes ); i ++ {
162
- info .Volumes [i ].Path = docker .GetDir ("" , info .Volumes [i ].ContainerPath )
163
- }
164
179
// portOrder := func(c1, c2 *model.Ports) bool {
165
180
// return c1.Type < c2.Type
166
181
// }
@@ -207,7 +222,7 @@ func CategoryList(c *gin.Context) {
207
222
}
208
223
209
224
rear := append ([]model.ServerCategoryList {}, list [0 :]... )
210
- list = append (list [:0 ], model.ServerCategoryList {Count : count , Name : "All" })
225
+ list = append (list [:0 ], model.ServerCategoryList {Count : count , Name : "All" , Font : "apps" })
211
226
list = append (list , rear ... )
212
227
c .JSON (http .StatusOK , & model.Result {Success : oasis_err2 .SUCCESS , Message : oasis_err2 .GetMsg (oasis_err2 .SUCCESS ), Data : list })
213
228
}
0 commit comments