-
-
-
-
-
-
+
+
+
+
-
-
-
-
- { dashboardId && (
- <>
-
-
-
-
-
- {/*
-
-
- */}
- {/*
*/}
- >
- )}
-
+
+
+
+
+
);
}
diff --git a/frontend/app/components/Dashboard/components/DashbaordListModal/DashbaordListModal.tsx b/frontend/app/components/Dashboard/components/DashbaordListModal/DashbaordListModal.tsx
index 49cef58f0..8a5892cb3 100644
--- a/frontend/app/components/Dashboard/components/DashbaordListModal/DashbaordListModal.tsx
+++ b/frontend/app/components/Dashboard/components/DashbaordListModal/DashbaordListModal.tsx
@@ -1,5 +1,4 @@
import React from 'react';
-import Modal from 'react-modal';
import { useStore } from 'App/mstore';
import { SideMenuitem, SideMenuHeader, Icon, Button } from 'UI';
@@ -12,19 +11,16 @@ function DashbaordListModal(props) {
Dashboards
{dashboards.map((item: any) => (
- //
- // {item.name}
- //
onItemClick(item)}
+ // onClick={() => onItemClick(item)} // TODO add click handler
leading = {(
-
+ {item.isPublic &&
}
{item.isPinned &&
}
)}
diff --git a/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx b/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx
index d7c7cfa05..90729935f 100644
--- a/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx
+++ b/frontend/app/components/Dashboard/components/DashboardMetricSelection/DashboardMetricSelection.tsx
@@ -1,9 +1,7 @@
import React from 'react';
-import WidgetWrapper from '../../WidgetWrapper';
-import { useDashboardStore } from '../../store/store';
+import WidgetWrapper from '../WidgetWrapper';
import { useObserver } from 'mobx-react-lite';
import cn from 'classnames';
-import { Button } from 'UI';
import { useStore } from 'App/mstore';
function WidgetCategoryItem({ category, isSelected, onClick, selectedWidgetIds, unSelectCategory }) {
@@ -30,7 +28,6 @@ function WidgetCategoryItem({ category, isSelected, onClick, selectedWidgetIds,
function DashboardMetricSelection(props) {
const { dashboardStore } = useStore();
const widgetCategories = dashboardStore?.widgetCategories;
- const widgetTemplates = dashboardStore?.widgetTemplates;
const [activeCategory, setActiveCategory] = React.useState(widgetCategories[0]);
const [selectedWidgets, setSelectedWidgets] = React.useState([]);
const selectedWidgetIds = selectedWidgets.map((widget: any) => widget.widgetId);
diff --git a/frontend/app/components/Dashboard/components/DashboardRouter/DashboardRouter.tsx b/frontend/app/components/Dashboard/components/DashboardRouter/DashboardRouter.tsx
new file mode 100644
index 000000000..82ab00a0e
--- /dev/null
+++ b/frontend/app/components/Dashboard/components/DashboardRouter/DashboardRouter.tsx
@@ -0,0 +1,45 @@
+import React from 'react';
+import { Switch, Route } from 'react-router';
+import { withRouter } from 'react-router-dom';
+
+import {
+ metrics,
+ metricDetails,
+ dashboardSelected,
+ dashboardMetricCreate,
+ withSiteId,
+} from 'App/routes';
+import DashboardView from '../DashboardView';
+import MetricsView from '../MetricsView';
+import WidgetView from '../WidgetView';
+
+interface Props {
+ history: any
+ match: any
+}
+function DashboardRouter(props: Props) {
+ const { match: { params: { siteId, dashboardId, metricId } } } = props;
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default withRouter(DashboardRouter);
\ No newline at end of file
diff --git a/frontend/app/components/Dashboard/components/DashboardRouter/index.ts b/frontend/app/components/Dashboard/components/DashboardRouter/index.ts
new file mode 100644
index 000000000..62c27a8fd
--- /dev/null
+++ b/frontend/app/components/Dashboard/components/DashboardRouter/index.ts
@@ -0,0 +1 @@
+export { default } from './DashboardRouter';
\ No newline at end of file
diff --git a/frontend/app/components/Dashboard/components/DashboardSideMenu/DashboardSideMenu.tsx b/frontend/app/components/Dashboard/components/DashboardSideMenu/DashboardSideMenu.tsx
index 646284d9e..c53a7a378 100644
--- a/frontend/app/components/Dashboard/components/DashboardSideMenu/DashboardSideMenu.tsx
+++ b/frontend/app/components/Dashboard/components/DashboardSideMenu/DashboardSideMenu.tsx
@@ -3,23 +3,23 @@ import React from 'react';
import { SideMenuitem, SideMenuHeader, Icon, Button } from 'UI';
import { useStore } from 'App/mstore';
import { withRouter } from 'react-router-dom';
-import { withSiteId, dashboardSelected, dashboardMetrics } from 'App/routes';
+import { withSiteId, dashboardSelected, metrics } from 'App/routes';
import { useModal } from 'App/components/Modal';
import DashbaordListModal from '../DashbaordListModal';
import DashboardModal from '../DashboardModal';
const SHOW_COUNT = 5;
-function DashboardSideMenu(props) {
+interface Props {
+ siteId: string
+ history: any
+}
+function DashboardSideMenu(props: Props) {
+ const { history, siteId } = props;
const { hideModal, showModal } = useModal();
- const { history } = props;
const { dashboardStore } = useStore();
const dashboardId = dashboardStore.selectedDashboard?.dashboardId;
const dashboardsPicked = dashboardStore.dashboards.slice(0, SHOW_COUNT);
const remainingDashboardsCount = dashboardStore.dashboards.length - SHOW_COUNT;
-
- // React.useEffect(() => {
- // showModal(, {});
- // }, []);
const redirect = (path) => {
history.push(path);
@@ -27,7 +27,7 @@ function DashboardSideMenu(props) {
const onItemClick = (dashboard) => {
dashboardStore.selectDashboardById(dashboard.dashboardId);
- const path = withSiteId(dashboardSelected(dashboard.dashboardId), parseInt(dashboardStore.siteId));
+ const path = withSiteId(dashboardSelected(dashboard.dashboardId), parseInt(siteId));
history.push(path);
};
@@ -36,7 +36,7 @@ function DashboardSideMenu(props) {
showModal(, {})
}
- return (
+ return useObserver(() => (
{dashboardsPicked.map((item: any) => (
@@ -48,7 +48,7 @@ function DashboardSideMenu(props) {
onClick={() => onItemClick(item)}
leading = {(
-
+ {item.isPublic &&
}
{item.isPinned &&
}
)}
@@ -79,7 +79,7 @@ function DashboardSideMenu(props) {
id="menu-manage-alerts"
title="Metrics"
iconName="bar-chart-line"
- onClick={() => redirect(withSiteId(dashboardMetrics(), dashboardStore.siteId))}
+ onClick={() => redirect(withSiteId(metrics(), siteId))}
/>
@@ -92,7 +92,7 @@ function DashboardSideMenu(props) {
/>
- );
+ ));
}
-export default withRouter(observer(DashboardSideMenu));
\ No newline at end of file
+export default withRouter(DashboardSideMenu);
\ No newline at end of file
diff --git a/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx b/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx
index c229ae104..4ac3380c6 100644
--- a/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx
+++ b/frontend/app/components/Dashboard/components/DashboardView/DashboardView.tsx
@@ -7,9 +7,10 @@ import withModal from 'App/components/Modal/withModal';
import DashboardWidgetGrid from '../DashboardWidgetGrid';
interface Props {
-
+ siteId: number;
}
function DashboardView(props: Props) {
+ const { siteId } = props;
const { dashboardStore } = useStore();
const dashboard: any = dashboardStore.selectedDashboard
@@ -18,7 +19,7 @@ function DashboardView(props: Props) {
-
+
Right
diff --git a/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx b/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx
index 237d5fcb4..b52a25329 100644
--- a/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx
+++ b/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import { useStore } from 'App/mstore';
-import WidgetWrapper from '../../WidgetWrapper';
+import WidgetWrapper from '../WidgetWrapper';
import { NoContent, Button, Loader } from 'UI';
import { useObserver } from 'mobx-react-lite';
diff --git a/frontend/app/components/Dashboard/components/MetricListItem/MetricListItem.tsx b/frontend/app/components/Dashboard/components/MetricListItem/MetricListItem.tsx
new file mode 100644
index 000000000..cafcf53d8
--- /dev/null
+++ b/frontend/app/components/Dashboard/components/MetricListItem/MetricListItem.tsx
@@ -0,0 +1,48 @@
+import React from 'react';
+import { Icon, NoContent, Label, Link, Pagination } from 'UI';
+
+interface Props {
+ metric: any;
+}
+
+function DashboardLink({ dashboards}) {
+ return (
+ dashboards.map(dashboard => (
+
+
+
+ ))
+ );
+}
+
+function MetricListItem(props: Props) {
+ const { metric } = props;
+ return (
+
+
+
+ {metric.name}
+
+
+
+
+
{metric.owner}
+ {/*
+
+ {metric.isPublic ? 'Team' : 'Private'}
+
*/}
+
Last Modified
+
+ );
+}
+
+export default MetricListItem;
\ No newline at end of file
diff --git a/frontend/app/components/Dashboard/components/MetricListItem/index.ts b/frontend/app/components/Dashboard/components/MetricListItem/index.ts
new file mode 100644
index 000000000..b4c506a23
--- /dev/null
+++ b/frontend/app/components/Dashboard/components/MetricListItem/index.ts
@@ -0,0 +1 @@
+export { default } from './MetricListItem';
\ No newline at end of file
diff --git a/frontend/app/components/Dashboard/components/MetricsList/MetricsList.tsx b/frontend/app/components/Dashboard/components/MetricsList/MetricsList.tsx
index 656ce2d3a..9ef809261 100644
--- a/frontend/app/components/Dashboard/components/MetricsList/MetricsList.tsx
+++ b/frontend/app/components/Dashboard/components/MetricsList/MetricsList.tsx
@@ -1,24 +1,20 @@
import { useObserver } from 'mobx-react-lite';
import React from 'react';
-import { Icon, NoContent, Label, Link, Pagination } from 'UI';
+import { NoContent, Pagination } from 'UI';
import { useStore } from 'App/mstore';
import { getRE } from 'App/utils';
+import MetricListItem from '../MetricListItem';
interface Props { }
function MetricsList(props: Props) {
- const { dashboardStore } = useStore();
- const widgets = dashboardStore.widgets;
- const lenth = widgets.length;
- const currentPage = useObserver(() => dashboardStore.metricsPage);
- const metricsSearch = useObserver(() => dashboardStore.metricsSearch);
-
- const filterRE = getRE(metricsSearch, 'i');
- const list = widgets.filter(w => filterRE.test(w.name))
+ const { metricStore } = useStore();
+ const metrics = useObserver(() => metricStore.metrics);
+ const lenth = metrics.length;
- const totalPages = list.length;
- const pageSize = dashboardStore.metricsPageSize;
- const start = (currentPage - 1) * pageSize;
- const end = currentPage * pageSize;
+ const metricsSearch = useObserver(() => metricStore.metricsSearch);
+ const filterRE = getRE(metricsSearch, 'i');
+ const list = metrics.filter(w => filterRE.test(w.name));
+
return useObserver(() => (
@@ -28,44 +24,21 @@ function MetricsList(props: Props) {
Type
Dashboards
Owner
- Visibility & Edit Access
+ {/* Visibility & Edit Access
*/}
Last Modified
- {list.slice(start, end).map((metric: any) => (
-
-
-
- {metric.name}
-
-
-
-
Dashboards
-
{metric.owner}
-
- {metric.isPrivate ? (
-
-
- Private
-
- ) : (
-
-
- Team
-
- )}
-
-
Last Modified
-
+ {list.map((metric: any) => (
+
))}
dashboardStore.updateKey('metricsPage', page)}
- limit={pageSize}
+ page={metricStore.page}
+ totalPages={Math.ceil(lenth / metricStore.pageSize)}
+ onPageChange={(page) => metricStore.updateKey('page', page)}
+ limit={metricStore.pageSize}
debounceRequest={100}
/>
diff --git a/frontend/app/components/Dashboard/components/MetricsView/MetricsView.tsx b/frontend/app/components/Dashboard/components/MetricsView/MetricsView.tsx
index b8ec01d25..18c1204bb 100644
--- a/frontend/app/components/Dashboard/components/MetricsView/MetricsView.tsx
+++ b/frontend/app/components/Dashboard/components/MetricsView/MetricsView.tsx
@@ -3,9 +3,16 @@ import { Button, PageTitle, Icon, Link } from 'UI';
import { withSiteId, dashboardMetricCreate } from 'App/routes';
import MetricsList from '../MetricsList';
import MetricsSearch from '../MetricsSearch';
+import { useStore } from 'App/mstore';
+import { useObserver } from 'mobx-react-lite';
function MetricsView(props) {
- return (
+ const { metricStore } = useStore();
+
+ React.useEffect(() => {
+ metricStore.fetchList();
+ }, []);
+ return useObserver(() => (
@@ -16,7 +23,7 @@ function MetricsView(props) {
- );
+ ));
}
export default MetricsView;
\ No newline at end of file
diff --git a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx
new file mode 100644
index 000000000..53f15faf5
--- /dev/null
+++ b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx
@@ -0,0 +1,27 @@
+import React from 'react';
+
+interface Props {
+ metric: any;
+}
+function WidgetChart(props: Props) {
+ const { metric } = props;
+ const renderChart = () => {
+ const { metricType } = metric;
+ if (metricType === 'timeseries') {
+ return
Chart
;
+ }
+
+ if (metricType === 'table') {
+ return
Table
;
+ }
+
+ return
Unknown
;
+ }
+ return (
+
+ {renderChart()}
+
+ );
+}
+
+export default WidgetChart;
\ No newline at end of file
diff --git a/frontend/app/components/Dashboard/components/WidgetChart/index.ts b/frontend/app/components/Dashboard/components/WidgetChart/index.ts
new file mode 100644
index 000000000..0ea9108ea
--- /dev/null
+++ b/frontend/app/components/Dashboard/components/WidgetChart/index.ts
@@ -0,0 +1 @@
+export { default } from './WidgetChart'
diff --git a/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx b/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx
index 9cd0002dc..373c399c9 100644
--- a/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx
+++ b/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx
@@ -7,16 +7,19 @@ import { useObserver } from 'mobx-react-lite';
import { HelpText, Button, Icon } from 'UI'
import FilterSeries from '../FilterSeries';
import { withRouter } from 'react-router-dom';
+import { confirm } from 'UI/Confirmation';
interface Props {
history: any;
match: any;
+ onDelete: () => void;
}
function WidgetForm(props: Props) {
const { history, match: { params: { siteId, dashboardId, metricId } } } = props;
- const { dashboardStore } = useStore();
- const metric: any = dashboardStore.currentWidget;
+ console.log('WidgetForm params', props.match.params);
+ const { metricStore } = useStore();
+ const metric: any = metricStore.instance;
const timeseriesOptions = metricOf.filter(i => i.type === 'timeseries');
const tableOptions = metricOf.filter(i => i.type === 'table');
@@ -24,31 +27,44 @@ function WidgetForm(props: Props) {
const isTimeSeries = metric.metricType === 'timeseries';
const _issueOptions = [{ text: 'All', value: 'all' }].concat(issueOptions);
- const write = ({ target: { value, name } }) => dashboardStore.editWidget({ [ name ]: value });
+ const write = ({ target: { value, name } }) => metricStore.merge({ [ name ]: value });
const writeOption = (e, { value, name }) => {
- dashboardStore.editWidget({ [ name ]: value });
+ metricStore.merge({ [ name ]: value });
if (name === 'metricValue') {
- dashboardStore.editWidget({ metricValue: [value] });
+ metricStore.merge({ metricValue: [value] });
}
if (name === 'metricOf') {
if (value === FilterKey.ISSUE) {
- dashboardStore.editWidget({ metricValue: ['all'] });
+ metricStore.merge({ metricValue: ['all'] });
}
}
if (name === 'metricType') {
if (value === 'timeseries') {
- dashboardStore.editWidget({ metricOf: timeseriesOptions[0].value, viewType: 'lineChart' });
+ metricStore.merge({ metricOf: timeseriesOptions[0].value, viewType: 'lineChart' });
} else if (value === 'table') {
- dashboardStore.editWidget({ metricOf: tableOptions[0].value, viewType: 'table' });
+ metricStore.merge({ metricOf: tableOptions[0].value, viewType: 'table' });
}
}
};
const onSave = () => {
- dashboardStore.saveMetric(metric, dashboardId);
+ metricStore.save(metric, dashboardId);
+ }
+
+ const onDelete = async () => {
+ if (await confirm({
+ header: 'Confirm',
+ confirmButton: 'Yes, Delete',
+ confirmation: `Are you sure you want to permanently delete this metric?`
+ })) {
+ metricStore.delete(metric).then(props.onDelete);
+ // props.remove(instance.alertId).then(() => {
+ // toggleForm(null, false);
+ // });
+ }
}
return useObserver(() => (
@@ -88,15 +104,15 @@ function WidgetForm(props: Props) {
)}
{metric.metricOf === FilterKey.ISSUE && (
- <>
-
issue type
-
- >
+ <>
+
issue type
+
+ >
)}
{metric.metricType === 'table' && (
@@ -154,9 +170,9 @@ function WidgetForm(props: Props) {
Save
- {metric.widgetId && (
+ {metric.exists() && (
<>
-