Refactor frontend views
All checks were successful
Build and push image / build-containers (push) Successful in 10m14s
All checks were successful
Build and push image / build-containers (push) Successful in 10m14s
This commit is contained in:
@ -2,43 +2,20 @@
|
||||
|
||||
# pyright: reportUnusedFunction=false
|
||||
import logging
|
||||
import math
|
||||
from typing import Annotated, cast
|
||||
from fastapi import APIRouter, Depends, Request, Response
|
||||
from pydantic import BaseModel
|
||||
|
||||
from sshecret.backend import AuditFilter, Operation
|
||||
|
||||
from sshecret_admin.auth import LocalUserInfo
|
||||
from sshecret_admin.services import AdminBackend
|
||||
|
||||
from .common import PagingInfo
|
||||
from ..dependencies import FrontendDependencies
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PagingInfo(BaseModel):
|
||||
page: int
|
||||
limit: int
|
||||
total: int
|
||||
offset: int = 0
|
||||
|
||||
@property
|
||||
def first(self) -> int:
|
||||
"""The first result number."""
|
||||
return self.offset + 1
|
||||
|
||||
@property
|
||||
def last(self) -> int:
|
||||
"""Return the last result number."""
|
||||
return self.offset + self.limit
|
||||
|
||||
@property
|
||||
def total_pages(self) -> int:
|
||||
"""Return total pages."""
|
||||
return math.ceil(self.total / self.limit)
|
||||
|
||||
|
||||
def create_router(dependencies: FrontendDependencies) -> APIRouter:
|
||||
"""Create clients router."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user