Skip to content

Commit

Permalink
Merge pull request #4697 from beyondessential/release-2023-27
Browse files Browse the repository at this point in the history
Release 2023-27
  • Loading branch information
rohan-bes authored Jul 4, 2023
2 parents 5a6ac93 + b383ddd commit 3929fd9
Show file tree
Hide file tree
Showing 535 changed files with 4,089 additions and 3,514 deletions.
2 changes: 1 addition & 1 deletion packages/admin-panel-server/src/viz-builder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export * from './dashboardVisualisation';
export * from './mapOverlayVisualisation';
export * from './types';
export * from './validators';
export * from './constants';
export * from './constants';
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
export { MapOverlayVisualisationExtractor } from './MapOverlayVisualisationExtractor';
export { combineMapOverlayVisualisation } from './combineMapOverlayVisualisation';
export * from './validators';
export * from './types';
export * from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ export type MapOverlayVisualisationResource = { mapOverlay: MapOverlay; report:
// };
//
export type MapOverlayVizResource = MapOverlayVisualisationResource;
//| LegacyMapOverlayVisualisationResource;
// | LegacyMapOverlayVisualisationResource;
76 changes: 76 additions & 0 deletions packages/admin-panel/src/pages/resources/DhisInstancesPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Tupaia
* Copyright (c) 2017 - 2023 Beyond Essential Systems Pty Ltd
*/

import React from 'react';
import PropTypes from 'prop-types';
import { ResourcePage } from './ResourcePage';

const FIELDS = [
{
Header: 'Code',
source: 'code',
},
{
Header: 'Readonly',
source: 'readonly',
type: 'boolean',
editConfig: {
type: 'boolean',
},
},
{
Header: 'Config',
source: 'config',
type: 'jsonTooltip',
editConfig: {
type: 'jsonEditor',
default: '{}',
},
},
];

const COLUMNS = [
...FIELDS,
{
Header: 'Edit',
type: 'edit',
source: 'id',
actionConfig: {
editEndpoint: 'dhisInstances',
fields: FIELDS,
},
},
{
Header: 'Delete',
source: 'id',
type: 'delete',
actionConfig: {
endpoint: `dhisInstances`,
},
},
];

const CREATE_CONFIG = {
title: 'New Dhis Instance',
actionConfig: {
editEndpoint: 'dhisInstances',
fields: FIELDS,
},
};

export const DhisInstancesPage = ({ getHeaderEl, ...props }) => (
<ResourcePage
title="DHIS Instances"
endpoint="dhisInstances"
columns={COLUMNS}
createConfig={CREATE_CONFIG}
getHeaderEl={getHeaderEl}
{...props}
/>
);

DhisInstancesPage.propTypes = {
getHeaderEl: PropTypes.func.isRequired,
};
68 changes: 68 additions & 0 deletions packages/admin-panel/src/pages/resources/SupersetInstancesPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Tupaia MediTrak
* Copyright (c) 2017 Beyond Essential Systems Pty Ltd
*/

import React from 'react';
import PropTypes from 'prop-types';
import { ResourcePage } from './ResourcePage';

const FIELDS = [
{
Header: 'Code',
source: 'code',
},
{
Header: 'Config',
source: 'config',
type: 'jsonTooltip',
editConfig: {
type: 'jsonEditor',
default: '{}',
},
},
];

const COLUMNS = [
...FIELDS,
{
Header: 'Edit',
type: 'edit',
source: 'id',
actionConfig: {
editEndpoint: 'supersetInstances',
fields: FIELDS,
},
},
{
Header: 'Delete',
source: 'id',
type: 'delete',
actionConfig: {
endpoint: `supersetInstances`,
},
},
];

const CREATE_CONFIG = {
title: 'New Superset Instance',
actionConfig: {
editEndpoint: 'supersetInstances',
fields: FIELDS,
},
};

export const SupersetInstancesPage = ({ getHeaderEl, ...props }) => (
<ResourcePage
title="mSupply Superset Instances"
endpoint="supersetInstances"
columns={COLUMNS}
createConfig={CREATE_CONFIG}
getHeaderEl={getHeaderEl}
{...props}
/>
);

SupersetInstancesPage.propTypes = {
getHeaderEl: PropTypes.func.isRequired,
};
3 changes: 3 additions & 0 deletions packages/admin-panel/src/pages/resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ export { ExternalDatabaseConnectionsPage } from './ExternalDatabaseConnectionsPa
export { EntityHierarchyPage } from './EntityHierarchyPage';
export { PermissionGroupsViewerPage } from './PermissionGroupsViewerPage';
export { CustomLandingPagesPage } from './CustomLandingPagesPage';
export { DataElementDataServicesPage } from './DataElementDataServicesPage';
export { DhisInstancesPage } from './DhisInstancesPage';
export { SupersetInstancesPage } from './SupersetInstancesPage';
14 changes: 13 additions & 1 deletion packages/admin-panel/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ import {
DataTablesPage,
ExternalDatabaseConnectionsPage,
EntityHierarchyPage,
DataElementDataServicesPage,
DhisInstancesPage,
SupersetInstancesPage,
} from './pages/resources';
import { DataElementDataServicesPage } from './pages/resources/DataElementDataServicesPage';

export const ROUTES = [
{
Expand Down Expand Up @@ -241,6 +243,16 @@ export const ROUTES = [
to: '',
component: ExternalDatabaseConnectionsPage,
},
{
label: 'DHIS Instances',
to: '/dhis-instances',
component: DhisInstancesPage,
},
{
label: 'mSupply Superset Instances',
to: '/superset-instances',
component: SupersetInstancesPage,
},
],
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,21 @@ const getAdjustedOrganisationUnitsAndAggregations = async (
return [aggregation, dataSourceEntities];
}

const { aggregationEntityType, dataSourceEntityType, dataSourceEntityFilter } =
aggregation.config;
const [dataSourceEntities, relationships] =
await entityProvider.getDataSourceEntitiesAndRelationships(
hierarchy,
organisationUnitCodes,
aggregationEntityType,
dataSourceEntityType,
dataSourceEntityFilter,
);
const {
aggregationEntityType,
dataSourceEntityType,
dataSourceEntityFilter,
} = aggregation.config;
const [
dataSourceEntities,
relationships,
] = await entityProvider.getDataSourceEntitiesAndRelationships(
hierarchy,
organisationUnitCodes,
aggregationEntityType,
dataSourceEntityType,
dataSourceEntityFilter,
);

return [
{
Expand Down
4 changes: 3 additions & 1 deletion packages/central-server/src/apiV2/GETCountries.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export class GETCountries extends GETHandler {
async findSingleRecord(countryId, options) {
const countryPermissionChecker = accessPolicy =>
assertCountryPermissions(accessPolicy, this.models, countryId);
await this.assertPermissions(assertAnyPermissions([assertBESAdminAccess, countryPermissionChecker]));
await this.assertPermissions(
assertAnyPermissions([assertBESAdminAccess, countryPermissionChecker]),
);

return super.findSingleRecord(countryId, options);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Tupaia
* Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd
Expand Down
7 changes: 7 additions & 0 deletions packages/central-server/src/apiV2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ apiV2.get('/facilities/:recordId?', useRouteHandler(GETClinics));
apiV2.get('/geographicalAreas/:recordId?', useRouteHandler(GETGeographicalAreas));
apiV2.get('/reports/:recordId?', useRouteHandler(GETReports));
apiV2.get('/dhisInstances/:recordId?', useRouteHandler(TupaiaAdminGETHandler));
apiV2.get('/supersetInstances/:recordId?', useRouteHandler(TupaiaAdminGETHandler));
apiV2.get('/dataServiceSyncGroups/:recordId?', useRouteHandler(GETSyncGroups));
apiV2.get('/dataServiceSyncGroups/:recordId/logs', useRouteHandler(GETSyncGroupLogs));
apiV2.get('/dataServiceSyncGroups/:recordId/logs/count', useRouteHandler(GETSyncGroupLogsCount));
Expand Down Expand Up @@ -288,6 +289,8 @@ apiV2.post('/dataServiceSyncGroups/:recordId/sync', useRouteHandler(ManuallySync
apiV2.post('/dataElementDataServices', useRouteHandler(BESAdminCreateHandler));
apiV2.post('/externalDatabaseConnections', useRouteHandler(BESAdminCreateHandler));
apiV2.post('/landingPages', useRouteHandler(CreateLandingPage));
apiV2.post('/dhisInstances', useRouteHandler(BESAdminCreateHandler));
apiV2.post('/supersetInstances', useRouteHandler(BESAdminCreateHandler));

/**
* PUT routes
Expand Down Expand Up @@ -326,6 +329,8 @@ apiV2.put('/dataElementDataServices/:recordId', useRouteHandler(BESAdminEditHand
apiV2.put('/externalDatabaseConnections/:recordId', useRouteHandler(BESAdminEditHandler));
apiV2.put('/entityHierarchy/:recordId', useRouteHandler(BESAdminEditHandler));
apiV2.put('/landingPages/:recordId', useRouteHandler(EditLandingPage));
apiV2.put('/dhisInstances/:recordId', useRouteHandler(BESAdminEditHandler));
apiV2.put('/supersetInstances/:recordId', useRouteHandler(BESAdminEditHandler));

/**
* DELETE routes
Expand Down Expand Up @@ -360,6 +365,8 @@ apiV2.delete('/dataServiceSyncGroups/:recordId', useRouteHandler(DeleteSyncGroup
apiV2.delete('/dataElementDataServices/:recordId', useRouteHandler(BESAdminDeleteHandler));
apiV2.delete('/externalDatabaseConnections/:recordId', useRouteHandler(BESAdminDeleteHandler));
apiV2.delete('/landingPages/:recordId', useRouteHandler(BESAdminDeleteHandler));
apiV2.delete('/dhisInstances/:recordId', useRouteHandler(BESAdminDeleteHandler));
apiV2.delete('/supersetInstances/:recordId', useRouteHandler(BESAdminDeleteHandler));

apiV2.use(handleError); // error handler must come last

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { respond, DatabaseError, UnauthenticatedError } from '@tupaia/utils';
import { LegacyCountChangesHandler } from './LegacyCountChangesHandler';
import { allowNoPermissions } from '../../../permissions';
import { buildMeditrakSyncQuery } from "../meditrakSync";
import { buildMeditrakSyncQuery } from '../meditrakSync';

const handleNonLegacyRequest = async (req, res) => {
const { models } = req;
Expand Down
2 changes: 1 addition & 1 deletion packages/central-server/src/apiV2/meditrakApp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export { getChanges } from './getChanges';
export { getSocialFeed } from './getSocialFeed';
export { getUserRewards } from './getUserRewards';
export { postChanges } from './postChanges';
export * from './countChanges';
export * from './countChanges';
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export { buildPermissionsBasedMeditrakSyncQuery } from './permissionsBasedMeditr
export {
supportsPermissionsBasedSync,
PERMISSIONS_BASED_SYNC_MIN_APP_VERSION,
} from './supportsPermissionsBasedSync';
} from './supportsPermissionsBasedSync';
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export { addSurveyImage } from './addSurveyImage';
export { addSurveyFile } from './addSurveyFile';
export { updateOrCreateSurveyResponse } from './updateOrCreateSurveyResponse';
export { fetchRequestingMeditrakDevice } from './fetchRequestingMeditrakDevice';
export { getColumnsForMeditrakApp } from './getColumnsForMeditrakApp';
export { getColumnsForMeditrakApp } from './getColumnsForMeditrakApp';
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,17 @@ export const constructForSingle = (models, recordType) => {
},
],
};
case TYPES.DHIS_INSTANCE:
return {
code: [isAString],
readonly: [hasContent, isBoolean],
config: [hasContent],
};
case TYPES.SUPERSET_INSTANCE:
return {
code: [isAString],
config: [hasContent],
};
default:
throw new ValidationError(`${recordType} is not a valid POST endpoint`);
}
Expand Down
19 changes: 10 additions & 9 deletions packages/central-server/src/kobo/startSyncWithKoBo.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,16 @@ export async function syncWithKoBo(models, dataBroker, syncGroupCode) {
await validateSyncGroup(models, dataServiceSyncGroup);

// Pull data from KoBo
const koboData = await dataBroker.pull(
{
code: syncGroupCode,
type: dataBroker.getDataSourceTypes().SYNC_GROUP,
},
{
startSubmissionTime: dataServiceSyncGroup.sync_cursor,
},
);
const koboData =
(await dataBroker.pull(
{
code: syncGroupCode,
type: dataBroker.getDataSourceTypes().SYNC_GROUP,
},
{
startSubmissionTime: dataServiceSyncGroup.sync_cursor,
},
)) || [];

await models.wrapInTransaction(async transactingModels => {
// Create new survey_responses in Tupaia
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* Copyright (c) 2017 - 2021 Beyond Essential Systems Pty Ltd
*/

export { setupMapOverlayTestData } from './setupMapOverlayTestData';
export { setupMapOverlayTestData } from './setupMapOverlayTestData';
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const DATA_ELEMENTS = dataElements({
POP01: { code: 'POP01', dataElementCode: 'POP01', service_type: 'dhis' },
POP02: { code: 'POP02', dataElementCode: 'POP02', service_type: 'dhis' },
DIF01: { code: 'DIF01', dataElementCode: 'DIF01_DHIS', service_type: 'dhis' },
NON_DHIS_1: { code: 'NON_DHIS_1', service_type: 'superset' }
NON_DHIS_1: { code: 'NON_DHIS_1', service_type: 'superset' },
});

export const DATA_GROUPS = dataGroups({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ describe('DhisService', () => {
};

it('uses AnalyticsPuller for dataElements', async () => {
await dhisService.pull([DATA_ELEMENTS.POP01], 'dataElement', { dataServiceMapping: DEFAULT_DATA_SERVICE_MAPPING });
await dhisService.pull([DATA_ELEMENTS.POP01], 'dataElement', {
dataServiceMapping: DEFAULT_DATA_SERVICE_MAPPING,
});
expect(mockPullAnalytics).toHaveBeenCalledOnceWith([dhisApi], [DATA_ELEMENTS.POP01], {
dataServiceMapping: DEFAULT_DATA_SERVICE_MAPPING,
});
Expand Down Expand Up @@ -297,9 +299,7 @@ describe('DhisService', () => {
const getApisForDataSourcesSpy = jest.spyOn(GetDhisApi, 'getApisForDataSources');

it('looks up the api from the given data source', async () => {
const dataSources = [
DATA_ELEMENTS.POP01,
];
const dataSources = [DATA_ELEMENTS.POP01];
const options = {
organisationUnitCodes: ['TO'],
dataServiceMapping: DEFAULT_DATA_SERVICE_MAPPING,
Expand Down
Loading

0 comments on commit 3929fd9

Please sign in to comment.