Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
CG demo instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Debanjan Dey authored and Debanjan Dey committed Dec 27, 2021
1 parent 9a79fae commit 079b64c
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 104 deletions.
3 changes: 2 additions & 1 deletion frontend/.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
REACT_APP_BASE_URL=http://localhost:5000
REACT_APP_BASE_URL=https://dev-main.chaosgenius.io
REACT_APP_IS_DEMO=true
2 changes: 1 addition & 1 deletion frontend/src/components/Analystics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const Analystics = ({ kpi, setAnalystics, onboarding }) => {
scheduler_params_time: schedule
}
};
dispatch(kpiSettingSetup(kpi, data));
dispatch(kpiSettingSetup(kpi, data, customToast));
}
};

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/DashboardForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ const DashboardForm = ({ setText, setModal, onboarding }) => {
dashboard_name: formData.dashboardname,
kpi_list: formData.kpi
};
dispatch(getUpdateDashboard(payload));
dispatch(getUpdateDashboard(payload, customToast));
} else {
const dashboardData = {
dashboard_name: formData.dashboardname,
kpi_list: formData.kpi
};
dispatch(getCreateDashboard(dashboardData));
dispatch(getCreateDashboard(dashboardData, customToast));
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Dashboardcards/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Dashboardcards = ({ dashboarddata, setChange }) => {
};

const onDelete = (value) => {
dispatch(getDashboardDelete({ dashboard_id: value.id }));
dispatch(getDashboardDelete({ dashboard_id: value.id }, customToast));
};

const customToast = (data) => {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/DataSourceForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ const DataSourceForm = ({ onboarding, setModal, setText }) => {
sourceDefinitionId: sourceDefinitionId
}
};
dispatch(createDataSource(bingPayload));
dispatch(createDataSource(bingPayload, customToast));
} else {
const payload = {
connection_type: selectedDatasource.value,
Expand All @@ -403,7 +403,7 @@ const DataSourceForm = ({ onboarding, setModal, setText }) => {
sourceDefinitionId: sourceDefinitionId
}
};
dispatch(createDataSource(payload));
dispatch(createDataSource(payload, customToast));
}
}
};
Expand Down Expand Up @@ -445,7 +445,7 @@ const DataSourceForm = ({ onboarding, setModal, setText }) => {
connectionConfiguration: editedForm
}
};
dispatch(updateDatasourceById(dsId, payload));
dispatch(updateDatasourceById(dsId, payload, customToast));
}
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/DataSourceTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const DataSourceTable = ({ tableData, changeData, search }) => {
const payload = {
data_source_id: datasource.id
};
dispatch(deleteDatasource(payload));
dispatch(deleteDatasource(payload, customToast));
};

const datasourceIcon = (type) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/KPITable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const KPITable = ({ kpiData, kpiLoading, kpiSearch, changeData }) => {
};

const onDelete = (kpi) => {
dispatch(kpiDisable(kpi.id));
dispatch(kpiDisable(kpi.id, customToast));
};

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/KpiExplorerForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -622,15 +622,15 @@ const KpiExplorerForm = ({ onboarding, setModal, setText }) => {
dashboard: formdata.dashboardNameList.map((el) => el.value)
};
if (data[2] === 'edit') {
dispatch(getUpdatekpi(kpiId, { name: formdata.kpiname }));
dispatch(getUpdatekpi(kpiId, { name: formdata.kpiname }, customToast));
} else {
dispatchgetAllKpiExplorerSubmit(kpiInfo);
}
}
};

const dispatchgetAllKpiExplorerSubmit = (kpiInfo) => {
dispatch(getAllKpiExplorerSubmit(kpiInfo));
dispatch(getAllKpiExplorerSubmit(kpiInfo, customToast));
};

const onTestQuery = () => {
Expand Down
17 changes: 10 additions & 7 deletions frontend/src/redux/actions/DashboardHome.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { env } from '../../env';
import { getRequest, postRequest } from '../../utils/http-helper';
import {
DASHBOARD_LIST_URL,
Expand Down Expand Up @@ -77,12 +78,13 @@ export const getDashboardDeleteFailure = () => {
};
};

export const getDashboardDelete = (params) => {
export const getDashboardDelete = (params, customToast) => {
return async (dispatch) => {
dispatch(getDashboardDeleteRequest());
const URL = attachParams(DASHBOARD_DELETE_URL, params);
const { data, error, status } = await postRequest({
url: URL
url: URL,
customToast
});
if (error) {
dispatch(getDashboardDeleteFailure());
Expand Down Expand Up @@ -111,12 +113,13 @@ export const getCreateDashboardFailure = () => {
};
};

export const getCreateDashboard = (dashboard) => {
export const getCreateDashboard = (dashboard, customToast) => {
return async (dispatch) => {
dispatch(getCreateDashboardRequest());
const { data, error, status } = await postRequest({
url: DASHBOARD_CREATE_URL,
data: dashboard
data: dashboard,
customToast
});
if (error) {
dispatch(getCreateDashboardFailure());
Expand Down Expand Up @@ -179,17 +182,17 @@ export const getUpdateDashboardFailure = () => {
};
};

export const getUpdateDashboard = (payload) => {
export const getUpdateDashboard = (payload, customToast) => {
return async (dispatch) => {
dispatch(getUpdateDashboardRequest());
//const URL = attachParams(DASHBOARD_UPDATE_URL, params);
const { data, error, status } = await postRequest({
url: DASHBOARD_UPDATE_URL,
data: JSON.stringify(payload),
headers: {
'Content-Type': 'application/json'
},
noAuth: true
noAuth: true,
customToast
});
if (error) {
dispatch(getUpdateDashboardFailure());
Expand Down
55 changes: 35 additions & 20 deletions frontend/src/redux/actions/DataSources.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
DELETE_DATASOURCE,
TEST_CONNECTION
} from '../../utils/url-helper';
import { env } from '../../env';

import { getRequest, postRequest } from '../../utils/http-helper';

Expand Down Expand Up @@ -155,12 +156,13 @@ export const createDatesourceFailure = () => {
};
};

export const createDataSource = (formData) => {
export const createDataSource = (formData, customToast) => {
return async (dispatch) => {
dispatch(createDatasourceRequested());
const { data, error, status } = await postRequest({
url: CREATE_DATASOURCE,
data: formData
data: formData,
customToast
});
if (error) {
dispatch(createDatesourceFailure());
Expand Down Expand Up @@ -189,12 +191,13 @@ export const deleteDatesourceFailure = () => {
};
};

export const deleteDatasource = (id) => {
export const deleteDatasource = (id, customToast) => {
return async (dispatch) => {
dispatch(deleteDatasourceRequested());
const { data, error, status } = await postRequest({
url: DELETE_DATASOURCE,
data: id
data: id,
customToast
});
if (error) {
dispatch(deleteDatesourceFailure());
Expand Down Expand Up @@ -286,21 +289,33 @@ export const updateDatasourceByIdFailure = () => {
};
};

export const updateDatasourceById = (id, updateData) => {
return async (dispatch) => {
dispatch(updateDatasourceByIdRequest());
const { data, error, status } = await postRequest({
url: `${CONNECTION_URL}/${id}/test-and-update`,
data: JSON.stringify(updateData),
headers: {
'Content-Type': 'application/json;charset=UTF-8'
},
noAuth: true
});
if (error) {
dispatch(updateDatasourceByIdFailure());
} else if (data && status === 200) {
dispatch(updateDatasourceByIdSuccess(data));
export const updateDatasourceById = (id, updateData, customToast) => {
if (env.REACT_APP_IS_DEMO === 'true') {
if (customToast) {
customToast({
type: 'error',
header: 'This is a demo version'
});
}
};
return {
type: 'default'
};
} else {
return async (dispatch) => {
dispatch(updateDatasourceByIdRequest());
const { data, error, status } = await postRequest({
url: `${CONNECTION_URL}/${id}/test-and-update`,
data: JSON.stringify(updateData),
headers: {
'Content-Type': 'application/json;charset=UTF-8'
},
noAuth: true
});
if (error) {
dispatch(updateDatasourceByIdFailure());
} else if (data && status === 200) {
dispatch(updateDatasourceByIdSuccess(data));
}
};
}
};
Loading

0 comments on commit 079b64c

Please sign in to comment.