Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
richturner committed May 3, 2024
1 parent 47d6afa commit cecabd9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
16 changes: 16 additions & 0 deletions ui/app/custom/src/pages/page-custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {css, html, TemplateResult} from "lit";
import {customElement} from "lit/decorators.js";
import {AppStateKeyed, Page, PageProvider} from "@openremote/or-app";
import {EnhancedStore} from "@reduxjs/toolkit";
import {CustomData} from "../../../../component/model";
import rest from "../../../../component/rest";

export function pageCustomProvider(store: EnhancedStore<AppStateKeyed>): PageProvider<AppStateKeyed> {
return {
Expand Down Expand Up @@ -47,6 +49,20 @@ export class PageCustom extends Page<AppStateKeyed> {
`
}

protected firstUpdated(changedProperties: Map<string, any>) {
let submitter = async() => {
// Crude custom REST API call example
return await rest.api.CustomEndpointResource.submitData({
name: "Commander Data",
age: 1234
});
}

submitter()
.then(() => console.log("Successfully posted to custom endpoint"))
.catch((reason) => console.log("Failed to post to custom endpoint"));
}

stateChanged(state: AppStateKeyed): void {

}
Expand Down
13 changes: 10 additions & 3 deletions ui/component/rest/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import rest from "@openremote/rest";
import {ApiClient} from "./restclient";



export class RestApi {

protected _apiClient: ApiClient;

constructor(apiClient: ApiClient) {
this._apiClient = apiClient;
}

get api() {
return rest.api;
return this._apiClient;
}
}

export default new RestApi();
export default new RestApi(new ApiClient());

0 comments on commit cecabd9

Please sign in to comment.