Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- web/public/AIOS_DEPLOY_RECEIPT +1 -1
- web/s71_frontend_contracts.py +2 -1
- web/src/apps/catalog/useCatalogData.ts +59 -5
- web/src/customer-grid/CustomerGrid.tsx +3 -2
- web/src/customer-grid/MapView.tsx +5 -6
RELEASES.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v86",
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "5aef04c1e (5aef04c1e404)",
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v86",
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
5aef04c1e (5aef04c1e404)
|
web/public/AIOS_DEPLOY_RECEIPT
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
9b2ce4c855610f54752a0f35e4049696a37d9723f1a6af5be2452e8e366090fc
|
web/s71_frontend_contracts.py
CHANGED
|
@@ -55,7 +55,8 @@ def catalog_host_scan() -> int:
|
|
| 55 |
]
|
| 56 |
for index, old, new in controls:
|
| 57 |
mutant = sources.copy()
|
| 58 |
-
|
|
|
|
| 59 |
if mutant[index] == sources[index] or not catalog_host_faults(*mutant):
|
| 60 |
faults.append('control did not fail: ' + old)
|
| 61 |
print('FAIL NC S71 Catalog host: ' + old)
|
|
|
|
| 55 |
]
|
| 56 |
for index, old, new in controls:
|
| 57 |
mutant = sources.copy()
|
| 58 |
+
# A control removes every copy of its anchor: a second copy keeps the contract green.
|
| 59 |
+
mutant[index] = mutant[index].replace(old, new)
|
| 60 |
if mutant[index] == sources[index] or not catalog_host_faults(*mutant):
|
| 61 |
faults.append('control did not fail: ' + old)
|
| 62 |
print('FAIL NC S71 Catalog host: ' + old)
|
web/src/apps/catalog/useCatalogData.ts
CHANGED
|
@@ -54,8 +54,10 @@ function projectRow(record: QueryResponse["records"][number], properties: Proper
|
|
| 54 |
}
|
| 55 |
|
| 56 |
const FALLBACK_PAGE_SIZE = 50;
|
| 57 |
-
//
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
|
| 60 |
function pageCap(value: unknown): number | null {
|
| 61 |
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : null;
|
|
@@ -63,7 +65,7 @@ function pageCap(value: unknown): number | null {
|
|
| 63 |
|
| 64 |
/** Negotiate a bounded request size without changing an existing cursor. */
|
| 65 |
async function firstPage(database: string, body: QueryRequest, signal: AbortSignal) {
|
| 66 |
-
let limit = Math.min(body.limit, serverPageSize);
|
| 67 |
for (let attempt = 0; ; attempt += 1) {
|
| 68 |
signal.throwIfAborted();
|
| 69 |
let response: QueryResponse;
|
|
@@ -111,8 +113,8 @@ export interface CatalogPageRequest {
|
|
| 111 |
}
|
| 112 |
|
| 113 |
export async function loadCatalogData(database: string, scope: CatalogReadScope, signal: AbortSignal,
|
| 114 |
-
page: CatalogPageRequest = {}): Promise<CatalogData> {
|
| 115 |
-
const properties = await documentProperties(await typedOpenApi(signal), database);
|
| 116 |
signal.throwIfAborted();
|
| 117 |
const filters = typedFilters(scope);
|
| 118 |
const search = page.search?.trim();
|
|
@@ -191,6 +193,58 @@ export function useCatalogData(database: string, scope: CatalogReadScope, search
|
|
| 191 |
};
|
| 192 |
}
|
| 193 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
/** Resolve only saved product codes, independently of the visible search and filters. */
|
| 195 |
export async function loadCatalogPlacements(database: string, key: string, codes: string[], signal: AbortSignal): Promise<Row[]> {
|
| 196 |
const rows: Row[] = [];
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
const FALLBACK_PAGE_SIZE = 50;
|
| 57 |
+
// The QueryRequest per-response maximum. A whole-book walk asks for it on page 1.
|
| 58 |
+
const RECORDS_PAGE_SIZE = 500;
|
| 59 |
+
// A cursor keeps its negotiated request size across page changes. Unknown until a server answers.
|
| 60 |
+
let serverPageSize: number | null = null;
|
| 61 |
|
| 62 |
function pageCap(value: unknown): number | null {
|
| 63 |
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : null;
|
|
|
|
| 65 |
|
| 66 |
/** Negotiate a bounded request size without changing an existing cursor. */
|
| 67 |
async function firstPage(database: string, body: QueryRequest, signal: AbortSignal) {
|
| 68 |
+
let limit = serverPageSize === null ? body.limit : Math.min(body.limit, serverPageSize);
|
| 69 |
for (let attempt = 0; ; attempt += 1) {
|
| 70 |
signal.throwIfAborted();
|
| 71 |
let response: QueryResponse;
|
|
|
|
| 113 |
}
|
| 114 |
|
| 115 |
export async function loadCatalogData(database: string, scope: CatalogReadScope, signal: AbortSignal,
|
| 116 |
+
page: CatalogPageRequest = {}, documentRead?: Properties): Promise<CatalogData> {
|
| 117 |
+
const properties = documentRead ?? await documentProperties(await typedOpenApi(signal), database);
|
| 118 |
signal.throwIfAborted();
|
| 119 |
const filters = typedFilters(scope);
|
| 120 |
const search = page.search?.trim();
|
|
|
|
| 193 |
};
|
| 194 |
}
|
| 195 |
|
| 196 |
+
export interface CatalogRecords { fields: Field[]; rows: Row[] }
|
| 197 |
+
|
| 198 |
+
/** Read every page of one query. The document is read once and one limit holds for the whole walk. */
|
| 199 |
+
export async function loadCatalogRecords(database: string, scope: CatalogReadScope, signal: AbortSignal,
|
| 200 |
+
query: Pick<CatalogPageRequest, "search" | "searchFields"> = {},
|
| 201 |
+
onPage?: (data: CatalogRecords) => void): Promise<CatalogRecords> {
|
| 202 |
+
const properties = await documentProperties(await typedOpenApi(signal), database);
|
| 203 |
+
const cursors: (string | null)[] = [null];
|
| 204 |
+
let limit = RECORDS_PAGE_SIZE;
|
| 205 |
+
let data: CatalogRecords = { fields: [], rows: [] };
|
| 206 |
+
for (;;) {
|
| 207 |
+
const page = await loadCatalogData(database, scope, signal,
|
| 208 |
+
{ ...query, cursor: cursors[cursors.length - 1], limit, priorCursors: [...cursors] }, properties);
|
| 209 |
+
limit = page.limit;
|
| 210 |
+
data = { fields: page.fields, rows: [...data.rows, ...page.rows] };
|
| 211 |
+
onPage?.(data);
|
| 212 |
+
if (!page.nextCursor) return data;
|
| 213 |
+
cursors.push(page.nextCursor);
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
type RecordsState = CatalogRecords & { key: string; loading: boolean; error: string };
|
| 218 |
+
|
| 219 |
+
/** Hold every record of the query. Rows grow per page and loading stays true until the last page. */
|
| 220 |
+
export function useCatalogRecords(database: string, scope: CatalogReadScope, searchFields: string[] = []) {
|
| 221 |
+
const [search, setSearch] = useState("");
|
| 222 |
+
const scopeJson = JSON.stringify(scope);
|
| 223 |
+
const searchJson = JSON.stringify(searchFields);
|
| 224 |
+
const key = `${database}::${scopeJson}::${searchJson}::${search}`;
|
| 225 |
+
const [attempt, setAttempt] = useState(0);
|
| 226 |
+
const [state, setState] = useState<RecordsState>(() => ({ fields: [], rows: [], key, loading: true, error: "" }));
|
| 227 |
+
const retry = useCallback(() => setAttempt((value) => value + 1), []);
|
| 228 |
+
|
| 229 |
+
useEffect(() => {
|
| 230 |
+
const controller = new AbortController();
|
| 231 |
+
setState((live) => ({ fields: live.fields, rows: [], key, loading: true, error: "" }));
|
| 232 |
+
void loadCatalogRecords(database, JSON.parse(scopeJson) as CatalogReadScope, controller.signal,
|
| 233 |
+
{ search, searchFields: JSON.parse(searchJson) }, (data) => {
|
| 234 |
+
if (!controller.signal.aborted) setState({ ...data, key, loading: true, error: "" });
|
| 235 |
+
}).then((data) => {
|
| 236 |
+
if (!controller.signal.aborted) setState({ ...data, key, loading: false, error: "" });
|
| 237 |
+
}).catch((error: unknown) => {
|
| 238 |
+
if (!controller.signal.aborted) setState((live) => ({ fields: live.fields, rows: [], key, loading: false,
|
| 239 |
+
error: error instanceof Error ? error.message : "The App could not be loaded." }));
|
| 240 |
+
});
|
| 241 |
+
return () => controller.abort();
|
| 242 |
+
}, [database, scopeJson, searchJson, search, key, attempt]);
|
| 243 |
+
|
| 244 |
+
const live = state.key === key ? state : { fields: state.fields, rows: [] as Row[], key, loading: true, error: "" };
|
| 245 |
+
return { fields: live.fields, rows: live.rows, loading: live.loading, error: live.error, retry, search, setSearch };
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
/** Resolve only saved product codes, independently of the visible search and filters. */
|
| 249 |
export async function loadCatalogPlacements(database: string, key: string, codes: string[], signal: AbortSignal): Promise<Row[]> {
|
| 250 |
const rows: Row[] = [];
|
web/src/customer-grid/CustomerGrid.tsx
CHANGED
|
@@ -6440,7 +6440,7 @@ function CustomerGridSurface({
|
|
| 6440 |
return;
|
| 6441 |
if (key === "f") {
|
| 6442 |
const box = isPagedOdooApplication
|
| 6443 |
-
? shellRef.current?.querySelector<HTMLInputElement>('form[aria-label="Product pages"] input[type="search"], form[aria-label="Customer
|
| 6444 |
: searchRef.current;
|
| 6445 |
if (!box) return;
|
| 6446 |
event.preventDefault();
|
|
@@ -11442,7 +11442,8 @@ function CustomerGridSurface({
|
|
| 11442 |
.cg-toolbar:has(> .cg-page-count) > .cg-count:not(.cg-page-count):not(.cg-count-pending) { display: none; }
|
| 11443 |
`}</style>
|
| 11444 |
<span className="cg-count cg-page-count" role="status" aria-live="polite">
|
| 11445 |
-
{catalogData ? `${catalogData.rows.length.toLocaleString()} ${catalogData.rows.length === 1 ? "record" : "records"}
|
|
|
|
| 11446 |
</span>
|
| 11447 |
</> : cohortAction}
|
| 11448 |
filterSeed={filterSeed}
|
|
|
|
| 6440 |
return;
|
| 6441 |
if (key === "f") {
|
| 6442 |
const box = isPagedOdooApplication
|
| 6443 |
+
? shellRef.current?.querySelector<HTMLInputElement>('form[aria-label="Product pages"] input[type="search"], form[aria-label="Customer search"] input[type="search"]')
|
| 6444 |
: searchRef.current;
|
| 6445 |
if (!box) return;
|
| 6446 |
event.preventDefault();
|
|
|
|
| 11442 |
.cg-toolbar:has(> .cg-page-count) > .cg-count:not(.cg-page-count):not(.cg-count-pending) { display: none; }
|
| 11443 |
`}</style>
|
| 11444 |
<span className="cg-count cg-page-count" role="status" aria-live="polite">
|
| 11445 |
+
{catalogData ? `${catalogData.rows.length.toLocaleString()} ${catalogData.rows.length === 1 ? "record" : "records"}${isRoutingApplication ? "" : " on this page"}`
|
| 11446 |
+
: isRoutingApplication ? "Loading records" : "Loading page"}
|
| 11447 |
</span>
|
| 11448 |
</> : cohortAction}
|
| 11449 |
filterSeed={filterSeed}
|
web/src/customer-grid/MapView.tsx
CHANGED
|
@@ -63,7 +63,7 @@ import { AppFrame } from "./AppFrame";
|
|
| 63 |
// C1: Routing and Catalog are Odoo Apps; verify_icons.py holds these two marks to TEMPLATES.
|
| 64 |
import { AppFrameMarks } from "../apps/templateMarks";
|
| 65 |
import { CatalogApp } from "../apps/catalog/CatalogApp";
|
| 66 |
-
import {
|
| 67 |
import type { CatalogApplicationDefinition, CatalogViewSpec } from "./CatalogView";
|
| 68 |
import { applicationTemplateSurface } from "./viewModes";
|
| 69 |
import { LAND_PATH, LAKE_PATHS } from "./mapGeometry";
|
|
@@ -5118,7 +5118,7 @@ function RouteApplicationMapView({ props, titleKey, applicationId }: {
|
|
| 5118 |
props: MapViewProps & { field: Field }; titleKey: string; applicationId: string;
|
| 5119 |
}) {
|
| 5120 |
const [customerPid, setCustomerPid] = useState<number | null>(null);
|
| 5121 |
-
const data =
|
| 5122 |
filters: props.activeView?.config.filters ?? [],
|
| 5123 |
filterConj: props.activeView?.config.filterConj ?? "and",
|
| 5124 |
sorts: props.activeView?.config.sorts ?? [],
|
|
@@ -5160,17 +5160,16 @@ function RouteApplicationMapView({ props, titleKey, applicationId }: {
|
|
| 5160 |
applicationId={applicationId} onOpen={openCustomer} customerDetail={customerDetail}
|
| 5161 |
onCustomerBack={() => setCustomerPid(null)} routingFilters={<>
|
| 5162 |
{props.routingFilters}
|
| 5163 |
-
<form className="cg-catalog-record-head" aria-label="Customer
|
| 5164 |
event.preventDefault(); setCustomerPid(null); data.setSearch(search.trim());
|
| 5165 |
}}>
|
| 5166 |
<input className="cg-input" type="search" aria-label="Search customers" placeholder="Search customers"
|
| 5167 |
value={search} onChange={(event) => setSearch(event.target.value)} />
|
| 5168 |
<button className="cg-btn" type="submit" disabled={data.loading && search.trim() === data.search}>Search</button>
|
| 5169 |
-
<button className="cg-btn" type="button" disabled={data.loading || !data.hasPrevious} onClick={data.previous}>Previous</button>
|
| 5170 |
<span role="status" aria-live="polite" aria-label={selectedPending ? "Loading selected customers" : undefined}>
|
| 5171 |
-
{data.loading ? "Loading customers" : selectedPending ? "Loading stops" :
|
|
|
|
| 5172 |
</span>
|
| 5173 |
-
<button className="cg-btn" type="button" disabled={data.loading || !!data.error || !data.nextCursor} onClick={data.next}>Next</button>
|
| 5174 |
</form>
|
| 5175 |
{data.error && <div className="cg-catalog-library-error" role="alert"><span>{data.error}</span>
|
| 5176 |
<button className="cg-btn" type="button" disabled={data.loading} onClick={data.retry}>Retry</button></div>}
|
|
|
|
| 63 |
// C1: Routing and Catalog are Odoo Apps; verify_icons.py holds these two marks to TEMPLATES.
|
| 64 |
import { AppFrameMarks } from "../apps/templateMarks";
|
| 65 |
import { CatalogApp } from "../apps/catalog/CatalogApp";
|
| 66 |
+
import { useCatalogPlacements, useCatalogRecords } from "../apps/catalog/useCatalogData";
|
| 67 |
import type { CatalogApplicationDefinition, CatalogViewSpec } from "./CatalogView";
|
| 68 |
import { applicationTemplateSurface } from "./viewModes";
|
| 69 |
import { LAND_PATH, LAKE_PATHS } from "./mapGeometry";
|
|
|
|
| 5118 |
props: MapViewProps & { field: Field }; titleKey: string; applicationId: string;
|
| 5119 |
}) {
|
| 5120 |
const [customerPid, setCustomerPid] = useState<number | null>(null);
|
| 5121 |
+
const data = useCatalogRecords(props.tableKey, {
|
| 5122 |
filters: props.activeView?.config.filters ?? [],
|
| 5123 |
filterConj: props.activeView?.config.filterConj ?? "and",
|
| 5124 |
sorts: props.activeView?.config.sorts ?? [],
|
|
|
|
| 5160 |
applicationId={applicationId} onOpen={openCustomer} customerDetail={customerDetail}
|
| 5161 |
onCustomerBack={() => setCustomerPid(null)} routingFilters={<>
|
| 5162 |
{props.routingFilters}
|
| 5163 |
+
<form className="cg-catalog-record-head" aria-label="Customer search" style={{ flexWrap: "wrap", margin: 0 }} onSubmit={(event) => {
|
| 5164 |
event.preventDefault(); setCustomerPid(null); data.setSearch(search.trim());
|
| 5165 |
}}>
|
| 5166 |
<input className="cg-input" type="search" aria-label="Search customers" placeholder="Search customers"
|
| 5167 |
value={search} onChange={(event) => setSearch(event.target.value)} />
|
| 5168 |
<button className="cg-btn" type="submit" disabled={data.loading && search.trim() === data.search}>Search</button>
|
|
|
|
| 5169 |
<span role="status" aria-live="polite" aria-label={selectedPending ? "Loading selected customers" : undefined}>
|
| 5170 |
+
{data.loading ? "Loading customers" : selectedPending ? "Loading stops" : data.error ? ""
|
| 5171 |
+
: `${data.rows.length.toLocaleString()} ${data.rows.length === 1 ? "customer" : "customers"}`}
|
| 5172 |
</span>
|
|
|
|
| 5173 |
</form>
|
| 5174 |
{data.error && <div className="cg-catalog-library-error" role="alert"><span>{data.error}</span>
|
| 5175 |
<button className="cg-btn" type="button" disabled={data.loading} onClick={data.retry}>Retry</button></div>}
|