api: Remove generated API files from repo + update build.

All these files can be generated using the `make api` command and there
is no real need to commit these into the repo. Only the api/go files
need to be comitted of how the Go import system works.

This also updates the Rust, Go, JS and gRPC-web (JS) code generation and
UI build to use the nix-shell environment instead of using Docker.
This commit is contained in:
Orne Brocaar
2024-04-01 14:27:15 +01:00
parent a91f5ff1d3
commit d170c7dd79
439 changed files with 848 additions and 346789 deletions

View File

@ -12,29 +12,29 @@ interface IProps {
function Admin(props: PropsWithChildren<IProps>) {
const [admin, setAdmin] = useState<boolean>(false);
const setIsAdmin = () => {
if (!props.isDeviceAdmin && !props.isGatewayAdmin && !props.isTenantAdmin) {
setAdmin(SessionStore.isAdmin());
} else {
if (props.tenantId === undefined) {
throw new Error("No tenantId is given");
}
if (props.isTenantAdmin) {
setAdmin(SessionStore.isAdmin() || SessionStore.isTenantAdmin(props.tenantId));
}
if (props.isDeviceAdmin) {
setAdmin(SessionStore.isAdmin() || SessionStore.isTenantDeviceAdmin(props.tenantId));
}
if (props.isGatewayAdmin) {
setAdmin(SessionStore.isAdmin() || SessionStore.isTenantGatewayAdmin(props.tenantId));
}
}
};
useEffect(() => {
const setIsAdmin = () => {
if (!props.isDeviceAdmin && !props.isGatewayAdmin && !props.isTenantAdmin) {
setAdmin(SessionStore.isAdmin());
} else {
if (props.tenantId === undefined) {
throw new Error("No tenantId is given");
}
if (props.isTenantAdmin) {
setAdmin(SessionStore.isAdmin() || SessionStore.isTenantAdmin(props.tenantId));
}
if (props.isDeviceAdmin) {
setAdmin(SessionStore.isAdmin() || SessionStore.isTenantDeviceAdmin(props.tenantId));
}
if (props.isGatewayAdmin) {
setAdmin(SessionStore.isAdmin() || SessionStore.isTenantGatewayAdmin(props.tenantId));
}
}
};
SessionStore.on("change", setIsAdmin);
setIsAdmin();

View File

@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react";
import React, { useState, useEffect, useCallback } from "react";
import { Table } from "antd";
import { ColumnsType } from "antd/es/table";
@ -23,21 +23,24 @@ function DataTable(props: IProps) {
const [rows, setRows] = useState<object[]>([]);
const [loading, setLoading] = useState<boolean>(true);
const onChangePage = (page: number, pz?: number | void) => {
setLoading(true);
const onChangePage = useCallback(
(page: number, pz?: number | void) => {
setLoading(true);
if (!pz) {
pz = pageSize;
}
if (!pz) {
pz = pageSize;
}
props.getPage(pz, (page - 1) * pz, (totalCount: number, rows: object[]) => {
setCurrentPage(page);
setTotalCount(totalCount);
setRows(rows);
setPageSize(pz || 0);
setLoading(false);
});
};
props.getPage(pz, (page - 1) * pz, (totalCount: number, rows: object[]) => {
setCurrentPage(page);
setTotalCount(totalCount);
setRows(rows);
setPageSize(pz || 0);
setLoading(false);
});
},
[props, pageSize],
);
const onShowSizeChange = (page: number, pageSize: number) => {
onChangePage(page, pageSize);
@ -53,7 +56,7 @@ function DataTable(props: IProps) {
useEffect(() => {
onChangePage(currentPage, pageSize);
}, [props, currentPage, pageSize]);
}, [props, currentPage, pageSize, onChangePage]);
const { getPage, refreshKey, ...otherProps } = props;
let loadingProps = undefined;

View File

@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react";
import React, { useState, useEffect, useCallback } from "react";
import { Link, useLocation, useNavigate } from "react-router-dom";
import { Menu, MenuProps, Typography } from "antd";
@ -67,7 +67,7 @@ function SideMenu() {
navigate(`/tenants/${value}`);
};
const parseLocation = () => {
const parseLocation = useCallback(() => {
const path = location.pathname;
const tenantRe = /\/tenants\/([\w-]{36})/g;
const match = tenantRe.exec(path);
@ -134,7 +134,7 @@ function SideMenu() {
if (/\/tenants\/[\w-]{36}\/applications.*/g.exec(path)) {
setSelectedKey("tenant-applications");
}
};
}, [location.pathname, tenantId]);
useEffect(() => {
SessionStore.on("tenant.change", setTenant);
@ -150,11 +150,11 @@ function SideMenu() {
return () => {
SessionStore.removeListener("tenant.change", setTenant);
};
}, []);
}, [parseLocation]);
useEffect(() => {
parseLocation();
}, [location]);
}, [location, parseLocation]);
let items: MenuProps["items"] = [];