Skip to content

Commit

Permalink
Init litterassessment extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ridoo committed Mar 14, 2024
1 parent c1e08b7 commit dc26d93
Show file tree
Hide file tree
Showing 16 changed files with 249 additions and 3 deletions.
3 changes: 1 addition & 2 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ services:
- .devcontainer/.env.local
restart: "no"
volumes:
#- ./.devcontainer/docker/geonode/custom_entrypoint.sh:/usr/src/geonode/custom_entrypoint.sh
- ./.devcontainer/_gitignore:/usr/src/geonode/.gitignore
- ./.devcontainer/_vscode:/usr/src/geonode/.vscode
ports:
- "8001:8001"
#command: /usr/src/geonode/custom_entrypoint.sh
#command: /usr/src/geonode/custom_entrypoint.sh
command: sleep infinity

celery:
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ x-common-django:
# configuration
- ./favicon.ico:/srv/docker/volumes/geonode_plastops-statics/_data/static/geonode/img/facicon.ico
- ./geonode/geonode/settings_override.py:/usr/src/geonode/geonode/settings_override.py
- ./geonode/geonode/static/mapstore/extensions/index.json:/usr/src/geonode/geonode/static/mapstore/extensions/index.json
- ./geonode/fixtures:/usr/src/geonode/fixtures
# contrib apps
- ./geonode/apps/customizations:/usr/src/geonode/customizations
- ./geonode/apps/litter_assessment:/usr/src/geonode/litter_assessment
- ./geonode/apps/externalapplications/externalapplications:/usr/src/geonode/externalapplications
# volumes
- statics:/mnt/volumes/statics
Expand Down Expand Up @@ -82,7 +84,7 @@ services:
- LETSENCRYPT_MODE=disabled
- RESOLVER=127.0.0.11
ports:
- "8001:443"
- "8443:443"
volumes:
- statics:/mnt/volumes/statics
# Link to a custom certificate here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@
overrideLocalConfig(localConfig, _)
}

localConfig.plugins.dataset_viewer.push({
name: "LitterAssessmentPlugin",
//disableIf: "{context.get(state('gnLayerResourceData'), 'subtype') !== 'raster'}"
});

// IMPORTANT!!! REMOVE AFTER DEVELOPMENT
// temporary changes to develop extension
// use absolute extensions folder path to correctly get http://localhost:8082 endpoint
localConfig.extensionsFolder = '';
// ensure that the http://localhost:8082 endpoint will not use proxy but direct requests
localConfig.proxyUrl.useCORS.push('http://localhost:8082');

var pluginPageName = "catalogue";
var selectedPluginName = "ResourcesGrid";

Expand Down
26 changes: 26 additions & 0 deletions geonode/apps/litter_assessment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

from django.apps import AppConfig

import logging
logger = logging.getLogger(__name__)


def run_setup_hooks(*args, **kwargs):
from django.conf import settings

settings.MAPSTORE_TRANSLATIONS_PATH += (
"/static/mapstore/ea-translations",
)


class LitterAssessmentConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'litter_assessment'
type = 'GEONODE_APP'

def ready(self):
super().ready()
run_setup_hooks()


default_app_config = 'litter_assessment.LitterAssessmentConfig'
28 changes: 28 additions & 0 deletions geonode/apps/litter_assessment/client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

node_modules/
node/
dist/
build/
target/
*.sublime-*
npm-debug.log
package-lock.json
coverage/
web/client/libs/Cesium/
web/cesium.zip
web/.classpath
web/.project
.idea
*.iml
_site
.sass-cache
.jekyll-metadata
*.lock
docs/developer-guide/reference/
web/client/mapstore/docs/
web/docs
.classpath
.project
.settings/
debug.log
.vscode/settings.json
26 changes: 26 additions & 0 deletions geonode/apps/litter_assessment/client/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2015-2023, 52°North GmbH
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the MapStore2 Project.
7 changes: 7 additions & 0 deletions geonode/apps/litter_assessment/client/assets/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": [
{
"name": "LitterAssessmentPlugin"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"locale": "en-US",
"messages": {
"extension": {
"message": "Message!"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"locale": "it-IT",
"messages": {
"extension": {
"message": "Messaggio!"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* extension css */

.extension {
position: absolute;
background-color: red;
top: 50%;
left: 50%;
padding: 8px;
transform: translate(-50%, -50%);
z-index: 100000;
font-size: 100px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2021, 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.
*/

import React from 'react';
import { connect } from 'react-redux';
import Message from "@mapstore/framework/components/I18N/Message";
import '@js/extension/assets/style.css';

function Extension() {
return (
<div className="extension">
<Message msgId="extension.message" />
</div>
);
}

const ConnectedExtension = connect(() => ({}))(Extension);

export default {
name: __MAPSTORE_EXTENSION_CONFIG__.name,
component: ConnectedExtension,
reducers: {},
epics: {},
containers: {}
};
49 changes: 49 additions & 0 deletions geonode/apps/litter_assessment/client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "client",
"version": "1.0.0",
"description": "mapstore extension",
"eslintConfig": {
"extends": [
"@mapstore/eslint-config-mapstore"
],
"parserOptions": {
"babelOptions": {
"configFile": "./node_modules/mapstore/build/babel.config.js"
}
},
"globals": {
"__MAPSTORE_PROJECT_CONFIG__": false,
"__MAPSTORE_EXTENSION_CONFIG__": false
}
},
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all",
"not IE 11",
"not UCAndroid 12.12"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"scripts": {
"compile": "mapstore-project compile extension && node ./postCompile.js",
"lint": "eslint js --ext .jsx,.js",
"start": "mapstore-project start extension",
"test": "mapstore-project test extension",
"test:watch": "mapstore-project test:watch extension"
},
"devDependencies": {
"@mapstore/project": "1.0.27"
},
"dependencies": {
"mapstore": "git+https://github.com/geosolutions-it/MapStore2.git#2022.02.xx"
},
"mapstore": {
"extensionName": "LitterAssessmentPlugin"
}
}
30 changes: 30 additions & 0 deletions geonode/apps/litter_assessment/client/postCompile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require('fs-extra');
const path = require('path');
const extensionsPath = path.join(__dirname, '..', '..', 'geonode', 'static', 'mapstore', 'extensions');
// const extensionIndexPath = path.join(extensionsPath, 'index.json');
// const extensionIndex = fs.existsSync(extensionIndexPath) ? require(extensionIndexPath) : {};

const EXTENSION_NAME = 'LitterAssessmentPlugin';

// let error = false;
// Object.keys(extensionIndex).forEach(extensionName => {
// const endpoints = extensionIndex[extensionName];
// Object.keys(endpoints).forEach(key => {
// if (endpoints[key].match('http://localhost:8082/extension')) {
// error = true;
// console.error('');
// console.error('//////////////////////////////////////');
// console.error('/// Error: dev url ' + key + ': ' + endpoints[key]);
// console.error('/// -> please replace http://localhost:8082/extension with /static/mapstore/extensions/' + extensionName);
// console.error('//////////////////////////////////////');
// console.error('');
// }
// });
// });

//if (!error) {
fs.moveSync(
path.resolve(__dirname, 'dist'),
path.resolve(extensionsPath, EXTENSION_NAME),
{ overwrite: true });
//}
1 change: 1 addition & 0 deletions geonode/apps/litter_assessment/client/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client-v1.0.0-
1 change: 1 addition & 0 deletions geonode/geonode/settings_override.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@


INSTALLED_APPS += (
"litter_assessment",
"externalapplications",
"customizations",
)
7 changes: 7 additions & 0 deletions geonode/geonode/static/mapstore/extensions/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"LitterAssessmentPlugin": {
"bundle": "http://localhost:8082/extension/index.js",
"translations": "http://localhost:8082/extension/translations",
"assets": "http://localhost:8082/extension/assets"
}
}

0 comments on commit dc26d93

Please sign in to comment.