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 dto.PageInfo
AcmeAccountID string `json:"acmeAccountID"` AcmeAccountID string `json:"acmeAccountID"`
Domain string `json:"domain"` 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 { type WebsiteSSLCreate struct {

View file

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

View file

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