mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-09 11:55:52 +08:00
feat(app): Add a favorite feature for installed applications (#8477)
Refs https://github.com/1Panel-dev/1Panel/issues/5903
This commit is contained in:
parent
46120a74ed
commit
d8f1c462f1
10 changed files with 69 additions and 11 deletions
|
|
@ -80,6 +80,7 @@ type AppInstalledOperate struct {
|
|||
DockerCompose string `json:"dockerCompose"`
|
||||
TaskID string `json:"taskID"`
|
||||
DeleteImage bool `json:"deleteImage"`
|
||||
Favorite bool `json:"favorite"`
|
||||
}
|
||||
|
||||
type AppInstallUpgrade struct {
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ type AppInstallDTO struct {
|
|||
DockerCompose string `json:"dockerCompose"`
|
||||
WebUI string `json:"webUI"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
Favorite bool `json:"favorite"`
|
||||
App AppDetail `json:"app"`
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ type AppInstall struct {
|
|||
HttpPort int `json:"httpPort"`
|
||||
HttpsPort int `json:"httpsPort"`
|
||||
WebUI string `json:"webUI"`
|
||||
App App `json:"app" gorm:"-:migration"`
|
||||
Favorite bool `json:"favorite"`
|
||||
|
||||
App App `json:"app" gorm:"-:migration"`
|
||||
}
|
||||
|
||||
func (i *AppInstall) GetPath() string {
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ func (a *AppInstallService) Page(req request.AppInstalledSearch) (int64, []respo
|
|||
installs []model.AppInstall
|
||||
err error
|
||||
)
|
||||
opts = append(opts, repo.WithOrderRuleBy("favorite", "descending"))
|
||||
|
||||
if req.Name != "" {
|
||||
opts = append(opts, repo.WithByLikeName(req.Name))
|
||||
|
|
@ -301,6 +302,9 @@ func (a *AppInstallService) Operate(req request.AppInstalledOperate) error {
|
|||
return upgradeInstall(upgradeReq)
|
||||
case constant.Reload:
|
||||
return opNginx(install.ContainerName, constant.NginxReload)
|
||||
case constant.Favorite:
|
||||
install.Favorite = req.Favorite
|
||||
return appInstallRepo.Save(context.Background(), &install)
|
||||
default:
|
||||
return errors.New("operate not support")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1476,6 +1476,7 @@ func handleInstalled(appInstallList []model.AppInstall, updated bool, sync bool)
|
|||
Website: installed.App.Website,
|
||||
Document: installed.App.Document,
|
||||
},
|
||||
Favorite: installed.Favorite,
|
||||
}
|
||||
if updated {
|
||||
installDTO.DockerCompose = installed.DockerCompose
|
||||
|
|
|
|||
|
|
@ -28,14 +28,15 @@ const (
|
|||
type AppOperate string
|
||||
|
||||
var (
|
||||
Start AppOperate = "start"
|
||||
Stop AppOperate = "stop"
|
||||
Restart AppOperate = "restart"
|
||||
Delete AppOperate = "delete"
|
||||
Sync AppOperate = "sync"
|
||||
Backup AppOperate = "backup"
|
||||
Update AppOperate = "update"
|
||||
Rebuild AppOperate = "rebuild"
|
||||
Upgrade AppOperate = "upgrade"
|
||||
Reload AppOperate = "reload"
|
||||
Start AppOperate = "start"
|
||||
Stop AppOperate = "stop"
|
||||
Restart AppOperate = "restart"
|
||||
Delete AppOperate = "delete"
|
||||
Sync AppOperate = "sync"
|
||||
Backup AppOperate = "backup"
|
||||
Update AppOperate = "update"
|
||||
Rebuild AppOperate = "rebuild"
|
||||
Upgrade AppOperate = "upgrade"
|
||||
Reload AppOperate = "reload"
|
||||
Favorite AppOperate = "favorite"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ func InitAgentDB() {
|
|||
migrations.AddAppIgnore,
|
||||
migrations.UpdateWebsite,
|
||||
migrations.UpdateWebsiteAcmeAccount,
|
||||
migrations.UpdateAppInstall,
|
||||
})
|
||||
if err := m.Migrate(); err != nil {
|
||||
global.LOG.Error(err)
|
||||
|
|
|
|||
|
|
@ -352,3 +352,13 @@ var UpdateWebsiteAcmeAccount = &gormigrate.Migration{
|
|||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
var UpdateAppInstall = &gormigrate.Migration{
|
||||
ID: "20250425-update-appInstall",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
if err := tx.AutoMigrate(&model.AppInstall{}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ export namespace App {
|
|||
canUpdate: boolean;
|
||||
path: string;
|
||||
httpPort?: number;
|
||||
favorite: boolean;
|
||||
app: App;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,6 +184,34 @@
|
|||
</el-button>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<span class="ml-1">
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
:content="$t('website.cancelFavorite')"
|
||||
placement="top-start"
|
||||
v-if="installed.favorite"
|
||||
>
|
||||
<el-button
|
||||
link
|
||||
icon="Star"
|
||||
type="warning"
|
||||
@click="favoriteInstall(installed)"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
:content="$t('website.favorite')"
|
||||
placement="top-start"
|
||||
v-else
|
||||
>
|
||||
<el-button
|
||||
link
|
||||
icon="Star"
|
||||
type="info"
|
||||
@click="favoriteInstall(installed)"
|
||||
></el-button>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center justify-end gap-1">
|
||||
<el-button
|
||||
|
|
@ -441,6 +469,7 @@ const operateReq = reactive({
|
|||
installId: 0,
|
||||
operate: '',
|
||||
detailId: 0,
|
||||
favorite: false,
|
||||
});
|
||||
const backupRef = ref();
|
||||
const uploadRef = ref();
|
||||
|
|
@ -557,6 +586,13 @@ const openOperate = (row: any, op: string) => {
|
|||
}
|
||||
};
|
||||
|
||||
const favoriteInstall = (row: App.AppInstalled) => {
|
||||
operateReq.installId = row.id;
|
||||
operateReq.operate = 'favorite';
|
||||
operateReq.favorite = !row.favorite;
|
||||
operate();
|
||||
};
|
||||
|
||||
const openIgnore = () => {
|
||||
ignoreRef.value.acceptParams();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue