Skip to content

Commit

Permalink
limiting the dataset name length
Browse files Browse the repository at this point in the history
  • Loading branch information
ashaban committed Jul 9, 2019
1 parent a44d086 commit 42140d6
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 64 deletions.
Binary file modified dhis2App/GOFR.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion dhis2App/config/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"BACKEND_HOST": ".",
"BACKEND_PORT": "3000",
"BACKEND_PROTOCAL": "http"
"BACKEND_PROTOCOL": "http"
}
2 changes: 1 addition & 1 deletion dhis2App/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>GOFR</title><link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons" rel=stylesheet><link href=static/css/app.05e0d5f39fd1c80eac6b8575798ef273.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=static/js/manifest.37a2ecbb1d1b7e6c9ada.js></script><script type=text/javascript src=static/js/vendor.a48bd08214a109aa4c96.js></script><script type=text/javascript src=static/js/app.3f20db2e5b44adb9b216.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>GOFR</title><link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons" rel=stylesheet><link href=static/css/app.c5c260c6c77fd58936ed736f87b52faa.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=static/js/manifest.37a2ecbb1d1b7e6c9ada.js></script><script type=text/javascript src=static/js/vendor.a48bd08214a109aa4c96.js></script><script type=text/javascript src=static/js/app.8049fa39c176a9c3c906.js></script></body></html>
2 changes: 1 addition & 1 deletion facility-recon-backend/gui/config/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"BACKEND_HOST": ".",
"BACKEND_PORT": "3000",
"BACKEND_PROTOCAL": "http"
"BACKEND_PROTOCOL": "http"
}
2 changes: 1 addition & 1 deletion facility-recon-backend/gui/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>GOFR</title><link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons" rel=stylesheet><link href=static/css/app.05e0d5f39fd1c80eac6b8575798ef273.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=static/js/manifest.37a2ecbb1d1b7e6c9ada.js></script><script type=text/javascript src=static/js/vendor.a48bd08214a109aa4c96.js></script><script type=text/javascript src=static/js/app.3f20db2e5b44adb9b216.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>GOFR</title><link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons" rel=stylesheet><link href=static/css/app.c5c260c6c77fd58936ed736f87b52faa.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=static/js/manifest.37a2ecbb1d1b7e6c9ada.js></script><script type=text/javascript src=static/js/vendor.a48bd08214a109aa4c96.js></script><script type=text/javascript src=static/js/app.8049fa39c176a9c3c906.js></script></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

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

8 changes: 4 additions & 4 deletions facility-recon-backend/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2208,10 +2208,10 @@ if (cluster.isMaster) {
const mappingDB = fields.source1DB + userID + fields.source2DB;
if (!source1Id || !source2Id) {
winston.error({
error: 'Missing either Source1ID or Source2ID or both',
error: 'Missing either Source1 ID or Source2 ID or both',
});
res.status(400).json({
error: 'Missing either Source1ID or Source2ID or both',
error: 'Missing either Source1 ID or Source2 ID or both',
});
return;
}
Expand Down Expand Up @@ -2327,11 +2327,11 @@ if (cluster.isMaster) {
const totalLevels = fields.totalLevels;
if (!source1Id) {
winston.error({
error: 'Missing either Source1ID',
error: 'Missing either Source1 ID',
});
res.set('Access-Control-Allow-Origin', '*');
res.status(400).json({
error: 'Missing either Source1ID',
error: 'Missing either Source1 ID',
});
return;
}
Expand Down
42 changes: 1 addition & 41 deletions facility-recon-backend/lib/mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,46 +242,6 @@ module.exports = function () {
});
},

getMappingDBsOld(name, userID, callback) {
const mongoose = require('mongoose');
mongoose.connect(uri);
const dbConn = mongoose.connection;
const mappingDBs = [];
dbConn.on('error', console.error.bind(console, 'connection error:'));
dbConn.once('open', () => {
mongoose.connection.db.admin().command({
listDatabases: 1,
}, (error, results) => {
async.eachSeries(results.databases, (database, nxtDB) => {
let dbName1 = database.name;
if (dbName1.startsWith(name + userID) || dbName1.endsWith(userID + name)) {
dbName1 = dbName1.replace(name, '');
const splitedDB = dbName1.split(userID);
if (!splitedDB[0] == '' && !splitedDB[1] == '') {
return nxtDB();
}
dbName1 = dbName1.replace(userID, '');
// const db = results.databases.find(db => db.name === dbName1 + userID);
if (dbName1) {
mappingDBs.push(database.name);
return nxtDB();
}
return nxtDB();
}
if (dbName1.includes(name)) {
// this checks data source pair created from shared data sources
// check the posistion of 'name'
let checkingDB;
if (dbName1.startsWith(name)) {
checkingDB = dbName1.replace(name, '');
}
}
return nxtDB();
}, () => callback(mappingDBs));
});
});
},

getMappingDBs(dataSourceID, callback) {
const mappingDBs = [];
const mongoose = require('mongoose');
Expand All @@ -305,7 +265,7 @@ module.exports = function () {
if (pairs) {
pairs = JSON.parse(JSON.stringify(pairs));
async.eachSeries(pairs, (pair, nxtPair) => {
const db = pair.source1.name + pair.userID._id + pair.source2.name;
const db = mixin.toTitleCase(pair.source1.name) + pair.userID._id + mixin.toTitleCase(pair.source2.name);
mappingDBs.push({
source1Name: pair.source1.name,
source2Name: pair.source2.name,
Expand Down
2 changes: 1 addition & 1 deletion facility-recon-gui/config/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"BACKEND_HOST": ".",
"BACKEND_PORT": "3000",
"BACKEND_PROTOCAL": "http"
"BACKEND_PROTOCOL": "http"
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
v-model="name"
box
required
@blur="ensureNameUnique"
@input="ensureNameUnique"
:error-messages="nameErrors"
color="deep-purple"
label="Source Name"
></v-text-field>
Expand Down Expand Up @@ -145,7 +148,8 @@ export default {
},
data () {
return {
datasetLimitWarn: false
datasetLimitWarn: false,
nameErrors: []
}
},
methods: {
Expand All @@ -165,6 +169,26 @@ export default {
this.datasetLimitWarn = true
}
})
},
ensureNameUnique () {
this.nameErrors = []
if (this.name === '') {
return this.nameErrors.push('Name is required')
}
if (this.name.length > 35) {
return this.nameErrors.push('Name must not exceed 35 characters')
}
for (let invalidChar of this.invalidCharacters) {
if (this.name.indexOf(invalidChar) !== -1) {
return this.nameErrors.push('Name is invalid')
}
}
for (let dtSrc of this.$store.state.dataSources) {
if (dtSrc.name === this.name) {
this.nameErrors.push('This Name Exists')
return false
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,14 @@ export default {
if (this.uploadName === '') {
return this.uploadNameErrors.push('Upload name is required')
}
if (this.uploadName.length > 35) {
return this.uploadNameErrors.push('Name must not exceed 35 characters')
}
for (let invalidChar of this.invalidCharacters) {
if (this.uploadName.indexOf(invalidChar) !== -1) {
return this.uploadNameErrors.push('Name is invalid')
}
}
for (let dtSrc of this.$store.state.dataSources) {
if (dtSrc.name === this.uploadName) {
this.uploadNameErrors.push('This Name Exists')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</v-toolbar-title>
</v-toolbar>
<v-card-text>
Are you sure you want to delete {{server.name}} {{server.host}} <br> This will also delete the Database
This will delete the dataset from the database. Are you sure you want to delete {{server.name}} {{server.host}}
</v-card-text>
<v-card-actions>
<v-btn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {eventBus} from '../../main'
import {
eventBus
} from '../../main'
import axios from 'axios'
const backendServer = process.env.BACKEND_SERVER
export const dataSourcesMixin = {
Expand All @@ -11,7 +13,8 @@ export const dataSourcesMixin = {
sourceType: '',
limitShareByOrgId: false,
shareWithAll: false,
shareToSameOrgid: true
shareToSameOrgid: true,
invalidCharacters: ['"', '/', '\\', '.']
}
},
methods: {
Expand Down
4 changes: 2 additions & 2 deletions facility-recon-gui/src/components/FacilityReconScores.vue
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
>
<v-icon left>thumb_down</v-icon>No Match
</v-btn>
<span>Save this Source 1 location as having no match</span>
<span>Mark this source 1 location as being ignored</span>
</v-tooltip>
</v-flex>
<v-flex xs2>
Expand All @@ -291,7 +291,7 @@
slot="activator"
>
<v-btn
color="teal darken-2"
color="teal darken-6"
round
style="color: white;"
value="all"
Expand Down
3 changes: 2 additions & 1 deletion facility-recon-gui/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ getDHIS2StoreConfig((storeConfig) => {
} else {
if (guiConfig.BACKEND_HOST === '.') {
guiConfig.BACKEND_HOST = window.location.hostname
guiConfig.BACKEND_PROTOCOL = window.location.protocol.replace(':', '')
}
axios.defaults.baseURL = guiConfig.BACKEND_PROTOCAL + '://' + guiConfig.BACKEND_HOST + ':' + guiConfig.BACKEND_PORT
axios.defaults.baseURL = guiConfig.BACKEND_PROTOCOL + '://' + guiConfig.BACKEND_HOST + ':' + guiConfig.BACKEND_PORT
}
// get general config of App and pass it to the App component as props
let defaultGenerConfig = JSON.stringify(store.state.config.generalConfig)
Expand Down

0 comments on commit 42140d6

Please sign in to comment.