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

chore(deps): bump ini from 1.3.5 to 1.3.8 #148

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3731e1d
feat: BIN VALIDATION BITCH (#131)
sgrund14 Dec 2, 2020
0af5f2e
chore: redirect to reserve instances when you arent editing a config …
sgrund14 Dec 2, 2020
c8f9100
fix: disabled buttons
sgrund14 Dec 2, 2020
f6fe3ac
refactor: remove lambda process, allow for wasted units (#140)
JohnEFerguson Dec 5, 2020
395c3e3
feat: sort nested config parts by their order (#141)
JohnEFerguson Dec 7, 2020
f9d4869
fix: issue squashing (#142)
sgrund14 Dec 7, 2020
23c569a
fix: remove electron builder targets
Dec 7, 2020
a004b01
fix: old config bug
sgrund14 Dec 7, 2020
556a10d
refactor: change is_... to is_eligible_for_reserve_cat... (refs #137)…
JohnEFerguson Dec 7, 2020
3e821ab
fix: add eligible update to patient POST route
Dec 7, 2020
1135cfb
fix: update patient ingestion
Dec 7, 2020
c126d93
chore: little bug fixes
sgrund14 Dec 7, 2020
241c556
feat: use appveyor to make windows build (#147)
JohnEFerguson Dec 9, 2020
0aa844c
Update appveyor.yaml
JohnEFerguson Dec 9, 2020
4d286de
Merge branch 'master' of github.com:JohnEFerguson/project-reserve
sgrund14 Dec 9, 2020
c6d0de8
chore: use --win flag to specify that we want to build for Window
Dec 9, 2020
55693ab
fix: issue #155 validation on empty row
sgrund14 Dec 22, 2020
bfb00c8
Merge branch 'master' of github.com:JohnEFerguson/project-reserve
sgrund14 Dec 22, 2020
5fc7055
feat: only try one download case for the csv
sgrund14 Jan 9, 2021
b4b70ed
fix: issues
sgrund14 Jan 11, 2021
e9e4d1f
fix: (hopefully) only allow CSV downloads on windows
sgrund14 Jan 14, 2021
34724e5
fix: disabled in progress and size error fixed
sgrund14 Jan 26, 2021
b89b866
feat: make criteria fields of default categories default
JohnEFerguson Jan 27, 2021
0ecfe25
chore(deps): bump ini from 1.3.5 to 1.3.8
dependabot[bot] Jan 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions build/entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
</dict>
</plist>
Binary file modified build/icon.ico
Binary file not shown.
10 changes: 10 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ try {

// use server for route
mainWindow.loadURL(`http://localhost:${env.PORT}`)

mainWindow.webContents.session.on(
'will-download',
(event, downloadItem, webContents) => {
downloadItem.setSaveDialogOptions({
filters: [{ name: 'CSV', extensions: ['csv'] }],
message: 'Download CSV',
})
}
)
}

app.on('ready', createWindow)
Expand Down
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@
"private": true,
"build": {
"productName": "Project Reserve",
"appId": "your.id",
"appId": "project.reserve",
"mac": {
"category": "your.app.category.type"
},
"win": {
"target": [
{
"target": "nsis"
}
]
},
"files": [
"build/*",
Expand All @@ -33,7 +39,7 @@
"build:client": "cross-env NODE_ENV=production webpack --config build/webpack.client.config.js --progress",
"build:server": "cross-env NODE_ENV=production webpack --config build/webpack.server.config.js --progress",
"pack": "electron-builder --dir",
"dist": "yarn build && DEBUG=electron-builder electron-builder",
"dist": "yarn build && DEBUG=electron-builder electron-builder --win --mac",
"postinstall": "electron-builder install-app-deps"
},
"dependencies": {
Expand All @@ -45,6 +51,8 @@
"body-parser": "^1.19.0",
"compression": "^1.7.4",
"dotenv": "^8.2.0",
"electron-builder-squirrel-windows": "^22.10.4",
"electron-notarize": "^1.0.0",
"express": "^4.17.1",
"http": "^0.0.1-security",
"isomorphic-fetch": "^3.0.0",
Expand Down
80 changes: 75 additions & 5 deletions src/api/main/routes/configurations.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ router.get("/configurations/:id", async (req, res) => {
{
model: db.reserveCategory,
as: "reserveCategories",
order: [['reserveCatetories.`order`', 'ASC']],
include: [
{
model: db.priority,
include: [
{
model: db.categoryCriteria,
as: "categoryCriteria",
order: [['order', 'ASC']],
include: [
{
model: db.categoryCriteriaElement,
Expand All @@ -41,6 +43,7 @@ router.get("/configurations/:id", async (req, res) => {
{
model: db.numericCriteria,
as: "numericCriteria",
order: [['order', 'ASC']],
include: [
{
model: db.numericCriteriaBucket,
Expand All @@ -51,6 +54,7 @@ router.get("/configurations/:id", async (req, res) => {
],
},
],

},
],
})
Expand Down Expand Up @@ -106,6 +110,7 @@ router.get("/configurations/:id/fieldNames", async (req, res) => {
where: { configurationId, isDefault: false },
});


const categoryCriteriaFields = await db.sequelize.query(
`
SELECT id, name FROM category_criteria
Expand All @@ -118,6 +123,30 @@ router.get("/configurations/:id/fieldNames", async (req, res) => {
);


const categoryCriteriaFieldsDefault = await db.sequelize.query(
`
SELECT id, name FROM category_criteria
WHERE priority_id IN (
SELECT id FROM priority
WHERE reserve_category_id in (SELECT id FROM reserve_category WHERE configuration_id = ${configurationId} AND is_default)
);
`,
{ type: SELECT }
);


const categoryCriteriaFieldsNotDefault = await db.sequelize.query(
`
SELECT id, name FROM category_criteria
WHERE priority_id IN (
SELECT id FROM priority
WHERE reserve_category_id in (SELECT id FROM reserve_category WHERE configuration_id = ${configurationId} AND NOT is_default)
);
`,
{ type: SELECT }
);


const possibleValues = await Promise.all(categoryCriteriaFields[0].map(async (criteria) => {
const values = await db.sequelize.query(
`
Expand All @@ -140,17 +169,29 @@ router.get("/configurations/:id/fieldNames", async (req, res) => {
}, {})


const numericCriteriaFields = await db.sequelize.query(
const numericCriteriaFieldsRequired = await db.sequelize.query(
`
SELECT name, min, max FROM numeric_criteria
WHERE priority_id IN (
SELECT id FROM priority
WHERE reserve_category_id in (SELECT id FROM reserve_category WHERE configuration_id = ${configurationId})
WHERE reserve_category_id in (SELECT id FROM reserve_category WHERE configuration_id = ${configurationId} AND is_default)
);
`,
{ type: SELECT }
);

const numericCriteriaFieldsNotRequired = await db.sequelize.query(
`
SELECT name, min, max FROM numeric_criteria
WHERE priority_id IN (
SELECT id FROM priority
WHERE reserve_category_id in (SELECT id FROM reserve_category WHERE configuration_id = ${configurationId} AND NOT is_default)
);
`,
{ type: SELECT }
);


const names = new Set()

const fieldNames = [
Expand All @@ -159,14 +200,27 @@ router.get("/configurations/:id/fieldNames", async (req, res) => {
reserveCategoryNames.forEach((cat) => {
if (!names.has(cat.name)) {
fieldNames.push({
name: "is_" + cat.name.toLowerCase().split(" ").join("_"),
name: "is_eligible_for_reserve_cat_" + cat.name.toLowerCase().split(" ").join("_"),
required: true,
dataType: "BOOLEAN",
})
names.add(cat.name)
}
});
categoryCriteriaFields[0].forEach((criteria) => {

categoryCriteriaFieldsDefault[0].forEach((criteria) => {
if (!names.has(criteria.name)) {
fieldNames.push({
name: criteria.name.toLowerCase().split(" ").join("_"),
required: true,
dataType: "STRING",
possibleValues: possibleValuesMap[criteria.id]
})
names.add(criteria.name)
}
});

categoryCriteriaFieldsNotDefault[0].forEach((criteria) => {
if (!names.has(criteria.name)) {
fieldNames.push({
name: criteria.name.toLowerCase().split(" ").join("_"),
Expand All @@ -177,7 +231,20 @@ router.get("/configurations/:id/fieldNames", async (req, res) => {
names.add(criteria.name)
}
});
numericCriteriaFields[0].forEach((criteria) => {

numericCriteriaFieldsRequired[0].forEach((criteria) => {
if (!names.has(criteria.name)) {
fieldNames.push({
name: criteria.name.toLowerCase().split(" ").join("_"),
required: true,
dataType: "NUMBER",
possibleValues: { min: criteria.min, max: criteria.max }
})
names.add(criteria.name)
}
});

numericCriteriaFieldsNotRequired[0].forEach((criteria) => {
if (!names.has(criteria.name)) {
fieldNames.push({
name: criteria.name.toLowerCase().split(" ").join("_"),
Expand All @@ -189,6 +256,9 @@ router.get("/configurations/:id/fieldNames", async (req, res) => {
}
});




res.json(fieldNames);
});

Expand Down
8 changes: 4 additions & 4 deletions src/api/main/routes/patients.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ router.post("/patients", async (req, res) => {

// add reserve categories
const reserveCategoryFieldNames = fields
.filter((f) => f.startsWith("is_") && rawPat[f])
.map((f) => f.substr(3));
.filter((f) => f.startsWith("is_eligible_for_reserve_cat_") && rawPat[f])
.map((f) => f.substr(28));
const reserveCategories = db.reserveCategory.findAll({
where: {
configurationId,
Expand Down Expand Up @@ -76,7 +76,7 @@ router.post("/patients", async (req, res) => {

// add numeric criteria values
const possibleNumericCriteriaFields = fields.filter(
(f) => !f.startsWith("is_")
(f) => !f.startsWith("is_eligible_for_reserve_cat_")
);
const numericCriteria = db.numericCriteria.findAll({
where: {
Expand Down Expand Up @@ -129,7 +129,7 @@ router.post("/patients", async (req, res) => {

// add category criteria values
const possibleCategoryCriteriaFields = fields.filter(
(f) => !f.startsWith("is_")
(f) => !f.startsWith("is_eligible_for_reserve_cat_")
);
const categoryCriteria = db.categoryCriteria.findAll({
where: { name: { [Op.in]: possibleCategoryCriteriaFields } },
Expand Down
34 changes: 12 additions & 22 deletions src/api/main/routes/source_files.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ router.get('/sourceFiles/:id', async (req, res) => {
return res.json(await db.sourceFile.findOne({ where: { id } }))
})

// GET one source file id
// GET nth reserve patients
router.get('/sourceFiles/:id/nthReservePatients', async (req, res) => {
const { db } = req
const id = req.params.id
Expand All @@ -47,6 +47,13 @@ router.get('/sourceFiles/:id/nthReservePatients', async (req, res) => {
)
})

// GET the number of left over units for reserve instance
router.get('/sourceFiles/:id/leftOver', async (req, res) => {
const { db } = req
const id = req.params.id
return res.json((await db.sourceFile.findOne({ where: { id } })).left_over)
})

// GET all patients for a source file
router.get('/sourceFiles/:id/patients', async (req, res) => {
const { db } = req
Expand All @@ -55,7 +62,7 @@ router.get('/sourceFiles/:id/patients', async (req, res) => {
if (req.query.givenUnit)
filterLosers += `and ${
req.query.givenUnit === 'false' ? 'not' : ''
} given_unit`
} given_unit`

return res.json(await getPatientsWithAttributes(db, id, filterLosers))
})
Expand Down Expand Up @@ -85,7 +92,6 @@ router.post('/sourceFiles/:id/process', async (req, res) => {
})
)


const patients = await Promise.all(
(
await db.patient.findAll({
Expand All @@ -105,17 +111,13 @@ router.post('/sourceFiles/:id/process', async (req, res) => {
let given = 0
let i = 0
while (i < f.patients.length) {


if (given < f.size && !selectedPatients.has(f.patients[i])) {

selectedPatients.add(f.patients[i])
allocatedPatientGroups[f.patients[i]] = f.name
given += 1
notSelectedPatients.delete(f.patients[i])

if (given == f.size) {

nthReservePatients.push({
name: f.name,
nthRecipientPrimaryId: f.patients[i],
Expand All @@ -128,20 +130,8 @@ router.post('/sourceFiles/:id/process', async (req, res) => {
leftOver += f.size - given
})

const notSelectedPatientsArray = Array.from(notSelectedPatients)
let i = 0
// give left over to unallocated patients if there are any
while (leftOver > 0 && i < notSelectedPatientsArray.length) {
const pat = notSelectedPatientsArray[i]
selectedPatients.add(pat)
allocatedPatientGroups[pat] = 'None'
leftOver -= 1
i += 1
}

// update patients
selectedPatients.forEach(async (pId) => {

const patient = await db.patient.findOne({ where: { id: pId } })
patient.given_unit = true
patient.group_allocated_under = allocatedPatientGroups[pId]
Expand All @@ -150,9 +140,9 @@ router.post('/sourceFiles/:id/process', async (req, res) => {

const nthReservePatientsWithNames = await Promise.all(
nthReservePatients.map(async (f) => {
const name = (
await db.patient.findOne({ where: { id: f.nthRecipientPrimaryId } })
)
const name = await db.patient.findOne({
where: { id: f.nthRecipientPrimaryId },
})

return { name: f.name, nthRecipientId: name.dataValues.recipient_id }
})
Expand Down
18 changes: 18 additions & 0 deletions src/notarize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require('dotenv').config();
const { notarize } = require('electron-notarize');

exports.default = async function notarizing(context) {
const { electronPlatformName, appOutDir } = context;
if (electronPlatformName !== 'darwin') {
return;
}

const appName = context.packager.appInfo.productFilename;

return await notarize({
appBundleId: 'project.reserve',
appPath: `${appOutDir}/${appName}.app`,
appleId: process.env.APPLEID,
appleIdPassword: process.env.APPLEIDPASS,
});
};
3 changes: 2 additions & 1 deletion src/public/components/ConfigSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default {
},
}
</script>
<style lang="stylus">
<style scoped lang="stylus">
.configSummaryContainer {
grid-column: span 3;
margin: auto;
Expand Down Expand Up @@ -174,6 +174,7 @@ export default {
border-radius: 18px;
background-color: var(--light-grey);
padding: 9px 18px;
word-break: break-word;
}
.iconWrapper {
position: relative;
Expand Down
Loading