diff --git a/src/components/PluginConfigPage/PluginConfigPage.tsx b/src/components/PluginConfigPage/PluginConfigPage.tsx index ea23f21..d352dfa 100644 --- a/src/components/PluginConfigPage/PluginConfigPage.tsx +++ b/src/components/PluginConfigPage/PluginConfigPage.tsx @@ -16,7 +16,7 @@ const PLUGIN_CONFIGURED_QUERY_PARAM_TRUTHY_VALUE = 'true'; const PLUGIN_CONFIGURED_VERSION_QUERY_PARAM = 'pluginConfiguredVersion'; -const DEFAULT_API_URL = 'http://localhost:8080'; +const DEFAULT_API_URL = 'http://localhost:8000'; /** * When everything is successfully configured, reload the page, and pass along a few query parameters @@ -84,6 +84,7 @@ export const PluginConfigPage: FC = ({ setPluginConnectionCheckError(pluginConnectionResponse); } else { setPluginIsConnected(pluginConnectionResponse); + reloadPageWithPluginConfiguredQueryParams(pluginConnectionResponse, true); } setCheckingIfPluginIsConnected(false); diff --git a/src/components/PluginConfigPage/parts/ConfigurationForm/index.tsx b/src/components/PluginConfigPage/parts/ConfigurationForm/index.tsx index 27c19ca..7ed24e4 100644 --- a/src/components/PluginConfigPage/parts/ConfigurationForm/index.tsx +++ b/src/components/PluginConfigPage/parts/ConfigurationForm/index.tsx @@ -84,7 +84,7 @@ const ConfigurationForm: FC = ({ onSuccessfulSetup, defaultDataExporterAp

1. Launch the DataExporter backend

- Run hobby, dev or production backend. See{' '} + Run the backend. See{' '} here {' '} @@ -97,8 +97,8 @@ const ConfigurationForm: FC = ({ onSuccessfulSetup, defaultDataExporterAp The DataExporter backend must be reachable from your Grafana installation. Some examples are:
- - http://host.docker.internal:8080 -
- http://localhost:8080 + - http://host.docker.internal:8000 +
- http://localhost:8000
diff --git a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx index 9c7494a..1af10d9 100644 --- a/src/panels/corpglory-dataexporter-panel/components/Panel.tsx +++ b/src/panels/corpglory-dataexporter-panel/components/Panel.tsx @@ -7,8 +7,18 @@ import { deleteTask, getStaticFile, getTasks, queryApi } from '../../../services import { getDashboardByUid, getDatasources } from '../../../services/grafana_backend_service'; import { contextSrv } from 'grafana/app/core/core'; +import { css } from '@emotion/css'; -import { Table, Button, HorizontalGroup, Modal, LoadingPlaceholder } from '@grafana/ui'; +import { + Table, + Button, + HorizontalGroup, + VerticalGroup, + Modal, + LoadingPlaceholder, + TimeRangeInput, + useStyles2, +} from '@grafana/ui'; import { PanelProps, toDataFrame, @@ -20,6 +30,7 @@ import { PanelModel, DataQuery, DataSourceSettings, + TimeRange, } from '@grafana/data'; import { RefreshEvent } from '@grafana/runtime'; @@ -41,6 +52,8 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { const [isModalOpen, setModalVisibility] = useState(false); + const [selectedTimeRange, setTimeRange] = useState(timeRange); + useEffect(() => { async function getCurrentDashboard(): Promise { const currentDashboardUid = getDashboardUid(window.location.toString()); @@ -143,9 +156,8 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { async function onAddTaskClick(): Promise { const selectedQueries = _.filter(queries, (query: QueryTableRowConfig) => query.selected); - // TODO: timerange picker - const timerange: [number, number] = [timeRange.from.unix(), timeRange.to.unix()]; + const timerange: [number, number] = [selectedTimeRange.from.unix(), selectedTimeRange.to.unix()]; // TODO: move this function to API Service await queryApi('/task', { method: 'POST', @@ -350,6 +362,8 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { setQueries(updatedQueries); } + const styles = useStyles2(getStyles); + return (
{tasksDataFrame === null ? ( @@ -368,25 +382,39 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { > Add Task - + {queriesDataFrame === null ? ( // TODO: if datasource responds with error, display the error ) : (
- - - - + + + { + setTimeRange(newTimeRange); + }} + /> + +
+ + + + )} @@ -396,3 +424,13 @@ export function Panel({ width, height, timeRange, eventBus }: Props) { ); } + +const getStyles = () => ({ + calendarModal: css` + section { + position: fixed; + top: 20%; + z-index: 1061; + } + `, +}); diff --git a/src/plugin_state.ts b/src/plugin_state.ts index 0812be3..3aa8344 100644 --- a/src/plugin_state.ts +++ b/src/plugin_state.ts @@ -90,7 +90,13 @@ class PluginState { this.grafanaBackend.get(this.GRAFANA_PLUGIN_SETTINGS_URL); static updateGrafanaPluginSettings = async (data: UpdateGrafanaPluginSettingsProps, enabled = true) => - this.grafanaBackend.post(this.GRAFANA_PLUGIN_SETTINGS_URL, { ...data, enabled, pinned: true }); + this.grafanaBackend.post( + this.GRAFANA_PLUGIN_SETTINGS_URL, + { ...data, enabled, pinned: true }, + // @ts-ignore + // for some reason, there is no `options` argument in Grafana's public types for BackendSrv but it exists + { showSuccessAlert: false } + ); static createGrafanaToken = async () => { const baseUrl = '/api/auth/keys'; @@ -98,14 +104,22 @@ class PluginState { const existingKey = keys.find((key: { id: number; name: string; role: string }) => key.name === 'DataExporter'); if (existingKey) { - await this.grafanaBackend.delete(`${baseUrl}/${existingKey.id}`); + // @ts-ignore + // for some reason, there is no `options` argument in Grafana's public types for BackendSrv but it exists + await this.grafanaBackend.delete(`${baseUrl}/${existingKey.id}`, undefined, { showSuccessAlert: false }); } - return await this.grafanaBackend.post(baseUrl, { - name: 'DataExporter', - role: 'Admin', - secondsToLive: null, - }); + return await this.grafanaBackend.post( + baseUrl, + { + name: 'DataExporter', + role: 'Admin', + secondsToLive: null, + }, + // @ts-ignore + // for some reason, there is no `options` argument in Grafana's public types for BackendSrv but it exists + { showSuccessAlert: false } + ); }; static timeout = (pollCount: number) => new Promise((resolve) => setTimeout(resolve, 10 * 2 ** pollCount));