feat: The certificate list supports sorting by expiration date. (#10372)

Refs https://github.com/1Panel-dev/1Panel/issues/10371
This commit is contained in:
CityFun 2025-09-15 13:37:27 +08:00 committed by GitHub
parent 0ba83d1353
commit 7e8581a7de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 1 deletions

View file

@ -6,6 +6,8 @@ type WebsiteSSLSearch struct {
dto.PageInfo
AcmeAccountID string `json:"acmeAccountID"`
Domain string `json:"domain"`
OrderBy string `json:"orderBy" validate:"required,oneof=expire_date"`
Order string `json:"order" validate:"required,oneof=null ascending descending"`
}
type WebsiteSSLCreate struct {

View file

@ -59,7 +59,11 @@ func (w WebsiteSSLService) Page(search request.WebsiteSSLSearch) (int64, []respo
result []response.WebsiteSSLDTO
opts []repo.DBOption
)
opts = append(opts, repo.WithOrderBy("created_at desc"))
if search.OrderBy != "" && search.Order != "null" {
opts = append(opts, repo.WithOrderRuleBy(search.OrderBy, search.Order))
} else {
opts = append(opts, repo.WithOrderBy("created_at desc"))
}
if search.Domain != "" {
opts = append(opts, websiteSSLRepo.WithByDomain(search.Domain))
}

View file

@ -43,6 +43,7 @@
:columns="columns"
localKey="sslColumn"
:height-diff="260"
@sort-change="changeSort"
>
<el-table-column type="selection" width="30" />
<el-table-column
@ -144,6 +145,7 @@
:formatter="dateFormat"
show-overflow-tooltip
width="180px"
sortable
/>
<fu-table-operations
:ellipsis="3"
@ -211,6 +213,8 @@ let selects = ref<any>([]);
const columns = ref([]);
const req = reactive({
domain: '',
orderBy: 'expire_date',
order: 'ascending',
});
const routerButton = [
@ -302,11 +306,19 @@ const mobile = computed(() => {
return globalStore.isMobile();
});
const changeSort = ({ order }) => {
req.orderBy = 'expire_date';
req.order = order;
search();
};
const search = () => {
const request = {
page: paginationConfig.currentPage,
pageSize: paginationConfig.pageSize,
domain: req.domain,
orderBy: req.orderBy,
order: req.order,
};
loading.value = true;
searchSSL(request)