mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-11-10 21:21:13 +08:00
feat: increase maximum page size and update related components (#14370)
This commit is contained in:
9 files changed
+17
-14
No files matched your search
@@ -23,7 +23,7 @@ type APIKeyItem struct {
|
||||
|
||||
type APIKeySearch struct {
|
||||
Page int `json:"page" minimum:"1" example:"1"`
|
||||
PageSize int `json:"pageSize" minimum:"1" maximum:"100" example:"20"`
|
||||
PageSize int `json:"pageSize" minimum:"1" maximum:"500" example:"20"`
|
||||
ExcludeRevoked bool `json:"excludeRevoked" default:"false"`
|
||||
}
|
||||
type APIKeyPage struct {
|
||||
|
||||
@@ -32,6 +32,8 @@ import (
|
||||
|
||||
var apiKeyMutationMu sync.Mutex
|
||||
|
||||
const apiKeyMaxPageSize = 500
|
||||
|
||||
type APIKeyService struct {
|
||||
Provider auth.APIKeyOwnerProvider
|
||||
RevokeTerminals terminalsession.RevokeFunc
|
||||
@@ -105,7 +107,7 @@ func (s *APIKeyService) Search(c *gin.Context, req dto.APIKeySearch) (*dto.APIKe
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if req.Page < 1 || req.PageSize < 1 || req.PageSize > 100 {
|
||||
if req.Page < 1 || req.PageSize < 1 || req.PageSize > apiKeyMaxPageSize {
|
||||
return nil, buserr.New("ErrInvalidParams")
|
||||
}
|
||||
keys, err := repo.NewAPIKeyRepo().List(owner.Type, owner.ID, req.ExcludeRevoked)
|
||||
|
||||
@@ -148,7 +148,7 @@ func (s *MCPService) ManagementOwner(c *gin.Context, write bool) (auth.APIKeyOwn
|
||||
}
|
||||
return owner, nil
|
||||
}
|
||||
func validMCPPage(page, size int) bool { return page > 0 && page <= 1000000 && size > 0 && size <= 100 }
|
||||
func validMCPPage(page, size int) bool { return page > 0 && page <= 1000000 && size > 0 && size <= 500 }
|
||||
func (s *MCPService) catalog() ([]contract.Tool, error) {
|
||||
unavailable := func() error {
|
||||
return contract.Fail("MCP_CATALOG_UNAVAILABLE", 503, "The installed MCP tool catalog is unavailable or incompatible")
|
||||
|
||||
@@ -33895,7 +33895,7 @@ const docTemplate = `{
|
||||
},
|
||||
"pageSize": {
|
||||
"example": 20,
|
||||
"maximum": 100,
|
||||
"maximum": 500,
|
||||
"minimum": 1,
|
||||
"type": "integer"
|
||||
}
|
||||
|
||||
@@ -231,6 +231,7 @@ usePaginationCache({
|
||||
id: () => props.cacheId,
|
||||
scope: () => props.cacheScope,
|
||||
search: () => emit('search'),
|
||||
pageSizes: () => props.pageSizes,
|
||||
refreshOnRestore: () => props.refreshOnRestore,
|
||||
});
|
||||
const tableRef = ref();
|
||||
|
||||
@@ -14,6 +14,7 @@ interface Options {
|
||||
id: () => string | undefined;
|
||||
scope: () => string | number | undefined;
|
||||
search: () => void;
|
||||
pageSizes?: () => readonly number[];
|
||||
refreshOnRestore?: () => boolean;
|
||||
}
|
||||
|
||||
@@ -65,8 +66,11 @@ export const usePaginationCache = (options: Options) => {
|
||||
}
|
||||
const initial = defaults.get(pagination)!;
|
||||
const saved = readPanelCache<Partial<Pagination>>('pagination', activeKey);
|
||||
const page = positiveInteger(saved?.currentPage) ? saved.currentPage : initial.currentPage;
|
||||
const size = positiveInteger(saved?.pageSize) ? saved.pageSize : initial.pageSize;
|
||||
const pageSizes = options.pageSizes?.();
|
||||
const validSize =
|
||||
positiveInteger(saved?.pageSize) && (!pageSizes?.length || pageSizes.includes(saved.pageSize));
|
||||
const size = validSize ? saved.pageSize : initial.pageSize;
|
||||
const page = validSize && positiveInteger(saved?.currentPage) ? saved.currentPage : initial.currentPage;
|
||||
const changed = pagination.currentPage !== page || pagination.pageSize !== size;
|
||||
restoring = true;
|
||||
try {
|
||||
@@ -75,6 +79,7 @@ export const usePaginationCache = (options: Options) => {
|
||||
} finally {
|
||||
restoring = false;
|
||||
}
|
||||
if (saved && !validSize) writePanelCache('pagination', activeKey, { currentPage: page, pageSize: size });
|
||||
return changed;
|
||||
};
|
||||
// The initial restore deliberately does not emit: the parent owns its first query.
|
||||
|
||||
@@ -93,7 +93,6 @@
|
||||
<ComplexTable
|
||||
:data="displayItems"
|
||||
:pagination-config="pagination"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:scrollbar-always-on="isCompactTable"
|
||||
:height-diff="310"
|
||||
@search="search"
|
||||
|
||||
@@ -22,13 +22,7 @@
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="w-full min-w-0 overflow-x-auto" v-loading="loading">
|
||||
<ComplexTable
|
||||
:data="displayItems"
|
||||
:pagination-config="pagination"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:height="500"
|
||||
@search="search"
|
||||
>
|
||||
<ComplexTable :data="displayItems" :pagination-config="pagination" :height="500" @search="search">
|
||||
<el-table-column
|
||||
:label="$t('commons.table.date')"
|
||||
prop="startedAt"
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<ComplexTable
|
||||
:data="items"
|
||||
:pagination-config="pagination"
|
||||
:page-sizes="apiKeyPageSizes"
|
||||
:scrollbar-always-on="isMobile"
|
||||
@search="search"
|
||||
>
|
||||
@@ -215,6 +216,7 @@ const detailVisible = ref(false);
|
||||
const secret = ref('');
|
||||
const secretBusy = ref(false);
|
||||
const secretAction = ref<'reveal' | 'copy'>('reveal');
|
||||
const apiKeyPageSizes = [5, 10, 20, 50, 100, 200, 500];
|
||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 });
|
||||
let searchVersion = 0;
|
||||
let secretRequestVersion = 0;
|
||||
|
||||
Reference in new issue
Block a user