Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(dnm) Enketo changes on 3.x architecture (#7821) #7835

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
86d6fbe
Bulk user upload (#7678)
m5r Jul 25, 2022
a28450d
Remove zero-width unicode characters from incoming message
garethbowen Jul 25, 2022
dda222f
Title test too long for mobile 340px view port width - Apply ellipsis…
elvisdorkenoo Jul 21, 2022
3b88479
update the version number
njogz Jul 26, 2022
a9facab
update google-libphonenumber to version 3.2.30
njogz Jul 29, 2022
f747054
Use the locale cookie to set the language
garethbowen May 23, 2022
d9f034c
Setting version to 3.17.0
latin-panda Aug 31, 2022
54da1ab
Make privacy policy available without authentication
garethbowen Aug 2, 2022
08485f0
7721 - Display labels in action buttons when device is small (#7722)
latin-panda Aug 11, 2022
8286402
Set contact as primary contact of a place with bulk user upload (#7693)
m5r Aug 30, 2022
45bbfd1
Cherry pick: 7653 - Reports filter redesign
latin-panda Sep 1, 2022
4c94a79
Fix `npm ci` hanging (#7630)
m5r Jun 11, 2022
813e152
6215 - can_edit permission (#7733)
latin-panda Sep 8, 2022
f6b1db2
Cherry-picked: 7746 - Search bar redesign (#7758)
latin-panda Sep 9, 2022
1b3ad9f
Uplift GitHub workflows to run on ubuntu-22.04 (#7748)
jkuester Sep 15, 2022
7decc21
Update default/standard config forms to pass validation (#7739)
jkuester Sep 6, 2022
703902c
Update the levels displayed in breadcrumbs across the app (#7732)
elvisdorkenoo Sep 22, 2022
1f66f32
5710 add breadcrumbs to tasks lists (#7757)
elvisdorkenoo Sep 22, 2022
a5039de
Revert "Update default/standard config forms to pass validation (#7739)"
jkuester Oct 6, 2022
ce6e846
Stabilising e2e for 3.17 (#7838)
latin-panda Oct 6, 2022
6821913
6345 - Uplift to enketo-core version 5.18.1 (#7256)
jkuester Aug 16, 2022
ef6d236
7694 - Add `add-date` XPath function (#7729)
jkuester Aug 24, 2022
e97a810
Update default/standard config forms to pass validation (#7739)
jkuester Sep 6, 2022
7a724d8
Update openrosa-xpath-evaluator to fix scientific notation bug
garethbowen Sep 20, 2022
49f87ac
Remove custom today XPath function (#7821)
jkuester Oct 4, 2022
bcbf778
Fix webapp package-lock
jkuester Oct 17, 2022
d29bb77
Remove Simprints support
garethbowen Apr 24, 2022
70dfc5e
Fix merge conflict in standard immunization_visit form
jkuester Oct 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/actions/deploy-with-medic-conf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on: ['deployment']

jobs:
deployment:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

build:
name: Compile the app
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

steps:
- name: Get Docker Hub username
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
config-tests:
needs: build
name: Config Tests
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
strategy:
matrix:
grunt-cmd: [ 'exec:test-config-standard', 'exec:test-config-default']
Expand All @@ -78,7 +78,7 @@ jobs:
publish:
needs: [tests,config-tests]
name: Publish branch build
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
Expand All @@ -98,7 +98,7 @@ jobs:
tests:
needs: build
name: ${{ matrix.grunt-cmd }} on node ${{ matrix.node-version }}
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
env:
NODE: ${{ matrix.node-version }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
jobs:
cleanup:
name: Deleting old published artefacts
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scalability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build:
name: Set up Medic on EC2 and Execute Jmeter on another EC2
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Set TAG_NAME var
run: echo "TAG_NAME=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
Expand All @@ -25,4 +25,4 @@ jobs:
- name: Execute Jmeter
env:
SCALABILITY_ARN: ${{ secrets.SCALABILITY_ARN }}
run: cd tests/scalability && ./start_jmeter_ec2.sh
run: cd tests/scalability && ./start_jmeter_ec2.sh
10 changes: 6 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ module.exports = function(grunt) {
test: {
files: {
['http://admin:pass@localhost:4984/medic-test']: 'build/ddocs/medic.json',
['http://admin:pass@localhost:4984/medic-test-logs']: 'build/ddocs/medic/_attachments/ddocs/logs.json',
},
},
staging: {
Expand Down Expand Up @@ -540,11 +541,12 @@ module.exports = function(grunt) {
'patch webapp/node_modules/moment/locale/hi.js < webapp/patches/moment-hindi-use-euro-numerals.patch',

// patch enketo to always mark the /inputs group as relevant
'patch webapp/node_modules/enketo-core/src/js/Form.js < webapp/patches/enketo-inputs-always-relevant.patch',
'patch webapp/node_modules/enketo-core/src/js/form.js < webapp/patches/enketo-inputs-always-relevant_form.patch',
'patch webapp/node_modules/enketo-core/src/js/relevant.js < webapp/patches/enketo-inputs-always-relevant_relevant.patch',

// patch enketo so forms with no active pages are considered valid
// https://github.com/medic/medic/issues/5484
'patch webapp/node_modules/enketo-core/src/js/page.js < webapp/patches/enketo-handle-no-active-pages.patch',
// patch enketo to fix repeat name collision bug - this should be removed when upgrading to a new version of enketo-core
// https://github.com/enketo/enketo-core/issues/815
'patch webapp/node_modules/enketo-core/src/js/calculate.js < webapp/patches/enketo-repeat-name-collision.patch',

// patch messageformat to add a default plural function for languages not yet supported by make-plural #5705
'patch webapp/node_modules/messageformat/lib/plurals.js < webapp/patches/messageformat-default-plurals.patch',
Expand Down
3 changes: 1 addition & 2 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ Github actions will artifact all files in tests/logs. This is the directory any

### Test Architecture

Our github actions spin up an ubuntu-18.04 machine. Installs software and then launches Couchdb and Horticulturalist in a docker container. This is needed to run our applications in the specific node versions we support while allowing our test code to run in versions of node it they support. This creates a paradigm to keep in mind when writing tests. Tests run on the ubuntu machine. Any test code that starts a server or runs an executable is running outside of the horti container. The ports are exposed for all our services and horti has access to the cht-core root via a volume. Horti can also talk to the host by getting the gateway of the docker network.

Our GitHub actions spin up an ubuntu-22.04 machine. Installs software and then launches Couchdb and Horticulturalist in a docker container. This is needed to run our applications in the specific node versions we support while allowing our test code to run in versions of node it they support. This creates a paradigm to keep in mind when writing tests. Tests run on the ubuntu machine. Any test code that starts a server or runs an executable is running outside of the horti container. The ports are exposed for all our services and horti has access to the cht-core root via a volume. Horti can also talk to the host by getting the gateway of the docker network.

### Glossary

Expand Down
6 changes: 3 additions & 3 deletions admin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"bikram-sambat-bootstrap": "^1.5.0",
"bootstrap": "^3.4.1",
"font-awesome": "^4.7.0",
"google-libphonenumber": "^3.2.27",
"google-libphonenumber": "^3.2.30",
"gsm": "^0.1.4",
"jquery": "^3.5.1",
"lodash": "^4.17.19",
Expand Down
30 changes: 30 additions & 0 deletions admin/src/css/theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,33 @@ ul {
.people-section {
margin-bottom: 30px;
}

.modal {
height: fit-content;
max-height: 70%;
top: 20%;
left: 25%;
width: 50%;
margin: 0px;
padding: 0px;
}

.modal-dialog {
width: auto;
margin: 0px;
padding: 0px;
}

.modal-content {
width: auto;
}

.summary-box {
border-bottom-width:0px !important;
padding-bottom:20px !important;
}

.summary-number {
font-size: 7rem;
margin-bottom: -15px;
}
2 changes: 1 addition & 1 deletion admin/src/js/controllers/edit-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ angular
return UpdateUser($scope.editUserModel.username, updates);
}

return CreateUser(updates);
return CreateUser.createSingleUser(updates);
})
.then(() => {
$scope.setFinished();
Expand Down
7 changes: 4 additions & 3 deletions admin/src/js/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ angular.module('controllers').controller('MainCtrl',
$log,
$scope,
$state,
$translate,
$window,
Auth,
Language,
Location,
Session
Session,
SetLanguage
) {
'ngInject';

Expand All @@ -23,7 +24,7 @@ angular.module('controllers').controller('MainCtrl',
});
};

$translate.use('en');
Language().then(locale => SetLanguage(locale));
$scope.authorized = false;
$scope.navbarCollapsed = true;
Auth.any([['can_configure'], ['can_view_outgoing_messages'], ['can_export_all']])
Expand Down
150 changes: 150 additions & 0 deletions admin/src/js/controllers/multiple-user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
angular.module('controllers').controller('MultipleUserCtrl', function(
$scope,
$uibModalInstance,
$window,
CreateUser,
DB
) {

'use strict';
'ngInject';

$scope.status = { uploading: false };
$scope.displayAddMultipleModal = true;
$scope.displayUnavailableModal = false;
$scope.displayUploadConfirm = false;
$scope.displayProcessingStatus = false;
$scope.displayFinishSummary = false;
$scope.outputFileUrl = '';
$scope.processTotal = '';
const USER_LOG_DOC_ID = 'bulk-user-upload-';

$scope.onCancel = function () {
$scope.clearScreen();
$uibModalInstance.dismiss();
};

const getLogsByType = (docPrefix) => {
return DB({ logsDB: true })
.allDocs({
startkey: docPrefix,
endkey: docPrefix + '\ufff0',
include_docs: true
})
.then(result => {
if (!result || !result.rows || !result.rows.length) {
return;
}
return result.rows
.map(row => row.doc)
.sort((a, b) => new Date(b.bulk_uploaded_on) - new Date(a.bulk_uploaded_on));
});
};

const prepareStringForCSV = (str) => {
if (!str) {
return str;
}
return '"' + str.replace(/"/g, '""') + '"';
};

const convertToCSV = doc => {
if (!doc || !doc.data) {
return;
}
const eol = '\r\n';
const delimiter = ',';
const columns = ['import.status:excluded', 'import.message:excluded', 'import.username:excluded'];
let output = columns.join(delimiter) + eol;

doc.data.forEach(record => {
if (record.import) {
output += [
prepareStringForCSV(record.import.status),
prepareStringForCSV(record.import.message),
prepareStringForCSV(record.username),
].join(delimiter) + eol;
}
});

const file = new Blob([output], { type: 'text/csv;charset=utf-8;' });
return URL.createObjectURL(file);
};

$scope.processUpload = function () {
$scope.clearScreen();
$scope.displayProcessingStatus = true;
return $scope.uploadedData
.text()
.then(data => CreateUser.createMultipleUsers(data))
.then(() => getLogsByType(USER_LOG_DOC_ID))
.then(docs => {
if (!docs || !docs.length) {
// eslint-disable-next-line no-console
console.error('CreateMultipleUser : Error getting logs by type');
$scope.setError('CreateMultipleUser : Error getting logs by type');
} else {
$scope.uploadProcessLog = docs[0];
$scope.processTotal = $scope.uploadProcessLog.progress.parsing.total;
$scope.successUsersNumber = $scope.uploadProcessLog.progress.saving.successful;
$scope.ignoredUsersNumber = $scope.uploadProcessLog.progress.saving.ignored;
$scope.failedUsersNumber = $scope.uploadProcessLog.progress.saving.failed;
$scope.$apply();
$scope.outputFileUrl = convertToCSV( $scope.uploadProcessLog);
$scope.showFinishSummary();
}
})
.catch(error => {
// eslint-disable-next-line no-console
console.error(error, 'CreateMultipleUser : Error processing data after upload');
$scope.setError(error, 'CreateMultipleUser : Error processing data after upload');
});
};

$scope.showFinishSummary = function () {
$scope.clearScreen();
$scope.displayFinishSummary = true;
$scope.$apply();
};

$scope.showDisplayUploadConfirm = function () {
$scope.clearScreen();
$scope.displayUploadConfirm = true;
$scope.$apply();
};

$scope.backToAppManagement = function () {
$window.location.href = '/admin/#/users';
$window.location.reload();
$scope.clearScreen();
$uibModalInstance.dismiss();
$scope.$apply();
};

$scope.clearScreen = function () {
$scope.displayAddMultipleModal = false;
$scope.displayUnavailableModal = false;
$scope.displayUploadConfirm = false;
$scope.displayProcessingStatus = false;
$scope.displayFinishSummary = false;
};

const upload = function() {
const files = $('#users-upload .uploader')[0].files;
if (!files || files.length === 0) {
return;
}
$scope.usersFilename = files[0].name;
$scope.uploadedData = files[0];
$scope.showDisplayUploadConfirm();
};

angular.element(function () {
$('#users-upload .uploader').on('change', upload);
$('#users-upload .choose').on('click', function(e) {
e.preventDefault();
$('#users-upload .uploader').click();
});
});
}
);
19 changes: 18 additions & 1 deletion admin/src/js/controllers/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ angular.module('controllers').controller('UpgradeCtrl',
return DB().get('_design/medic')
.then(function(ddoc) {
$scope.currentDeploy = ddoc.deploy_info;

const currentVersion = Version.currentVersion($scope.currentDeploy);
$scope.isUsingFeatureRelease = !!currentVersion && typeof currentVersion.featureRelease !== 'undefined';
});
};

Expand Down Expand Up @@ -94,7 +97,21 @@ angular.module('controllers').controller('UpgradeCtrl',
endkey: [ 'release', 'medic', 'medic', minVersion.major, minVersion.minor, minVersion.patch],
descending: true,
limit: 50
})
}),
featureReleases: !$scope.isUsingFeatureRelease ? builds({
startkey: [minVersion.featureRelease, 'medic', 'medic', {}],
endkey: [
minVersion.featureRelease,
'medic',
'medic',
minVersion.major,
minVersion.minor,
minVersion.patch,
minVersion.beta,
],
descending: true,
limit: 50,
}) : [],
}).then(function(results) {
$scope.versions = results;
});
Expand Down
8 changes: 8 additions & 0 deletions admin/src/js/controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ angular.module('controllers').controller('UsersCtrl',
});
};

$scope.showAddMultipleUsersModal = function() {
Modal({
templateUrl: 'templates/multiple_user_modal.html',
controller: 'MultipleUserCtrl',
model: {},
});
};

$scope.$on('UsersUpdated', function() {
$scope.updateList();
});
Expand Down
Loading