updated as in the objectHeaterApi
This commit is contained in:
parent
59356aad27
commit
29902bc40b
6 changed files with 25 additions and 22 deletions
|
|
@ -9,9 +9,10 @@ import { pondURL } from "./pond";
|
|||
export interface IObjectHeaterAPIContext {
|
||||
addObjectHeater: (
|
||||
name: string,
|
||||
heater: pond.ObjectHeaterSettings
|
||||
heater: pond.ObjectHeaterSettings,
|
||||
as?: string
|
||||
) => Promise<AxiosResponse<pond.AddObjectHeaterResponse>>;
|
||||
getObjectHeater: (key: string) => Promise<AxiosResponse<pond.GetObjectHeaterResponse>>;
|
||||
getObjectHeater: (key: string, as?: string) => Promise<AxiosResponse<pond.GetObjectHeaterResponse>>;
|
||||
listObjectHeaters: (
|
||||
limit: number,
|
||||
offset: number,
|
||||
|
|
@ -24,19 +25,20 @@ export interface IObjectHeaterAPIContext {
|
|||
types?: string[],
|
||||
numerical?: boolean
|
||||
) => Promise<AxiosResponse<pond.ListObjectHeatersResponse>>;
|
||||
removeObjectHeater: (key: string) => Promise<AxiosResponse<pond.RemoveObjectHeaterResponse>>;
|
||||
removeObjectHeater: (key: string, as?: string) => Promise<AxiosResponse<pond.RemoveObjectHeaterResponse>>;
|
||||
updateObjectHeater: (
|
||||
key: string,
|
||||
name: string,
|
||||
settings: pond.ObjectHeaterSettings,
|
||||
asRoot?: true
|
||||
as?: string
|
||||
) => Promise<AxiosResponse<pond.UpdateObjectHeaterResponse>>;
|
||||
updateLink: (
|
||||
parentKey: string,
|
||||
parentType: string,
|
||||
objectID: string,
|
||||
objectType: string,
|
||||
permissions: string[]
|
||||
permissions: string[],
|
||||
as?: string
|
||||
) => Promise<any>;
|
||||
listObjectHeatersPageData: (
|
||||
limit: number,
|
||||
|
|
@ -58,9 +60,9 @@ interface Props {}
|
|||
export default function ObjectHeaterProvider(props: PropsWithChildren<Props>) {
|
||||
const { children } = props;
|
||||
const { get, del, post, put } = useHTTP();
|
||||
const [{ as }] = useGlobalState();
|
||||
//const [{ as }] = useGlobalState();
|
||||
|
||||
const addObjectHeater = (name: string, settings: pond.ObjectHeaterSettings) => {
|
||||
const addObjectHeater = (name: string, settings: pond.ObjectHeaterSettings, as?: string) => {
|
||||
if (as)
|
||||
return post<pond.AddObjectHeaterResponse>(
|
||||
pondURL("/objectHeaters?name=" + name + "&as=" + as),
|
||||
|
|
@ -69,14 +71,14 @@ export default function ObjectHeaterProvider(props: PropsWithChildren<Props>) {
|
|||
return post<pond.AddObjectHeaterResponse>(pondURL("/objectHeaters?name=" + name), settings);
|
||||
};
|
||||
|
||||
const getObjectHeater = (key: string) => {
|
||||
const getObjectHeater = (key: string, as?: string) => {
|
||||
if (as) {
|
||||
return get<pond.GetObjectHeaterResponse>(pondURL("/objectHeaters/" + key + "?as=" + as));
|
||||
}
|
||||
return get<pond.GetObjectHeaterResponse>(pondURL("/objectHeaters/" + key));
|
||||
};
|
||||
|
||||
const removeObjectHeater = (key: string) => {
|
||||
const removeObjectHeater = (key: string, as?: string) => {
|
||||
if (as)
|
||||
return del<pond.RemoveObjectHeaterResponse>(pondURL("/objectHeaters/" + key + "?as=" + as));
|
||||
return del<pond.RemoveObjectHeaterResponse>(pondURL("/objectHeaters/" + key));
|
||||
|
|
@ -113,7 +115,7 @@ export default function ObjectHeaterProvider(props: PropsWithChildren<Props>) {
|
|||
);
|
||||
};
|
||||
|
||||
const updateObjectHeater = (key: string, name: string, settings: pond.ObjectHeaterSettings) => {
|
||||
const updateObjectHeater = (key: string, name: string, settings: pond.ObjectHeaterSettings, as?: string) => {
|
||||
if (as) {
|
||||
return put<pond.UpdateObjectHeaterResponse>(
|
||||
pondURL("/objectHeaters/" + key + "?as=" + as + "&name=" + name),
|
||||
|
|
@ -131,7 +133,8 @@ export default function ObjectHeaterProvider(props: PropsWithChildren<Props>) {
|
|||
parentType: string,
|
||||
objectID: string,
|
||||
objectType: string,
|
||||
permissions: string[]
|
||||
permissions: string[],
|
||||
as?: string
|
||||
) => {
|
||||
if (as)
|
||||
return post(pondURL(`/objectHeaters/` + parentID + `/link?as=${as}`), {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue