Skip to content

Commit

Permalink
Towards quicksight dashboard.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbernstein committed Nov 15, 2023
1 parent 28a75ef commit fa8d2dd
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
DiagnosticsData,
FeatureFlags,
SitewideAnnouncementsData,
StatisticsData,
StatisticsData, DashboardURIData,
} from "./interfaces";
import { CollectionData } from "@thepalaceproject/web-opds-client/lib/interfaces";
import DataFetcher from "@thepalaceproject/web-opds-client/lib/DataFetcher";
Expand Down Expand Up @@ -195,6 +195,8 @@ export default class ActionCreator extends BaseActionCreator {

static readonly DIAGNOSTICS = "DIAGNOSTICS";

static readonly DASHBOARD_URI : "DASHBOARD_URI"

csrfToken: string;

constructor(fetcher?: DataFetcher, csrfToken?: string) {
Expand Down Expand Up @@ -1095,4 +1097,14 @@ export default class ActionCreator extends BaseActionCreator {
value,
};
}

fetchDashboardUri(dashboardId: string) {
const url = "/admin/quicksight_embed/" + dashboardId;
return this.fetchJSON<DashboardURIData>(
ActionCreator.DASHBOARD_URI,
url
).bind(this);
}

}

2 changes: 2 additions & 0 deletions src/components/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Footer from "./Footer";
import Stats from "./Stats";
import CirculationEvents from "./CirculationEvents";
import title from "../utils/title";
import QuicksightDashboard from "./QuicksightDashboard";

export interface DashboardPageProps extends React.Props<DashboardPageProps> {
params: {
Expand Down Expand Up @@ -48,6 +49,7 @@ export default class DashboardPage extends React.Component<DashboardPageProps> {
store={this.context.editorStore}
library={library}
/>
<QuicksightDashboard/>
</main>
<Footer />
</div>
Expand Down
55 changes: 55 additions & 0 deletions src/components/QuicksightDashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import * as React from "react";
import ActionCreator from "../actions";

export interface QuicksightDashboardStateProps {
}

export interface QuicksightDashboardDispatchProps {
fetchDashboardUri?: () => Promise<any>;
}

export interface QuicksightDashboardProps
extends QuicksightDashboardStateProps,QuicksightDashboardDispatchProps {}

export interface QuicksightDashboardState {
dashboardId: string
}



export class QuicksightDashboard extends React.Component <
QuicksightDashboardProps,
QuicksightDashboardState
>{
context: { dashboardId: boolean}

constructor(props) {
super(props);
this.state = {dashboardId: "library"}
}
render(): JSX.Element {
return (
<div className="quicksight-dashboard">
<h2>Quicksight Dashboard</h2>
<iframe src="https://www.amazon.com" height="800" width="1000"/>
</div>
);
}
}

function mapStateToProps(state, ownProps) {
return {
events: state.editor.circulationEvents.data || [],
fetchError: state.editor.circulationEvents.fetchError,
isLoaded: state.editor.circulationEvents.isLoaded,
};
}

function mapDispatchToProps(dispatch) {
const actions = new ActionCreator();
return {
fetchDashboardUri: () => dispatch(actions.fetchDashboardUri(dispatch.dashboardId)),
};
}

export default QuicksightDashboard;
5 changes: 5 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,3 +469,8 @@ export interface AdvancedSearchQuery {
export interface AdvancedSearchData {
query: AdvancedSearchQuery;
}

export interface DashboardURIData {
uri: string;
}

0 comments on commit fa8d2dd

Please sign in to comment.