diff --git a/.eslintrc b/.eslintrc index e8b8747a50..15d3d1472e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -192,7 +192,7 @@ "react/jsx-uses-vars": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md "react/no-did-mount-set-state": [2, "allow-in-func"], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md "react/no-did-update-set-state": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md - "react/no-multi-comp": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md + "react/no-multi-comp": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md "react/no-unknown-property": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md "react/prop-types": [2, { ignore: ["children"]}], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md "react/react-in-jsx-scope": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md diff --git a/build.sh b/build.sh index d0bf047364..44adf91ab4 100755 --- a/build.sh +++ b/build.sh @@ -7,5 +7,11 @@ npm run cleandoc npm run lint npm test npm run doc -mvn clean install +if [ $# -eq 0 ] + then + mvn clean install + else + mvn clean install -Dmapstore2.version=$1 +fi + npm run cleandoc diff --git a/web/client/actions/version.js b/web/client/actions/version.js new file mode 100644 index 0000000000..e81326e581 --- /dev/null +++ b/web/client/actions/version.js @@ -0,0 +1,39 @@ +/** + * Copyright 2015, GeoSolutions Sas. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ + +const axios = require('../libs/ajax'); + +const CHANGE_VERSION = 'CHANGE_VERSION'; +const LOAD_VERSION_ERROR = 'LOAD_VERSION_ERROR'; + +function changeVersion(version) { + return { + type: CHANGE_VERSION, + version + }; +} + +function loadVersionError(e) { + return { + type: LOAD_VERSION_ERROR, + error: e + }; +} + +function loadVersion(config = 'version.txt') { + return (dispatch) => { + return axios.get(config).then((response) => { + dispatch(changeVersion(response.data)); + }).catch((e) => { + dispatch(loadVersionError(e)); + }); + }; +} + +module.exports = {CHANGE_VERSION, LOAD_VERSION_ERROR, + loadVersion, loadVersionError, changeVersion}; diff --git a/web/client/localConfig.json b/web/client/localConfig.json index 7a6ca49270..32e61ab7d8 100644 --- a/web/client/localConfig.json +++ b/web/client/localConfig.json @@ -32,7 +32,7 @@ "cfg": { "tools": ["locate"] } - }, "DrawerMenu", { + }, "Version", "DrawerMenu", { "name": "Identify", "showIn": ["Settings"], "cfg": { @@ -111,7 +111,7 @@ }, "Login", "OmniBar", "BurgerMenu", "Expander", "GlobeViewSwitcher" ], - "desktop": ["Map", "HelpLink", "Share", "DrawerMenu", { + "desktop": ["Map", "HelpLink", "Share", "DrawerMenu", "Version", { "name": "Identify", "showIn": ["IdentifyBar", "Settings"], "cfg": { diff --git a/web/client/plugins/Version.jsx b/web/client/plugins/Version.jsx new file mode 100644 index 0000000000..5cb82684f9 --- /dev/null +++ b/web/client/plugins/Version.jsx @@ -0,0 +1,55 @@ +/* + * Copyright 2016, GeoSolutions Sas. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ + +const React = require('react'); +const {connect} = require('react-redux'); + +const Message = require('../components/I18N/Message'); + +/** + * Version Plugin. Shows current MapStore2 version + * @class Version + * @memberof plugins + * @static + * + */ +const Version = connect((state) => ({ + version: state.version && state.version.current +}))(React.createClass({ + propTypes: { + version: React.PropTypes.string + }, + getDefaultProps() { + return { + version: 'DEV' + }; + }, + render() { + return : {this.props.version}; + } +})); + +const assign = require('object-assign'); + +const Empty = React.createClass({ + render() { + return null; + } +}); + +module.exports = { + VersionPlugin: assign(Empty, { + Settings: { + tool: , + position: 4 + } + }), + reducers: { + version: require('../reducers/version') + } +}; diff --git a/web/client/product/app.jsx b/web/client/product/app.jsx index 40d761ba14..d445b93d7d 100644 --- a/web/client/product/app.jsx +++ b/web/client/product/app.jsx @@ -14,6 +14,7 @@ const startApp = () => { const ConfigUtils = require('../utils/ConfigUtils'); const {loadMaps} = require('../actions/maps'); + const {loadVersion} = require('../actions/version'); const StandardApp = require('../components/app/StandardApp'); @@ -30,7 +31,8 @@ const startApp = () => { }, {}); const initialActions = [ - () => loadMaps(ConfigUtils.getDefaults().geoStoreUrl, ConfigUtils.getDefaults().initialMapFilter || "*") + () => loadMaps(ConfigUtils.getDefaults().geoStoreUrl, ConfigUtils.getDefaults().initialMapFilter || "*"), + loadVersion ]; const appConfig = { diff --git a/web/client/product/plugins.js b/web/client/product/plugins.js index 926749e6a0..d059277912 100644 --- a/web/client/product/plugins.js +++ b/web/client/product/plugins.js @@ -67,7 +67,8 @@ module.exports = { ThemeSwitcherPlugin: require('../plugins/ThemeSwitcher'), ScrollTopPlugin: require('../plugins/ScrollTop'), GoFull: require('../plugins/GoFull'), - GlobeViewSwitcherPlugin: require('../plugins/GlobeViewSwitcher') + GlobeViewSwitcherPlugin: require('../plugins/GlobeViewSwitcher'), + VersionPlugin: require('../plugins/Version') }, requires: { ReactSwipe: require('react-swipeable-views').default, diff --git a/web/client/reducers/version.js b/web/client/reducers/version.js new file mode 100644 index 0000000000..78227282f5 --- /dev/null +++ b/web/client/reducers/version.js @@ -0,0 +1,26 @@ +/** + * Copyright 2017, GeoSolutions Sas. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ + +const { CHANGE_VERSION } = require('../actions/version'); +const assign = require('object-assign'); + +function version(state = null, action) { + switch (action.type) { + case CHANGE_VERSION: { + return assign({}, state, + { + current: action.version + } + ); + } + default: + return state; + } +} + +module.exports = version; diff --git a/web/client/themes/default/ms2-theme.less b/web/client/themes/default/ms2-theme.less index 31c1ed8bac..8735028f1f 100644 --- a/web/client/themes/default/ms2-theme.less +++ b/web/client/themes/default/ms2-theme.less @@ -1024,3 +1024,7 @@ select.form-control option { .tooltip { z-index: 10000; } + +.application-version-label { + font-weight: bold; +} diff --git a/web/client/translations/data.de-DE b/web/client/translations/data.de-DE index 01df880190..a0b8d1ca7a 100644 --- a/web/client/translations/data.de-DE +++ b/web/client/translations/data.de-DE @@ -21,6 +21,9 @@ "enable": "Aktiviere", "layers": "Ebenen", "warning": "Warnung", + "version": { + "label": "Version" + }, "layerProperties": { "windowTitle": "Ebenen Eigenschaften", "title": "Titel", diff --git a/web/client/translations/data.en-US b/web/client/translations/data.en-US index ce11eb37fb..334ff92a7a 100644 --- a/web/client/translations/data.en-US +++ b/web/client/translations/data.en-US @@ -21,6 +21,9 @@ "enable": "Enable", "layers": "Layers", "warning": "Warning", + "version": { + "label": "Version" + }, "layerProperties": { "windowTitle": "Layer Properties", "title": "Title", diff --git a/web/client/translations/data.fr-FR b/web/client/translations/data.fr-FR index 9fb8b1e6c9..0f9a53b6cc 100644 --- a/web/client/translations/data.fr-FR +++ b/web/client/translations/data.fr-FR @@ -21,6 +21,9 @@ "enable": "Activer", "layers": "Couches", "warning": "Attention", + "version": { + "label": "Version" + }, "layerProperties": { "windowTitle": "Propriétés de la couche", "title": "Titre", diff --git a/web/client/translations/data.it-IT b/web/client/translations/data.it-IT index 31afee639c..22af284f36 100644 --- a/web/client/translations/data.it-IT +++ b/web/client/translations/data.it-IT @@ -21,6 +21,9 @@ "enable": "Abilita", "layers": "Livelli", "warning": "Attenzione", + "version": { + "label": "Versione" + }, "layerProperties": { "windowTitle": "Proprietà del livello", "title": "Titolo", diff --git a/web/client/version.txt b/web/client/version.txt new file mode 100644 index 0000000000..5cce0991a3 --- /dev/null +++ b/web/client/version.txt @@ -0,0 +1 @@ +${mapstore2.version} diff --git a/web/pom.xml b/web/pom.xml index 1050004060..40b6286e90 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -82,12 +82,30 @@ - - maven-resources-plugin 2.6 + + version + process-classes + + copy-resources + + + ${basedir}/target/mapstore + UTF-8 + + + ${basedir}/client + true + + **/version.txt + + + + + html, configuration files and images process-classes