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

Feature/pwa #1558

Open
wants to merge 50 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b4b0e8a
AtlasOfLivingAustralia/biocollect#1532
temi May 31, 2023
5d1780c
AtlasOfLivingAustralia/biocollect#1532
temi Aug 1, 2023
dfaaca7
AtlasOfLivingAustralia/biocollect#1532
temi Aug 3, 2023
994ee3a
AtlasOfLivingAustralia/biocollect#1532
temi Aug 9, 2023
ee4a271
Implements additional project fields for biocollect initiator (#1541)…
jack-brinkman Aug 17, 2023
4b55142
AtlasOfLivingAustralia/biocollect#1532
temi Aug 28, 2023
6896004
AtlasOfLivingAustralia/biocollect#1532
temi Aug 28, 2023
03b000d
AtlasOfLivingAustralia/biocollect#1532
temi Aug 28, 2023
60e8de0
AtlasOfLivingAustralia/biocollect#1532
temi Aug 29, 2023
f470772
AtlasOfLivingAustralia/biocollect#1532
temi Sep 17, 2023
a1e3e03
Merge branch 'feature/cognito' into feature/pwa
temi Oct 6, 2023
eb90541
- updated chrome version
temi Oct 10, 2023
98ae5b9
- added storage management
temi Oct 12, 2023
091242e
- removed functional test
temi Oct 16, 2023
d29cdc9
- parameterised batch size
temi Oct 16, 2023
aa5c39a
- added prompt to reload when indexeddb connection fails
temi Oct 17, 2023
7650762
- notify parent when deletion is complete
temi Oct 19, 2023
e758106
- added a list of caches that should not be deleted
temi Dec 8, 2023
2e3273d
- added cache to delete as a separate config
temi Dec 12, 2023
0387aba
- checking in for testing
temi Feb 1, 2024
4f2cb56
- modified the page navigated to by back, cancel or save buttons
temi Feb 7, 2024
2f0eaf4
- added missing images.js
temi Feb 7, 2024
a7bea58
- added new navigation logic
temi Feb 8, 2024
6a1008a
- fixed a bug with map zoom in during caching
temi Feb 8, 2024
e5fc7eb
- added feature to select sites to download if survey sites larger th…
temi Feb 9, 2024
4df0c7e
- stacked table for pwa
temi May 6, 2024
8ae0db6
Merge branch 'master' into feature/pwa
temi May 10, 2024
a1066f5
- fixed incorrectly checked file
temi May 10, 2024
ddcafaf
- added missing libraries
temi May 12, 2024
deee49a
- added sw.js to asset exclusion list
temi May 12, 2024
b19903a
- added sw.js to minify exclusion list
temi May 12, 2024
c2641de
added default codec none on pwa config file
temi May 13, 2024
2186740
- resolve site regardless site update fails
temi May 14, 2024
1a26d41
- reordered components in survey offline page
temi May 31, 2024
3abaeec
- updated chrome version
temi May 31, 2024
aae9df0
- added site search feature
temi Jun 3, 2024
ba60f5c
- silently fail site download
temi Jun 4, 2024
c955dd5
Merge branch 'develop' into feature/pwa
temi Aug 29, 2024
5e2d4e5
migrated functional test to webdriverio
temi Sep 4, 2024
57af071
upgraded node version
temi Sep 13, 2024
c757ab3
- added pwa test cases
temi Sep 24, 2024
308c548
- WIP
temi Oct 1, 2024
721230d
- WIP
temi Oct 2, 2024
5663d5e
- WIP
temi Oct 3, 2024
cfda857
updated functional test code
temi Nov 15, 2024
5c2fa8e
updated packages
temi Nov 15, 2024
a28462b
updated script command
temi Nov 15, 2024
f89f138
headless mode
temi Nov 15, 2024
d9b128b
start ecodata first
temi Nov 17, 2024
f791efa
do not generate style sheet for test environment
temi Nov 18, 2024
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: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install nodejs
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20

- run: npm install

Expand Down
16 changes: 13 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ buildscript {
}
}

plugins {
id "com.gorylenko.gradle-git-properties" version "2.4.1"
}


version "$biocollectVersion"
group "au.org.ala"
Expand Down Expand Up @@ -111,6 +115,8 @@ dependencies {
implementation('org.grails.plugins:http-builder-helper:1.1.0') {
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}

implementation 'com.opencsv:opencsv:5.7.0'
implementation "org.apache.httpcomponents:httpclient:4.5.7"
runtimeOnly 'org.webjars:jquery:1.12.4'
implementation 'dk.glasius:external-config:3.0.0'
Expand Down Expand Up @@ -151,10 +157,13 @@ dependencies {
runtimeOnly 'com.bertramlabs.plugins:less-asset-pipeline:3.3.1'
implementation 'com.bertramlabs.plugins:sass-asset-pipeline:3.2.5'
implementation 'org.codehaus.groovy:groovy-dateutil:2.5.0'

implementation "com.nimbusds:nimbus-jose-jwt:9.25.6"
implementation "io.jsonwebtoken:jjwt-impl:0.11.5"
implementation "io.jsonwebtoken:jjwt-jackson:0.11.5"
implementation "io.jsonwebtoken:jjwt-api:0.11.5"
if (!Boolean.valueOf(inplace)) {
implementation "org.grails.plugins:ala-map-plugin:3.0.1"
implementation "org.grails.plugins:ecodata-client-plugin:7.0-SNAPSHOT"
implementation "org.grails.plugins:ecodata-client-plugin:7.0-PWA-SNAPSHOT"
}

testCompileOnly "org.grails:grails-test-mixins:3.3.0"
Expand Down Expand Up @@ -200,7 +209,8 @@ assets {
maxThreads = 6
minifyOptions = [
languageMode : 'ES6', //languageIn
targetLanguage: 'ES5', // languageOut
// targetLanguage: 'ES5', // languageOut
excludes: ['sw.js', '**/*.min.js']
]

includes = []
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
biocollectVersion=7.0-SNAPSHOT
biocollectVersion=7.0-PWA-SNAPSHOT
grailsVersion=6.2.0
grailsGradlePluginVersion=6.1.2
assetPipelineVersion=4.3.0
Expand Down
Binary file added grails-app/assets/images/map-not-cached.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 22 additions & 7 deletions grails-app/assets/javascripts/MapUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Biocollect.MapUtilities = {
var options = {baseLayer: undefined, otherLayers: {}};
baseLayers = baseLayers || [];
baseLayers.forEach(function (baseLayer) {
var baseConfig = Biocollect.MapUtilities.getBaseLayer(baseLayer.code);
var baseConfig = Biocollect.MapUtilities.getBaseLayer(baseLayer.code, baseLayer);
var title = baseConfig.title || baseLayer.displayText;
if (baseLayer.isSelected) {
options.baseLayer = baseConfig;
Expand All @@ -156,15 +156,18 @@ Biocollect.MapUtilities = {
/**
* Get {L.tileLayer | L.Google} base map for a given code.
* @param code
* @param config - used to get basemap url
* @returns {L.tileLayer | L.Google}
*/
getBaseLayer: function (code) {
var option, layer;
getBaseLayer: function (code, config) {
config = config || {};
var option, layer,
url = config.url;
switch (code) {
case 'minimal':
option = {
// See https://cartodb.com/location-data-services/basemaps/
url: 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png',
url: url || 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png',
options: {
subdomains: "abcd",
attribution: 'Map data &copy; <a target="_blank" rel="noopener noreferrer" href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, imagery &copy; <a target="_blank" rel="noopener noreferrer" href="http://cartodb.com/attributions">CartoDB</a>',
Expand All @@ -177,7 +180,7 @@ Biocollect.MapUtilities = {
case 'worldimagery':
option = {
// see https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9
url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
url: url || 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
options: {
attribution: '<a target="_blank" rel="noopener noreferrer" href="https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9">Tiles from Esri</a> &mdash; Sources: Esri, DigitalGlobe, Earthstar Geographics, CNES/Airbus DS, GeoEye, USDA FSA, USGS, Aerogrid, IGN, IGP, and the GIS User Community',
maxZoom: 21,
Expand All @@ -186,10 +189,22 @@ Biocollect.MapUtilities = {
};
layer = L.tileLayer(option.url, option.options);
break;
case 'maptilersatellite':
option = {
url: url || 'https://api.maptiler.com/maps/hybrid/256/{z}/{x}/{y}.jpg?key=O11Deo7fBLatChkUYGIH',
options: {
attribution: '<a href="https://www.maptiler.com/copyright/" target="_blank">© MapTiler</a> <a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap contributors</a>',
maxZoom: 21,
maxNativeZoom: 21
}
};
layer = L.tileLayer(option.url, option.options);
break;

case 'detailed':
option = {
// see https://wiki.openstreetmap.org/wiki/Standard_tile_layer
url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
url: url || 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
options: {
subdomains: "abc",
attribution: '&copy; <a target="_blank" rel="noopener noreferrer" href="https://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>',
Expand All @@ -202,7 +217,7 @@ Biocollect.MapUtilities = {
case 'topographic':
option = {
// see https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f
url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}',
url: url || 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}',
options: {
attribution: '<a target="_blank" rel="noopener noreferrer" href="https://www.arcgis.com/home/item.html?id=30e5fe3149c34df1ba922e6f5bbf808f">Tiles from Esri</a> &mdash; Sources: Esri, HERE, Garmin, Intermap, INCREMENT P, GEBCO, USGS, FAO, NPS, NRCAN, GeoBase, IGN, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), &copy; OpenStreetMap contributors, GIS User Community',
maxZoom: 21,
Expand Down
115 changes: 115 additions & 0 deletions grails-app/assets/javascripts/biocollect-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
var biocollect = {
utils: {
/**
* https://stackoverflow.com/a/20584396
* @param node
* @returns {*}
*/
nodeScriptReplace: function nodeScriptReplace(node) {
if (biocollect.utils.nodeScriptIs(node) === true) {
node.parentNode.replaceChild(biocollect.utils.nodeScriptClone(node), node);
} else {
var i = -1, children = node.childNodes;
while (++i < children.length) {
biocollect.utils.nodeScriptReplace(children[i]);
}
}

return node;
},

/**
* https://stackoverflow.com/a/20584396
* @param node
* @returns {HTMLScriptElement}
*/
nodeScriptClone: function nodeScriptClone(node) {
var script = document.createElement("script");
script.text = node.innerHTML;

var i = -1, attrs = node.attributes, attr;
while (++i < attrs.length) {
script.setAttribute((attr = attrs[i]).name, attr.value);
}
return script;
},

/**
* https://stackoverflow.com/a/20584396
* @param node
* @returns {boolean}
*/
nodeScriptIs: function nodeScriptIs(node) {
return node.tagName === 'SCRIPT';
},
readDocument: function readDocument(file) {
var deferred = $.Deferred();
if (file) {
var reader = new FileReader();
reader.onload = function (e) {
var contents = e.target.result;
deferred.resolve({data: {blob: contents, file: file}});
};

reader.onerror = function (e) {
deferred.reject({message: "Failed to read file" + file.name});
};

reader.readAsArrayBuffer(file);
} else {
deferred.reject();
}

return deferred.promise();
},
saveDocument: function saveDocument(result) {
var deferred = $.Deferred(),
file = result.data.file,
blob = result.data.blob,
document = biocollect.utils.createDocument(file, blob);

if (window.entities)
window.entities.saveDocument(document).then(deferred.resolve, function (error) {
deferred.reject({data: document, error: error});
});
else
deferred.reject();

return deferred.promise();
},
fetchDocument: function fetchDocument(result) {
var documentId = result.data;
return window.entities.offlineGetDocument(documentId);
},
addObjectURL: function addObjectURL(document) {
var url = ImageViewModel.createObjectURL(document);
if (url) {
document.thumbnailUrl = document.url = url;
}
},
createDocument: function createDocument(file, blob) {
return {
blob: blob,
contentType: file.type,
filename: file.name,
name: file.name,
filesize: file.size,
dateTaken: new Date(file.lastModified).toISOStringNoMillis(),
staged: false,
attribution: "",
licence: "",
entityUpdated: true
};
},
getReturnToAddressForPWA: function getReturnToAddressForPWA() {
const context = new URL(window.location.href).searchParams.get('context');
switch (context) {
case 'global':
return fcConfig.globalReturnToAddress;
case 'survey':
default:
return fcConfig.surveyReturnToAddress;
}
}
}
}
Loading
Loading