-
Notifications
You must be signed in to change notification settings - Fork 87
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
[WIP] merge 2.3 into 2.4 #4904
Closed
Closed
[WIP] merge 2.3 into 2.4 #4904
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4647642
Port Offline feature from older ngeo version
gberaudo a140465
Make eslint happy
gberaudo c4e92a7
Simplify imports
gberaudo 8531beb
Use same signature for webpack.dev.js and webpack.prod.js
gberaudo 1469f6e
Revert "Use same signature for webpack.dev.js and webpack.prod.js"
gberaudo 30dcb78
Allow passing a plain service to the Offline service manager
gberaudo 2580af7
Merge branch 'allow_overriding_vector_encoder' into port_offline_feature
gberaudo c19561f
Add improvements for apps
gberaudo 4c27b6c
Merge pull request #4348 from camptocamp/port_offline_feature
llienher bd4ef6a
Merge remote-tracking branch 'upstream/2.3' into pull_2.3_in_2.4
llienher 34a8d91
Fix various typescript errors
llienher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html ng-app='app'> | ||
<head> | ||
<title>Offline example</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" | ||
content="initial-scale=1.0, user-scalable=no, width=device-width"> | ||
<meta name="mobile-web-app-capable" content="yes"> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.7.3/localforage.min.js"></script> | ||
</head> | ||
<body ng-controller="MainController as ctrl" ng-class="{offline: ctrl.ngeoNetworkStatus.isDisconnected()}"> | ||
<div class="offline-msg alert-danger" translate>You are currently offline.</div> | ||
<div id="map" ngeo-map="ctrl.map"> | ||
<ngeo-offline | ||
ngeo-offline-map="ctrl.map" | ||
ngeo-offline-extentsize="ctrl.offlineExtentSize"> | ||
</ngeo-offline> | ||
</div> | ||
<p id="desc">This example shows how to use the <code><a href="../apidoc/ngeo.offline.component.html" title="Read our documentation">ngeo-offline</a></code> component.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* @module app.offline | ||
*/ | ||
const exports = {}; | ||
|
||
import './offline.less'; | ||
import './common_dependencies.js'; | ||
import olMap from 'ol/Map.js'; | ||
|
||
import olView from 'ol/View.js'; | ||
import olLayerTile from 'ol/layer/Tile.js'; | ||
import olSourceOSM from 'ol/source/OSM.js'; | ||
import ngeoMapModule from 'ngeo/map/module.js'; | ||
import ngeoOfflineModule from 'ngeo/offline/module.js'; | ||
import ngeoOfflineConfiguration from 'ngeo/offline/Configuration.js'; | ||
import NgeoOfflineServiceManager from 'ngeo/offline/ServiceManager.js'; | ||
import angular from 'angular'; | ||
|
||
|
||
// Useful to work on example - remove me later | ||
import 'bootstrap/js/modal.js'; | ||
import 'jquery-ui/ui/widgets/resizable.js'; | ||
import 'jquery-ui/ui/widgets/draggable.js'; | ||
|
||
/** @type {!angular.IModule} **/ | ||
exports.module = angular.module('app', [ | ||
'gettext', | ||
ngeoMapModule.name, | ||
ngeoOfflineModule.name, | ||
NgeoOfflineServiceManager.module.name, | ||
]); | ||
|
||
exports.module.value('ngeoOfflineTestUrl', '../../src/offline/component.html'); | ||
|
||
// Define the offline download configuration service | ||
ngeoOfflineModule.service('ngeoOfflineConfiguration', ngeoOfflineConfiguration); | ||
|
||
class MainController { | ||
|
||
/** | ||
* @param {ngeoFeatureOverlayMgr} ngeoFeatureOverlayMgr ngeo feature overlay manager service. | ||
* @param {ngeoNetworkStatus} ngeoNetworkStatus ngeo network status service. | ||
* @param {NgeoOfflineServiceManager} ngeoOfflineServiceManager ngeo offline service. | ||
* @ngInject | ||
*/ | ||
constructor(ngeoFeatureOverlayMgr, ngeoNetworkStatus, ngeoOfflineServiceManager) { | ||
|
||
/** | ||
* Save a square of 10 km sideways (Map's unit is the meter). | ||
* @type {number} | ||
* @export | ||
*/ | ||
this.offlineExtentSize = 10000; | ||
|
||
/** | ||
* @type {ngeoNetworkStatus} | ||
* @export | ||
*/ | ||
this.ngeoNetworkStatus = ngeoNetworkStatus; | ||
|
||
/** | ||
* @type {ol.Map} | ||
* @export | ||
*/ | ||
this.map = new olMap({ | ||
layers: [ | ||
new olLayerTile({ | ||
source: new olSourceOSM() | ||
}) | ||
], | ||
view: new olView({ | ||
center: [352379, 5172733], | ||
zoom: 4 | ||
}) | ||
}); | ||
|
||
ngeoFeatureOverlayMgr.init(this.map); | ||
|
||
ngeoOfflineServiceManager.setSaveService('offlineDownloader'); | ||
ngeoOfflineServiceManager.setRestoreService('ngeoOfflineRestorer'); | ||
} | ||
} | ||
|
||
|
||
exports.module.controller('MainController', MainController); | ||
|
||
|
||
export default exports; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
@import "~bootstrap/dist/css/bootstrap.css"; | ||
@import "~font-awesome/less/font-awesome.less"; | ||
|
||
#map { | ||
width: 600px; | ||
height: 400px; | ||
position: relative; | ||
} | ||
|
||
ngeo-offline { | ||
div { | ||
z-index: 1; | ||
} | ||
.main-button { | ||
position: absolute; | ||
right: 1rem; | ||
bottom: 5rem; | ||
cursor: pointer; | ||
.no-data { | ||
color: black; | ||
} | ||
.with-data { | ||
color: red; | ||
} | ||
.no-data, .with-data { | ||
background-color: white; | ||
text-align: center; | ||
font-size: 2.5rem; | ||
line-height: 2rem; | ||
border-radius: 2rem; | ||
font-family: FontAwesome; | ||
&::after { | ||
content: @fa-var-arrow-circle-o-down; | ||
} | ||
} | ||
} | ||
|
||
.validate-extent { | ||
position: absolute; | ||
bottom: 0.5rem; | ||
width: 10rem; | ||
left: calc(~"50% - 5rem"); | ||
} | ||
|
||
.in-progress { | ||
position: absolute; | ||
left: calc(~"50% - 3.3rem"); | ||
top: calc(~"50% - 3rem"); | ||
color: white; | ||
font-weight: bold; | ||
background-color: #337ab7; | ||
padding: 2rem 2rem; | ||
border-radius: 1rem; | ||
} | ||
|
||
.modal-content { | ||
width: 30rem; | ||
} | ||
|
||
.modal-body { | ||
button { | ||
display: block; | ||
margin: 0.5rem auto; | ||
width: 25rem; | ||
} | ||
} | ||
} | ||
|
||
.offline-msg { | ||
display: none; | ||
} | ||
.offline .offline-msg { | ||
display: block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import angular from 'angular'; | ||
/** | ||
* @module ngeo.message.modalComponent | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be removed |
||
import 'jquery-ui/ui/widgets/draggable.js'; | ||
import 'bootstrap/js/src/modal.js'; | ||
import angular from 'angular'; | ||
|
||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/** | ||
* @module ngeo.offline.AbstractLocalforageWrapper | ||
*/ | ||
/** | ||
* @typedef {{ | ||
* id: number, | ||
* plugin: string, | ||
* command: string, | ||
* args: !Array<*>, | ||
* context: (*|undefined) | ||
* }} | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
let Action; | ||
|
||
/** | ||
* @abstract | ||
*/ | ||
const exports = class AbstractLocalforageWrapper { | ||
constructor() { | ||
this.waitingPromises_ = new Map(); | ||
this.currentId_ = 0; | ||
} | ||
|
||
setItem(...args) { | ||
return this.createAction('setItem', ...args); | ||
} | ||
|
||
getItem(...args) { | ||
return this.createAction('getItem', ...args); | ||
} | ||
|
||
clear() { | ||
return this.createAction('clear'); | ||
} | ||
|
||
config(...args) { | ||
return this.createAction('config', ...args); | ||
} | ||
|
||
/** | ||
* @export | ||
* @param {string} command . | ||
* @param {...*} args . | ||
* @return {Promise} . | ||
*/ | ||
createAction(command, ...args) { | ||
const id = ++this.currentId_; | ||
/** | ||
* @type {Action} | ||
*/ | ||
const action = { | ||
'plugin': 'localforage', | ||
'command': command, | ||
'args': args, | ||
'id': id | ||
}; | ||
const waitingPromise = {}; | ||
const promise = new Promise((resolve, reject) => { | ||
waitingPromise['resolve'] = resolve; | ||
waitingPromise['reject'] = reject; | ||
}); | ||
this.waitingPromises_.set(id, waitingPromise); | ||
this.postToBackend(action); | ||
return promise; | ||
} | ||
|
||
/** | ||
* @export | ||
* @param {*} event . | ||
*/ | ||
receiveMessage(event) { | ||
/** | ||
* @type {Action} | ||
*/ | ||
const action = event['data']; | ||
const id = action['id']; | ||
const command = action['command']; | ||
const args = action['args'] || []; | ||
const context = action['context']; | ||
const msg = action['msg']; | ||
|
||
const waitingPromise = this.waitingPromises_.get(id); | ||
if (command === 'error') { | ||
console.error(msg, args, context); | ||
if (waitingPromise) { | ||
waitingPromise.reject(args, context); | ||
this.waitingPromises_.delete(id); | ||
} | ||
} else if (command === 'response') { | ||
waitingPromise.resolve(...args); | ||
this.waitingPromises_.delete(id); | ||
} else { | ||
console.error('Unhandled command', JSON.stringify(action, null, '\t')); | ||
} | ||
} | ||
|
||
/** | ||
* @abstract | ||
* @protected | ||
* @param {Action} action . | ||
*/ | ||
postToBackend(action) { | ||
} | ||
}; | ||
|
||
|
||
export default exports; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be removed?