Skip to content

Commit

Permalink
Merge pull request #3149 from camptocamp/merge22
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin/2.2'
  • Loading branch information
sbrunner authored Nov 23, 2017
2 parents 2195b36 + 0c71a2b commit 7076508
Show file tree
Hide file tree
Showing 41 changed files with 878 additions and 71 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ rules:
no-console: 0
globals:
angular: false
Cesium: false
goog: false
google: false
d3: false
Bloodhound: false
ol: false
olcs: false
proj4: false
saveAs: false
ngeo: false
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ apidoc: .build/apidoc
dist: dist/ngeo.js dist/ngeo-debug.js dist/gmf.js

.PHONY: check
check: git-attributes eof-newline lint check-examples test dist build-gmf-apps check-ngeox
check: lint check-examples test dist build-gmf-apps

.PHONY: check-ngeox
check-ngeox: options/ngeox.js
Expand All @@ -214,7 +214,10 @@ build-gmf-apps: $(foreach APP,$(GMF_APPS),$(addprefix contribs/gmf/build/$(APP),
check-examples: $(BUILD_EXAMPLES_CHECK_TIMESTAMP_FILES)

.PHONY: lint
lint: .build/eslint.timestamp
lint: .build/eslint.timestamp git-attributes eof-newline check-ngeox

.PHONY: eslint
eslint: .build/eslint.timestamp

.PHONY: git-attributes
git-attributes:
Expand Down Expand Up @@ -289,7 +292,7 @@ gh-pages:
$(GMF_SRC_JS_FILES) \
$(GMF_EXAMPLES_JS_FILES) \
$(GMF_APPS_JS_FILES)
./node_modules/.bin/eslint $(filter-out .build/node_modules.timestamp .eslintrc.yaml .eslintrc-es6.yaml, $?)
./node_modules/.bin/eslint $(filter-out .build/node_modules.timestamp .eslintrc.yaml .eslintrc-es6.yaml, $^)
touch $@

dist/ngeo.js: .build/ngeo.json \
Expand Down
5 changes: 4 additions & 1 deletion buildtools/mako_build.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ _ngeo_folder = '' if ngeo_folder is UNDEFINED else ngeo_folder
"${_ngeo_folder}contribs/gmf/src/**/*.js",
% endif
"node_modules/openlayers/src/**/*.js",
"node_modules/openlayers/build/ol.ext/*.js"
"node_modules/openlayers/build/ol.ext/*.js",
"node_modules/ol-cesium/src/**/*.js"
],
"compile": {
% if entry_point:
Expand All @@ -49,6 +50,8 @@ _ngeo_folder = '' if ngeo_folder is UNDEFINED else ngeo_folder
"node_modules/openlayers/externs/proj4js.js",
"node_modules/openlayers/externs/tilejson.js",
"node_modules/openlayers/externs/topojson.js",
"node_modules/ol-cesium/Cesium.externs.js",
"node_modules/ol-cesium/externs/olcsx.js",
"${_ngeo_folder}externs/angular-gettext.js",
"${_ngeo_folder}externs/d3.js",
"${_ngeo_folder}externs/google_maps_api_v3_27.js",
Expand Down
1 change: 1 addition & 0 deletions buildtools/ngeo-debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"src": [
"node_modules/openlayers/src/**/*.js",
"node_modules/openlayers/build/ol.ext/*.js",
"node_modules/ol-cesium/src/**/*.js",
"src/**/*.js",
".build/templatecache.js"
]
Expand Down
1 change: 1 addition & 0 deletions buildtools/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ let manager = new closure.Manager({
'contribs/**/src/**/*.js',
'externs/*.js',
'node_modules/openlayers/src/**/*.js',
'node_modules/ol-cesium/src/**/*.js',
'node_modules/openlayers/build/ol.ext/*.js'
],
main: ['examples/*.js', 'contribs/**/examples/*.js', 'contribs/**/apps/**/*.js']
Expand Down
4 changes: 3 additions & 1 deletion contribs/gmf/apps/mobile/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@
<gmf-disclaimer gmf-disclaimer-map="::mainCtrl.map"></gmf-disclaimer>
<div class="alert alert-info alert-dismissible fade in hidden-xs" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="{{'Close' | translate }}"><span aria-hidden="true" class="fa fa-times"></span></button>
<span>{{"You're using the mobile application. Check out the" | translate }} <a href="http://camptocamp.github.io/ngeo/master/examples/contribs/gmf/apps/desktop/?no_redirect">{{'standard application' | translate}}</a>.</span>
<span translate
translate-params-url="'http://camptocamp.github.io/ngeo/master/examples/contribs/gmf/apps/desktop/?no_redirect'">
You're using the mobile application. Check out the <a href="{{url}}">standard application</a>.</span>
</div>
</div>
</main>
Expand Down
4 changes: 3 additions & 1 deletion contribs/gmf/apps/mobile_alt/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@
<gmf-disclaimer gmf-disclaimer-map="::mainCtrl.map"></gmf-disclaimer>
<div class="alert alert-info alert-dismissible fade in hidden-xs" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="{{'Close' | translate }}"><span aria-hidden="true" class="fa fa-times"></span></button>
<span>{{"You're using the mobile application. Check out the" | translate }} <a href="http://camptocamp.github.io/ngeo/master/examples/contribs/gmf/apps/desktop/?no_redirect">{{'standard application' | translate}}</a>.</span>
<span translate
translate-params-url="'http://camptocamp.github.io/ngeo/master/examples/contribs/gmf/apps/desktop/?no_redirect'">
You're using the mobile application. Check out the <a href="{{url}}">standard application</a>.</span>
</div>
</div>
</main>
Expand Down
77 changes: 56 additions & 21 deletions contribs/gmf/src/controllers/abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ gmf.AbstractController = function(config, $scope, $injector) {
/**
* @param {gmfx.AuthenticationEvent} evt Event.
*/
const userChange = function(evt) {
const userChange = (evt) => {
const user = evt.detail.user;
const roleId = (user.username !== null) ? user.role_id : undefined;

Expand All @@ -151,14 +151,18 @@ gmf.AbstractController = function(config, $scope, $injector) {
});

// Reload theme and background layer when login status changes.
const previousThemeName = this.gmfThemeManager.getThemeName();
this.gmfThemeManager.setThemeName('', true);
if (evt.type !== 'ready') {
this.updateCurrentTheme_();
this.updateCurrentBackgroundLayer_(true);
this.updateCurrentTheme_(previousThemeName);
} else {
// initialize default background layer
this.setDefaultBackground_(null, true);
}
// Reload themes when login status changes.
this.gmfThemes_.loadThemes(roleId);
this.updateHasEditableLayers_();
}.bind(this);
};

ol.events.listen(gmfAuthentication, 'ready', userChange);
ol.events.listen(gmfAuthentication, 'login', userChange);
Expand Down Expand Up @@ -201,15 +205,19 @@ gmf.AbstractController = function(config, $scope, $injector) {
}
}

const backgroundLayerMgr = $injector.get('ngeoBackgroundLayerMgr');
/**
* @type {ngeo.BackgroundLayerMgr}
* @private
*/
this.backgroundLayerMgr_ = $injector.get('ngeoBackgroundLayerMgr');

// watch any change on dimensions object to refresh the background layer
$scope.$watchCollection(() => this.dimensions, () => {
backgroundLayerMgr.updateDimensions(this.map, this.dimensions);
this.backgroundLayerMgr_.updateDimensions(this.map, this.dimensions);
});

backgroundLayerMgr.on('change', () => {
backgroundLayerMgr.updateDimensions(this.map, this.dimensions);
this.backgroundLayerMgr_.on('change', () => {
this.backgroundLayerMgr_.updateDimensions(this.map, this.dimensions);
});

/**
Expand Down Expand Up @@ -416,19 +424,9 @@ gmf.AbstractController = function(config, $scope, $injector) {
ngeoToolActivateMgr.registerTool(mapTools, printPanelActivate, false);

$scope.$root.$on(gmf.ThemeManagerEventType.THEME_NAME_SET, (event, name) => {
const map = this.map;
this.gmfThemes_.getThemeObject(name).then((theme) => {
if (theme) {
const backgrounds = theme.functionalities.default_basemap;
if (backgrounds && backgrounds.length > 0) {
const background = backgrounds[0];
this.gmfThemes_.getBgLayers(this.dimensions).then((layers) => {
const layer = ol.array.find(layers, layer => layer.get('label') === background);
if (layer) {
backgroundLayerMgr.set(map, layer);
}
});
}
this.setDefaultBackground_(theme, false);
}
});
});
Expand Down Expand Up @@ -463,7 +461,7 @@ gmf.AbstractController = function(config, $scope, $injector) {
}

if (background) {
backgroundLayerMgr.set(this.map, background);
this.backgroundLayerMgr_.set(this.map, background);
}
});
}.bind(this);
Expand Down Expand Up @@ -648,16 +646,53 @@ gmf.AbstractController.prototype.initLanguage = function() {


/**
* @param {gmfThemes.GmfTheme} theme Theme.
* @param {boolean} use_permalink Get background from the permalink.
* @private
*/
gmf.AbstractController.prototype.setDefaultBackground_ = function(theme, use_permalink) {
this.gmfThemes_.getBgLayers(this.dimensions).then((layers) => {
let default_basemap;
let layer;

if (use_permalink) {
// get the background from the permalink
layer = this.permalink_.getBackgroundLayer(layers);
}
if (!layer) {
if (this.gmfUser.functionalities) {
// get the background from the user settings
default_basemap = this.gmfUser.functionalities.default_basemap;
} else if (theme) {
// get the background from the theme
default_basemap = theme.functionalities.default_basemap;
}
if (default_basemap && default_basemap.length > 0) {
layer = ol.array.find(layers, layer => layer.get('label') === default_basemap[0]);
}
}
// fallback to the layers list, use the second one because the first is the blank layer.
layer = layer || layers[1];
goog.asserts.assert(layer);

this.backgroundLayerMgr_.set(this.map, layer);
});
};

/**
* @param {string} fallbackThemeName fallback theme name.
* @private
*/
gmf.AbstractController.prototype.updateCurrentTheme_ = function() {
gmf.AbstractController.prototype.updateCurrentTheme_ = function(fallbackThemeName) {
this.gmfThemes_.getThemesObject().then((themes) => {
const themeName = this.permalink_.defaultThemeNameFromFunctionalities();
if (themeName) {
const theme = gmf.Themes.findThemeByName(themes, /** @type {string} */ (themeName));
if (theme) {
this.gmfThemeManager.addTheme(theme, true);
}
} else {
this.gmfThemeManager.setThemeName(fallbackThemeName, true);
}
});
};
Expand Down
3 changes: 2 additions & 1 deletion contribs/gmf/src/datasource/externaldatasourcesmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ goog.provide('gmf.datasource.ExternalDataSourcesManager');

goog.require('ol.events');
goog.require('gmf');
goog.require('ngeo.File');
/** @suppress {extraRequire} */
goog.require('ngeo.fileService');
goog.require('ngeo.datasource.DataSources');
goog.require('ngeo.datasource.File');
goog.require('ngeo.datasource.FileGroup');
Expand Down
20 changes: 14 additions & 6 deletions contribs/gmf/src/directives/displayquerygrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ goog.require('ol.style.Style');

ngeo.module.value('gmfDisplayquerygridTemplateUrl',
/**
* @param {!angular.JQLite} $element Element.
* @param {!angular.Attributes} $attrs Attributes.
* @return {string} Template URL.
*/
* @param {!angular.JQLite} $element Element.
* @param {!angular.Attributes} $attrs Attributes.
* @return {string} Template URL.
*/
($element, $attrs) => {
const templateUrl = $attrs['gmfDisplayquerygridTemplateurl'];
return templateUrl !== undefined ? templateUrl :
Expand Down Expand Up @@ -75,7 +75,7 @@ function gmfDisplayquerygridTemplateUrl($element, $attrs, gmfDisplayquerygridTem
* empty columns be hidden? Default: `false`.
* @htmlAttribute {number?} gmf-displayquerygrid-maxrecenterzoom Optional. Maximum
* zoom-level to use when zooming to selected features.
* @htmlAttribute {gmfx.GridMergeTabs?} gmf-displayquerygrid-gridmergetabas Optional.
* @htmlAttribute {gmfx.GridMergeTabs?} gmf-displayquerygrid-gridmergetabs Optional.
* Configuration to merge grids with the same attributes into a single grid.
*
* @ngdoc component
Expand Down Expand Up @@ -106,6 +106,7 @@ gmf.module.component('gmfDisplayquerygrid', gmf.displayquerygridComponent);
* @param {angular.$injector} $injector Main injector.
* @param {!angular.Scope} $scope Angular scope.
* @param {ngeox.QueryResult} ngeoQueryResult ngeo query result.
* @param {ngeo.MapQuerent} ngeoMapQuerent ngeo map querent service.
* @param {ngeo.FeatureOverlayMgr} ngeoFeatureOverlayMgr The ngeo feature
* overlay manager service.
* @param {angular.$timeout} $timeout Angular timeout service.
Expand All @@ -117,7 +118,7 @@ gmf.module.component('gmfDisplayquerygrid', gmf.displayquerygridComponent);
* @ngdoc controller
* @ngname GmfDisplayquerygridController
*/
gmf.DisplayquerygridController = function($injector, $scope, ngeoQueryResult,
gmf.DisplayquerygridController = function($injector, $scope, ngeoQueryResult, ngeoMapQuerent,
ngeoFeatureOverlayMgr, $timeout, ngeoCsvDownload, $element) {

const queryOptions = /** @type {ngeox.QueryOptions} */ (
Expand All @@ -142,6 +143,12 @@ gmf.DisplayquerygridController = function($injector, $scope, ngeoQueryResult,
*/
this.ngeoQueryResult = ngeoQueryResult;

/**
* @type {ngeo.MapQuerent}
* @private
*/
this.ngeoMapQuerent_ = ngeoMapQuerent;

/**
* @type {ngeo.CsvDownload}
* @private
Expand Down Expand Up @@ -655,6 +662,7 @@ gmf.DisplayquerygridController.prototype.clear = function() {
this.tooManyResults = false;
this.features_.clear();
this.highlightFeatures_.clear();
this.ngeoMapQuerent_.clear();
this.featuresForSources_ = {};
if (this.unregisterSelectWatcher_) {
this.unregisterSelectWatcher_();
Expand Down
10 changes: 9 additions & 1 deletion contribs/gmf/src/directives/displayquerywindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ gmf.module.component('gmfDisplayquerywindow', gmf.displayquerywindowComponent);
* @param {!jQuery} $element Element.
* @param {!angular.Scope} $scope Angular scope.
* @param {!ngeox.QueryResult} ngeoQueryResult ngeo query result.
* @param {!ngeo.MapQuerent} ngeoMapQuerent ngeo map querent service.
* @param {!ngeo.FeatureOverlayMgr} ngeoFeatureOverlayMgr The ngeo feature
* overlay manager service.
* @constructor
Expand All @@ -98,7 +99,7 @@ gmf.module.component('gmfDisplayquerywindow', gmf.displayquerywindowComponent);
* @ngdoc controller
* @ngname GmfDisplayquerywindowController
*/
gmf.DisplayquerywindowController = function($element, $scope, ngeoQueryResult,
gmf.DisplayquerywindowController = function($element, $scope, ngeoQueryResult, ngeoMapQuerent,
ngeoFeatureOverlayMgr) {

/**
Expand Down Expand Up @@ -138,6 +139,12 @@ gmf.DisplayquerywindowController = function($element, $scope, ngeoQueryResult,
pending: false
};

/**
* @type {ngeo.MapQuerent}
* @private
*/
this.ngeoMapQuerent_ = ngeoMapQuerent;

/**
* @type {?ngeox.QueryResultSource}
* @export
Expand Down Expand Up @@ -500,6 +507,7 @@ function(opt_lastFeature) {
gmf.DisplayquerywindowController.prototype.close = function() {
this.open = false;
this.clear();
this.ngeoMapQuerent_.clear();
};


Expand Down
Loading

0 comments on commit 7076508

Please sign in to comment.