Skip to content
Merged

Dev #412

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
4f12a73
form.js adapted to read multiple features
Jun 9, 2020
475985d
improved formatting
Jun 9, 2020
ff933f9
projectDraf created for testing multiple geometries
Jun 10, 2020
e38bfcb
created test function for multiple polygons
Jun 10, 2020
2241b43
test single and multiple geometry for project creation
Jun 16, 2020
6a3bd29
test functions for overlapping geoms
Jul 1, 2020
293c8de
groups overlap
Jul 2, 2020
6417fa2
adjust structure of test for groups overlap
Hagellach37 Jul 2, 2020
62b45d8
add assertion to test number of groups correct
Hagellach37 Jul 2, 2020
f6a4c45
add some print and rename variable
Hagellach37 Jul 2, 2020
61a7a19
fix test
Hagellach37 Jul 2, 2020
5bbc06f
add test for polygons within
Hagellach37 Jul 2, 2020
6baa368
add test for polygons within
Hagellach37 Jul 2, 2020
b70f320
add test for polygons within
Hagellach37 Jul 2, 2020
c324f0c
wip groups within other groups
Hagellach37 Jul 2, 2020
6ac8e2b
fix bug in zoom level
Hagellach37 Jul 2, 2020
1c041f0
trying to find out bug while saving project geometry to postgres
Jul 8, 2020
e8145b0
trying to save multiple geometries into postgres
Jul 8, 2020
cdb18c9
changed geometry column in DB
Jul 8, 2020
42f8437
found bug postgres import #374
Hagellach37 Jul 8, 2020
0869347
fix postgres import bug and use geometry collection instead of list
Hagellach37 Jul 8, 2020
984e299
multiple geoms dissolve return none
Jul 20, 2020
4716d3a
multiple polygons as input does not incorporate second polygon
Jul 23, 2020
6f93029
completeness tutorial adjusted path to geojson file
Jul 27, 2020
e454a8b
put number of features for input geom in definitions.py
Jul 28, 2020
ccf8932
union cascaded outside of loop
Jul 29, 2020
aa1bd3f
Delete project_geom_-MC6zDSrCeUXzyCCwTQ_.geojson
Hagellach37 Aug 4, 2020
59edbeb
Delete project_geom_-MClQtGCC_sgKTB7mAeW.geojson
Hagellach37 Aug 4, 2020
b0af0ec
Delete project_geom_-MCw-n1trbI1yzqDEOuc.geojson
TahiraU Aug 4, 2020
3d37038
Delete project_geom_-MCw0zzwMY4ZNExGSrvw.geojson
TahiraU Aug 4, 2020
f44d1d5
Delete project_geom_-MCwCkpstMiHcHQmL3Ex.geojson
TahiraU Aug 4, 2020
40dafce
Delete raw_input_-MC6vz49TfX2dk-6myDd.geojson
TahiraU Aug 4, 2020
eb2cce6
Delete raw_input_-MC6zDSrCeUXzyCCwTQ_.geojson
TahiraU Aug 4, 2020
de09816
Delete raw_input_-MClQtGCC_sgKTB7mAeW.geojson
TahiraU Aug 4, 2020
0601b29
Delete raw_input_-MCw-n1trbI1yzqDEOuc.geojson
TahiraU Aug 4, 2020
bde303c
Delete raw_input_-MCw0zzwMY4ZNExGSrvw.geojson
TahiraU Aug 4, 2020
85e5edc
Delete raw_input_-MCwCkpstMiHcHQmL3Ex.geojson
TahiraU Aug 4, 2020
fcee8d8
Delete mapswipe_workers.log.2020-07-13
TahiraU Aug 4, 2020
5d400d3
Delete mapswipe_workers.log.2020-07-21
TahiraU Aug 4, 2020
2e423b4
Delete mapswipe_workers.log.2020-07-20
TahiraU Aug 4, 2020
92ddb56
Delete raw_groups_-MC6vz49TfX2dk-6myDd.txt
TahiraU Aug 4, 2020
87e8695
Delete raw_tasks_-MC6vz49TfX2dk-6myDd.txt
TahiraU Aug 4, 2020
3c38233
test function improved
Aug 4, 2020
8a1326f
Merge branch 'multiPolygons' of https://github.com/mapswipe/python-ma…
Aug 4, 2020
f401e03
max input geometries extended to 10
Aug 4, 2020
84aeb92
merge multiPolygons into dev
Hagellach37 Aug 4, 2020
3c660ed
Merge pull request #406 from mapswipe/hotfix-firebase-db-rules-tutorial
Hagellach37 Aug 10, 2020
3411036
set up manager dasboard to upload tutorial data #409
Hagellach37 Aug 15, 2020
8b4a62f
Update database.rules.json
Hagellach37 Aug 18, 2020
64fb4f9
change datastructure for tutorials
Hagellach37 Aug 20, 2020
f47027e
add solid waste tutorial
Hagellach37 Aug 20, 2020
1aa571c
change db rules to query multiple tutorial to allow filter in the app
Hagellach37 Aug 20, 2020
45f787a
change db rules to query multiple tutorial to allow filter in the app
Hagellach37 Aug 20, 2020
84fe8f4
add image upload to tutorial creation page
Hagellach37 Sep 9, 2020
5cf43d7
add example images as attributes to tutorial
Hagellach37 Sep 9, 2020
2df97cc
add max tasks per project to project creation form
Hagellach37 Sep 9, 2020
9cf33ca
add max tasks per user to project creation
Hagellach37 Sep 9, 2020
c549009
small bugfix duplicate attribute for projectType
Hagellach37 Sep 9, 2020
d9f0a4e
maxTasksPerUser as integer
Hagellach37 Sep 9, 2020
6057749
add tutorial and add tutorial Id to project
Hagellach37 Sep 10, 2020
1412188
remove unused attributes from tutorial
Hagellach37 Sep 10, 2020
2376855
add tutorial creation workflow to run command
Hagellach37 Sep 10, 2020
71ce357
add script to add tutorialId to all projects
Hagellach37 Sep 10, 2020
4869863
work on comments
Hagellach37 Sep 10, 2020
0aab6d5
Merge pull request #410 from mapswipe/tutorial-new-structure
Hagellach37 Sep 10, 2020
364fbc0
add counters on project level
Hagellach37 Sep 10, 2020
b604399
Merge pull request #411 from mapswipe/firebase_functions_project_counts
Hagellach37 Sep 10, 2020
31a798c
change word on tutorial creation page
Hagellach37 Sep 10, 2020
5242993
add projectType to script
Hagellach37 Sep 10, 2020
8842551
don't change data type of task geometry in postgres
Hagellach37 Sep 10, 2020
46c05e4
adjust text for build area tutorial
Hagellach37 Sep 10, 2020
71dd342
fix xMax in tutorial
Hagellach37 Sep 10, 2020
acd9e81
update tutorial text for solid waste
Hagellach37 Sep 11, 2020
89d9fa0
add geojson with solid waste tutorial examples
Hagellach37 Sep 11, 2020
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ mapswipe_workers/config/configuration.json
# don´t upload data dir
data/

mapswipe-data/

# don't upload app config for project managers dashboard
app.js

Expand Down
12 changes: 11 additions & 1 deletion firebase/database.rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
||
(auth != null && query.orderByChild == 'status' && query.equalTo == 'build_area_tutorial' && query.limitToFirst == 1)
||
(auth != null && query.orderByChild == 'status' && query.equalTo == 'completeness_tutorial' && query.limitToFirst == 1)
||
// only team members can query by their own teamId
(auth != null && query.orderByChild == 'teamId' &&
query.equalTo == root.child('/v2/users/'+auth.uid+'/teamId').val())
Expand Down Expand Up @@ -45,6 +47,14 @@
"complete"
]
},
"tutorialDrafts": {
// only project managers can write projectDrafts
".read": false,
".write": "auth.token.projectManager === true",
".indexOn": [
"complete"
]
},
"groups": {
".write": false,
".read": "auth.token.projectManager === true",
Expand Down Expand Up @@ -137,4 +147,4 @@
}
}
}
}
}
25 changes: 24 additions & 1 deletion firebase/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ exports.counter = functions.database.ref('/v2/results/{projectId}/{groupId}/{use
const endTimeRef = admin.database().ref('/v2/results/'+context.params.projectId+'/'+context.params.groupId+'/'+context.params.userId+'/endTime')
const timeSpentMappingRef = admin.database().ref('/v2/results/'+context.params.projectId+'/'+context.params.groupId+'/'+context.params.userId+'/timeSpentMappingRef')

// references for project based counters for tasks and groups
const projectTaskContributionCountRef = admin.database().ref('/v2/users/'+context.params.userId+'/contributions/'+context.params.projectId+'/taskContributionCount')
const projectGroupContributionCountRef = admin.database().ref('/v2/users/'+context.params.userId+'/contributions/'+context.params.projectId+'/groupContributionCount')

// Counter for groups
const groupFinishedCount = groupFinishedCountRef.transaction((currentCount) => {
return currentCount + 1
Expand Down Expand Up @@ -118,6 +122,25 @@ exports.counter = functions.database.ref('/v2/results/{projectId}/{groupId}/{use
})
promises.push(contributions)

// counters for tasks and groups per user and per project
const projectTaskContributionCount = numberOfTasksRef.once('value')
.then((dataSnapshot) => {
const numberOfTasks = dataSnapshot.val()
return numberOfTasks
})
.then((numberOfTasks) => {
return projectTaskContributionCountRef.transaction((currentCount) => {
return currentCount + numberOfTasks
})
})
promises.push(projectTaskContributionCount)

// Counter for groups
const projectGroupContributionCount = projectGroupContributionCountRef.transaction((currentCount) => {
return currentCount + 1
});
promises.push(projectGroupContributionCount)

// // TODO: Does not work
// const timeSpentMapping = timeSpentMappingRef.set((timeSpentMapping) => {
// const startTime = startTimeRef.once('value')
Expand Down Expand Up @@ -268,4 +291,4 @@ exports.decProjectProgress = functions.database.ref('/v2/projects/{projectId}/re
})
})
return projectProgress
})
})
2 changes: 1 addition & 1 deletion firebase/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"eslint-utils": "^1.4.1"
},
"engines": {
"node": "8"
"node": "10"
},
"private": true
}
24 changes: 23 additions & 1 deletion manager_dashboard/manager_dashboard/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
<li class="nav-item active">
<a class="nav-link" href="create.html">CREATE PROJECTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="tutorial.html">CREATE TUTORIAL</a>
</li>
<li class="nav-item">
<a class="nav-link" href="manage.html">MANAGE PROJECTS</a>
</li>
Expand Down Expand Up @@ -141,7 +144,7 @@ <h3>Basic Project Information</h3>
</li>
<li>
<label for="visibility">Visibility</label>
<select name="visibility" id="visibility">
<select name="visibility" id="visibility" onchange="displayTeamSettings(this.value)">
<option value="public">Public</option>
</select>
<span>Choose either "public" or select the team for which this project should be displayed.</span>
Expand All @@ -161,6 +164,12 @@ <h3>Basic Project Information</h3>
</select>
<span>Select the type of your project.</span>
</li>
<li>
<label for="tutorial">Tutorial</label>
<select name="tutorial" id="tutorial">
</select>
<span>Choose which tutorial should be used for this project. Make sure that this aligns with what you are looking for.</span>
</li>
<li>
<label for="projectDetails">Project Details</label>
<textarea name="projectDetails" id="projectDetails" onkeyup="adjust_textarea(this)"></textarea>
Expand Down Expand Up @@ -233,6 +242,19 @@ <h3>Project Tasks Geometry</h3>
</ul>
</form>
</div>
<div class="container" id="form_team_settings">
<h3>Team Settings</h3>
<form class="form-style-7">
<ul>
<li>
<label for="maxTasksPerUser">Max Tasks Per User</label>
<input type="number" name="maxTasksPerUser" id="maxTasksPerUser" value="-1" min="-1">
<span>How many tasks each user is allowed to work on for this project. "-1" indicates that no limit is set.</span>
</li>
<li></li>
</ul>
</form>
</div>
<div class="container" id="form_tile_server_a">
<h3>Tile Server A</h3>
<form class="form-style-7">
Expand Down
3 changes: 3 additions & 0 deletions manager_dashboard/manager_dashboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
<li class="nav-item">
<a class="nav-link" href="create.html">CREATE PROJECTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="tutorial.html">CREATE TUTORIAL</a>
</li>
<li class="nav-item">
<a class="nav-link" href="manage.html">MANAGE PROJECTS</a>
</li>
Expand Down
194 changes: 194 additions & 0 deletions manager_dashboard/manager_dashboard/js/forms-tutorial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
//auto expand textarea
function adjust_textarea(h) {
h.style.height = "20px";
h.style.height = (h.scrollHeight)+"px";
}

function initForm() {
displayProjectTypeForm("build_area")
}

function openImageFile(event) {
var input = event.target;
console.log(event.target.id)
element_id = event.target.id + 'File'

var reader = new FileReader();
reader.onload = function(){
try {
var dataURL = reader.result;
var output = document.getElementById(element_id);
output.src = dataURL;
}
catch(err) {
element_id = event.target.id + 'Text'
var output = document.getElementById(element_id);
output.innerHTML = '<b>Error reading Image file</b><br>' + err;
}
};
reader.readAsDataURL(input.files[0]);
};

function displayProjectTypeForm(projectType) {
document.getElementById("projectType").value = projectType;
switch (projectType) {
case "build_area":
displayTileServer("bing", "A");
document.getElementById("form_zoom_level").style.display = "block";
document.getElementById("form_tile_server_a").style.display = "block";
document.getElementById("form_tile_server_b").style.display = "None";
break;
case "footprint":
displayTileServer("bing", "A");
document.getElementById("form_zoom_level").style.display = "None";
document.getElementById("form_tile_server_a").style.display = "block";
document.getElementById("form_tile_server_b").style.display = "None";
break;
case "change_detection":
case "completeness":
displayTileServer("bing", "A");
displayTileServer("bing", "B");
document.getElementById("form_zoom_level").style.display = "block";
document.getElementById("form_tile_server_a").style.display = "block";
document.getElementById("form_tile_server_b").style.display = "block";
break;
}
}

function addTileServerCredits (tileServerName, which) {
var credits = {
"bing": "© 2019 Microsoft Corporation, Earthstar Geographics SIO",
"maxar_premium": "© 2019 Maxar",
"maxar_standard": "© 2019 Maxar",
"esri": "© 2019 ESRI",
"esri_beta": "© 2019 ESRI",
"mapbox": "© 2019 MapBox",
"sinergise": "© 2019 Sinergise",
"custom": "Please add imagery credits here."
}
document.getElementById("tileServer"+which+"Credits").value = credits[tileServerName]
}


function displayTileServer (tileServerName, which) {
switch (tileServerName) {
case "custom":
document.getElementById("tileServer"+which+"UrlField").style.display = "block";
document.getElementById("tileServer"+which+"LayerNameField").style.display = "block";
break;
case "sinergise":
document.getElementById("tileServer"+which+"UrlField").style.display = "None";
document.getElementById("tileServer"+which+"LayerNameField").style.display = "block";
break;
default:
document.getElementById("tileServer"+which+"UrlField").style.display = "None";
document.getElementById("tileServer"+which+"LayerNameField").style.display = "None";
}
addTileServerCredits(tileServerName, which)
}

function clear_fields() {
console.log('clear fields.')
displayProjectTypeForm("build_area")
}

function displaySuccessMessage() {
//document.getElementById("import-formular").style.display = "None";
alert('Your project has been uploaded. It can take up to one hour for the project to appear in the dashboard.')
}

function displayImportForm() {
document.getElementById("import-formular").style.display = "block";
}

function openJsonFile(event) {
var input = event.target;

// clear info field
var info_output = document.getElementById("screenInfo");
info_output.innerHTML = '';
info_output.style.display = 'block'

// Check file size before loading
var filesize = input.files[0].size;
if (filesize > 1 * 1024 * 1024) {
var err='filesize is too big (max 1MB): ' + filesize/(1000*1000)
info_output.innerHTML = '<b>Error reading GeoJSON file</b><br>' + err;
info_output.style.display = 'block'
} else {
info_output.innerHTML += 'File Size is valid <br>';
info_output.style.display = 'block'

var reader = new FileReader();
reader.onload = function(){

try {
var text = reader.result;
var screensJsonData = JSON.parse(text)
// check number of screens
numberOfScreens = Object.keys(screensJsonData).length
console.log('number of screens: ' + numberOfScreens)

info_output.innerHTML += 'Number of Screens: ' + numberOfScreens + '<br>';
info_output.style.display = 'block'
screens = text

}
catch(err) {
info_output.innerHTML = '<b>Error reading JSON file</b><br>' + err;
info_output.style.display = 'block'
}
};
reader.readAsText(input.files[0]);
}
};

function openGeoJsonFile(event) {
var input = event.target;

// clear info field
var info_output = document.getElementById("tutorialTasksInfo");
info_output.innerHTML = '';
info_output.style.display = 'block'

// Check file size before loading
var filesize = input.files[0].size;
if (filesize > 1 * 1024 * 1024) {
var err='filesize is too big (max 1MB): ' + filesize/(1000*1000)
info_output.innerHTML = '<b>Error reading GeoJSON file</b><br>' + err;
info_output.style.display = 'block'
} else {
info_output.innerHTML += 'File Size is valid <br>';
info_output.style.display = 'block'

var reader = new FileReader();
reader.onload = function(){

try {
var text = reader.result;
var geoJsonData = JSON.parse(text)
// check number of screens
numberOfFeatures = Object.keys(geoJsonData["features"]).length
console.log('number of features: ' + numberOfFeatures)

info_output.innerHTML += 'Number of Features: ' + numberOfFeatures + '<br>';
info_output.style.display = 'block'
tutorialTasks = text

}
catch(err) {
info_output.innerHTML = '<b>Error reading GeoJSON file</b><br>' + err;
info_output.style.display = 'block'
}
};
reader.readAsText(input.files[0]);
}
};


function closeModal() {
var modal = document.getElementById("uploadModal");
modal.style.display = "none";
var modalSuccess = document.getElementById("modalSuccess");
modalSuccess.style.display = "none";
}
Loading