mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-18 07:56:57 +00:00
Grid/List View Pagination Fix
This commit is contained in:
parent
a1a5e5e299
commit
809bf19eb4
@ -116,21 +116,19 @@ export default function Dashboard() {
|
|||||||
|
|
||||||
const [currentPage, setCurrentPage] = useState<number>(1);
|
const [currentPage, setCurrentPage] = useState<number>(1);
|
||||||
const [maxPage, setMaxPage] = useState<number>(1);
|
const [maxPage, setMaxPage] = useState<number>(1);
|
||||||
const [itemsPerPage, setItemsPerPage] = useState<number>(5);
|
|
||||||
const [applications, setApplications] = useState<Application[]>([]);
|
const [applications, setApplications] = useState<Application[]>([]);
|
||||||
const [servers, setServers] = useState<Server[]>([]);
|
const [servers, setServers] = useState<Server[]>([]);
|
||||||
const [isGridLayout, setIsGridLayout] = useState<boolean>(false);
|
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
|
|
||||||
const [searchTerm, setSearchTerm] = useState<string>("");
|
const [searchTerm, setSearchTerm] = useState<string>("");
|
||||||
const [isSearching, setIsSearching] = useState<boolean>(false);
|
const [isSearching, setIsSearching] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
const savedLayout = Cookies.get("layoutPreference-app");
|
||||||
const savedLayout = Cookies.get("layoutPreference-app");
|
const initialIsGridLayout = savedLayout === "grid";
|
||||||
const layout_bool = savedLayout === "grid";
|
const initialItemsPerPage = initialIsGridLayout ? 15 : 5;
|
||||||
setIsGridLayout(layout_bool);
|
|
||||||
setItemsPerPage(layout_bool ? 15 : 5);
|
const [isGridLayout, setIsGridLayout] = useState<boolean>(initialIsGridLayout);
|
||||||
}, []);
|
const [itemsPerPage, setItemsPerPage] = useState<number>(initialItemsPerPage);
|
||||||
|
|
||||||
const toggleLayout = () => {
|
const toggleLayout = () => {
|
||||||
const newLayout = !isGridLayout;
|
const newLayout = !isGridLayout;
|
||||||
|
|||||||
@ -116,9 +116,7 @@ export default function Dashboard() {
|
|||||||
|
|
||||||
const [currentPage, setCurrentPage] = useState<number>(1)
|
const [currentPage, setCurrentPage] = useState<number>(1)
|
||||||
const [maxPage, setMaxPage] = useState<number>(1)
|
const [maxPage, setMaxPage] = useState<number>(1)
|
||||||
const [itemsPerPage, setItemsPerPage] = useState<number>(4)
|
|
||||||
const [servers, setServers] = useState<Server[]>([])
|
const [servers, setServers] = useState<Server[]>([])
|
||||||
const [isGridLayout, setIsGridLayout] = useState<boolean>(false)
|
|
||||||
const [loading, setLoading] = useState<boolean>(true)
|
const [loading, setLoading] = useState<boolean>(true)
|
||||||
|
|
||||||
const [editId, setEditId] = useState<number | null>(null)
|
const [editId, setEditId] = useState<number | null>(null)
|
||||||
@ -144,23 +142,23 @@ export default function Dashboard() {
|
|||||||
|
|
||||||
const [monitoringInterval, setMonitoringInterval] = useState<NodeJS.Timeout | null>(null);
|
const [monitoringInterval, setMonitoringInterval] = useState<NodeJS.Timeout | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
const savedLayout = Cookies.get("layoutPreference-servers");
|
||||||
const savedLayout = Cookies.get("layoutPreference-servers")
|
const initialIsGridLayout = savedLayout === "grid";
|
||||||
const layout_bool = savedLayout === "grid"
|
const initialItemsPerPage = initialIsGridLayout ? 6 : 4;
|
||||||
setIsGridLayout(layout_bool)
|
|
||||||
setItemsPerPage(layout_bool ? 6 : 4)
|
const [isGridLayout, setIsGridLayout] = useState<boolean>(initialIsGridLayout);
|
||||||
}, [])
|
const [itemsPerPage, setItemsPerPage] = useState<number>(initialItemsPerPage);
|
||||||
|
|
||||||
const toggleLayout = () => {
|
const toggleLayout = () => {
|
||||||
const newLayout = !isGridLayout
|
const newLayout = !isGridLayout;
|
||||||
setIsGridLayout(newLayout)
|
setIsGridLayout(newLayout);
|
||||||
Cookies.set("layoutPreference-servers", newLayout ? "grid" : "standard", {
|
Cookies.set("layoutPreference-servers", newLayout ? "grid" : "standard", {
|
||||||
expires: 365,
|
expires: 365,
|
||||||
path: "/",
|
path: "/",
|
||||||
sameSite: "strict",
|
sameSite: "strict",
|
||||||
})
|
});
|
||||||
setItemsPerPage(newLayout ? 6 : 4)
|
setItemsPerPage(newLayout ? 6 : 4); // Update itemsPerPage based on new layout
|
||||||
}
|
};
|
||||||
|
|
||||||
const add = async () => {
|
const add = async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user