diff --git a/build/docma-config.json b/build/docma-config.json
index 2ee8061022..c5aedcca7b 100644
--- a/build/docma-config.json
+++ b/build/docma-config.json
@@ -120,12 +120,9 @@
"web/client/components/data/featuregrid/editors/NumberEditor.jsx",
"web/client/components/data/identify/GeocodeViewer.jsx",
"web/client/components/data/identify/IdentifyContainer.jsx",
- "web/client/components/data/query/AutocompleteField.jsx",
+ "web/client/components/data/query/AutocompleteFieldHOC.jsx",
"web/client/components/map/leaflet/DrawSupport.jsx",
"web/client/components/plugins/PluginsContainer.jsx",
- "web/client/components/mapcontrols/annotations/Annotations.jsx",
- "web/client/components/mapcontrols/annotations/AnnotationsEditor.jsx",
- "web/client/components/mapcontrols/annotations/AnnotationsConfig.js",
"web/client/components/misc/cardgrids/SideCard.jsx",
"web/client/components/misc/cardgrids/SideGrid.jsx",
"web/client/components/misc/enhancers/emptyState.jsx",
@@ -135,7 +132,6 @@
"web/client/components/misc/panels/DockablePanel.jsx",
"web/client/components/misc/panels/DockPanel.jsx",
"web/client/components/misc/panels/PanelHeader.jsx",
- "web/client/components/misc/sidebar/Sidebar.jsx",
"web/client/components/misc/toolbar/Toolbar.jsx",
"web/client/components/misc/transfer/Transfer.jsx",
"web/client/components/misc/EmptyView.jsx",
@@ -152,7 +148,6 @@
"web/client/actions/index.jsdoc",
"web/client/actions/controls.js",
"web/client/actions/fullscreen.js",
- "web/client/actions/globeswitcher.js",
"web/client/actions/maplayout.js",
"web/client/actions/map.js",
"web/client/actions/maps.js",
@@ -171,7 +166,6 @@
"web/client/reducers/index.jsdoc",
"web/client/reducers/controls.js",
"web/client/reducers/featuregrid.js",
- "web/client/reducers/globeswitcher.js",
"web/client/reducers/mapInfo.js",
"web/client/reducers/maps.js",
"web/client/reducers/maptype.js",
@@ -186,7 +180,6 @@
"web/client/epics/featuregrid.js",
"web/client/epics/feedbackMask.js",
"web/client/epics/fullscreen.js",
- "web/client/epics/globeswitcher.js",
"web/client/epics/maplayout.js",
"web/client/epics/maptype.js",
"web/client/epics/notifications.js",
@@ -270,8 +263,6 @@
"web/client/plugins/MapTemplates.jsx",
"web/client/plugins/MapViews.jsx",
"web/client/plugins/Measure.jsx",
- "web/client/plugins/MeasurePanel.jsx",
- "web/client/plugins/MeasureResults.jsx",
"web/client/plugins/MediaEditor.jsx",
"web/client/plugins/MetadataExplorer.jsx",
"web/client/plugins/MetadataInfo/index.jsx",
@@ -306,7 +297,6 @@
"web/client/plugins/Tutorial.jsx",
"web/client/plugins/UserExtensions.jsx",
"web/client/plugins/UserSession.jsx",
- "web/client/plugins/Version.jsx",
"web/client/plugins/LayerDownload.jsx",
"web/client/plugins/Widgets.jsx",
"web/client/plugins/WidgetsBuilder.jsx",
diff --git a/package.json b/package.json
index b45563cd4e..37f14ac65e 100644
--- a/package.json
+++ b/package.json
@@ -150,8 +150,6 @@
"@turf/point-on-surface": "4.1.0",
"@turf/polygon-to-linestring": "4.1.0",
"@znemz/cesium-navigation": "4.0.0",
- "ag-grid-community": "20.2.0",
- "ag-grid-react": "20.2.0",
"assert": "2.0.0",
"axios": "0.28.1",
"b64-to-blob": "1.2.19",
@@ -165,7 +163,6 @@
"chroma-js": "1.3.7",
"classnames": "2.2.5",
"codemirror": "5.65.16",
- "colorbrewer": "1.0.0",
"concurrently": "6.4.0",
"connected-react-router": "6.3.2",
"d3-format": "3.1.0",
diff --git a/web/client/actions/__tests__/importer-test.js b/web/client/actions/__tests__/importer-test.js
deleted file mode 100644
index 8a1d78e058..0000000000
--- a/web/client/actions/__tests__/importer-test.js
+++ /dev/null
@@ -1,315 +0,0 @@
-/**
- * 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.
- */
-
-import expect from 'expect';
-
-import {
- IMPORTS_LOADING,
- loadImports,
- IMPORTS_LIST_LOADED,
- loadImport,
- IMPORT_LOADED,
- createImport,
- IMPORT_CREATED,
- deleteImport,
- IMPORT_DELETE,
- runImport,
- IMPORT_RUN_SUCCESS,
- loadLayer,
- LAYER_LOADED,
- updateLayer,
- loadTask,
- IMPORTS_TASK_LOADED,
- updateTask,
- IMPORTS_TASK_UPDATED,
- deleteTask,
- IMPORTS_TASK_DELETE,
- loadTransform,
- IMPORTS_TRANSFORM_LOAD,
- updateTransform,
- IMPORTS_TRANSFORM_UPDATED,
- editTransform,
- IMPORTS_TRANSFORM_CHANGE,
- deleteTransform,
- IMPORTS_TRANSFORM_DELETE,
- loadStylerTool,
- selectWorkSpace,
- loadWorkspaces,
- createWorkspace,
- IMPORTER_WORKSPACE_LOADED,
- IMPORTER_WORKSPACE_SELECTED,
- IMPORTER_WORKSPACE_CREATED,
- dismissWorkspaceCreationStatus,
- IMPORTER_WORKSPACE_STATUS_CHANGE
-} from '../importer';
-
-import { MAP_CONFIG_LOADED } from '../config';
-
-/* This utility function runs a serie of test on an action creator
- with multiple dispatch inside
- You have to pass an array of functions that tests the action dispatched by
- the action creator. TODO evaulate to put in a TestUtils.
-*/
-const runAsyncTest = (url, action, tests, done, params = [], state) => {
- let count = 0;
- action(url, ...params)((actionResult) => {
- try {
- tests[count](actionResult);
- count++;
- if (count === tests.length - 1) {
- done();
- }
- } catch (e) {
- done(e);
- }
-
-
- }, () => state);
-};
-// NOTE use # to skip parameters by the API
-describe('Test correctness of the importer actions', () => {
- // most common test
- const testLoading = (actionResult) => {
- expect(actionResult.type).toBe(IMPORTS_LOADING);
- };
- it('load imports list loading', (done) => {
- const testImports = (actionResult) => {
- let imports = actionResult && actionResult.imports;
- expect(actionResult.type).toBe(IMPORTS_LIST_LOADED);
- expect(imports).toExist();
- expect(imports.length).toBe(2);
- };
- let url = 'base/web/client/test-resources/importer/imports.json#';
- let tests = [testLoading, testImports, testLoading ];
- runAsyncTest(url, loadImports, tests, done);
- });
- it('single import load', (done) => {
- const testImportCreation = (actionResult) => {
- expect(actionResult.type).toBe(IMPORT_LOADED);
- };
- let url = 'base/web/client/test-resources/importer/import.json#';
- let tests = [testLoading, testImportCreation ];
- runAsyncTest(url, loadImport, tests, done);
- });
- it('import creation', (done) => {
- const testImportCreation = (actionResult) => {
- expect(actionResult.type).toBe(IMPORT_CREATED);
- };
- let url = 'base/web/client/test-resources/importer/import.json#';
- let tests = [testLoading, testImportCreation ];
- runAsyncTest(url, createImport, tests, done, [1]);
- });
- it('import delete', (done) => {
- const testDeleteImport = (actionResult) => {
- expect(actionResult.type).toBe(IMPORT_DELETE);
- expect(actionResult.id).toBe(1);
- };
- let url = 'base/web/client/test-resources/importer/import.json#';
- let tests = [testLoading, testDeleteImport, testLoading ];
- runAsyncTest(url, deleteImport, tests, done, [1]);
- });
- it('import run', (done) => {
- const testRunImport = (actionResult) => {
- expect(actionResult.type).toBe(IMPORT_RUN_SUCCESS);
- expect(actionResult.importId).toBe(1);
- };
- let url = 'base/web/client/test-resources/importer/import.json#';
- let tests = [testLoading, testRunImport, testLoading ];
- runAsyncTest(url, runImport, tests, done, [1]);
- });
-
- // layer
- it('layer load', (done) => {
- const testLoadLayer = (actionResult) => {
- expect(actionResult.type).toBe(LAYER_LOADED);
- expect(actionResult.importId).toBe(1);
- expect(actionResult.taskId).toBe(2);
- expect(actionResult.layer).toExist();
- };
- let url = 'base/web/client/test-resources/importer/layer.json#';
- let tests = [testLoading, testLoadLayer, testLoading ];
- runAsyncTest(url, loadLayer, tests, done, [1, 2]);
- });
-
- it('layer update', (done) => {
- const testLoadLayer = (actionResult) => {
- expect(actionResult.type).toBe(LAYER_LOADED);
- expect(actionResult.importId).toBe(1);
- expect(actionResult.taskId).toBe(2);
- };
- let url = 'base/web/client/test-resources/importer/task.json#';
- let tests = [testLoading, testLoadLayer, testLoading ];
- runAsyncTest(url, updateLayer, tests, done, [1, 2]);
- });
-
- // task
- it('task load', (done) => {
- const testLoadLayer = () => {
-
- };
- const testLoadTask = (actionResult) => {
- expect(actionResult.type).toBe(IMPORTS_TASK_LOADED);
- expect(actionResult.task).toExist();
- };
- let url = 'base/web/client/test-resources/importer/task.json#';
- let tests = [testLoading, testLoadTask, testLoadLayer, testLoading ];
- runAsyncTest(url, loadTask, tests, done);
- });
- // task
- it('task update', (done) => {
- const testLoadLayer = () => {
-
- };
- const testLoadTask = (actionResult) => {
- expect(actionResult.type).toBe(IMPORTS_TASK_UPDATED);
- expect(actionResult.importId).toBe(1);
- expect(actionResult.taskId).toBe(2);
- expect(actionResult.task).toExist();
- };
- const testUpdateUI = (fun) => {
- expect(fun).toExist();
- fun('base/web/client/test-resources/importer/task.json#', 1, 2);
- };
- let url = 'base/web/client/test-resources/importer/task.json#';
- let state = {
- importer: {
- selectedImport: {
- id: 1,
- targetWorkspace: {
- workspace: {
- name: "TEST"
- }
- }
- }
- }
- };
- let tests = [testLoading, testLoadTask, testLoadLayer, testUpdateUI];
- runAsyncTest(url, updateTask, tests, done, [1, 2, {}], state );
-
- });
-
- it('task element update', (done) => {
- const testLoadLayer = () => {
-
- };
- const testLoadTask = (actionResult) => {
- expect(actionResult.type).toBe(IMPORTS_TASK_UPDATED);
- expect(actionResult.importId).toBe(1);
- expect(actionResult.taskId).toBe(2);
- expect(actionResult.task).toExist();
- };
- let url = 'base/web/client/test-resources/importer/task.json#';
- let tests = [testLoading, testLoadTask, testLoadLayer, testLoading ];
- runAsyncTest(url, updateTask, tests, done, [1, 2, {}, "target"]);
- });
- it('task delete', (done) => {
- const testdeleteTask = (actionResult) => {
- expect(actionResult.type).toBe(IMPORTS_TASK_DELETE);
- expect(actionResult.importId).toBe(1);
- expect(actionResult.taskId).toBe(2);
- };
- let url = 'base/web/client/test-resources/importer/task.json#';
- let tests = [testLoading, testdeleteTask, testLoading ];
- runAsyncTest(url, deleteTask, tests, done, [1, 2, {}]);
- });
-
- // transform
- it('transform load', (done) => {
- const testLoadTransform = (actionResult) => {
- expect(actionResult.type).toBe(IMPORTS_TRANSFORM_LOAD);
- expect(actionResult.importId).toBe(1);
- expect(actionResult.taskId).toBe(2);
- expect(actionResult.transformId).toBe(3);
- expect(actionResult.transform).toExist();
- };
- let url = 'base/web/client/test-resources/importer/transform.json#';
- let tests = [testLoading, testLoadTransform, testLoading ];
- runAsyncTest(url, loadTransform, tests, done, [1, 2, 3]);
- });
- // transform
- it('transform update', (done) => {
- const testUpdateTransform = (actionResult) => {
- expect(actionResult.type).toBe(IMPORTS_TRANSFORM_UPDATED);
- expect(actionResult.importId).toBe(1);
- expect(actionResult.taskId).toBe(2);
- expect(actionResult.transformId).toBe(3);
- };
- let url = 'base/web/client/test-resources/importer/transform.json#';
- let tests = [testLoading, testUpdateTransform, testLoading ];
- runAsyncTest(url, updateTransform, tests, done, [1, 2, 3]);
- });
- // transform
- it('transform delete', (done) => {
- const testdeleteTransform = (actionResult) => {
- expect(actionResult.type).toBe(IMPORTS_TRANSFORM_DELETE);
- expect(actionResult.importId).toBe(1);
- expect(actionResult.taskId).toBe(2);
- expect(actionResult.transformId).toBe(3);
- };
- let url = 'base/web/client/test-resources/importer/transform.json#';
- let tests = [testLoading, testdeleteTransform, testLoading ];
- runAsyncTest(url, deleteTransform, tests, done, [1, 2, 3]);
- });
-
- it('transform edit', () => {
- let transform = {options: [1, 2, 3]};
- const result = editTransform(transform);
- expect(result.type).toBe(IMPORTS_TRANSFORM_CHANGE);
- expect(result.transform).toBe(transform);
- });
- // load styler
- it('load styler tool', (done) => {
- const testConfigureMap = (actionResult) => {
- expect(actionResult.type).toBe(MAP_CONFIG_LOADED);
- expect(actionResult.config).toExist();
- expect(actionResult.config.map).toExist();
- expect(actionResult.config.map.layers).toExist();
- expect(actionResult.config.map.layers.length).toBe(2);
- done();
- };
- let url = 'base/web/client/test-resources/importer/layer.json#';
- let tests = [testConfigureMap];
- runAsyncTest(url, loadStylerTool, tests, done, [], {importer: {selectedImport: {targetWorkspace: { workspace: {name: "TEST"}}}}});
- });
- // select workspace
- it('load styler tool', () => {
- const wsName = "worskpace_name";
- let res = selectWorkSpace(wsName);
- expect(res).toExist();
- expect(res.type).toBe(IMPORTER_WORKSPACE_SELECTED);
- expect(res.workspace).toBe(wsName);
- });
-
- // load workspaces
- it('load workspaces', (done) => {
- const testWorkspaces = (actionResult) => {
- expect(actionResult.type).toBe(IMPORTER_WORKSPACE_LOADED);
- done();
- };
- let url = 'base/web/client/test-resources/geoserver/rest/workspaces.json#';
- let tests = [testWorkspaces];
- runAsyncTest(url, loadWorkspaces, tests, done, []);
- });
- // load workspaces
- it('create workspace', (done) => {
- const testWorkspaceCreated = (actionResult) => {
- expect(actionResult.type).toBe(IMPORTER_WORKSPACE_CREATED);
- done();
- };
- let url = 'base/web/client/test-resources/geoserver/rest/workspaces.json#';
- let tests = [testLoading, testWorkspaceCreated];
- runAsyncTest(url, createWorkspace, tests, done, []);
- });
- // load workspaces
- it('update workspace creation status', () => {
- let res = dismissWorkspaceCreationStatus();
- expect(res).toExist();
- expect(res.type).toBe(IMPORTER_WORKSPACE_STATUS_CHANGE);
- });
-
-});
diff --git a/web/client/actions/__tests__/rasterstyler-test.js b/web/client/actions/__tests__/rasterstyler-test.js
deleted file mode 100644
index 2abeb2ee40..0000000000
--- a/web/client/actions/__tests__/rasterstyler-test.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.
- */
-
-import expect from 'expect';
-
-import {
- SET_RASTERSTYLE_PARAMETER,
- SET_RASTER_LAYER,
- setRasterStyleParameter,
- setRasterLayer
-} from '../rasterstyler';
-
-describe('Test correctness of the rasterstyle actions', () => {
-
- it('setRasterStyleParameter', () => {
- const retVal = setRasterStyleParameter('cmp', 'property', 'val');
- expect(retVal).toExist();
- expect(retVal.type).toBe(SET_RASTERSTYLE_PARAMETER);
- expect(retVal.component).toBe('cmp');
- expect(retVal.property).toBe('property');
- expect(retVal.value).toBe('val');
- });
- it('setRasterLayer', () => {
- const retVal = setRasterLayer('layer');
- expect(retVal).toExist();
- expect(retVal.type).toBe(SET_RASTER_LAYER);
- expect(retVal.layer).toBe('layer');
- });
-});
diff --git a/web/client/actions/__tests__/styler-test.js b/web/client/actions/__tests__/styler-test.js
deleted file mode 100644
index f4565831de..0000000000
--- a/web/client/actions/__tests__/styler-test.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright 20167, 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 expect from 'expect';
-
-import { STYLER_RESET, SET_STYLER_LAYER, setStylerLayer, reset } from '../styler';
-
-describe('Test correctness of the rasterstyle actions', () => {
-
- it('setStylerLayer', () => {
- const layer = {name: "TEST"};
- const retVal = setStylerLayer(layer);
- expect(retVal).toExist();
- expect(retVal.type).toBe(SET_STYLER_LAYER);
- expect(retVal.layer).toBe(layer);
- });
- it('setRasterLayer', () => {
- const layer = {name: "TEST"};
- const retVal = reset(layer);
- expect(retVal).toExist();
- expect(retVal.type).toBe(STYLER_RESET);
- expect(retVal.layer).toBe(layer);
- });
-});
diff --git a/web/client/actions/__tests__/tasks-test.js b/web/client/actions/__tests__/tasks-test.js
deleted file mode 100644
index 951b7917ae..0000000000
--- a/web/client/actions/__tests__/tasks-test.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * 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.
- */
-
-import expect from 'expect';
-
-import {
- taskSuccess,
- taskStarted,
- taskError,
- startTask,
- TASK_STARTED,
- TASK_SUCCESS,
- TASK_ERROR
-} from '../tasks';
-
-describe('Test correctness of the tasks actions', () => {
- it('test taskSuccess action', () => {
- let result = {value: "true"};
- let name = "myName";
- let actionPayload = null;
- const retVal = taskSuccess(result, name, actionPayload);
- expect(retVal).toExist();
- expect(retVal.type).toBe(TASK_SUCCESS);
- expect(retVal.result).toBe(result);
- expect(retVal.name).toBe(name);
- expect(retVal.actionPayload).toBe(null);
- });
-
- it('test taskError action', () => {
- let error = {value: "true"};
- let name = "myName";
- let actionPayload = null;
- const retVal = taskError(error, name, actionPayload);
- expect(retVal).toExist();
- expect(retVal.type).toBe(TASK_ERROR);
- expect(retVal.error).toBe(error);
- expect(retVal.name).toBe(name);
- expect(retVal.actionPayload).toBe(null);
- });
-
-
- it('test taskStarted action', () => {
- let name = "myName";
- const retVal = taskStarted(name);
- expect(retVal).toExist();
- expect(retVal.type).toBe(TASK_STARTED);
- expect(retVal.name).toBe(name);
- });
-
- it('startTask', done => {
- let started = false;
- let executed = false;
- let dispatchable = startTask((payload, callback) => {executed = true; expect(payload).toBe("payload"); callback(); }, "payload", "task", "actionPayload");
- dispatchable((action) => {
- if (action.type === TASK_STARTED) {
- expect(action.name).toBe("task");
- started = true;
- }
- if (action.type === TASK_SUCCESS) {
- expect(action.actionPayload).toBe("actionPayload");
- expect(started).toBe(true);
- expect(executed).toBe(true);
- done();
- }
- });
- });
-});
diff --git a/web/client/actions/importer.js b/web/client/actions/importer.js
deleted file mode 100644
index 6218eaa211..0000000000
--- a/web/client/actions/importer.js
+++ /dev/null
@@ -1,721 +0,0 @@
-/**
- * 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.
- */
-import API from '../api/geoserver/Importer';
-
-import Workspaces from '../api/geoserver/Workspaces';
-import { configureMap } from './config';
-import { isString } from 'lodash';
-import assign from 'object-assign';
-export const IMPORTS_LOADING = 'IMPORTS_LOADING';
-export const IMPORTS_CREATION_ERROR = 'IMPORTS_CREATION_ERROR';
-export const IMPORT_CREATED = 'IMPORT_CREATED';
-
-export const IMPORTS_TASK_CREATED = 'IMPORTS_TASK_CREATED';
-export const IMPORTS_TASK_LOADED = 'IMPORTS_TASK_LOADED';
-export const IMPORTS_TASK_LOAD_ERROR = 'IMPORTS_TASK_LOAD_ERROR';
-export const IMPORTS_TASK_UPDATED = 'IMPORTS_TASK_UPDATED';
-export const IMPORTS_TASK_DELETE = 'IMPORTS_TASK_DELETE';
-export const IMPORTS_TASK_CREATION_ERROR = 'IMPORTS_TASK_CREATION_ERROR';
-
-export const LAYER_LOADED = 'LAYER_LOADED';
-export const LAYER_UPDATED = 'LAYER_UPDATED';
-
-export const IMPORTS_TRANSFORM_LOAD = 'IMPORTS_TRANSFORM_LOAD';
-export const IMPORTS_TRANSFORM_LOAD_ERROR = 'IMPORTS_TRANSFORM_LOAD_ERROR';
-export const IMPORTS_TRANSFORM_CHANGE = 'IMPORTS_TRANSFORM_CHANGE';
-
-export const IMPORTS_TRANSFORM_DELETE = 'IMPORTS_TRANSFORM_DELETE';
-export const IMPORTS_TRANSFORM_UPDATED = 'IMPORTS_TRANSFORM_UPDATED';
-
-export const IMPORTS_FILE_UPLOADED = 'IMPORTS_FILE_UPLOADED';
-export const IMPORTS_UPLOAD_PROGRESS = 'IMPORTS_UPLOAD_PROGRESS';
-
-export const IMPORTS_LIST_LOADED = 'IMPORTS_LIST_LOADED';
-export const IMPORTS_LIST_LOAD_ERROR = 'IMPORTS_LIST_LOAD_ERROR';
-export const TASK_PROGRESS_UPDATED = 'TASK_PROGRESS_UPDATED';
-
-export const IMPORT_LOADED = 'IMPORT_LOADED';
-export const IMPORT_LOAD_ERROR = 'IMPORT_LOAD_ERROR';
-export const IMPORT_RUN_SUCCESS = 'IMPORT_RUN_SUCCESS';
-export const IMPORT_RUN_ERROR = 'IMPORT_RUN_ERROR';
-export const IMPORT_DELETE = 'IMPORT_DELETE';
-export const IMPORT_DELETE_ERROR = 'IMPORT_DELETE_ERROR';
-
-export const IMPORTER_WORKSPACE_SELECTED = 'IMPORTER_WORKSPACE_SELECTED';
-export const IMPORTER_WORKSPACE_LOADED = 'IMPORTER_WORKSPACE_LOADED';
-export const IMPORTER_WORKSPACE_CREATED = 'IMPORTER_WORKSPACE_CREATED';
-export const IMPORTER_WORKSPACE_CREATION_ERROR = 'IMPORTER_WORKSPACE_CREATION_ERROR';
-export const IMPORTER_WORKSPACE_STATUS_CHANGE = 'IMPORTER_WORKSPACE_STATUS_CHANGE';
-/** *****************/
-/* UTILITY */
-/** *****************/
-
-/**
- * Check if task matches with the preset.
- * The match is by state, data.file.format and data.file.name
- * (also regex allowed for file name).
- */
-export const matchPreset = function(preset, task) {
- if (preset.state && preset.state !== task.state) {
- return false;
- }
- if (preset.data && task.data) {
- if (preset.data.format && preset.data.format !== task.data.format) {
- return false;
- }
- if (preset.data.file && preset.data.file !== task.data.file) {
- try {
- let patt = new RegExp(preset.data.file);
- if (!patt.test(task.data.file)) {
- return false;
- }
- } catch (e) {
- return false;
- }
-
- }
- }
- return true;
-};
-// for the moment supports only dataStore.name with only one change
-export const applyPlaceholders = function(preset, model) {
-
- let replaceTargetWorkspace = function(el) {
- if (isString(el)) {
- return el.replace("{targetWorkspace}", model.targetWorkspace && model.targetWorkspace.workspace && model.targetWorkspace.workspace.name);
- }
- return el;
- };
- if (preset && preset.changes && preset.changes.target && preset.changes.target.dataStore && preset.changes.target.dataStore.name) {
- return assign({}, preset, {
- changes: assign({}, preset.changes, {
- target: assign({}, preset.changes.target, {
- dataStore: assign({}, preset.changes.target.dataStore, {
- name: replaceTargetWorkspace(preset.changes.target.dataStore.name)
- })
- })
- })
- });
- }
- return preset;
-
-};
-/** *****************/
-/* ACTION CREATORS */
-/** *****************/
-
-export function loading(details, isLoading = true) {
- return {
- type: IMPORTS_LOADING,
- loading: isLoading,
- details: details
- };
-}
-export function loadError(e) {
- return {
- type: IMPORTS_LIST_LOAD_ERROR,
- error: e
- };
-}
-
-/** IMPORT **/
-export function importCretationError(e) {
- return {
- type: IMPORTS_CREATION_ERROR,
- error: e
- };
-}
-export function importCreated(importObj) {
- return {
- type: IMPORT_CREATED,
- "import": importObj
- };
-}
-
-export function importTaskCreated(importId, tasks) {
- return {
- type: IMPORTS_TASK_CREATED,
- importId: importId,
- tasks: tasks
- };
-}
-
-export function importTaskUpdated(task, importId, taskId) {
- return {
- type: IMPORTS_TASK_UPDATED,
- task,
- importId,
- taskId
- };
-}
-
-export function importTaskDeleted(importId, taskId) {
- return {
- type: IMPORTS_TASK_DELETE,
- importId,
- taskId
- };
-}
-
-export function importsLoaded(imports) {
- return {
- type: IMPORTS_LIST_LOADED,
- imports: imports
- };
-}
-
-export function importLoaded(importObj) {
- return {
- type: IMPORT_LOADED,
- "import": importObj
- };
-}
-export function importLoadError(e) {
- return {
- type: IMPORT_LOAD_ERROR,
- "error": e
- };
-}
-
-export function importRunSuccess(importId) {
- return {
- type: IMPORT_RUN_SUCCESS,
- importId
- };
-}
-
-export function importRunError(importId, error) {
- return {
- type: IMPORT_RUN_ERROR,
- importId,
- error
- };
-}
-export function importDeleted(id) {
- return {
- type: IMPORT_DELETE,
- id: id
- };
-}
-
-export function importDeleteError(id, e) {
- return {
- type: IMPORT_DELETE_ERROR,
- error: e,
- id
- };
-}
-
-/** TASKS **/
-
-export function importTaskLoaded(task) {
- return {
- type: IMPORTS_TASK_LOADED,
- task: task
- };
-}
-export function importTaskLoadError(e) {
- return {
- type: IMPORTS_TASK_LOAD_ERROR,
- task: e
- };
-}
-export function importTaskCreationError(e) {
- return {
- type: IMPORTS_TASK_CREATION_ERROR,
- error: e
- };
-}
-
-export function layerLoaded(importId, taskId, layer) {
- return {
- type: LAYER_LOADED,
- importId,
- taskId,
- layer
- };
-}
-
-export function layerUpdated(importId, taskId, layer) {
- return {
- type: LAYER_LOADED,
- importId,
- taskId,
- layer
- };
-}
-export function taskProgressUpdated(importId, taskId, info) {
- return {
- type: TASK_PROGRESS_UPDATED,
- importId,
- taskId,
- info
- };
-}
-/** TRANSFORMS **/
-export function transformLoaded(importId, taskId, transformId, transform) {
- return {
- type: IMPORTS_TRANSFORM_LOAD,
- importId,
- taskId,
- transformId,
- transform
- };
-}
-
-export function editTransform(transform) {
- return {
- type: IMPORTS_TRANSFORM_CHANGE,
- transform
- };
-}
-
-export function transformLoadError(importId, taskId, transformId, error) {
- return {
- type: IMPORTS_TRANSFORM_LOAD_ERROR,
- importId,
- taskId,
- transformId,
- error
- };
-}
-export function transformDeleted(importId, taskId, transformId) {
- return {
- type: IMPORTS_TRANSFORM_DELETE,
- importId,
- taskId,
- transformId
- };
-}
-export function transformUpdated(importId, taskId, transformId, transform) {
- return {
- type: IMPORTS_TRANSFORM_UPDATED,
- importId,
- taskId,
- transformId,
- transform
- };
-}
-/** FILE UPLOAD **/
-export function fileUploaded(files) {
- return {
- type: IMPORTS_FILE_UPLOADED,
- "files": files
- };
-}
-
-export function uploadProgress(progress) {
- return {
- type: IMPORTS_UPLOAD_PROGRESS,
- progress: progress
- };
-}
-
-/** WORKSPACES **/
-export function selectWorkSpace(workspace) {
- return {
- type: IMPORTER_WORKSPACE_SELECTED,
- workspace: workspace
- };
-}
-export function workspacesLoaded(workspaces) {
- return {
- type: IMPORTER_WORKSPACE_LOADED,
- workspaces: workspaces
- };
-}
-
-export function workspaceCreated(name) {
- return {
- type: IMPORTER_WORKSPACE_CREATED,
- name
- };
-}
-export function workspaceCreationError(name, error) {
- return {
- type: IMPORTER_WORKSPACE_CREATION_ERROR,
- name,
- error
- };
-}
-/** *****************/
-/* DISPATCHERS */
-/** *****************/
-
-/** IMPORT **/
-export function createImport(geoserverRestURL, body = {}) {
- return (dispatch) => {
- dispatch(loading());
- let options = {
- headers: {
- 'Content-Type': 'application/json'
- }
- };
- API.createImport(geoserverRestURL, body, options).then((response) => {
- dispatch(importCreated(response && response.data && response.data.import));
- dispatch(loading(null, false));
- }).catch((e) => {
- dispatch(importCretationError(e));
- dispatch(loading(null, false));
- });
- };
-}
-export function loadImports(geoserverRestURL) {
- return (dispatch) => {
- dispatch(loading());
- API.getImports(geoserverRestURL).then((response) => {
- dispatch(importsLoaded(response && response.data && response.data.imports));
- dispatch(loading(null, false));
- }).catch((e) => {
- dispatch(loadError(e));
- dispatch(loading(null, false));
- });
- };
-}
-
-export function loadImport(geoserverRestURL, importId) {
- return (dispatch) => {
- dispatch(loading({importId: importId}));
- API.loadImport(geoserverRestURL, importId).then((response) => {
- dispatch(importLoaded(response && response.data && response.data.import));
- dispatch(loading({importId: importId}, false));
- }).catch((e) => {
- dispatch(importLoadError(e));
- dispatch(loading({importId: importId}, false));
- });
- };
-}
-export function deleteImport(geoserverRestURL, importId) {
- return (dispatch) => {
- dispatch(loading({importId: importId, message: "deleting"}));
- API.deleteImport(geoserverRestURL, importId).then(() => {
- dispatch(importDeleted(importId));
- dispatch(loading({importId: importId, message: "deleting"}, false));
- }).catch((e) => {
- dispatch(importDeleteError(importId, e));
- dispatch(loading({importId: importId, message: "deleting"}, false));
- });
- };
-}
-
-export function runImport(geoserverRestURL, importId) {
- return (dispatch, getState) => {
- dispatch(loading({importId}));
- API.runImport(geoserverRestURL, importId).then(() => {
- dispatch(importRunSuccess(importId));
- if (getState && getState().selectedImport && getState().selectedImport.id === importId) {
- dispatch(loading({importId}, false));
- dispatch(loadImport(geoserverRestURL, importId));
-
- } else {
- dispatch(loading({importId}, false));
- dispatch(loadImports(geoserverRestURL));
-
- }
- }).catch((e) => {importRunError(importId, e); });
- };
-}
-/** LAYER **/
-
-export function loadLayer(geoserverRestURL, importId, taskId) {
- return (dispatch) => {
- dispatch(loading({importId: importId, taskId: taskId, element: "layer", message: "loadinglayer"}));
- return API.loadLayer(geoserverRestURL, importId, taskId).then((response) => {
- dispatch(layerLoaded(importId, taskId, response && response.data && response.data.layer));
- dispatch(loading({importId: importId, taskId: taskId, element: "layer", message: "loadinglayer"}, false));
- });
- };
-}
-export function updateLayer(geoserverRestURL, importId, taskId, layer) {
- return (dispatch) => {
- dispatch(loading({importId: importId, taskId: taskId, element: "layer", message: "loadinglayer"}));
-
- return API.updateLayer(geoserverRestURL, importId, taskId, layer).then((response) => {
- dispatch(layerUpdated(importId, taskId, response && response.data && response.data.layer));
- dispatch(loading({importId: importId, taskId: taskId, element: "layer", message: "loadinglayer"}, false));
- });
- };
-}
-/** TASKS **/
-export function loadTask(geoserverRestURL, importId, taskId) {
- return (dispatch) => {
- dispatch(loading({importId: importId, taskId: taskId}));
- API.loadTask(geoserverRestURL, importId, taskId).then((response) => {
- dispatch(importTaskLoaded(response && response.data && response.data.task));
- dispatch(loadLayer(geoserverRestURL, importId, taskId));
- dispatch(loading({importId: importId, taskId: taskId}, false));
- }).catch((e) => {
- dispatch(importTaskLoadError(e));
- dispatch(loading({importId: importId, taskId: taskId}, false));
- });
- };
-}
-export function updateUI(geoserverRestURL, importId, taskId) {
- return (dispatch, getState) => {
- let state = getState && getState() && getState().importer;
- if (state && state.selectedImport && state.selectedImport.id === importId && state.selectedTask && state.selectedTask.id === taskId) {
- dispatch(loadTask(geoserverRestURL, importId, taskId));
- dispatch(loading({importId, taskId}, false));
- } else if (state && state.selectedImport && state.selectedImport.id === importId) {
- dispatch(loadImport(geoserverRestURL, importId));
- dispatch(loading({importId}, false));
- } else {
- dispatch(loadImports(geoserverRestURL));
- dispatch(loading({importId}, false));
- }
- };
-}
-export function updateTask(geoserverRestURL, importId, taskId, body, element, message = "updating") {
- return (dispatch) => {
- let opts = {
- headers: {
- 'Content-Type': 'application/json'
- }
- };
-
- dispatch(loading({importId: importId, taskId: taskId, message}));
- return API.updateTask(geoserverRestURL, importId, taskId, element, body, opts).then((response) => {
- dispatch(importTaskUpdated(response && response.data && response.data.task, importId, taskId));
- dispatch(loading({importId: importId, taskId: taskId}, false));
- dispatch(updateUI(geoserverRestURL, importId, taskId));
- });
- };
-}
-
-export function deleteTask(geoserverRestURL, importId, taskId) {
- return (dispatch) => {
- dispatch(loading({importId: importId, taskId: taskId, message: "deleting"}));
- return API.deleteTask(geoserverRestURL, importId, taskId).then(() => {
- dispatch(importTaskDeleted(importId, taskId));
- dispatch(loading({importId: importId, taskId: taskId, message: "deleting"}, false));
- dispatch(loading({importId: importId, message: "deleting"}, false));
- });
- };
-}
-
-export function updateProgress(geoserverRestURL, importId, taskId) {
- return (dispatch) => {
- return API.getTaskProgress(geoserverRestURL, importId, taskId).then((response) => {
- dispatch(taskProgressUpdated(importId, taskId, response.data));
- });
- };
-}
-/** TRANFORMS **/
-export function loadTransform(geoserverRestURL, importId, taskId, transformId) {
- return (dispatch) => {
- dispatch(loading({importId: importId, taskId: taskId, transformId: transformId, message: "loading"}));
- return API.loadTransform(geoserverRestURL, importId, taskId, transformId).then((response) => {
- let transform = response && response.data;
- dispatch(transformLoaded(importId, taskId, transformId, transform));
- dispatch(loading({importId: importId, taskId: taskId, transformId: transformId, message: "loading"}, false));
- }).catch((e) => {transformLoadError(importId, taskId, transformId, e); });
- };
-}
-export function deleteTransform(geoserverRestURL, importId, taskId, transformId) {
- return (dispatch, getState) => {
- dispatch(loading({importId: importId, taskId: taskId, transformId: transformId, message: "loading"}));
- return API.deleteTransform(geoserverRestURL, importId, taskId, transformId).then(() => {
- dispatch(transformDeleted(importId, taskId, transformId));
- dispatch(loading({importId: importId, taskId: taskId, transformId: transformId, message: "loading"}, false));
- let state = getState().importer;
- if (state.selectedTask && state.selectedTask.id === taskId) {
- dispatch(loadTask(geoserverRestURL, importId, taskId));
- dispatch(loading({importId: importId, taskId: taskId, transformId: transformId, message: "loading"}, false));
- }
- }).catch((e) => {transformLoadError(importId, taskId, transformId, e); }); // TODO transform delete error
- };
-}
-
-export function updateTransform(geoserverRestURL, importId, taskId, transformId, transform) {
- return (dispatch) => {
- dispatch(loading({importId: importId, taskId: taskId, transformId: transformId, message: "loading"}));
- return API.updateTransform(geoserverRestURL, importId, taskId, transformId, transform).then((response) => {
- dispatch(transformUpdated(importId, taskId, transformId, response && response.data));
- dispatch(loading({importId: importId, taskId: taskId, transformId: transformId, message: "loading"}, false));
- }).catch((e) => {
- transformLoadError(importId, taskId, transformId, e); // TODO transform update error
- dispatch(loading({importId: importId, taskId: taskId, transformId: transformId, message: "loading"}, false));
- });
- };
-}
-/** PRESETS **/
-export function applyPreset(geoserverRestURL, importId, task, preset) {
-
- return (dispatch) => {
- const applyChange = (element, change) => { // TODO better as an action
- dispatch(updateTask(geoserverRestURL, importId, task.id, change, element, "applyPresets"));
- };
- if (preset.changes) {
- // update target, layer
- Object.keys(preset.changes).forEach((element) => {
- let values = preset.changes[element];
- if (Array.isArray(values)) {
- values.forEach(applyChange.bind(null, element));
- } else {
- applyChange(element, values);
- }
- });
- }
- if (preset.transforms) {
- preset.transforms.forEach( (transform) => {
- dispatch(loading({importId: importId, taskId: task.id, message: "applyPresets"}));
- API.addTransform(geoserverRestURL, importId, task.id, transform).then(() => {
- dispatch(loading({importId: importId, taskId: task.id, message: "applyPresets"}, false));
- });
- });
- }
- };
-}
-export function applyPresets(geoserverRestURL, importId, tasks, presets) {
- return (dispatch) => {
- if (tasks) {
- tasks.forEach( (task) => {
- presets.forEach( (preset) => {
- if (task.data) {
- if (matchPreset(preset, task)) {
- dispatch(applyPreset(geoserverRestURL, importId, task, preset));
- }
- } else {
- dispatch(loading({importId: importId, taskId: task.id, message: "analyzing"}));
- API.loadTask(geoserverRestURL, importId, task.id).then((response) => {
- dispatch(loading({importId: importId, taskId: task.id}, false));
- let completeTask = response && response.data && response.data.task;
- if (matchPreset(preset, completeTask)) {
- dispatch(applyPreset(geoserverRestURL, importId, completeTask, preset));
- }
- });
- }
-
- });
- });
- }
- };
-}
-
-export function loadWorkspaces(geoserverRestURL) {
- return (dispatch) => {
- Workspaces.getWorkspaces(geoserverRestURL).then((result) => {
- dispatch(workspacesLoaded(result.workspaces.workspace));
- });
- };
-}
-
-export function createWorkspace(geoserverRestURL, name, datastores = []) {
- return (dispatch) => {
- dispatch(loading());
- Workspaces.createWorkspace(geoserverRestURL, name).then(() => {
- dispatch(workspaceCreated(name));
-
- let count = datastores.length;
- if (count === 0) {
- dispatch(loading(null, false));
- } else {
- datastores.forEach((ds) => {
- // replace placeholder (this is required because in the importer the datastore name have to be unique, out of workspace)
- let datastore = ds;
- let dsname = ds.dataStore && ds.dataStore.name;
- let datastoreobj = assign({}, ds.dataStore, {name: dsname.replace("{workspace}", name)});
- datastore = assign({}, ds, {dataStore: datastoreobj});
-
- Workspaces.createDataStore(geoserverRestURL, name, datastore).then(() => {
- count--;
- if (count === 0) {
- dispatch(loading(null, false));
- }
- });
- });
- }
- }).catch((error) => {
- dispatch(workspaceCreationError(name, error));
- dispatch(loading(null, false));
-
- });
- };
-}
-
-export function dismissWorkspaceCreationStatus() {
- return {
- type: IMPORTER_WORKSPACE_STATUS_CHANGE,
- state: null
- };
-}
-
-/** UPLOAD **/
-export function uploadImportFiles(geoserverRestURL, importId, files, presets) {
- return (dispatch, getState) => {
- dispatch(loading({importId: importId, uploadingFiles: files}));
- let progressOpts = {
- progress: (progressEvent) => {
- dispatch(uploadProgress(progressEvent.loaded / progressEvent.total));
- }
- };
- API.uploadImportFiles(geoserverRestURL, importId, files, progressOpts).then((response) => {
- let tasks = response && response.data && response.data.tasks || response && response.data && [response.data.task];
- dispatch(fileUploaded(files));
- dispatch(importTaskCreated(importId, tasks));
- let state = getState();
- let impState = state.importer;
- if (impState && impState.selectedImport && impState.selectedImport.id === importId && tasks && tasks.length > 1) {
- dispatch(loadImport(geoserverRestURL, importId));
- }
- if (presets) {
- let newPreset = presets.map((preset) => applyPlaceholders(preset, state && state.importer && state.importer.selectedImport));
- dispatch(applyPresets(geoserverRestURL, importId, tasks, newPreset));
- }
- dispatch(loading({importId: importId}, false));
- }).catch((e) => {
- dispatch(importTaskCreationError(e));
- dispatch(loading({importId: importId}, false));
- });
- };
-}
-
-/** STYLER **/
-export function loadStylerTool(geoserverRestURL, importId, taskId) {
- return (dispatch, getState) => {
- return API.loadLayer(geoserverRestURL, importId, taskId).then((layerResponse) => {
- let layer = layerResponse && layerResponse.data && layerResponse.data.layer;
-
- let importObj = getState && getState().importer && getState().importer.selectedImport;
- let workspace = importObj.targetWorkspace && importObj.targetWorkspace.workspace.name;
- let stylerMapConfig = {
- "version": 2,
- "map": {
- "projection": "EPSG:3857",
- "units": "m",
- "center": {"x": 0, "y": 0, "crs": "EPSG:3857"},
- "zoom": 2,
- "maxExtent": [
- -20037508.34, -20037508.34,
- 20037508.34, 20037508.34
- ],
- "layers": [{
- "type": "osm",
- "title": "Open Street Map",
- "name": "mapnik",
- "source": "osm",
- "group": "background",
- "visibility": true
- }]
- }
- };
- let config = stylerMapConfig;
- config.map.layers = (config.map.layers || []).concat({
- "type": "wms",
- "url": "/geoserver/wms",
- "visibility": true,
- "title": layer.title,
- "name": workspace + ":" + layer.name,
- "group": "Styler",
- "format": "image/png8"
- });
- dispatch(configureMap(config));
- });
-
- };
-}
diff --git a/web/client/actions/rasterstyler.js b/web/client/actions/rasterstyler.js
deleted file mode 100644
index cbca1700c1..0000000000
--- a/web/client/actions/rasterstyler.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.
- */
-
-export const SET_RASTERSTYLE_PARAMETER = 'SET_RASTERSTYLE_PARAMETER';
-export const SET_RASTER_LAYER = 'SET_RASTER_LAYER';
-
-export function setRasterStyleParameter(component, property, value) {
- return {
- type: SET_RASTERSTYLE_PARAMETER,
- component,
- property,
- value
- };
-}
-export function setRasterLayer(layer) {
- return {
- type: SET_RASTER_LAYER,
- layer
- };
-}
diff --git a/web/client/actions/share.js b/web/client/actions/share.js
deleted file mode 100644
index 079294dad2..0000000000
--- a/web/client/actions/share.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * 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.
- */
-
-export const CHANGE_SHARE_STATE = 'CHANGE_SHARE_STATE';
-
-export function changeShareState(enabled) {
- return {
- type: CHANGE_SHARE_STATE,
- enabled: enabled
- };
-}
diff --git a/web/client/actions/styler.js b/web/client/actions/styler.js
deleted file mode 100644
index 673f4dbd2a..0000000000
--- a/web/client/actions/styler.js
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.
- */
-
-export const STYLE_SAVED = 'STYLER_STYLE_SAVED';
-export const SET_STYLER_LAYER = 'SET_STYLER_LAYER';
-export const STYLE_SAVE_ERROR = 'STYLE_SAVE_ERROR';
-export const STYLER_RESET = 'STYLER_RESET';
-
-import Layers from '../api/geoserver/Layers';
-import { saveStyle } from '../api/geoserver/Styles';
-
-export function setStylerLayer(layer) {
- return {
- type: SET_STYLER_LAYER,
- layer
- };
-}
-export function styleSaved(name, style) {
- return {
- type: STYLE_SAVED,
- name,
- style
- };
-}
-export function styleSaveError(layer, style, error) {
- return {
- type: STYLE_SAVE_ERROR,
- layer,
- style,
- error
- };
-}
-export function reset(layer) {
- return {
- type: STYLER_RESET,
- layer
- };
-}
-export function saveLayerDefaultStyle(geoserverBaseUrl, layerName, style) {
- return (dispatch) => {
- return Layers.getLayer(geoserverBaseUrl, layerName).then((layer) => {
- saveStyle(geoserverBaseUrl, layer.defaultStyle && layer.defaultStyle.name, style).then(()=> {
- dispatch(styleSaved(layer.defaultStyle.name, style));
- }).catch((e) => {styleSaveError(layerName, layer.defaultStyle, e); });
-
- }).catch((e) => {styleSaveError(layerName, null, e); });
-
- };
-}
diff --git a/web/client/actions/tasks.js b/web/client/actions/tasks.js
deleted file mode 100644
index ec41369929..0000000000
--- a/web/client/actions/tasks.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.
- */
-export const TASK_STARTED = 'TASK_STARTED';
-export const TASK_SUCCESS = 'TASK_SUCCESS';
-export const TASK_ERROR = 'TASK_ERROR';
-
-export function taskSuccess(result, name, actionPayload) {
- return {
- type: TASK_SUCCESS,
- result,
- name,
- actionPayload
- };
-}
-
-export function taskStarted(name) {
- return {
- type: TASK_STARTED,
- name
- };
-}
-
-export function taskError(error, name, actionPayload) {
- return {
- type: TASK_ERROR,
- error,
- name,
- actionPayload
- };
-}
-
-export function startTask(task, taskPayload, name, actionPayload) {
- return (dispatch) => {
- dispatch(taskStarted(name));
- task(taskPayload, (result) => {
- dispatch(taskSuccess(result, name, actionPayload));
- }, (error) => {
- dispatch(taskError(error, name, actionPayload));
- });
- };
-}
-
diff --git a/web/client/actions/vectorstyler.js b/web/client/actions/vectorstyler.js
deleted file mode 100644
index 44bea603ee..0000000000
--- a/web/client/actions/vectorstyler.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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.
- */
-import uuid from 'uuid';
-
-export const SET_VECTOR_RULE_PARAMETER = 'SET_VECTOR_RULE_PARAMETER';
-export const NEW_VECTOR_RULE = 'NEW_VECTOR_RULE';
-export const REMOVE_VECTOR_RULE = 'REMOVE_VECTOR_RULE';
-export const SELECT_VECTOR_RULE = 'SELECT_VECTOR_RULE';
-export const SET_VECTORSTYLE_PARAMETER = 'SET_VECTORSTYLE_PARAMETER';
-export const SET_VECTOR_LAYER = 'SET_VECTOR_LAYER';
-
-export function setVectorStyleParameter(component, property, value) {
- return {
- type: SET_VECTORSTYLE_PARAMETER,
- component,
- property,
- value
- };
-}
-export function setVectorRuleParameter(property, value) {
- return {
- type: SET_VECTOR_RULE_PARAMETER,
- property,
- value
- };
-}
-export function setVectorLayer(layer) {
- return {
- type: SET_VECTOR_LAYER,
- layer
- };
-}
-export function newVectorRule() {
- return {
- type: NEW_VECTOR_RULE,
- id: uuid.v1()
- };
-}
-export function removeVectorRule(id) {
- return {
- type: REMOVE_VECTOR_RULE,
- id
- };
-}
-export function selectVectorRule(id) {
- return {
- type: SELECT_VECTOR_RULE,
- id
- };
-}
diff --git a/web/client/api/MapConfigDAO.js b/web/client/api/MapConfigDAO.js
deleted file mode 100644
index b3b49be551..0000000000
--- a/web/client/api/MapConfigDAO.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.
- */
-import axios from '../libs/ajax';
-
-import ConfigUtils from '../utils/ConfigUtils';
-/**
- * API for local config
- */
-var Api = {
- get: function(url) {
- return axios.get(url).then((response) => {
- return response.data;
- });
- },
-
- /**
- * Returns Merged configurations from base url and GeoStore
- */
- getMergedConfig: function(baseConfigURL, mapId, geoStoreBase) {
- var url = ( geoStoreBase || "/mapstore/rest/geostore/" ) + "data/" + mapId;
- if (!mapId) {
- return Api.get(baseConfigURL);
- }
-
- return axios.all([axios.get(baseConfigURL), axios.get(url)])
- .then( (args) => {
- var baseConfig = args[0].data;
- var mapConfig = args[1].data;
- return ConfigUtils.mergeConfigs(baseConfig, mapConfig);
- }).catch( () => {
- return Api.get(baseConfigURL);
- });
- }
-};
-
-export default Api;
diff --git a/web/client/api/WFS3.js b/web/client/api/WFS3.js
deleted file mode 100644
index b3d5aff87d..0000000000
--- a/web/client/api/WFS3.js
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2019, 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 axios from 'axios';
-import head from 'lodash/head';
-import isString from 'lodash/isString';
-import ConfigUtils from '../utils/ConfigUtils';
-
-const capabilitiesCache = {};
-
-const collectionToLayer = (collection) => {
- const { name, title, extent, links } = collection;
- const spatial = extent && extent.spatial || [-180, -90, 180, 90];
- const { href: layerUrl, type: format } = head((links || []).filter(({ rel }) => rel === 'tiles')) || {};
- const { href: tilingSchemes } = head((links || []).filter(({ rel }) => rel === 'tilingSchemes')) || {};
- const { href: tilingScheme } = head((links || []).filter(({ rel }) => rel === 'tilingScheme')) || {};
- return {
- name,
- title,
- type: 'wfs3',
- visibility: true,
- url: layerUrl,
- format,
- tilingScheme,
- tilingSchemes,
- bbox: {
- crs: 'EPSG:4326',
- bounds: {
- minx: spatial[0],
- miny: spatial[1],
- maxx: spatial[2],
- maxy: spatial[3]
- }
- }
- };
-};
-
-const searchAndPaginate = (json = {}, startPosition, maxRecords, text, url) => {
- const { collections } = json;
- const filteredLayers = collections
- .filter((layer = {}) => !text
- || layer.name && layer.name.toLowerCase().indexOf(text.toLowerCase()) !== -1
- || layer.title && layer.title.toLowerCase().indexOf(text.toLowerCase()) !== -1);
- return {
- numberOfRecordsMatched: filteredLayers.length,
- numberOfRecordsReturned: Math.min(maxRecords, filteredLayers.length),
- nextRecord: startPosition + Math.min(maxRecords, filteredLayers.length) + 1,
- records: filteredLayers
- .filter((layer, index) => index >= startPosition - 1 && index < startPosition - 1 + maxRecords)
- .map((collection) => ({
- ...collection,
- ...collectionToLayer(collection),
- capabilitiesUrl: url
- }))
- };
-};
-
-const parseUrl = function(url) {
- const serviceUrl = (url || '').split(/\/wfs3\//)[0];
- return `${serviceUrl}/wfs3/collections`;
-};
-
-export const getRecords = function(url, startPosition, maxRecords, text) {
- const cached = capabilitiesCache[url];
- if (cached && new Date().getTime() < cached.timestamp + (ConfigUtils.getConfigProp('cacheExpire') || 60) * 1000) {
- return new Promise((resolve) => {
- resolve(searchAndPaginate(cached.data, startPosition, maxRecords, text, url));
- });
- }
- return axios.get(parseUrl(url))
- .then(({ data }) => {
- capabilitiesCache[url] = {
- timestamp: new Date().getTime(),
- data
- };
- return searchAndPaginate(data, startPosition, maxRecords, text, url);
- });
-};
-
-export const textSearch = function(url, startPosition, maxRecords, text) {
- return getRecords(url, startPosition, maxRecords, text);
-};
-
-export const getTilingSchemes = (layer) => {
- const { tilingSchemes, tilingScheme } = layer;
- if (isString(tilingSchemes)) {
- return axios.get(tilingSchemes)
- .then(({ data }) => {
- return data && data.tilingSchemes && data.tilingSchemes.length > 0
- ? axios.all(
- data.tilingSchemes.map((tilingSchemeId) =>
- axios.get(tilingScheme.replace('{tilingSchemeId}', tilingSchemeId))
- .then(({ data: scheme }) => scheme)
- .catch(() => null)
- )
- )
- .then((schemes) => ({
- tilingSchemes: {
- url: tilingSchemes,
- schemes: schemes.filter(scheme => scheme)
- },
- allowedSRS: schemes
- .filter(scheme => scheme)
- .reduce((acc, { supportedCRS }) => {
- return {
- ...acc,
- [supportedCRS]: true
- };
- }, {})
- }))
- : {
- tilingSchemes: {
- url: tilingSchemes,
- schemes: null
- },
- allowedSRS: {}
- };
- });
- }
- return new Promise((resolve) => resolve(tilingSchemes));
-};
-
-export const getLayerFromId = (serviceUrl, collectionId) => {
- return axios.get(`${parseUrl(serviceUrl)}/${collectionId}`)
- .then(({ data: collection }) => {
- const layer = collectionToLayer(collection);
- return getTilingSchemes(layer)
- .then((params) => ({
- ...layer,
- ...params
- }));
- });
-};
-
-export const reset = () => {
- Object.keys(capabilitiesCache).forEach(key => {
- delete capabilitiesCache[key];
- });
-};
diff --git a/web/client/api/__tests__/WFS3-test.js b/web/client/api/__tests__/WFS3-test.js
deleted file mode 100644
index c3b28b5ba3..0000000000
--- a/web/client/api/__tests__/WFS3-test.js
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright 2019, 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 expect from 'expect';
-import {
- getTilingSchemes,
- getLayerFromId,
- textSearch,
- reset
-} from '../WFS3';
-import MockAdapter from 'axios-mock-adapter';
-import axios from '../../libs/ajax';
-
-let mockAxios;
-
-describe('Test WFS3 API', () => {
-
- beforeEach(done => {
- mockAxios = new MockAdapter(axios);
- setTimeout(done);
- });
-
- afterEach(done => {
- mockAxios.restore();
- setTimeout(done);
- reset();
- });
-
- it('test getTilingSchemes', (done) => {
-
- const TILING_SCHEMES_URL = '/geoserver/wfs3/collections/layer_name/tiles';
- const TILING_SCHEMES_ID = 'GoogleMapsCompatible';
- const TILING_SCHEME = {
- type: 'TileMatrixSet',
- identifier: 'GoogleMapsCompatible',
- title: 'GoogleMapsCompatible',
- supportedCRS: 'EPSG:3857',
- tileMatrix: [{
- matrixHeight: 1,
- matrixWidth: 1,
- tileHeight: 256,
- tileWidth: 256,
- identifier: '0',
- scaleDenominator: 559082263.9508929,
- topLeftCorner: [
- -20037508.34,
- 20037508
- ],
- type: 'TileMatrix'
- }],
- boundingBox: {
- crs: 'http://www.opengis.net/def/crs/EPSG/0/3857',
- lowerCorner: [
- -20037508.34,
- -20037508.34
- ],
- upperCorner: [
- 20037508.34,
- 20037508.34
- ],
- type: 'BoundingBox'
- },
- wellKnownScaleSet: 'http://www.opengis.net/def/wkss/OGC/1.0/GoogleMapsCompatible'
- };
-
- mockAxios.onGet(TILING_SCHEMES_URL).reply(() => {
- return [ 200, { tilingSchemes: [ TILING_SCHEMES_ID ] }];
- });
-
- mockAxios.onGet(`${TILING_SCHEMES_URL}/${TILING_SCHEMES_ID}`).reply(() => {
- return [ 200, TILING_SCHEME];
- });
-
- const layer = {
- tilingScheme: `${TILING_SCHEMES_URL}/{tilingSchemeId}`,
- tilingSchemes: TILING_SCHEMES_URL
- };
-
- getTilingSchemes(layer)
- .then(({ tilingSchemes, allowedSRS }) => {
- expect(allowedSRS).toEqual({ 'EPSG:3857': true });
- expect(tilingSchemes).toEqual({
- url: TILING_SCHEMES_URL,
- schemes: [ TILING_SCHEME ]
- });
- done();
- });
- });
-
- it('test getLayerFromId', (done) => {
- const SERVICE_URL = '/geoserver/wfs3/collections/';
- const COLLECTIONS_ID = 'layer_name';
- const TILING_SCHEMES_URL = '/geoserver/wfs3/collections/layer_name/tiles';
- const TILING_SCHEMES_ID = 'GoogleMapsCompatible';
- const COLLECTION = {
- name: COLLECTIONS_ID,
- title: 'Layer Title',
- extent: {
- spatial: [-180, -90, 180, 90]
- },
- links: [
- {
- href: '/geoserver/wfs3/collections/layer_name/tiles/{tilingSchemeId}/{level}/{row}/{col}',
- rel: 'tiles',
- type: 'application/vnd.mapbox-vector-tile'
- },
- {
- href: '/geoserver/wfs3/collections/layer_name/tiles/{tilingSchemeId}',
- rel: 'tilingScheme',
- type: 'application/json',
- title: '...'
- },
- {
- href: TILING_SCHEMES_URL,
- rel: 'tilingSchemes',
- type: 'application/json',
- title: '...'
- }
- ]
- };
-
- const TILING_SCHEME = {
- type: 'TileMatrixSet',
- identifier: 'GoogleMapsCompatible',
- title: 'GoogleMapsCompatible',
- supportedCRS: 'EPSG:3857',
- tileMatrix: [{
- matrixHeight: 1,
- matrixWidth: 1,
- tileHeight: 256,
- tileWidth: 256,
- identifier: '0',
- scaleDenominator: 559082263.9508929,
- topLeftCorner: [
- -20037508.34,
- 20037508
- ],
- type: 'TileMatrix'
- }],
- boundingBox: {
- crs: 'http://www.opengis.net/def/crs/EPSG/0/3857',
- lowerCorner: [
- -20037508.34,
- -20037508.34
- ],
- upperCorner: [
- 20037508.34,
- 20037508.34
- ],
- type: 'BoundingBox'
- },
- wellKnownScaleSet: 'http://www.opengis.net/def/wkss/OGC/1.0/GoogleMapsCompatible'
- };
-
- mockAxios.onGet(`${SERVICE_URL}${COLLECTIONS_ID}`).reply(() => {
- return [ 200, COLLECTION];
- });
-
- mockAxios.onGet(TILING_SCHEMES_URL).reply(() => {
- return [ 200, { tilingSchemes: [ TILING_SCHEMES_ID ] }];
- });
-
- mockAxios.onGet(`${TILING_SCHEMES_URL}/${TILING_SCHEMES_ID}`).reply(() => {
- return [ 200, TILING_SCHEME];
- });
-
- getLayerFromId(SERVICE_URL, COLLECTIONS_ID)
- .then((layer) => {
- expect(layer).toEqual({
- name: COLLECTIONS_ID,
- title: 'Layer Title',
- type: 'wfs3',
- visibility: true,
- url: '/geoserver/wfs3/collections/layer_name/tiles/{tilingSchemeId}/{level}/{row}/{col}',
- format: 'application/vnd.mapbox-vector-tile',
- tilingScheme: '/geoserver/wfs3/collections/layer_name/tiles/{tilingSchemeId}',
- tilingSchemes: {
- url: TILING_SCHEMES_URL,
- schemes: [ TILING_SCHEME ]
- },
- allowedSRS: { 'EPSG:3857': true },
- bbox: {
- crs: 'EPSG:4326',
- bounds: {
- minx: -180,
- miny: -90,
- maxx: 180,
- maxy: 90
- }
- }});
- done();
- });
- });
- it('test textSearch', (done) => {
- const TILING_SCHEMES_URL = '/geoserver/wfs3/collections';
- const START_POSITION = 1;
- const MAX_RECORDS = 1;
- const TEXT = '';
- const COLLECTIONS = [
- {
- name: 'layer_name_01',
- title: 'layer title 01',
- extent: {
- spatial: [-180, -90, 180, 90]
- },
- links: []
- },
- {
- name: 'layer_name_02',
- title: 'layer title 02',
- extent: {
- spatial: [-180, -90, 180, 90]
- },
- links: []
- }
- ];
-
- mockAxios.onGet(TILING_SCHEMES_URL)
- .reply(() => {
- return [ 200, { collections: COLLECTIONS }];
- });
- textSearch(TILING_SCHEMES_URL, START_POSITION, MAX_RECORDS, TEXT)
- .then((res) => {
- expect(res).toEqual({
- numberOfRecordsMatched: 2,
- numberOfRecordsReturned: 1,
- nextRecord: 3,
- records: [{
- name: 'layer_name_01',
- title: 'layer title 01',
- extent: { spatial: [ -180, -90, 180, 90 ] },
- links: [],
- type: 'wfs3',
- visibility: true,
- url: undefined,
- format: undefined,
- tilingScheme: undefined,
- tilingSchemes: undefined,
- bbox: { crs: 'EPSG:4326', bounds: { minx: -180, miny: -90, maxx: 180, maxy: 90 } },
- capabilitiesUrl: '/geoserver/wfs3/collections'
- }]
- });
- done();
- });
- });
-});
-
diff --git a/web/client/api/geoserver/Importer.js b/web/client/api/geoserver/Importer.js
deleted file mode 100644
index 1ca8f36204..0000000000
--- a/web/client/api/geoserver/Importer.js
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * 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.
- */
-import axios from '../../libs/ajax';
-
-
-var Api = {
- getImports: function(geoserverBaseUrl, options) {
- let url = geoserverBaseUrl + "imports";
- return axios.get(url, options);
- },
- createImport: function(geoserverBaseUrl, body, options) {
- let url = geoserverBaseUrl + "imports";
- return axios.post(url, body, options);
- },
- uploadImportFiles: function(geoserverBaseUrl, importId, files = [], options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks";
- let data = new FormData();
- files.forEach((file) => {data.append(file.name, file); });
- return axios.post(url, data, options);
- },
- loadImport: function(geoserverBaseUrl, importId, options) {
- let url = geoserverBaseUrl + "imports/" + importId;
- return axios.get(url, options);
- },
- updateTask: function( geoserverBaseUrl, importId, taskId, element, body, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId;
- // element can be target, layer, transforms...
- if (element && element !== "task") {
- url += "/" + element;
- }
- return axios.put(url, body, options);
- },
- loadTask: function( geoserverBaseUrl, importId, taskId, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId;
- return axios.get(url, options);
- },
- getTaskProgress: function( geoserverBaseUrl, importId, taskId, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId + "/progress";
- return axios.get(url, options);
- },
- loadLayer: function( geoserverBaseUrl, importId, taskId, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId + "/layer";
- return axios.get(url, options);
- },
- updateLayer: function( geoserverBaseUrl, importId, taskId, layer, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId + "/layer";
- return axios.put(url, layer, options);
- },
- loadTarget: function( geoserverBaseUrl, importId, taskId, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId + "/target";
- return axios.get(url, options);
- },
- runImport: function( geoserverBaseUrl, importId, opts = {}) {
- let url = geoserverBaseUrl + "imports/" + importId + "?async=true";
- const {headers = {}, ...options } = opts;
- return axios.post(url, null, {
- ...options,
- headers: {
- ...headers,
- 'Content-Type': ''
- }
- });
- },
- deleteImport: function(geoserverBaseUrl, importId, options) {
- let url = geoserverBaseUrl + "imports/" + importId;
- return axios.delete(url, options);
- },
- deleteTask: function(geoserverBaseUrl, importId, taskId, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId;
- return axios.delete(url, options);
- },
- addTransform: function(geoserverBaseUrl, importId, taskId, transform, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId + "/transforms";
- return axios.post(url, transform, options);
- },
- loadTransform: function(geoserverBaseUrl, importId, taskId, transformId, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId + "/transforms/" + transformId;
- return axios.get(url, options);
- },
- updateTransform: function(geoserverBaseUrl, importId, taskId, transformId, transform, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId + "/transforms/" + transformId;
- return axios.put(url, transform, options);
- },
- deleteTransform: function(geoserverBaseUrl, importId, taskId, transformId, options) {
- let url = geoserverBaseUrl + "imports/" + importId + "/tasks/" + taskId + "/transforms/" + transformId;
- return axios.delete(url, options);
- }
-};
-
-export default Api;
diff --git a/web/client/api/geoserver/Workspaces.js b/web/client/api/geoserver/Workspaces.js
deleted file mode 100644
index b80d6ef3fd..0000000000
--- a/web/client/api/geoserver/Workspaces.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.
- */
-
-import axios from '../../libs/ajax';
-
-
-var Api = {
- getWorkspaces: function(geoserverRestURL) {
- return axios.get(geoserverRestURL + 'workspaces.json', {
- 'headers': {
- 'Accept': 'application/json'
- }
- }).then(function(response) {
- return response.data;
- });
- },
- createWorkspace: function(geoserverRestURL, name) {
- let body = {
- workspace: {
- name: name
- }
- };
- return axios.post(geoserverRestURL + 'workspaces', body, {
- 'headers': {
- 'Accept': 'application/json'
- }
- });
- },
- createDataStore: function(geoserverRestURL, workspace, datastore) {
- return axios.post(geoserverRestURL + 'workspaces/' + workspace + "/datastores.json", datastore, {
- 'headers': {
- 'Accept': 'application/json'
- }
- });
- }
-};
-export default Api;
diff --git a/web/client/api/geoserver/__tests__/Importer-test.js b/web/client/api/geoserver/__tests__/Importer-test.js
deleted file mode 100644
index bff34246ff..0000000000
--- a/web/client/api/geoserver/__tests__/Importer-test.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2019, 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 expect from 'expect';
-
-import axios from '../../../libs/ajax';
-import MockAdapter from 'axios-mock-adapter';
-import SAMPLE_IMPORTS_1 from '../../../test-resources/importer/imports.json';
-const BASE_URL = '/GEOSERVER_TEST/';
-import Importer from '../Importer';
-describe('GeoServer Importer API', () => {
- let mock;
- beforeEach(() => {
- mock = new MockAdapter(axios);
- });
- afterEach(() => {
- mock.restore();
- });
- it('getImports', done => {
- mock.onGet(`${BASE_URL}imports`).reply(200, SAMPLE_IMPORTS_1);
- Importer.getImports(BASE_URL).then( ({data}) => {
- expect(data.imports).toExist();
- expect((data.imports).length).toBe(2);
- done();
- }).catch(e=> done(e));
- });
- it('uploadFiles', done => {
- const ID = 1;
- const FILE_NAME = 'foobar.txt';
- const FILE_CONTENT = ['foo', 'bar'];
-
- const FILE = new File(FILE_CONTENT, FILE_NAME);
- mock.onPost(`${BASE_URL}imports/${ID}/tasks`).reply((config) => {
- expect(config.data).toExist();
- expect(config.data.get(FILE_NAME)).toExist();
- expect(config.data.get(FILE_NAME).name).toBe(FILE_NAME);
- return [200];
- });
- Importer.uploadImportFiles(BASE_URL, ID, [FILE]).then(() => {
- done();
- }).catch(e => done(e));
- });
- it('runImport', done => {
- const ID = 1;
- mock.onPost(`${BASE_URL}imports/${ID}?async=true`).reply( (config) => {
- // check that the post do not contains default axios Content-Type
- // to prevent GeoServer to fail because of invalid Content-Type
- // (POST request with empty body should not have Content-Type)
- expect(config.headers['Content-Type']).toBe('');
- return [200, ''];
- });
- Importer.runImport(BASE_URL, ID).then(({}) => {
- done();
- }).catch(e => done(e));
- });
-});
diff --git a/web/client/api/geoserver/__tests__/Workspaces-test.js b/web/client/api/geoserver/__tests__/Workspaces-test.js
deleted file mode 100644
index 7aa78a3aef..0000000000
--- a/web/client/api/geoserver/__tests__/Workspaces-test.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 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.
- */
-
-import expect from 'expect';
-
-import API from '../Workspaces';
-
-describe('Test Workspaces rest API', () => {
- it('getWorkspaces', (done) => {
- API.getWorkspaces("base/web/client/test-resources/geoserver/rest/").then((workspaces)=> {
- expect(workspaces).toExist();
- done();
- });
- });
- it('saveDatastore', (done) => {
- API.createDataStore("base/web/client/test-resources/geoserver/rest/", "test", "STYLE_BODY").then((response)=> {
- expect(response).toExist();
- done();
- });
- });
-});
diff --git a/web/client/components/I18N/LangSelector.jsx b/web/client/components/I18N/LangSelector.jsx
deleted file mode 100644
index 78db661521..0000000000
--- a/web/client/components/I18N/LangSelector.jsx
+++ /dev/null
@@ -1,54 +0,0 @@
-
-/**
- * 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.
- */
-import React from 'react';
-
-import { FormControl } from 'react-bootstrap';
-import PropTypes from 'prop-types';
-import { getSupportedLocales } from '../../utils/LocaleUtils';
-
-class LangSelector extends React.Component {
- static propTypes = {
- id: PropTypes.string,
- locales: PropTypes.object,
- currentLocale: PropTypes.string,
- onLanguageChange: PropTypes.func
- };
-
- static defaultProps = {
- id: "mapstore-langselector",
- locales: {},
- currentLocale: 'en-US',
- onLanguageChange: function() {}
- };
-
- render() {
- var val;
- var label;
- var list = [];
- let locales = getSupportedLocales();
- for (let lang in locales) {
- if (locales.hasOwnProperty(lang)) {
- val = locales[lang].code;
- label = locales[lang].description;
- list.push();
- }
- }
- return (
-
- {list}
-
- );
- }
-
- launchNewLangAction = (e) => {
- this.props.onLanguageChange(e.target.value);
- };
-}
-
-export default LangSelector;
diff --git a/web/client/components/I18N/__tests__/LangSelector-test.jsx b/web/client/components/I18N/__tests__/LangSelector-test.jsx
deleted file mode 100644
index 6c3f1622ac..0000000000
--- a/web/client/components/I18N/__tests__/LangSelector-test.jsx
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import LangSelector from '../LangSelector';
-import TestUtils from 'react-dom/test-utils';
-
-describe('LangSelector', () => {
- beforeEach((done) => {
- document.body.innerHTML = '
';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('checks default', () => {
- var lbl;
- var value;
-
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- const cmpDom = ReactDOM.findDOMNode(cmp);
- expect(cmpDom).toExist();
-
- const opts = cmpDom.childNodes;
- const langs = {
- 'Italiano': 'it-IT',
- 'English': 'en-US',
- 'Français': 'fr-FR',
- 'Deutsch': 'de-DE',
- 'Español': 'es-ES',
- "ä¸æ–‡": "zh-ZH",
- 'Nederlands': 'nl-NL',
- 'Hrvatski': 'hr-HR',
- 'Português': 'pt-PT',
- "tiếng Việt": "vi-VN",
- 'Suomi': 'fi-FI',
- 'Svenska': 'sv-SE',
- 'Slovak': 'sk-SK',
- 'Islensku': 'is-IS',
- 'Dansk': 'da-DK'
- };
-
- for (let i = 0; i < opts.length; i++) {
- lbl = opts[i].innerHTML;
- value = opts[i].value;
- expect(langs.hasOwnProperty(lbl)).toBe(true);
- expect(langs[lbl]).toBe(value);
- }
- });
-
- it('checks if a change of the combo fires the proper action', () => {
- let newLang;
- const cmp = ReactDOM.render( {
- newLang = lang;
- }}/>, document.getElementById("container"));
- const cmpDom = ReactDOM.findDOMNode(cmp);
-
- cmpDom.value = "it-IT";
- TestUtils.Simulate.change(cmpDom, {target: {value: 'it-IT'}});
- // select.children[1].click();
-
- expect(newLang).toBe('it-IT');
- });
-});
diff --git a/web/client/components/TOC/fragments/settings/FeatureInfoFormat.jsx b/web/client/components/TOC/fragments/settings/FeatureInfoFormat.jsx
deleted file mode 100644
index 1741c78fc5..0000000000
--- a/web/client/components/TOC/fragments/settings/FeatureInfoFormat.jsx
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.
- */
-
-import React from 'react';
-
-import PropTypes from 'prop-types';
-import { DropdownList } from 'react-widgets';
-import { getAvailableInfoFormat, getLabelFromValue } from '../../../../utils/MapInfoUtils';
-import { Grid } from 'react-bootstrap';
-import Message from '../../../I18N/Message';
-
-/**
- * FeatureInfoFormat shows the infoformat selected for that layer or the default one taken
- * from the general settings.
- * @class
- * @memberof components.toc
- * @prop {object} [element] the layer options
- * @prop {object} [label] the label shown for the combobox
- * @prop {object} [defaultInfoFormat] the object used to show options labels
- * @prop {string} [generalInfoFormat] the infoFormat value set in the general settings
- * @prop {function} [onInfoFormatChange] it updates the infoFormat and/or viewer for the given layer
- */
-export default class extends React.Component {
- static propTypes = {
- element: PropTypes.object,
- label: PropTypes.object,
- defaultInfoFormat: PropTypes.object,
- generalInfoFormat: PropTypes.string,
- onChange: PropTypes.func
- };
-
- static defaultProps = {
- defaultInfoFormat: getAvailableInfoFormat(),
- generalInfoFormat: "text/plain",
- onChange: () => {},
- label:
- };
-
- getInfoFormat = (infoFormats) => {
- return Object.keys(infoFormats).map((infoFormat) => {
- return infoFormat;
- });
- }
- render() {
- // the selected value if missing on that layer should be set to the general info format value and not the first one.
- const data = this.getInfoFormat(this.props.defaultInfoFormat);
- const checkDisabled = !!(this.props.element.featureInfo && this.props.element.featureInfo.viewer);
- return (
-
- {this.props.element.type === "wms" ?
- [(),
- ( {
- this.props.onChange("featureInfo", Object.assign({}, {
- ['format']: value,
- ['viewer']: this.props.element.featureInfo ? this.props.element.featureInfo.viewer : undefined
- }));
- }} />
- )] : null}
-
- );
- }
-}
diff --git a/web/client/components/TOC/fragments/settings/__tests__/FeatureInfoFormat-test.jsx b/web/client/components/TOC/fragments/settings/__tests__/FeatureInfoFormat-test.jsx
deleted file mode 100644
index 3cf8c0326f..0000000000
--- a/web/client/components/TOC/fragments/settings/__tests__/FeatureInfoFormat-test.jsx
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * 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.
- */
-
-import expect from 'expect';
-import React from 'react';
-import ReactDOM from 'react-dom';
-import ReactTestUtils from 'react-dom/test-utils';
-
-import FeatureInfoFormat from '../FeatureInfoFormat';
-
-describe('test Layer Properties FeatureInfoFormat module component', () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('tests FeatureInfoFormat component', () => {
- const l = {
- name: 'layer00',
- title: 'Layer',
- visibility: true,
- storeIndex: 9,
- type: 'shapefile',
- url: 'fakeurl'
- };
- const label = "label";
- // wrap in a stateful component, stateless components render return null
- // see: https://facebook.github.io/react/docs/top-level-api.html#reactdom.render
- const comp = ReactDOM.render(, document.getElementById("container"));
- expect(comp).toExist();
- const span = ReactTestUtils.scryRenderedDOMComponentsWithTag( comp, "span" );
- expect(span).toExist();
- expect(span.length).toBe(0);
- });
- it('tests FeatureInfoFormat component for wms', () => {
- const l = {
- name: 'layer00',
- title: 'Layer',
- visibility: true,
- storeIndex: 9,
- type: 'wms',
- url: 'fakeurl',
- featureInfo: {
- format: 'JSON'
- }
- };
- const label = "label";
- const handlers = {
- onChange() {}
- };
- let spy = expect.spyOn(handlers, "onChange");
- // wrap in a stateful component, stateless components render return null
- // see: https://facebook.github.io/react/docs/top-level-api.html#reactdom.render
- const comp = ReactDOM.render(, document.getElementById("container"));
- expect(comp).toExist();
- const span = ReactTestUtils.scryRenderedDOMComponentsWithTag( comp, "span" );
- expect(span).toExist();
- expect(span.length).toBe(2);
- span[1].click();
- const li = ReactTestUtils.scryRenderedDOMComponentsWithTag( comp, "li" );
- expect(li).toExist();
- li[0].click();
- expect(spy.calls.length).toBe(1);
- });
- it('tests FeatureInfoFormat component for wms using generalInfoFormat', () => {
- const l = {
- name: 'layer00',
- title: 'Layer',
- visibility: true,
- storeIndex: 9,
- type: 'wms',
- url: 'fakeurl'
- };
- const generalInfoFormat = "text/html";
- const label = "label";
- const comp = ReactDOM.render( {}}/>, document.getElementById("container"));
- expect(comp).toExist();
- const div = ReactTestUtils.scryRenderedDOMComponentsWithTag( comp, "div" );
- expect(div[2]).toExist();
- expect(div[2].textContent).toBe("HTML");
-
- });
-});
diff --git a/web/client/components/data/featuregrid/renderers/cell.css b/web/client/components/data/featuregrid/renderers/cell.css
deleted file mode 100644
index 09ded72ec5..0000000000
--- a/web/client/components/data/featuregrid/renderers/cell.css
+++ /dev/null
@@ -1,4 +0,0 @@
-
-.ms2 .react-grid-Row.row-selected .react-grid-Cell.modified {
- background-color: orange;
-}
diff --git a/web/client/components/data/identify/DefaultHeader.jsx b/web/client/components/data/identify/DefaultHeader.jsx
deleted file mode 100644
index 776b313e25..0000000000
--- a/web/client/components/data/identify/DefaultHeader.jsx
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-
-import React from 'react';
-
-import PropTypes from 'prop-types';
-
-class DefaultHeader extends React.Component {
- static propTypes = {
- title: PropTypes.string
- };
-
- render() {
- return {this.props.title} ;
- }
-}
-
-export default DefaultHeader;
diff --git a/web/client/components/data/identify/__tests__/DefaultHeader-test.jsx b/web/client/components/data/identify/__tests__/DefaultHeader-test.jsx
deleted file mode 100644
index b180babf7e..0000000000
--- a/web/client/components/data/identify/__tests__/DefaultHeader-test.jsx
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.
- */
-import React from 'react';
-
-import ReactDOM from 'react-dom';
-import DefaultHeader from '../DefaultHeader.jsx';
-import expect from 'expect';
-
-describe('DefaultHeader', () => {
-
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates the DefaultHeader component with defaults', () => {
- const header = ReactDOM.render(
- ,
- document.getElementById("container")
- );
-
- expect(header).toExist();
- });
-
- it('creates the DefaultHeader component with title', () => {
- const header = ReactDOM.render(
- ,
- document.getElementById("container")
- );
-
- expect(header).toExist();
- const dom = ReactDOM.findDOMNode(header);
- expect(dom.innerHTML.indexOf('mytitle') !== -1).toBe(true);
- });
-});
diff --git a/web/client/components/data/identify/css/identify.css b/web/client/components/data/identify/css/identify.css
deleted file mode 100644
index 84f53dd747..0000000000
--- a/web/client/components/data/identify/css/identify.css
+++ /dev/null
@@ -1,62 +0,0 @@
-
-#mapstore-identify-revgeocoder {
- min-height: 40px;
- margin-bottom: 10px;
- border-bottom: solid 1px #BBB;
-}
-
-
-#mapstore-getfeatureinfo {
- max-width: 100%;
- position: absolute;
- max-width: 500px;
- z-index: 1023;
- box-shadow: 2px 2px 4px #A7A7A7;
-}
-
-@media (min-width: 500px) {
- #mapstore-getfeatureinfo {
- min-width: 500px;
- }
-}
-
-@media (min-width: 768px) {
- #mapstore-getfeatureinfo {
- min-width: 660px;
- }
-}
-
-#mapstore-getfeatureinfo .swipeable-view .panel-heading {
- border: none;
- height: 60px;
- padding: 0;
-}
-
-#mapstore-getfeatureinfo .swipeable-view .panel {
- border: none;
-}
-
-#mapstore-getfeatureinfo .modal-body .panel-body {
- padding: 0;
-}
-
-#mapstore-getfeatureinfo .swipeable-view .panel-heading .swipe-header-left-button {
- right: 55px;
- top: 0;
-}
-
-#mapstore-getfeatureinfo .swipeable-view .panel-heading .swipe-header-right-button {
- top: 0;
-}
-
-#mapstore-getfeatureinfo .swipeable-view .panel-title {
- font-weight: bold;
-}
-
-.mapstore-identify-modal {
- z-index: 2001;
-}
-
-#mapstore-getfeatureinfo .m-fullscreen-btn {
- cursor: pointer;
-}
diff --git a/web/client/components/data/query/AutocompleteField.jsx b/web/client/components/data/query/AutocompleteField.jsx
deleted file mode 100644
index 6d6f47dac3..0000000000
--- a/web/client/components/data/query/AutocompleteField.jsx
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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.
-*/
-
-
-import PropTypes from 'prop-types';
-
-import React from 'react';
-import { Combobox } from 'react-widgets';
-import { Glyphicon, Tooltip } from 'react-bootstrap';
-import AutocompleteListItem from './AutocompleteListItem';
-import { getMessageById } from '../../../utils/LocaleUtils';
-import { isLikeOrIlike } from '../../../utils/FilterUtils';
-import OverlayTrigger from '../../../components/misc/OverlayTrigger';
-import HTML from '../../../components/I18N/HTML';
-/**
- * Combobox with remote autocomplete functionality.
- * @memberof components.query
- * @class
- * @prop {bool} [disabled] if the combobox should be disabled
- * @prop {object} [filterField] the filterField values
- * @prop {string} [label] the label of the combobox
- * @prop {number} [maxFeaturesWPS] the max number of features for any page
- * @prop {string} [nextPage] the icon for the next page tool
- * @prop {string} [prevPage] the icon for the prev page tool
- * @prop {function} [onUpdateField] updated the filterfield values in the state
- * @prop {bool} [paginated] if true it displays the pagination if there is more than one page
- * @prop {string} [textField] the key used for the labes corresponding to filterField.options[x].label
- * @prop {function} [toggleMenu] it toggles the combobox menu
- * @prop {string} [valueField] the key used for the values corresponding to filterField.options[x].value
- *
- */
-class AutocompleteField extends React.Component {
- static propTypes = {
- dropUp: PropTypes.bool,
- disabled: PropTypes.bool,
- filterField: PropTypes.object,
- label: PropTypes.string,
- maxFeaturesWPS: PropTypes.number,
- nextPage: PropTypes.string,
- prevPage: PropTypes.string,
- onUpdateField: PropTypes.func,
- paginated: PropTypes.bool,
- textField: PropTypes.string,
- toggleMenu: PropTypes.func,
- valueField: PropTypes.string
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- label: null,
- nextPage: "chevron-right",
- prevPage: "chevron-left",
- onUpdateField: () => {},
- paginated: true,
- valueField: "value",
- textField: "label",
- toggleMenu: () => {},
- filterField: {}
- };
-
- getOptions = () => {
- return this.props.filterField &&
- this.props.filterField.options &&
- this.props.filterField.options[this.props.filterField.attribute] &&
- this.props.filterField.options[this.props.filterField.attribute].map(o => {
- return { value: o, label: o };
- });
- };
-
- renderPagination = () => {
- const numberOfPages = Math.ceil(this.props.filterField.fieldOptions.valuesCount / this.props.maxFeaturesWPS);
- const firstPage = this.props.filterField.fieldOptions.currentPage === 1 || !this.props.filterField.fieldOptions.currentPage;
- const lastPage = this.props.filterField.fieldOptions.currentPage === numberOfPages || !this.props.filterField.fieldOptions.currentPage;
- return (
-
- { !firstPage &&
- this.props.onUpdateField(this.props.filterField.rowId, "value", this.props.filterField.value, "string", {currentPage: this.props.filterField.fieldOptions.currentPage - 1, delayDebounce: 0}) }/>
- }
- { !lastPage &&
- this.props.onUpdateField(this.props.filterField.rowId, "value", this.props.filterField.value, "string", {currentPage: this.props.filterField.fieldOptions.currentPage + 1, delayDebounce: 0})}/>
- }
-
- );
- };
- renderField = () => {
- let selectedValue;
- if (this.props.filterField && this.props.filterField.value && this.props.filterField.value !== "*") {
- selectedValue = {
- 'value': this.props.filterField.value,
- 'label': this.props.filterField.value
- };
- }
- let options = this.getOptions() ? this.getOptions().slice(0) : [];
- if (this.props.paginated && options.length > 0) {
- options.push({ label: '', value: '', disabled: true, pagination: this.renderPagination() });
- }
- const messages = {
- emptyList: getMessageById(this.context.messages, "queryform.attributefilter.autocomplete.emptyList"),
- open: getMessageById(this.context.messages, "queryform.attributefilter.autocomplete.open"),
- emptyFilter: getMessageById(this.context.messages, "queryform.attributefilter.autocomplete.emptyFilter")
- };
- const tooltip = (
- );
- const field = ( this.handleChange(value)}
- onFocus={() => {this.handleFocus(options); }}
- onSelect={this.handleSelect}
- onToggle={() => {this.handleToggle(options); }}
- textField={this.props.textField}
- valueField={this.props.valueField}
- value={selectedValue && selectedValue.value}
- />);
- return isLikeOrIlike(this.props.filterField.operator) ? (
- { field }
- ) : field;
- }
- render() {
- let label = this.props.label ? () : ();
- return (
-
- {label}
- {this.renderField()}
-
);
- }
-
- // called before onChange
- handleSelect = () => {
- this.selected = true;
- };
-
- handleChange = (input) => {
- if (this.selected) {
- this.selected = false;
- if (input && input.value !== "") {
- this.props.onUpdateField(this.props.filterField.rowId, "value", input.value, "string", {currentPage: 1, selected: "selected", delayDebounce: 0});
- }
- } else {
- this.props.onUpdateField(this.props.filterField.rowId, "value", input, "string", {currentPage: 1, delayDebounce: 1000});
- }
- };
-
- // called before onToggle
- handleFocus = (options) => {
- this.loadWithoutfilter(options);
- };
-
- handleToggle = () => {
- this.props.toggleMenu(this.props.filterField.rowId, !this.props.filterField.openAutocompleteMenu);
- };
-
- loadWithoutfilter = (options) => {
- if (options.length === 0 && !this.props.filterField.value) {
- this.props.onUpdateField(this.props.filterField.rowId, "value", "", "string", {currentPage: 1, delayDebounce: 0});
- }
- };
-}
-
-export default AutocompleteField;
diff --git a/web/client/components/data/query/SimpleFilterField.jsx b/web/client/components/data/query/SimpleFilterField.jsx
deleted file mode 100644
index 3ac4856131..0000000000
--- a/web/client/components/data/query/SimpleFilterField.jsx
+++ /dev/null
@@ -1,328 +0,0 @@
-
-/**
- * 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.
- */
-
-import PropTypes from 'prop-types';
-import React from 'react';
-import { Panel, ButtonToolbar, Tooltip } from 'react-bootstrap';
-import Button from '../../misc/Button';
-import OverlayTrigger from '../../misc/OverlayTrigger';
-import ComboField from './ComboField';
-import NumberField from './NumberField';
-import TextField from './TextField';
-import { isEqual, head, findIndex } from 'lodash';
-
-class SimpleFilterField extends React.Component {
- static propTypes = {
- dropUp: PropTypes.bool,
- operator: PropTypes.string.isRequired,
- maxLabelSize: PropTypes.number,
- label: PropTypes.string,
- attribute: PropTypes.string.isRequired,
- optionsValues: PropTypes.array,
- defaultOptions: PropTypes.array,
- optionsLabels: PropTypes.object,
- values: PropTypes.oneOfType([PropTypes.array, PropTypes.object, PropTypes.number, PropTypes.string]),
- multivalue: PropTypes.bool,
- combo: PropTypes.bool,
- toolbar: PropTypes.bool,
- type: PropTypes.oneOf(['list', 'number', 'string']).isRequired,
- collapsible: PropTypes.bool,
- defaultExpanded: PropTypes.bool,
- eventKey: PropTypes.string,
- fieldId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
- checkboxStyle: PropTypes.object,
- radioStyle: PropTypes.object,
- comboStyle: PropTypes.object,
- sort: PropTypes.oneOf(['ASC', 'DESC', false]),
- exception: PropTypes.oneOfType([
- PropTypes.object,
- PropTypes.bool,
- PropTypes.string
- ]),
- required: PropTypes.bool,
- addAllOpt: PropTypes.bool,
- updateFilter: PropTypes.func,
- valueFormatter: PropTypes.func,
- options: PropTypes.object
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- options: null,
- operator: null,
- maxLabelSize: 20,
- sort: false,
- required: false,
- exception: false,
- checkboxStyle: {},
- radioStyle: {},
- comboStyle: {},
- optionsValues: [],
- optionsLabels: {},
- defaultOptions: [],
- values: [],
- attribute: "",
- multivalue: false,
- combo: false,
- toolbar: false,
- type: null,
- collapsible: false,
- defaultExpanded: false,
- updateFilter: () => {},
- valueFormatter: (value, labels) => {
- return labels[value] ? labels[value] : value;
- }
- };
-
- shouldComponentUpdate(nextProps) {
- return !isEqual(this.props, nextProps);
- }
-
- onRChange = (e) => {
- this.props.updateFilter(this.props.fieldId, {values: [e.target.value]});
- };
-
- onCheckChange = (e) => {
- let values;
- if (e.target.checked) {
- values = [...this.props.values, e.target.value];
- } else {
- values = this.props.values.filter((v) => {
- return v !== e.target.value;
- });
- }
- let exception = this.props.required && values.length === 0 ? true : false;
- this.props.updateFilter(this.props.fieldId, {values: values, exception: exception});
- };
-
- onComboChange = (id, fieldName, value) => {
- let values = Array.isArray(value) ? value : [value];
- let exception = this.props.required && values.length === 0 ? true : false;
- this.props.updateFilter(id, {values: values, exception: exception});
- };
-
- onNumberChange = (id, fieldName, value) => {
- this.props.updateFilter(id, {values: value});
- };
-
- onNumberException = (id, exception) => {
- this.props.updateFilter(id, {exception: exception});
- };
-
- onTextChange = (id, fieldName, value) => {
- let exception = this.props.required && value.length === 0 ? true : false;
- this.props.updateFilter(id, {values: value, exception: exception});
- };
-
- getOptionsValue = () => {
- let optionsValues = this.props.optionsValues.map((opt) => {
- let val = opt;
- if (val === null) {
- val = "null";
- } else if (typeof val !== 'string') {
- val = opt.toString();
- }
- return val;
- }, this);
- if ( this.props.defaultOptions.length > 0) {
- optionsValues = this.props.defaultOptions.reduce((opts, opt) => {
- let nOpt = head(optionsValues.filter((v) => {
- return v === opt;
- }));
- if (nOpt) {
- opts.push(nOpt);
- }
- return opts;
- }, []);
- } else if (this.props.sort) {
- optionsValues = this.props.sort === "ASC" ? optionsValues.sort() : optionsValues.sort().reverse();
- }
- return optionsValues;
- };
-
- renderLabel = (opt) => {
- let lab = this.props.valueFormatter(opt, this.props.optionsLabels, this.props.maxLabelSize);
- return opt.length > this.props.maxLabelSize ?
- {lab})}>
- {lab.slice(0, this.props.maxLabelSize - 4).trim() + "...."}
-
-
- : {lab};
- };
-
- renderRadioElements = () => {
- let optionsValues = this.getOptionsValue();
- return optionsValues.map((opt, idx) => {
- return (
- );
- }, this);
- };
-
- renderRadioPanel = () => {
- return this.renderRadioElements();
- };
-
- renderCheckboxElements = () => {
- let optionsValues = this.getOptionsValue();
- return optionsValues.map((opt, idx) => {
- return (
-
- );
- }, this);
- };
-
- renderToolbar = () => {
- return (
-
-
-
-
- );
- };
-
- renderCheckboxPanel = () => {
- return (
-
- {this.renderCheckboxElements()}
- {this.props.toolbar ? this.renderToolbar() : null}
-
- );
- };
-
- renderCombo = () => {
- let optionsValues = this.getOptionsValue();
- let options = optionsValues.map((o) => {
- return {val: o, text: this.props.valueFormatter(o, this.props.optionsLabels)};
- }, this);
- let val = this.props.values && this.props.values.length > 0 ? {fieldValue: this.props.multivalue ? this.props.values : this.props.values[0] } : {};
- return (
-
-
- {this.props.toolbar && this.props.multivalue ? this.renderToolbar() : null}
-
- );
- };
-
- renderCheckOrRadio = () => {
- return this.props.multivalue ? this.renderCheckboxPanel() : this.renderRadioPanel();
- };
-
- renderText = () => {
- return (
-
- );
-
- };
-
- renderNumber = () => {
- return (
- <"}
- lowLabel={this.props.optionsLabels.lowLabel}
- upLabel={this.props.optionsLabels.upLabel}
- fieldName={this.props.attribute}
- fieldRowId={this.props.fieldId}
- fieldValue={this.props.values}
- attType={this.props.type}
- onUpdateField={this.onNumberChange}
- onUpdateExceptionField={this.onNumberException}
- fieldException={this.props.exception}
- options={this.props.options}
-
- />);
- };
-
- renderList = () => {
- return this.props.combo ? this.renderCombo() : this.renderCheckOrRadio();
- };
-
- render() {
- let comp;
- switch (this.props.type) {
- case "list": {
- comp = this.renderList();
- break;
- }
- case "number": {
- comp = this.renderNumber();
- break;
- }
- case "string": {
- comp = this.renderText();
- break;
- }
- default: {
- comp = this.renderList();
- }
- }
- return (
-
- {comp}
-
- );
- }
-
- selectAll = () => {
- let values = this.getOptionsValue();
- this.props.updateFilter(this.props.fieldId, {values: values, exception: false});
- };
-
- clearAll = () => {
- this.props.updateFilter(this.props.fieldId, {values: [], exception: this.props.required});
- };
-}
-
-export default SimpleFilterField;
diff --git a/web/client/components/data/query/__tests__/AutocompleteField-test.jsx b/web/client/components/data/query/__tests__/AutocompleteField-test.jsx
deleted file mode 100644
index dd5b55b4b0..0000000000
--- a/web/client/components/data/query/__tests__/AutocompleteField-test.jsx
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import AutocompleteField from '../AutocompleteField';
-
-describe('AutocompleteField', () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('create a AutocompleteField component without any props', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
- it('create a AutocompleteField with 2 options', () => {
- let conf = {
- filterField:
- {options: [{
- value: "val1",
- label: "val1"
- }, {
- value: "val2",
- label: "val2"
- }]
- },
- autocompleteEnabled: true
- };
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- let node = ReactDOM.findDOMNode(cmp);
- expect(node).toExist();
- let inputs = node.getElementsByTagName("input");
- expect(inputs).toExist();
- expect(inputs.length).toBe(1);
-
- });
-});
diff --git a/web/client/components/data/query/__tests__/SimpleFilterFiled-test.jsx b/web/client/components/data/query/__tests__/SimpleFilterFiled-test.jsx
deleted file mode 100644
index d4f6383618..0000000000
--- a/web/client/components/data/query/__tests__/SimpleFilterFiled-test.jsx
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import SimpleFilterField from '../SimpleFilterField';
-
-describe('SimpleFilterField', () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('create a SimpleFilterField component without any props', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
- it('create a SimpleFilterField rendering radio', () => {
- let conf = {
- "fieldId": 1,
- "label": "Highway System",
- "attribute": "highway_system",
- "multivalue": false,
- "values": ["state"],
- "optionsValues": ["local", "state"],
- "optionsLabels": {
- "local": "Local",
- "state": "State"
- },
- "required": true,
- "sort": "ASC",
- "defaultExpanded": true,
- "collapsible": true
- };
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- let node = ReactDOM.findDOMNode(cmp);
- expect(node).toExist();
- let inputs = node.getElementsByTagName("input");
- expect(inputs).toExist();
- expect(inputs.length).toBe(2);
- expect(inputs[0].getAttribute("type")).toBe("radio");
- inputs[0].checked = true;
- expect(inputs[0].checked).toBe(true);
- let e = {target: {value: "local"}};
- cmp.onRChange(e);
- });
- it('create a SimpleFilterField rendering checkbox', () => {
- let conf = {
- "fieldId": 4,
- "label": "Day(s) of Week",
- "attribute": "day_of_week",
- "checkboxStyle": {"width": 80},
- "multivalue": true,
- "required": true,
- "sort": "ASC",
- "toolbar": true,
- "type": "list",
- "operator": "=",
- "defaultExpanded": true,
- "collapsible": true,
- "optionsValues": ["Monday", "Tuesday", "Wednesday"],
- "values": ["Monday", "Tuesday", "Wednesday"],
- "defaultOptions": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
- };
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- let node = ReactDOM.findDOMNode(cmp);
- expect(node).toExist();
- let inputs = node.getElementsByTagName("input");
- expect(inputs).toExist();
- expect(inputs.length).toBe(3);
- expect(inputs[0].getAttribute("type")).toBe("checkbox");
- expect(inputs[0].checked).toBe(true);
- expect(inputs[1].checked).toBe(true);
- expect(inputs[2].checked).toBe(true);
- inputs[0].checked = true;
- let e = {target: {value: "Monday", checked: false}};
- cmp.onCheckChange(e);
- e = {target: {value: "Monday", checked: true}};
- cmp.onCheckChange(e);
-
- });
- it('create a SimpleFilterField rendering combo single with bool', () => {
- let conf = {
- "fieldId": 4,
- "label": "Day(s) of Week",
- "attribute": "day_of_week",
- "multivalue": false,
- "sort": "ASC",
- "toolbar": true,
- "type": "list",
- "operator": "=",
- "defaultExpanded": true,
- "collapsible": true,
- "optionsValues": [false, true, null],
- "values": [false],
- "combo": true,
- "optionsLabels": {
- "true": "Y",
- "false": "N",
- "null": "Empty"
- }
- };
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- cmp.onComboChange("", "", "null");
- });
- it('create a SimpleFilterField rendering combo multi', () => {
- let conf = {
- "fieldId": 4,
- "label": "Day(s) of Week",
- "attribute": "day_of_week",
- "checkboxStyle": {"width": 80},
- "multivalue": true,
- "required": true,
- "sort": "DESC",
- "toolbar": true,
- "combo": true,
- "type": "list",
- "operator": "=",
- "defaultExpanded": true,
- "collapsible": true,
- "optionsValues": ["Monday", "Tuesday", "Wednesday"],
- "values": ["Monday", "Tuesday", "Wednesday"]
- };
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- cmp.selectAll();
- cmp.clearAll();
- cmp.shouldComponentUpdate("");
- });
- it('create a SimpleFilterField rendering number', () => {
- let conf = {
- "fieldId": 4,
- "label": "Day(s) of Week",
- "attribute": "day_of_week",
- "sort": "DESC",
- "type": "number",
- "operator": "><",
- "defaultExpanded": true,
- "collapsible": true
- };
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- cmp.selectAll();
- cmp.clearAll();
- cmp.onNumberChange(4, "day_of_week", 10);
- cmp.onNumberException(4, "exception");
- });
- it('create a SimpleFilterField rendering text', () => {
- let conf = {
- "fieldId": 4,
- "label": "Day(s) of Week",
- "attribute": "day_of_week",
- "sort": "DESC",
- "type": "text",
- "operator": "ilike",
- "defaultExpanded": true,
- "collapsible": true
- };
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- cmp.selectAll();
- cmp.clearAll();
- cmp.onTextChange(4, "day_of_week", "10");
- });
-});
diff --git a/web/client/components/file/FileUploader.jsx b/web/client/components/file/FileUploader.jsx
deleted file mode 100644
index 02315b5db9..0000000000
--- a/web/client/components/file/FileUploader.jsx
+++ /dev/null
@@ -1,151 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-import React from 'react';
-
-import { round } from 'lodash';
-import { Message, DateFormat } from '../I18N/I18N';
-import Spinner from 'react-spinkit';
-import { Glyphicon, ProgressBar, Table, Alert } from 'react-bootstrap';
-import Dropzone from 'react-dropzone';
-
-class FileUploader extends React.Component {
- static propTypes = {
- dropMessage: PropTypes.node,
- dropZoneStyle: PropTypes.object,
- dropZoneActiveStyle: PropTypes.object,
- beforeUploadMessage: PropTypes.node,
- // can be a boolean or an object like this : { progress: 0.99 }
- uploading: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
- onBeforeUpload: PropTypes.func,
- onUpload: PropTypes.func,
- uploadAdditionalParams: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
- // if exists do not run before upload and start directly the upload after drag
- allowUpload: PropTypes.object,
- error: PropTypes.object
- };
-
- static defaultProps = {
- beforeUploadMessage: ,
- dropMessage: ,
- dropZoneStyle: {
- borderStyle: "dashed",
- borderWidth: "3px",
- transition: "all 0.3s ease-in-out"
- },
- dropZoneActiveStyle: {
- backgroundColor: "#eee",
- borderWidth: "5px",
- boxShadow: "0px 0px 25px 14px #d9edf7"
-
- },
- onBeforeUpload: () => {},
- onUpload: () => {}
- };
-
- state = {};
-
- componentDidUpdate() {
- if (this.props.allowUpload && this.state && this.state.files) {
- this.uploadFiles(this.state.files);
- }
- }
-
- renderProgress = (uploading) => {
- if (uploading && uploading.progress) {
- let percent = round(uploading.progress * 100, 2);
- return ;
- }
- return null;
- };
-
- renderPreview = () => {
- return (
-
-
- |
- |
- |
- |
-
-
-
- {this.state.fileList && this.state.fileList.map((file, index) =>
- (
- {file.name} |
- {this.humanFileSize(file.size)} |
- {file.type} |
- |
-
) )
- }
);
- };
-
- renderError = () => {
- if (this.props.error) {
- return There was an error during the upload: {this.props.error.statusText}{this.props.error.data}
;
- }
- return null;
- };
-
- render() {
- if (this.state && this.state.files) {
- return {this.props.beforeUploadMessage}{this.renderPreview()}
;
- } else if ( this.props && this.props.uploading && !this.state.files ) {
- return (
-
- {this.renderProgress(this.props.uploading)}
- {this.renderPreview()}
-
);
- }
-
- return (
-
-
-
- {this.props.dropMessage}
-
-
- {this.renderError()}
);
-
- }
-
- humanFileSize = (size) => {
- var i = Math.floor( Math.log(size) / Math.log(1024) );
- return ( size / Math.pow(1024, i) ).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
- };
-
- uploadFiles = (files) => {
- if (!files) return;
- if (!this.props.allowUpload) {
- this.setState({files: files, fileList: files});
- this.props.onBeforeUpload(files);
- } else {
- this.setState({files: null, fileList: files});
- this.props.onUpload(files, this.props.uploadAdditionalParams);
- }
- };
-}
-
-export default FileUploader;
diff --git a/web/client/components/help/HelpToggleBtn.jsx b/web/client/components/help/HelpToggleBtn.jsx
deleted file mode 100644
index cdf0b53dd6..0000000000
--- a/web/client/components/help/HelpToggleBtn.jsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-
-
-import React from 'react';
-
-import ToggleButton from '../buttons/ToggleButton';
-import './help.css';
-
-/**
- * A toggle button class for enabling / disabling help modus
- */
-class HelpToggleBtn extends React.Component {
- static propTypes = {
- key: PropTypes.string,
- isButton: PropTypes.bool,
- glyphicon: PropTypes.string,
- pressed: PropTypes.bool,
- changeHelpState: PropTypes.func,
- changeHelpwinVisibility: PropTypes.func
- };
-
- static defaultProps = {
- key: 'helpButton',
- isButton: true,
- glyphicon: 'question-sign'
- };
-
- onClick = () => {
- this.props.changeHelpState(!this.props.pressed);
- this.props.changeHelpwinVisibility(false);
- };
-
- render() {
- return (
-
- );
- }
-}
-
-export default HelpToggleBtn;
diff --git a/web/client/components/help/__tests__/HelpToggleBtn-test.jsx b/web/client/components/help/__tests__/HelpToggleBtn-test.jsx
deleted file mode 100644
index da721945f3..0000000000
--- a/web/client/components/help/__tests__/HelpToggleBtn-test.jsx
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * 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.
- */
-import React from 'react';
-
-import ReactDOM from 'react-dom';
-import HelpToggleBtn from '../HelpToggleBtn';
-import expect from 'expect';
-
-describe('Test for HelpToggleBtn', () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- // test DEFAULTS
- it('creates the component with defaults', () => {
- const helpToggleBtn = ReactDOM.render(, document.getElementById("container"));
- expect(helpToggleBtn).toExist();
-
- const helpToggleBtnDom = ReactDOM.findDOMNode(helpToggleBtn);
- expect(helpToggleBtnDom).toExist();
-
- const icons = helpToggleBtnDom.getElementsByTagName('span');
- expect(icons.length).toBe(1);
-
- expect(helpToggleBtnDom.className.indexOf('default') >= 0).toBe(true);
- expect(helpToggleBtnDom.innerHTML).toExist();
- });
-
- it('test button state', () => {
- const helpToggleBtn = ReactDOM.render(, document.getElementById("container"));
- expect(helpToggleBtn).toExist();
-
- const helpToggleBtnDom = ReactDOM.findDOMNode(helpToggleBtn);
-
- expect(helpToggleBtnDom.className.indexOf('primary') >= 0).toBe(true);
- });
-
- it('test click handler calls right functions', () => {
- var triggered = 0;
- const clickFn = {
- changeHelpState: () => {triggered++; },
- changeHelpwinVisibility: () => {triggered++; }
- };
- // const spy = expect.spyOn(testHandlers, 'onClick');
- const helpToggleBtn = ReactDOM.render(, document.getElementById("container"));
-
- const helpToggleBtnDom = ReactDOM.findDOMNode(helpToggleBtn);
- helpToggleBtnDom.click();
-
- expect(triggered).toEqual(2);
- });
-
-});
diff --git a/web/client/components/manager/importer/BreadCrumb.jsx b/web/client/components/manager/importer/BreadCrumb.jsx
deleted file mode 100644
index 362bdbe1d8..0000000000
--- a/web/client/components/manager/importer/BreadCrumb.jsx
+++ /dev/null
@@ -1,68 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-import React from 'react';
-
-import Message from '../../I18N/Message';
-
-class BreadCrumb extends React.Component {
- static propTypes = {
- loading: PropTypes.bool,
- loadImports: PropTypes.func,
- loadImport: PropTypes.func,
- loadTask: PropTypes.func,
- selectedImport: PropTypes.object,
- selectedTask: PropTypes.object,
- selectedTransform: PropTypes.object
- };
-
- static defaultProps = {
- loadImports: () => {},
- loadImport: () => {},
- loadTask: () => {}
- };
-
- render() {
- if ( this.props.selectedImport && this.props.selectedTask && this.props.selectedTransform) {
- return (
- - {e.preventDefault(); this.props.loadImports(); }}>
- - {e.preventDefault(); this.props.loadImport(this.props.selectedImport.id); }}>
-
-
- - {e.preventDefault(); this.props.loadTask(this.props.selectedImport.id, this.props.selectedTask.id); }}>
- Package {this.props.selectedTask.id}
-
- - Transform {this.props.selectedTransform.id}
-
);
- }
- if ( this.props.selectedImport && this.props.selectedTask) {
- return (
-
- - {e.preventDefault(); this.props.loadImports(); }}>
- - {e.preventDefault(); this.props.loadImport(this.props.selectedImport.id); }}>
-
-
- - Package {this.props.selectedTask.id}
-
);
- }
- if (this.props.selectedImport) {
- return (
-
- - {e.preventDefault(); this.props.loadImports(); }}>
-
-
);
- }
- return (
-
-
-
);
- }
-}
-
-export default BreadCrumb;
diff --git a/web/client/components/manager/importer/Import.jsx b/web/client/components/manager/importer/Import.jsx
deleted file mode 100644
index 39749547c9..0000000000
--- a/web/client/components/manager/importer/Import.jsx
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * 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.
- */
-
-import React from 'react';
-import PropTypes from 'prop-types';
-import Spinner from 'react-spinkit';
-import OverlayTrigger from '../../misc/OverlayTrigger';
-
-import Message from '../../I18N/Message';
-import TaskProgress from './TaskProgress';
-import { getbsStyleForState } from '../../../utils/ImporterUtils';
-import { Grid, Row, Panel, Label, Table, Glyphicon, Tooltip } from 'react-bootstrap';
-import './style/importer.css';
-import Button from '../../misc/Button';
-
-class Task extends React.Component {
- static propTypes = {
- timeout: PropTypes.number,
- "import": PropTypes.object,
- loadImport: PropTypes.func,
- loadTask: PropTypes.func,
- loadStylerTool: PropTypes.func,
- runImport: PropTypes.func,
- updateProgress: PropTypes.func,
- deleteImport: PropTypes.func,
- deleteTask: PropTypes.func,
- deleteAction: PropTypes.node,
- placement: PropTypes.string
- };
-
- static contextTypes = {
- router: PropTypes.object,
- messages: PropTypes.object
- };
-
- static defaultProps = {
- placement: "bottom",
- deleteAction: ,
- timeout: 10000,
- "import": {},
- loadTask: () => {},
- runImport: () => {},
- loadImport: () => {},
- loadStylerTool: () => {},
- updateProgress: () => {},
- deleteImport: () => {},
- deleteTask: () => {}
- };
-
- componentDidMount() {
- if (this.props.import.state === "RUNNING") {
- // Check if some task is running the update is not needed
- this.interval = setInterval(this.props.loadImport.bind(null, this.props.import.id), this.props.timeout);
-
- }
- }
-
- componentWillUnmount() {
- if (this.interval) {
- clearInterval(this.interval);
- }
- }
-
- renderGeneral = (importObj) => {
- return (
-
-
-
- - {importObj.archive}
-
);
- };
-
- renderProgressTask = (task) => {
- if ( task.state === "RUNNING") {
- return ;
- }
- return null;
- };
-
- renderTask = (task) => {
- let tooltipDelete = {this.props.deleteAction};
- return (
- {e.preventDefault(); this.props.loadTask(task.id); }} >{task.id} |
- {this.renderProgressTask(task)}{this.renderLoadingTask(task)} |
-
-
-
-
- |
-
);
- };
-
- renderLoading = () => {
- if (this.props.import.loading) {
- return
;
- }
- return null;
- };
-
- renderLoadingMessage = (task) => {
- switch (task.message) {
- case "applyPresets":
- return ;
- case "deleting":
- return ;
- case "analyzing":
- return ;
- default:
- return null;
- }
- };
-
- renderLoadingTask = (task) => {
- if (task.loading) {
- return (
- {this.renderLoadingMessage(task)}
-
);
- }
- return null;
- };
-
- render() {
- return (
- {this.renderLoading()}} >
-
-
- {this.renderGeneral(this.props.import)}
-
-
-
-
-
-
- |
- |
- |
-
-
-
- {this.props.import.tasks.map(this.renderTask)}
-
-
-
-
- {
- this.props.import.tasks.reduce((prev, cur) => prev || cur.state === "READY", false) ?
-
- : null
- }
-
-
-
-
- );
- }
-
- editDefaultStyle = (taskId) => {
- this.context.router.history.push("/styler/openlayers");
- this.props.loadStylerTool(taskId);
- };
-}
-
-export default Task;
diff --git a/web/client/components/manager/importer/Importer.jsx b/web/client/components/manager/importer/Importer.jsx
deleted file mode 100644
index db9ec69323..0000000000
--- a/web/client/components/manager/importer/Importer.jsx
+++ /dev/null
@@ -1,263 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-import React from 'react';
-
-import Spinner from 'react-spinkit';
-import Message from '../../I18N/Message';
-import ImportsGrid from './ImportsGrid';
-import Workspace from './Workspace';
-import FileUploader from '../../file/FileUploader';
-import Task from './Task';
-import Import from './Import';
-import Transform from './Transform';
-import { Grid, Col, Row, Alert } from 'react-bootstrap';
-import BreadCrumb from './BreadCrumb';
-import { head } from 'lodash';
-
-class Importer extends React.Component {
- static propTypes = {
- loading: PropTypes.bool,
- taskCreationError: PropTypes.object,
- error: PropTypes.object,
- defaultPresets: PropTypes.string,
- /**
- * Presets: {PRESET_ID: [changes: [{target: {}, layer: {}}], match: function() {...}, transforms: [{}, {}] }]}
- */
- presets: PropTypes.object,
- uploading: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
- createImport: PropTypes.func,
- runImport: PropTypes.func,
- loadWorkspaces: PropTypes.func,
- workspaces: PropTypes.array,
- selectedWorkSpace: PropTypes.object,
- selectWorkSpace: PropTypes.func,
- workspaceCreationStatus: PropTypes.object,
- dismissWorkspaceCreationStatus: PropTypes.func,
- createWorkspace: PropTypes.func,
- datastoreTemplates: PropTypes.array,
- deleteImport: PropTypes.func,
- updateTask: PropTypes.func,
- deleteTask: PropTypes.func,
- loadImports: PropTypes.func,
- loadImport: PropTypes.func,
- loadTask: PropTypes.func,
- updateProgress: PropTypes.func,
- loadLayer: PropTypes.func,
- updateLayer: PropTypes.func,
- loadStylerTool: PropTypes.func,
- loadTransform: PropTypes.func,
- updateTransform: PropTypes.func,
- editTransform: PropTypes.func,
- deleteTransform: PropTypes.func,
- uploadImportFiles: PropTypes.func,
- selectedImport: PropTypes.object,
- selectedTask: PropTypes.object,
- selectedTransform: PropTypes.object,
- imports: PropTypes.array,
- onMount: PropTypes.func
- };
-
- static defaultProps = {
- createImport: () => {},
- loadImport: () => {},
- loadTask: () => {},
- loadLayer: () => {},
- loadTransform: () => {},
- editTransform: () => {},
- updateTransform: () => {},
- loadImports: () => {},
- updateProgress: () => {},
- deleteTransform: () => {},
- uploadImportFiles: () => {},
- loadWorkspaces: () => {},
- dismissWorkspaceCreationStatus: () => {},
- createWorkspace: () => {},
- onMount: () => {},
- imports: []
- };
-
- componentDidMount() {
- this.props.onMount();
- }
-
- getPresets = () => {
- return this.props.presets && this.props.presets[this.props.defaultPresets];
- };
-
- getImportCreationDefaults = () => {
- let presets = this.getPresets();
- if (!presets) {
- return {
- importCreationDefaults: {
- "import": {
- "targetWorkspace": {
- "workspace": {
- "name": "cite"
- }
- }
- }
- }
- };
- } else if (this.props.selectedWorkSpace) {
- return {
- "import": {
- "targetWorkspace": {
- "workspace": {
- "name": this.props.selectedWorkSpace.value
- }
- }
- }
- };
- }
- return head(presets.filter((preset) => preset.import ));
- };
-
- getTargetWorkspace = (selectedImport) => {
- let targetWorkspace = selectedImport && selectedImport.targetWorkspace;
- if (targetWorkspace) {
- return targetWorkspace && targetWorkspace.workspace && targetWorkspace.workspace.name;
- }
- let creationDefaults = this.getImportCreationDefaults();
- let importObj = creationDefaults && creationDefaults.import || creationDefaults && creationDefaults.importCreationDefaults && creationDefaults.importCreationDefaults.import;
- return importObj && importObj.targetWorkspace && importObj.targetWorkspace.workspace && importObj.targetWorkspace.workspace.name;
-
-
- };
-
- renderError = () => {
- if (this.props.error) {
- return There was an error during the import list loading: {this.props.error.statusText};
- }
- return null;
- };
-
- renderLoading = () => {
- if (this.props.loading) {
- return
;
- }
- return null;
- };
-
- renderDetails = () => {
- let breadcrumb = ();
- if ( this.props.selectedImport && this.props.selectedTask && this.props.selectedTransform) {
- return (
- {breadcrumb}
-
Transform {this.props.selectedTransform.id}
-
- );
- }
- if ( this.props.selectedImport && this.props.selectedTask) {
- return (
- {breadcrumb}
-
-
);
- }
- if (this.props.selectedImport) {
- return (
- {breadcrumb}
-
-
);
- }
- return (
- {breadcrumb}
-
-
);
- };
-
- render() {
- let message = this.props.selectedImport ? "importer.dropfileImport" : "importer.dropfile";
- return (
-
-
-
- }
- dropMessage={}
- uploading={this.props.uploading}
- allowUpload={this.props.selectedImport}
- onBeforeUpload={this.props.createImport.bind(null, this.getImportCreationDefaults())}
- onUpload={this.props.uploadImportFiles.bind(null, this.props.selectedImport && this.props.selectedImport.id)}
- uploadAdditionalParams={this.getPresets()} />
-
-
-
-
-
-
- {this.renderLoading()}
- {this.renderDetails()}
- {this.renderError()}
-
- );
- }
-
- createUpdateFunction = () => {
- return;
- };
-}
-
-export default Importer;
diff --git a/web/client/components/manager/importer/ImportsGrid.jsx b/web/client/components/manager/importer/ImportsGrid.jsx
deleted file mode 100644
index 9f9d26171b..0000000000
--- a/web/client/components/manager/importer/ImportsGrid.jsx
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * 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.
- */
-
-import React from 'react';
-import Spinner from 'react-spinkit';
-import PropTypes from 'prop-types';
-import { Table, Glyphicon, Label, Tooltip } from 'react-bootstrap';
-import { findIndex } from 'lodash';
-
-import Button from '../../misc/Button';
-import Message from '../../I18N/Message';
-import { getbsStyleForState } from '../../../utils/ImporterUtils';
-import OverlayTrigger from '../../misc/OverlayTrigger';
-
-class ImportsGrid extends React.Component {
- static propTypes = {
- loading: PropTypes.bool,
- timeout: PropTypes.number,
- loadImports: PropTypes.func,
- loadImport: PropTypes.func,
- deleteImport: PropTypes.func,
- imports: PropTypes.array,
- deleteAction: PropTypes.object,
- placement: PropTypes.string
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- timeout: 5000,
- loadImports: () => {},
- placement: "bottom",
- deleteAction: ,
- loadImport: () => {},
- deleteImport: () => {},
- imports: []
- };
-
- componentDidMount() {
- this.interval = setInterval(() => {this.update(); }, this.props.timeout);
- }
-
- componentWillUnmount() {
- clearInterval(this.interval);
- }
-
- renderLoadingMessage = (importObj) => {
- switch (importObj.message) {
- case "deleting":
- return ;
- default:
- return null;
- }
- };
-
- renderLoadingImport = (importObj) => {
- if (importObj.loading) {
- return {this.renderLoadingMessage(importObj)}
;
- }
- return null;
- };
-
- renderImportErrorMessage = (imp) => {
- if (imp && imp.error) {
- return ;
- }
- return null;
- };
-
- renderImport = (importObj) => {
- let tooltip = {this.props.deleteAction};
- return (
- {e.preventDefault(); this.props.loadImport(importObj.id); }} >{importObj.id} |
-
- {this.renderLoadingImport(importObj)}
- {this.renderImportErrorMessage(importObj)}
- |
-
-
-
-
- |
-
);
- };
-
- render() {
- if (this.props.loading && this.props.imports.length === 0) {
- return ;
- }
- return (
-
-
-
- |
- |
- |
-
-
-
- {this.props.imports.map(this.renderImport)}
-
-
- );
- }
-
- update = () => {
- if (this.props.imports) {
- let i = findIndex(this.props.imports, (importObj) => importObj.state === "RUNNING");
- if ( i >= 0 ) {
- this.props.loadImports();
- }
- }
- };
-}
-
-export default ImportsGrid;
diff --git a/web/client/components/manager/importer/Layer.jsx b/web/client/components/manager/importer/Layer.jsx
deleted file mode 100644
index d00a211a71..0000000000
--- a/web/client/components/manager/importer/Layer.jsx
+++ /dev/null
@@ -1,99 +0,0 @@
-
-/**
- * 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.
- */
-
-import React from 'react';
-import PropTypes from 'prop-types';
-
-import Button from '../../misc/Button';
-import { Panel } from 'react-bootstrap';
-import Message from '../../I18N/Message';
-
-
-class Layer extends React.Component {
- static propTypes = {
- layer: PropTypes.object,
- loading: PropTypes.bool,
- edit: PropTypes.bool,
- panProps: PropTypes.object,
- updateLayer: PropTypes.func
- };
-
- static defaultProps = {
- layer: {},
- edit: true,
- loading: false,
- updateLayer: () => {}
- };
-
- state = {};
-
- onChange = (event) => {
- let state = {};
- state[event.target.name] = event.target.value || "";
- this.setState(state);
- };
-
- renderInput = (name) => {
- let input;
- if (name !== "description") {
- input = ();
- } else {
- input = ();
- }
- return [ {name},
-
- {input}
- ];
- };
-
- render() {
- return (
-
- {["name", "title", "description"].map(this.renderInput)}
-
-
-
-
- );
- }
-
- isValid = () => {
- return this.state.name !== "";
- };
-
- isModified = () => {
- return Object.keys(this.state).some((element) => {
- return this.state[element] !== this.props.layer[element];
-
- });
- };
-
- isUpdateEnabled = () => {
- return this.isModified() && this.isValid() && !this.props.loading;
- };
-}
-
-export default Layer;
diff --git a/web/client/components/manager/importer/Task.jsx b/web/client/components/manager/importer/Task.jsx
deleted file mode 100644
index a779845fd6..0000000000
--- a/web/client/components/manager/importer/Task.jsx
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * 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.
- */
-
-import React from 'react';
-import PropTypes from 'prop-types';
-import { Grid, Col, Row, Panel, Label, Alert } from 'react-bootstrap';
-import Spinner from 'react-spinkit';
-import { DropdownList } from 'react-widgets';
-
-import Button from '../../misc/Button';
-import { Message } from '../../I18N/I18N';
-import { getbsStyleForState } from '../../../utils/ImporterUtils';
-import Layer from './Layer';
-import TransformsGrid from './TransformsGrid';
-
-class Task extends React.Component {
- static propTypes = {
- task: PropTypes.object,
- panStyle: PropTypes.object,
- updateTask: PropTypes.func,
- deleteTask: PropTypes.func,
- loadLayer: PropTypes.func,
- updateLayer: PropTypes.func,
- loadTransform: PropTypes.func,
- deleteTransform: PropTypes.func
- };
-
- static defaultProps = {
- task: {},
- panStyle: {
- minHeight: "250px"
- },
- updateTask: () => {},
- deleteTask: () => {},
- loadLayer: () => {},
- updateLayer: () => {},
- loadTransform: () => {},
- deleteTransform: () => {}
-
- };
-
- renderLoading = (element) => {
- if (this.props.task.loading ) {
- if (!element) {
- return ;
- } else if (this.props.task.element === element) {
- return ;
- }
- }
- return null;
- };
-
- renderErrorMessage = (task) => {
- if (task.errorMessage && task.state === "ERROR") {
- return (
- {task.errorMessage});
- }
- return null;
-
- };
-
- renderGeneral = (task) => {
- let modes = this.props.task.transformChain && this.props.task.transformChain.type === "vector" ? ["CREATE"] : ["CREATE", "REPLACE"];
- return (}>
-
-
- - {this.renderErrorMessage(task)}
-
- - {
- this.props.task.state === "READY" // force this to default because APPEND and REPLACE are not supported yet.
- /* this.props.task */? :
- task.updateMode}
-
- );
- };
-
- renderDataPanel = (data) => {
- return (}>
-
-
- - {data.file}
-
- - {data.format}
-
- );
- };
-
- renderTargetPanel = (target) => {
- if (!target) {
- return null;
- }
- return ({this.renderLoading("target")}}>
-
-
- - {target.dataStore && target.dataStore.type || target.coverageStore && target.coverageStore.type}
-
- - {target.dataStore && target.dataStore.name || target.coverageStore && target.coverageStore.name}
-
- );
- };
-
- render() {
- return (
- } >
-
-
-
- {this.renderGeneral(this.props.task)}
-
-
- {this.renderDataPanel(this.props.task.data)}
-
-
- {this.renderTargetPanel(this.props.task.target)}
-
-
- {this.renderLoading("layer")},
- style: this.props.panStyle
- }}
- layer={this.props.task.layer}
- updateLayer={this.props.updateLayer}/>
-
-
-
-
-
-
-
-
-
-
- );
- }
-
- updateMode = (value) => {
- this.props.updateTask({
- "updateMode": value
- });
- };
-}
-
-export default Task;
diff --git a/web/client/components/manager/importer/TaskProgress.jsx b/web/client/components/manager/importer/TaskProgress.jsx
deleted file mode 100644
index 7c688cfb22..0000000000
--- a/web/client/components/manager/importer/TaskProgress.jsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-import React from 'react';
-
-import { ProgressBar } from 'react-bootstrap';
-import Spinner from 'react-spinkit';
-
-class TaskProgress extends React.Component {
- static propTypes = {
- progress: PropTypes.number,
- update: PropTypes.func,
- total: PropTypes.number,
- timeout: PropTypes.number,
- state: PropTypes.string
- };
-
- static defaultProps = {
- timeout: 1000,
- update: () => {},
- progress: 0
- };
-
- componentDidMount() {
- this.interval = setInterval(this.update.bind(this), this.props.timeout);
- }
-
- componentWillUnmount() {
- clearInterval(this.interval);
- }
-
- render() {
- if (this.props.total) {
- let percent = 100 * this.props.progress / this.props.total;
- percent = percent.toFixed(2);
- return (
-
- );
- }
- return ;
- }
-
- update = () => {
- if (this.props.state === "RUNNING") {
- this.props.update();
- }
- };
-}
-
-export default TaskProgress;
diff --git a/web/client/components/manager/importer/Transform.jsx b/web/client/components/manager/importer/Transform.jsx
deleted file mode 100644
index adfccd9dec..0000000000
--- a/web/client/components/manager/importer/Transform.jsx
+++ /dev/null
@@ -1,81 +0,0 @@
-
-/**
- * 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.
- */
-
-import React from 'react';
-import Button from '../../misc/Button';
-import PropTypes from 'prop-types';
-import { Panel, Glyphicon, Tooltip } from 'react-bootstrap';
-import OverlayTrigger from '../../misc/OverlayTrigger';
-import { Message } from '../../I18N/I18N';
-import transforms from './transforms';
-
-class Transform extends React.Component {
- static propTypes = {
- transform: PropTypes.object,
- editTransform: PropTypes.func,
- updateTransform: PropTypes.func
- };
-
- static defaultProps = {
- transform: {},
- editTransform: () => {},
- updateTransform: () => {}
- };
-
- renderTransformOptions = () => {
- if (transforms[this.props.transform.type]) {
- let TransformEl = transforms[this.props.transform.type];
- return ();
- }
- return null;
- };
-
- renderSave = () => {
- return ;
- };
-
- renderHelpLink = () => {
- const tooltip =
- See More information about this transformation;
- if (transforms.help && transforms.help[this.props.transform.type]) {
- return ;
- }
- return null;
- };
-
- renderHeader = () => {
- return (
-
- {this.renderHelpLink()});
- };
-
- render() {
- return (
-
- {this.props.transform.type}
- {this.renderTransformOptions()}
- {this.renderSave()}
-
- );
- }
-
- isModified = () => {
- return this.props.transform && this.props.transform.status === "modified";
- };
-
- isValid = () => {
- return this.refs.transformForm && this.refs.transformForm.isValid(this.props.transform);
- };
-}
-
-export default Transform;
diff --git a/web/client/components/manager/importer/TransformsGrid.jsx b/web/client/components/manager/importer/TransformsGrid.jsx
deleted file mode 100644
index 3ff9d82eba..0000000000
--- a/web/client/components/manager/importer/TransformsGrid.jsx
+++ /dev/null
@@ -1,78 +0,0 @@
-
-/**
- * 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.
- */
-import React from 'react';
-import Spinner from 'react-spinkit';
-import PropTypes from 'prop-types';
-import { Panel, Table, Glyphicon, Tooltip } from 'react-bootstrap';
-
-import Message from '../../I18N/Message';
-import OverlayTrigger from '../../misc/OverlayTrigger';
-import Button from '../../misc/Button';
-
-class TransformsGrid extends React.Component {
- static propTypes = {
- loading: PropTypes.bool,
- panProps: PropTypes.object,
- type: PropTypes.string,
- loadTransform: PropTypes.func,
- deleteTransform: PropTypes.func,
- transforms: PropTypes.array,
- deleteAction: PropTypes.object,
- placement: PropTypes.string
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- placement: "bottom",
- deleteAction: ,
- transforms: [],
- loadTransform: () => {},
- deleteTransform: () => {}
- };
-
- renderTransform = (transform, index) => {
- let tooltip = {this.props.deleteAction};
- return (
- {e.preventDefault(); this.props.loadTransform(index); }}>{index} |
- {transform.type} |
-
-
-
-
- |
-
);
- };
-
- render() {
- if (this.props.loading && this.props.transforms.length === 0) {
- return ;
- }
- return (
- }>
-
-
-
- |
- |
- |
-
-
-
- {this.props.transforms.map(this.renderTransform)}
-
-
-
- );
- }
-}
-
-export default TransformsGrid;
diff --git a/web/client/components/manager/importer/Workspace.jsx b/web/client/components/manager/importer/Workspace.jsx
deleted file mode 100644
index 71c83bef3e..0000000000
--- a/web/client/components/manager/importer/Workspace.jsx
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * 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.
- */
-
-import React from 'react';
-import Select from 'react-select';
-import PropTypes from 'prop-types';
-import { FormControl, Alert } from 'react-bootstrap';
-
-import Message from '../../I18N/Message';
-import { getMessageById } from '../../../utils/LocaleUtils';
-import Button from '../../misc/Button';
-
-export default class extends React.Component {
- static propTypes = {
- enabled: PropTypes.bool,
- status: PropTypes.object,
- onStatusDismiss: PropTypes.func,
- selectWorkSpace: PropTypes.func,
- selectedWorkSpace: PropTypes.string,
- workspaces: PropTypes.array,
- loadWorkspaces: PropTypes.func,
- datastoreTemplates: PropTypes.array,
- createWorkspace: PropTypes.func
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- loadWorkspaces: () => {},
- createWorkspace: () => {},
- selectWorkSpace: () => {},
- onStatusDismiss: () => {},
- datastoreTemplates: []
- };
-
- state = {
- valid: false
- };
-
- componentDidMount() {
- if (!this.props.workspaces) this.props.loadWorkspaces();
- }
-
- renderAlert = () => {
- if (this.props.status && this.props.status.status === "error") {
- return (
-
- );
- } else if (this.props.status && this.props.status.status === "success") {
- return (
-
- );
- }
- return null;
- };
-
- render() {
- return (
-
- {this.props.enabled ?
- (
{this.props.selectedWorkSpace}
)
- : (
);
- }
-
- isValid = (name) => {
- // should not contain spaces
- return name.indexOf(" ") < 0 && name.length > 0;
- };
-
- validate = (e) => {
- let name = e.target.value;
- let valid = this.isValid(name);
- this.setState({valid, name});
- };
-
- createWorkspace = () => {
- let name = this.state && this.state.name;
- let valid = this.isValid(name);
- if (name && valid) {
- this.props.createWorkspace(name, this.props.datastoreTemplates);
- }
- };
-}
diff --git a/web/client/components/manager/importer/style/importer.css b/web/client/components/manager/importer/style/importer.css
deleted file mode 100644
index 9ef15187cf..0000000000
--- a/web/client/components/manager/importer/style/importer.css
+++ /dev/null
@@ -1,6 +0,0 @@
-.importer-button {
- margin-left: 5px;
-}
-.importer-page .importer-plugin{
- margin: 20px
-}
diff --git a/web/client/components/manager/importer/transforms/GdalAddoTransform.jsx b/web/client/components/manager/importer/transforms/GdalAddoTransform.jsx
deleted file mode 100644
index b1b56a3f76..0000000000
--- a/web/client/components/manager/importer/transforms/GdalAddoTransform.jsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-import React from 'react';
-
-import { FormControl } from 'react-bootstrap';
-import assign from 'object-assign';
-import { findIndex } from 'lodash';
-import { Message, Alert } from '../../../I18N/I18N';
-
-class GdalTranslateTransform extends React.Component {
- static propTypes = {
- transform: PropTypes.object,
- editTransform: PropTypes.func
- };
-
- static defaultProps = {
- transform: {
- options: [],
- levels: []
- },
- editTransform: () => {},
- updateTransform: () => {}
- };
-
- onChange = (event) => {
- let value = event.target.value || "";
- this.props.editTransform(assign({}, this.props.transform, {[event.target.name]: value.split(/\s+/g) }));
- };
-
- renderInvalid = () => {
- if (!this.isValid(this.props.transform)) {
- return This transform is not valid;
- }
- return null;
- };
-
- render() {
- return ();
- }
-
- isValid = (t) => {
- return t && t.options && findIndex(t.options, (e) => e === "") < 0 &&
- t.levels && findIndex(t.levels, (e) => e === "") < 0;
- };
-}
-
-export default GdalTranslateTransform;
diff --git a/web/client/components/manager/importer/transforms/GdalTranslateTransform.jsx b/web/client/components/manager/importer/transforms/GdalTranslateTransform.jsx
deleted file mode 100644
index 2f1a4967a7..0000000000
--- a/web/client/components/manager/importer/transforms/GdalTranslateTransform.jsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-import React from 'react';
-
-import { FormControl, Alert } from 'react-bootstrap';
-import assign from 'object-assign';
-import { Message } from '../../../I18N/I18N';
-import { findIndex } from 'lodash';
-
-class GdalTranslateTransform extends React.Component {
- static propTypes = {
- transform: PropTypes.object,
- editTransform: PropTypes.func,
- updateTransform: PropTypes.func
- };
-
- static defaultProps = {
- transform: {
- options: []
- },
- editTransform: () => {},
- updateTransform: () => {}
- };
-
- onChange = (event) => {
- let value = event.target.value || "";
- this.props.editTransform(assign({}, this.props.transform, {[event.target.name]: value.split(/\s+/g) }));
- };
-
- renderInvalid = () => {
- if (!this.isValid(this.props.transform)) {
- return This transform is not valid;
- }
- return null;
- };
-
- render() {
- return (
-
- {this.renderInvalid()}
-
);
- }
-
- isValid = (t) => {
- return t && t.options && findIndex(t.options, (e) => e === "") < 0;
- };
-}
-
-export default GdalTranslateTransform;
diff --git a/web/client/components/manager/importer/transforms/GdalWarpTransform.jsx b/web/client/components/manager/importer/transforms/GdalWarpTransform.jsx
deleted file mode 100644
index 8e547da1b2..0000000000
--- a/web/client/components/manager/importer/transforms/GdalWarpTransform.jsx
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * 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.
- */
-
-export default require('./GdalTranslateTransform').default;
diff --git a/web/client/components/manager/importer/transforms/index.js b/web/client/components/manager/importer/transforms/index.js
deleted file mode 100644
index 3c61a50c38..0000000000
--- a/web/client/components/manager/importer/transforms/index.js
+++ /dev/null
@@ -1,10 +0,0 @@
-export default {
- GdalAddoTransform: require("./GdalAddoTransform").default,
- GdalTranslateTransform: require('./GdalTranslateTransform').default,
- GdalWarpTransform: require('./GdalWarpTransform').default,
- help: {
- GdalAddoTransform: "http://www.gdal.org/gdaladdo.html",
- GdalTranslateTransform: "http://www.gdal.org/gdal_translate.html",
- GdalWarpTransform: "http://www.gdal.org/gdalwarp.html"
- }
-};
diff --git a/web/client/components/manager/users/GroupManager.jsx b/web/client/components/manager/users/GroupManager.jsx
deleted file mode 100644
index 65c799655d..0000000000
--- a/web/client/components/manager/users/GroupManager.jsx
+++ /dev/null
@@ -1,56 +0,0 @@
-
-/**
- * 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.
- */
-
-import PropTypes from 'prop-types';
-import React from 'react';
-import { ListGroup, ListGroupItem, Glyphicon } from 'react-bootstrap';
-
-import Button from '../misc/Button';
-
-class GroupManager extends React.Component {
- static propTypes = {
- // props
- groups: PropTypes.object,
- style: PropTypes.object,
- onDeleteGroup: PropTypes.func,
- onCreateGroup: PropTypes.func,
- user: PropTypes.object
- };
-
- static defaultProps = {
- groups: [],
- onUserGroupsChange: () => {},
- user: {}
- };
-
- render() {
- return (
-
-
-
- {this.props.groups.map( group => (
- {group.groupName}
-
- ))}
-
-
- );
- }
-}
-
-/*
-
-*/
-
-export default GroupManager;
diff --git a/web/client/components/map/leaflet/FeatureCollection.jsx b/web/client/components/map/leaflet/FeatureCollection.jsx
deleted file mode 100644
index 2017a56782..0000000000
--- a/web/client/components/map/leaflet/FeatureCollection.jsx
+++ /dev/null
@@ -1,31 +0,0 @@
-var PropTypes = require('prop-types');
-/**
- * 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.
- */
-
-var React = require('react');
-
-
-class Feature extends React.Component {
- static propTypes = {
- type: PropTypes.string,
- container: PropTypes.object, // TODO it must be a L.GeoJSON
- geometry: PropTypes.object
- };
-
- componentDidMount() {
- }
-
- componentWillUnmount() {
- }
-
- render() {
- return null;
- }
-}
-
-module.exports = Feature;
diff --git a/web/client/components/map/openlayers/__tests__/Layer-test.jsx b/web/client/components/map/openlayers/__tests__/Layer-test.jsx
index 00886485a3..e6f8a26af4 100644
--- a/web/client/components/map/openlayers/__tests__/Layer-test.jsx
+++ b/web/client/components/map/openlayers/__tests__/Layer-test.jsx
@@ -23,7 +23,6 @@ import '../plugins/GraticuleLayer';
import '../plugins/OverlayLayer';
import '../plugins/TMSLayer';
import '../plugins/WFSLayer';
-import '../plugins/WFS3Layer';
import '../plugins/ElevationLayer';
import '../plugins/ArcGISLayer';
@@ -2878,78 +2877,6 @@ describe('Openlayers layer', () => {
expect(layer.layer.getSource()).toBeTruthy();
});
- it('test render a wfs3 layer', () => {
-
- const options = {
- id: 'layer_id',
- name: 'layer_name',
- title: 'Layer Title',
- type: 'wfs3',
- visibility: true,
- url: '/geoserver/wfs3/collections/layer_name/tiles/{tilingSchemeId}/{level}/{row}/{col}',
- format: 'application/vnd.mapbox-vector-tile',
- tilingScheme: '/geoserver/wfs3/collections/layer_name/tiles/{tilingSchemeId}',
- tilingSchemes: {
- url: '/geoserver/wfs3/collections/layer_name/tiles',
- schemes: [
- {
- type: 'TileMatrixSet',
- identifier: 'GoogleMapsCompatible',
- title: 'GoogleMapsCompatible',
- supportedCRS: 'EPSG:3857',
- tileMatrix: [{
- matrixHeight: 1,
- matrixWidth: 1,
- tileHeight: 256,
- tileWidth: 256,
- identifier: '0',
- scaleDenominator: 559082263.9508929,
- topLeftCorner: [
- -20037508.34,
- 20037508
- ],
- type: 'TileMatrix'
- }],
- boundingBox: {
- crs: 'http://www.opengis.net/def/crs/EPSG/0/3857',
- lowerCorner: [
- -20037508.34,
- -20037508.34
- ],
- upperCorner: [
- 20037508.34,
- 20037508.34
- ],
- type: 'BoundingBox'
- },
- wellKnownScaleSet: 'http://www.opengis.net/def/wkss/OGC/1.0/GoogleMapsCompatible'
- }
- ]
- },
- bbox: {
- crs: 'EPSG:4326',
- bounds: {
- minx: -156.2575,
- miny: -90,
- maxx: 123.33333333333333,
- maxy: 46.5475
- }
- },
- allowedSRS: {
- 'EPSG:3857': true
- }
- };
- let layer = ReactDOM.render(, document.getElementById("container"));
-
- expect(layer).toBeTruthy();
- expect(map.getLayers().getLength()).toBe(1);
- expect(layer.layer.constructor.name).toBe('VectorTileLayer');
- expect(layer.layer.getSource().format_.constructor.name).toBe('MVT');
- });
-
it('should apply native ol min and max resolution on wms layer', () => {
const minResolution = 1222; // ~ zoom 7 Web Mercator
const maxResolution = 39135; // ~ zoom 2 Web Mercator
diff --git a/web/client/components/map/openlayers/plugins/WFS3Layer.js b/web/client/components/map/openlayers/plugins/WFS3Layer.js
deleted file mode 100644
index fa1aec492c..0000000000
--- a/web/client/components/map/openlayers/plugins/WFS3Layer.js
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * Copyright 2018, 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 head from 'lodash/head';
-import urlParser from 'url';
-
-import CoordinatesUtils from '../../../../utils/CoordinatesUtils';
-import MapUtils from '../../../../utils/MapUtils';
-import Layers from '../../../../utils/openlayers/Layers';
-import {addAuthenticationParameter} from '../../../../utils/SecurityUtils';
-
-import {get, getTransform} from 'ol/proj';
-import {applyTransform} from 'ol/extent';
-import TileGrid from 'ol/tilegrid/TileGrid';
-import VectorTileLayer from 'ol/layer/VectorTile';
-import VectorTile from 'ol/source/VectorTile';
-import MVT from 'ol/format/MVT';
-
-import { isVectorFormat } from '../../../../utils/VectorTileUtils';
-import { OL_VECTOR_FORMATS, applyStyle } from '../../../../utils/openlayers/VectorTileUtils';
-
-const createLayer = (options) => {
-
- const srs = CoordinatesUtils.normalizeSRS(options.srs || 'EPSG:3857', options.allowedSRS);
- const projection = get(srs);
- const metersPerUnit = projection.getMetersPerUnit();
-
- const tilingScheme = head(options.tilingSchemes
- && options.tilingSchemes.schemes
- && options.tilingSchemes.schemes.filter(({ supportedCRS }) => supportedCRS === srs));
-
- const { identifier: tilingSchemeId, tileMatrix, boundingBox } = tilingScheme || {};
- const scales = tileMatrix && tileMatrix.map(({ scaleDenominator }) => scaleDenominator);
- const mapResolutions = MapUtils.getResolutions();
-
- const scaleToResolution = s => s * 0.28E-3 / metersPerUnit;
- const matrixResolutions = options.resolutions || scales && scales.map(scaleToResolution);
- const resolutions = matrixResolutions || mapResolutions;
-
- const switchOriginXY = projection.getAxisOrientation().substr(0, 2) === 'ne';
- const origins = tileMatrix && tileMatrix
- .map(({ topLeftCorner } = {}) => topLeftCorner)
- .map(([ x, y ] = []) => switchOriginXY ? [y, x] : [x, y]);
-
- const tileSizes = tileMatrix && tileMatrix
- .map(({tileWidth, tileHeight}) => [tileWidth, tileHeight]);
-
- const bbox = options.bbox;
-
- const extent = bbox
- ? applyTransform([
- parseFloat(bbox.bounds.minx),
- parseFloat(bbox.bounds.miny),
- parseFloat(bbox.bounds.maxx),
- parseFloat(bbox.bounds.maxy)
- ], getTransform(bbox.crs, options.srs))
- : null;
-
- const tileGridExtent = boundingBox && boundingBox.lowerCorner && boundingBox.upperCorner
- ? [
- ...boundingBox.lowerCorner,
- ...boundingBox.upperCorner
- ]
- : null;
-
- const tileGrid = new TileGrid({
- extent: tileGridExtent,
- minZoom: 0,
- origins,
- origin: !origins ? [20037508.3428, -20037508.3428] : undefined,
- resolutions,
- tileSizes,
- tileSize: !tileSizes ? [256, 256] : undefined
- });
-
- let url = (options.url || '')
- .replace(/\{tilingSchemeId\}/, tilingSchemeId)
- .replace(/\{level\}/, '{z}')
- .replace(/\{row\}/, '{y}')
- .replace(/\{col\}/, '{x}');
-
- let queryParameters = { };
- addAuthenticationParameter(url, queryParameters, options.securityToken);
-
- const layerUrl = decodeURI(url);
- const queryParametersString = urlParser.format({ query: { ...queryParameters } });
-
- const Format = isVectorFormat(options.format) && OL_VECTOR_FORMATS[options.format] || MVT;
-
- const source = new VectorTile({
- format: new Format({
- dataProjection: srs,
- layerName: '_layer_'
- }),
- tileGrid,
- url: layerUrl + queryParametersString
- });
-
- const layer = new VectorTileLayer({
- extent,
- msId: options.id,
- source: source,
- visible: options.visibility !== false,
- zIndex: options.zIndex,
- minResolution: options.minResolution,
- maxResolution: options.maxResolution
- });
-
- applyStyle(options.vectorStyle, layer);
-
- return layer;
-};
-Layers.registerType('wfs3', {
- create: createLayer,
- update: (layer, newOptions, oldOptions) => {
- if (oldOptions.securityToken !== newOptions.securityToken
- || oldOptions.srs !== newOptions.srs) {
- return createLayer(newOptions);
- }
- if (oldOptions.minResolution !== newOptions.minResolution) {
- layer.setMinResolution(newOptions.minResolution === undefined ? 0 : newOptions.minResolution);
- }
- if (oldOptions.maxResolution !== newOptions.maxResolution) {
- layer.setMaxResolution(newOptions.maxResolution === undefined ? Infinity : newOptions.maxResolution);
- }
- return null;
- },
- render: () => {
- return null;
- }
-});
diff --git a/web/client/components/map/openlayers/plugins/index.js b/web/client/components/map/openlayers/plugins/index.js
index 028fd239f3..5fc479405d 100644
--- a/web/client/components/map/openlayers/plugins/index.js
+++ b/web/client/components/map/openlayers/plugins/index.js
@@ -17,7 +17,6 @@ export default {
TileProviderLayer: require('./TileProviderLayer').default,
VectorLayer: require('./VectorLayer').default,
WFSLayer: require('./WFSLayer').default,
- WFS3Layer: require('./WFS3Layer').default,
WMSLayer: require('./WMSLayer').default,
WMTSLayer: require('./WMTSLayer').default,
COGLayer: require('./COGLayer').default,
diff --git a/web/client/components/mapcontrols/annotations/Annotations.jsx b/web/client/components/mapcontrols/annotations/Annotations.jsx
deleted file mode 100644
index e9e0d60591..0000000000
--- a/web/client/components/mapcontrols/annotations/Annotations.jsx
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * 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.
- */
-
-import bbox from '@turf/bbox';
-import { countBy, head, isUndefined, keys, values } from 'lodash';
-import assign from 'object-assign';
-import PropTypes from 'prop-types';
-import React from 'react';
-import { Glyphicon } from 'react-bootstrap';
-import uuidv1 from 'uuid/v1';
-
-import { getGeometryGlyphInfo } from '../../../utils/LegacyAnnotationsUtils';
-import { getMessageById } from '../../../utils/LocaleUtils';
-import Message from '../../I18N/Message';
-import BorderLayout from '../../layout/BorderLayout';
-import SideGrid from '../../misc/cardgrids/SideGrid';
-import Filter from '../../misc/Filter';
-import Loader from '../../misc/Loader';
-import Toolbar from '../../misc/toolbar/Toolbar';
-import defaultConfig from './AnnotationsConfig';
-import SelectAnnotationsFile from './SelectAnnotationsFile';
-import Button from '../../misc/Button';
-
-/**
- * Annotations panel component.
- * It can be in different modes:
- * - list: when showing the current list of annotations on the map
- * - detail: when showing a detail of a specific annotation
- * - editing: when editing an annotation
- * When in list mode, the list of current map annotations is shown, with:
- * - summary card for each annotation, with full detail show on click
- * - upload annotations Button
- * - new annotation Button
- * - download annotations Button
- * - filtering widget
- * When in detail mode the configured editor is shown on the selected annotation, in viewer mode.
- * When in editing mode the configured editor is shown on the selected annotation, in editing mode.
- *
- * It also handles removal confirmation modals
- * @memberof components.mapControls.annotations
- * @class
- * @prop {string} id id of the borderlayout Component
- * @prop {boolean} closing user asked for closing panel when editing
- * @prop {boolean} styling flag to state status of styling during editing
- * @prop {boolean} showUnsavedChangesModal flag to state status of UnsavedChangesModal
- * @prop {boolean} showUnsavedStyleModal flag to state status of UnsavedStyleModal
- * @prop {object} editing annotation object currently under editing (null if we are not in editing mode)
- * @prop {function} toggleControl triggered when the user closes the annotations panel
- * @prop {object} removing object to remove, it is also a flag that means we are currently asking for removing an annotation / geometry. Toggles visibility of the confirm dialog
- * @prop {string} mode current mode of operation (list, editing, detail)
- * @prop {object} editor editor component, used in detail and editing modes
- * @prop {object[]} annotations list of annotations objects to list
- * @prop {string} current id of the annotation currently shown in the editor (when not in list mode)
- * @prop {object} config configuration object, where overridable stuff is stored (fields config for annotations, marker library, etc.) {@link #components.mapControls.annotations.AnnotationsConfig}
- * @prop {string} filter current filter entered by the user
- * @prop {function} onToggleUnsavedChangesModal toggles the view of the UnsavedChangesModal
- * @prop {function} onToggleUnsavedStyleModal toggles the view of the UnsavedStyleModal
- * @prop {function} onCancelRemove triggered when the user cancels removal
- * @prop {function} onCancelEdit triggered when the user cancels any changes to the properties or geometry
- * @prop {function} onCancelStyle triggered when the user cancels any changes to the style
- * @prop {function} onConfirmRemove triggered when the user confirms removal
- * @prop {function} onCancelClose triggered when the user cancels closing
- * @prop {function} onConfirmClose triggered when the user confirms closing
- * @prop {function} onAdd triggered when the user clicks on the new annotation button
- * @prop {function} onEdit triggered when the user clicks on the annotation card into annotation viewer
- * @prop {function} onZoom triggered when the user zooms to an annotation
- * @prop {function} onHighlight triggered when the mouse hovers an annotation card
- * @prop {function} onCleanHighlight triggered when the mouse is out of any annotation card
- * @prop {function} onDetail triggered when the user clicks on an annotation card
- * @prop {function} onFilter triggered when the user enters some text in the filtering widget
- * @prop {function} classNameSelector optional selector to assign custom a CSS class to annotations, based on
- * @prop {function} onSetErrorSymbol set a flag in the state to say if the default symbols exists
- * @prop {function} onDownload triggered when the user clicks on the download annotations button
- * @prop {function} onUpdateSymbols triggered when user click on refresh icon of the symbols addon
- * @prop {function} onToggleVisibility triggered when user click on annotation visibility icon
- * @prop {boolean} symbolErrors errors related to the symbols
- * @prop {object[]} lineDashOptions list of options for dashed lines
- * @prop {string} symbolsPath path to the svg folder
- * @prop {object[]} symbolList list of symbols
- * @prop {string} defaultShape default Shape
- * @prop {number} maxZoom max zoom for annotation (default 18)
- * @prop {string} defaultShapeStrokeColor default symbol stroke color
- * @prop {string} defaultShapeFillColor default symbol fill color
- * @prop {string} defaultShapeSize default symbol shape size in px
- * @prop {object} defaultStyles object with default symbol styles
- * @prop {number} textRotationStep rotation step of text styler
- * @prop {boolean} geodesic draw geodesic annotation (Currently applicable only for Circle annotation)
- *
- * the annotation's attributes.
- */
-class Annotations extends React.Component {
- static propTypes = {
- id: PropTypes.string,
- styling: PropTypes.bool,
- toggleControl: PropTypes.func,
- loading: PropTypes.bool,
- closing: PropTypes.bool,
- showUnsavedChangesModal: PropTypes.bool,
- showUnsavedStyleModal: PropTypes.bool,
- editing: PropTypes.object,
- removing: PropTypes.object,
- onCancelRemove: PropTypes.func,
- onConfirmRemove: PropTypes.func,
- onCancelClose: PropTypes.func,
- onToggleUnsavedChangesModal: PropTypes.func,
- onToggleUnsavedStyleModal: PropTypes.func,
- onResetCoordEditor: PropTypes.func,
- onAddNewFeature: PropTypes.func,
- onToggleUnsavedGeometryModal: PropTypes.func,
- onConfirmClose: PropTypes.func,
- onCancelEdit: PropTypes.func,
- onCancelStyle: PropTypes.func,
- onAdd: PropTypes.func,
- onZoom: PropTypes.func,
- onHighlight: PropTypes.func,
- onCleanHighlight: PropTypes.func,
- onDetail: PropTypes.func,
- mode: PropTypes.string,
- editor: PropTypes.func,
- annotations: PropTypes.array,
- current: PropTypes.string,
- config: PropTypes.object,
- filter: PropTypes.string,
- onFilter: PropTypes.func,
- classNameSelector: PropTypes.func,
- width: PropTypes.number,
- onDownload: PropTypes.func,
- onLoadAnnotations: PropTypes.func,
- onUpdateSymbols: PropTypes.func,
- onSetErrorSymbol: PropTypes.func,
- onToggleVisibility: PropTypes.func,
- onEdit: PropTypes.func,
- symbolErrors: PropTypes.array,
- lineDashOptions: PropTypes.array,
- symbolList: PropTypes.array,
- defaultShape: PropTypes.string,
- symbolsPath: PropTypes.string,
- maxZoom: PropTypes.number,
- defaultShapeSize: PropTypes.number,
- defaultShapeFillColor: PropTypes.string,
- defaultShapeStrokeColor: PropTypes.string,
- defaultStyles: PropTypes.object,
- onLoadDefaultStyles: PropTypes.func,
- textRotationStep: PropTypes.number,
- measurementAnnotationEdit: PropTypes.bool,
- geodesic: PropTypes.bool
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- mode: 'list',
- config: defaultConfig,
- classNameSelector: () => '',
- toggleControl: () => {},
- onUpdateSymbols: () => {},
- onSetErrorSymbol: () => {},
- onLoadAnnotations: () => {},
- annotations: [],
- maxZoom: 18,
- onLoadDefaultStyles: () => {}
- };
- state = {
- selectFile: false
- }
-
- componentDidMount() {
- this.props.onLoadDefaultStyles(this.props.defaultShape, this.props.defaultShapeSize, this.props.defaultShapeFillColor, this.props.defaultShapeStrokeColor,
- this.props.symbolsPath);
- }
-
- getConfig = () => {
- return assign({}, defaultConfig, this.props.config);
- };
-
- getGeomsThumbnail(geometry) {
- let glyph;
- const geoms = geometry?.features.reduce((p, c) => {
- if (c.properties && c.properties.isCircle) {
- return {...p, "Circle": true};
- }
- if (c.properties && c.properties.isText) {
- return {...p, "Text": true};
- }
- return {...p, [c.geometry.type]: true};
- }, {"Circle": false, "Text": false});
-
- if (countBy(values(geoms))?.true > 1) {
- glyph = "geometry-collection";
- } else {
- const type = keys(geoms).find(key => geoms[key] === true);
- glyph = getGeometryGlyphInfo(type)?.glyph;
- }
-
- return ;
- }
-
- renderField = (field, annotation) => {
- return (
- {this.renderFieldValue(field, annotation)}
-
);
- };
-
- renderFieldValue = (field, annotation) => {
- const fieldValue = annotation.properties[field.name] || '';
- if (field.type === 'html') {
- // Return the text content of the first child of the html string (to prevent collating all texts into a single word)
- return (new DOMParser).parseFromString(fieldValue, "text/html").documentElement.lastElementChild
- ?.firstChild
- ?.textContent || '';
- }
- return fieldValue;
- };
-
- renderThumbnail = ({featureType, geometry, properties = {}}) => {
- if (properties?.type === "Measure") {
- return (
-
- );
- } else if (featureType === "LineString" || featureType === "MultiLineString" ) {
- return (
- ;
- );
- }
- if (featureType === "Polygon" || featureType === "MultiPolygon" ) {
- return (
- ;
- );
- }
- if (featureType === "Circle") {
- return (
- ;
- );
- }
- if (featureType === "GeometryCollection" || featureType === "FeatureCollection") {
- return (
- {(!!(geometry.geometries || geometry.features || []).filter(f => f.type !== "MultiPoint").length || (properties.textValues && properties.textValues.length)) && (this.getGeomsThumbnail(geometry))}
- );
- }
- return (
- ;
- );
- };
-
- renderItems = (annotation) => {
- const {features: aFeatures, properties} = annotation;
- const cardActions = {
- onMouseEnter: () => {this.props.onHighlight(properties.id); },
- onMouseLeave: this.props.onCleanHighlight,
- onClick: () => this.props.onEdit(properties.id)
- };
- const annotationVisibility = properties && !isUndefined(properties.visibility) ? properties.visibility : true;
- return {
- ...this.getConfig().fields.reduce( (p, c)=> {
- return assign({}, p, {[c.name]: this.renderField(c, annotation)});
- }, {}),
- preview: this.renderThumbnail({featureType: "FeatureCollection", geometry: {features: aFeatures}, properties }),
- tools: {
- event.stopPropagation();
- const extent = bbox(annotation);
- this.props.onZoom(extent, 'EPSG:4326', this.props.maxZoom);
- }
- },
- {
- glyph: annotationVisibility ? 'eye-open' : 'eye-close',
- tooltipId: annotationVisibility ? "annotations.hide" : "annotations.show",
- onClick: (event) => {
- event.stopPropagation();
- this.props.onToggleVisibility(properties?.id);
- }
- }
-
- ]}/>,
- ...cardActions
- };
- };
-
- renderCards = () => {
- if (this.props.loading) {
- return (
-
-
-
- );
- }
- if (this.props.mode === 'list') {
- const annotationsPresent = !!this.props.annotations.length;
- return (
- <>
-
- ,
- visible: this.props.mode === "list",
- onClick: () => { this.setState(() => ({selectFile: true})); }
- },
- {
- glyph: 'plus',
- tooltip: ,
- visible: this.props.mode === "list",
- onClick: () => { this.props.onAdd(); }
- },
- {
- glyph: 'download',
- disabled: !(annotationsPresent),
- tooltip: ,
- visible: this.props.mode === "list",
- onClick: () => { this.props.onDownload(); }
- }
- ]}/>
-
-
-
-
-
- {!annotationsPresent && }
- { annotationsPresent &&
- this.renderItems(a))}/>
- }
-
- >
- );
- }
- const annotation = this.props.annotations && head(this.props.annotations.filter(a => a.properties.id === this.props.current));
- const Editor = this.props.editor;
- if (this.props.mode === 'detail') {
- return ();
- }
- // mode = editing
- return this.props.editing && ;
- };
-
- renderHeader() {
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
- }
-
- render() {
- let body;
- if (this.state.selectFile) {
- body = (
- }
- onFileChoosen={this.props.onLoadAnnotations}
- show={this.state.selectFile}
- disableOvveride={!(this.props.annotations && this.props.annotations.length > 0)}
- onClose={() => this.setState(() => ({selectFile: false}))}
- />);
-
-
- } else {
- body = ( {this.renderCards()} );
- }
- return (
- {body}
- );
-
- }
-
- applyFilter = (annotation) => {
- return !this.props.filter || this.getConfig().fields.reduce((previous, field) => {
- return (annotation.properties[field.name] || '').toUpperCase().indexOf(this.props.filter.toUpperCase()) !== -1 || previous;
- }, false);
- };
-}
-
-export default Annotations;
diff --git a/web/client/components/mapcontrols/annotations/AnnotationsConfig.js b/web/client/components/mapcontrols/annotations/AnnotationsConfig.js
deleted file mode 100644
index 00ee466e56..0000000000
--- a/web/client/components/mapcontrols/annotations/AnnotationsConfig.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.
- */
-
-import MarkerUtils from '../../../utils/MarkerUtils';
-
-const defaultIcon = MarkerUtils.markers.extra.icons[0];
-const defaultMarkers = MarkerUtils.markers.extra.getGrid();
-const glyphPrefix = 'fa';
-
-/**
- * Annotations configuration object.
- * Stores overridable configuration.
- *
- * The default configuration is the following:
- * - 2 fields (title and description)
- * - extra markers library {@link https://github.com/coryasilva/Leaflet.ExtraMarkers}
- * - font awesome glyphs for markers
- * - multiGeometry enabled
- *
- * To (partially) override the configuration use initialState in localConfig.json:
- * @example
- * Only overrides the list of fields
- * {
- * ...
- * "initialState": {
- * "defaultState": {
- * "annotations": {
- * "config": {
- * "fields": [{
- * "name": "myattribute",
- * "editable": true
- * "validator": "value.indexOf('fake') === -1",
- * "validateError": "annotations.error.fake"
- * }]
- * }
- * }
- * }
- * }
- * }
- *
- * @memberof components.mapControls.annotations
- * @class AnnotationsConfig
- */
-export default {
- /**
- * Available annotation fields.
- * A list of object specifying:
- * - name: the field synthetic name
- * - type: type of value for the field (text or html)
- * - validator: (optional) rule for validation
- * - validationError: (optional) id for the translations file containing the validation error message
- * - showLabel: whether to show or not the label of the field in the viewer / editor
- * - editable: whether the field can be edited or not in editing mode
- */
- fields: [
- {
- name: 'title',
- type: 'text',
- validator: (val) => val,
- validateError: 'annotations.mandatory',
- showLabel: true,
- editable: true
- },
- {
- name: 'description',
- type: 'html',
- showLabel: true,
- editable: true
- }
- ],
- /**
- * Grid of markers used to style annotations.
- */
- markers: defaultMarkers,
- /**
- * Markers icon sprite resource.
- */
- markerIcon: defaultIcon,
- /**
- * Markers used to style annotations configuration object.
- */
- markersConfig: MarkerUtils.markers.extra,
- /**
- * Allow multiGeometry or not (MultiPoint on a single annotation).
- */
- multiGeometry: false,
- /**
- * Available glyphs list (used by the markers styler).
- */
- glyphs: Object.keys(MarkerUtils.getGlyphs('fontawesome')),
- /**
- * Returns a CSS classname usable to draw a glyph for the given style (iconGlyph),
- * using the default glyphs library (font-awesome).
- * @param {string} style style object
- * @return {string} classname to draw the glyph
- */
- getGlyphClassName: (style) => {
- return glyphPrefix + " " + glyphPrefix + "-" + style.iconGlyph;
- },
- /**
- * Returns a marker configuration object for the given style, using the default (extra)
- * markers library.
- *
- * @param {string} style style object
- * @return {object} marker config object
- */
- getMarkerFromStyle: (style) => {
- return defaultMarkers.filter(m => m.name === style.iconShape)[0]
- .markers.filter(m2 => m2.name === style.iconColor)[0];
- }
-};
diff --git a/web/client/components/mapcontrols/annotations/AnnotationsEditor.jsx b/web/client/components/mapcontrols/annotations/AnnotationsEditor.jsx
deleted file mode 100644
index 1c9fdc1997..0000000000
--- a/web/client/components/mapcontrols/annotations/AnnotationsEditor.jsx
+++ /dev/null
@@ -1,900 +0,0 @@
-/*
- * Copyright 2018, 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 { head, isEmpty, isFunction, isUndefined } from 'lodash';
-import assign from 'object-assign';
-import PropTypes from 'prop-types';
-import React from 'react';
-import {
- Checkbox,
- Col,
- ControlLabel,
- FormControl,
- FormGroup,
- Glyphicon,
- Grid,
- Nav,
- NavItem,
- Row
-} from 'react-bootstrap';
-import ReactQuill from '../../../libs/quill/react-quill-suspense';
-
-import {
- coordToArray,
- getComponents,
- getGeometryGlyphInfo,
- getGeometryType,
- validateCoords
-} from '../../../utils/LegacyAnnotationsUtils';
-import { MEASURE_TYPE } from '../../../utils/MeasurementUtils';
-import { handleExpression } from '../../../utils/PluginsUtils';
-import Message from '../../I18N/Message';
-import ConfirmDialog from '../../misc/ConfirmDialog';
-import Portal from '../../misc/Portal';
-import Toolbar from '../../misc/toolbar/Toolbar';
-import Manager from '../../style/vector/Manager';
-import defaultConfig from './AnnotationsConfig';
-import FeaturesList from './FeaturesList';
-import GeometryEditor from '../../../plugins/Annotations/components/GeometryEditor';
-import { getApi } from '../../../api/userPersistedStorage';
-
-/**
- * (Default) Viewer / Editor for Annotations.
- * @memberof components.mapControls.annotations
- * @class
- * @prop {string} id identifier of the current annotation feature
- * @prop {function} onChangeFormat triggered every format change
- * @prop {string} format decimal or aeronautical degree for coordinates
- * @prop {string} mapProjection crs of the map
- * @prop {object} config configuration object, where overridable stuff is stored (fields config for annotations, marker library, etc.) {@link #components.mapControls.annotations.AnnotationsConfig}
- * @prop {object} editing feature object of the feature under editing (when editing mode is enabled, null otherwise)
- * @prop {boolean} drawing flag to state status of drawing during editing
- * @prop {boolean} styling flag to state status of styling during editing
- * @prop {object} errors key/value set of validation errors (field_name: error_id)
- * @prop {object} feature object with the annotation properties
- * @prop {bool} showBack shows / hides the back button in the view mode
- * @prop {bool} showEdit shows / hides the edit button in the view mode
- * @prop {function} onEdit triggered when the user clicks on the edit button
- * @prop {function} onCancelEdit triggered when the user cancels current editing session
- * @prop {function} onCancelStyle triggered when the user cancels style selection
- * @prop {function} onCancel triggered when the user cancels the addition/changes made to the annotation
- * @prop {function} onCleanHighlight triggered when the user exits 'details' mode
- * @prop {function} onHighlight triggered when the user hover the infoviewer card
- * @prop {function} onConfirmDeleteFeature triggered when the user confirms deletion of a feature
- * @prop {function} onAddText triggered when the user adds new Text geometry to the feature
- * @prop {function} onToggleUnsavedChangesModal toggles the view of the UnsavedChangesModal
- * @prop {function} onToggleUnsavedStyleModal toggles the view of the UnsavedStyleModal
- * @prop {function} onToggleUnsavedGeometryModal toggles the view of the UnsavedGeometryModal
- * @prop {function} onSetUnsavedChanges triggered when the user changes the value of any field, it sets a flag used to trigger the view of the UnsavedChangesModal
- * @prop {function} onAddNewFeature triggered when user click on save icon of the coordinate editor, this will add the feature being drawn to the list of features of the ft coll of the annotation
- * @prop {function} onChangeProperties triggered when the user changes the value of any field
- * @prop {function} onSetUnsavedStyle triggered when the user changes the style , it sets a flag used to trigger the view of the UnsavedStyleModal
- * @prop {function} onConfirmRemove triggered when the user confirms removal
- * @prop {function} onCancelRemove triggered when the user cancels removal
- * @prop {function} onCancelClose triggered when the user cancels closing
- * @prop {function} onConfirmClose triggered when the user confirms closing
- * @prop {function} onStartDrawing triggered before the user starts the drawing process
- * @prop {object} editedFields fields of the annotation
- * @prop {object} drawingText it contains info of the text annotation, 'drawing' if being added or 'show' used to show the modal to add the relative value
- * @prop {boolean} unsavedChanges flag used to trigger changes of showUnsavedChangesModal
- * @prop {boolean} unsavedStyle flag used to trigger changes of showUnsavedChangesModal
- * @prop {boolean} closing user asked for closing panel when editing
- * @prop {string} stylerType selected styler to be shown as body
- * @prop {boolean} showUnsavedStyleModal flag used to show the UnsavedChangesModal
- * @prop {boolean} showUnsavedChangesModal flag used to show the UnsavedStyleModal
- * @prop {boolean} showUnsavedGeometryModal flag used to display the modal after user clicks on back and has changed something in the coord editor
- * @prop {boolean} showDeleteFeatureModal flag used to display the modal after deleting a feature for confirmation
- * @prop {boolean} unsavedGeometry flag used to say if something has changed when coord editor is open
- * @prop {string} mode current mode of operation (list, editing, detail)
- * @prop {function} onRemove triggered when the user clicks on the remove button
- * @prop {function} onSave triggered when the user clicks on the save button
- * @prop {function} onSaveStyle triggered when the user saves changes to the style
- * @prop {function} onError triggered when a validation error occurs
- * @prop {function} onAddGeometry triggered when the user clicks on the add point button TODO FIX THIS
- * @prop {function} onDeleteGeometry triggered when the user clicks on the remove points button
- * @prop {function} onStyleGeometry triggered when the user clicks on the style button
- * @prop {function} onSetStyle triggered when the user changes a style property
- * @prop {function} onChangeSelected triggered when the user changes a value(lat or lon) of a coordinate in the coordinate editor
- * @prop {function} onChangeRadius triggered when the user changes the radius of the Circle in its coordinate editor
- * @prop {function} onChangeText triggered when the user changes the text of the Text Annotation in its coordinate editor
- * @prop {function} onSetInvalidSelected triggered when the user insert an invalid coordinate or remove a valid one i.e. ""
- * @prop {function} onHighlightPoint triggered when mouse goes over/off a CoordinatesRow
- * @prop {function} onResetCoordEditor triggered when the user goes back from the coordinate editor, it will open a dialog for unsaved changes
- * @prop {function} onZoom triggered when the user zooms to an annotation
- * @prop {function} onDownload triggered when the user exports
- * @prop {function} onChangeGeometryTitle triggered when the user changes geometry title in coordinate editor panel
- * @prop {function} onSelectFeature triggered when the user clicks on a geometry card
- * @prop {boolean} coordinateEditorEnabled triggered when the user zooms to an annotation
- * @prop {object} selected Feature containing the geometry and the properties used for the coordinated editor
- * @prop {object} aeronauticalOptions options for aeronautical format (seconds decimals and step)
- * @prop {number} maxZoom max zoome the for annotation (default 18)
- * @prop {function} onDeleteFeature triggered when user click on trash icon of the coordinate editor
- * @prop {function} onUpdateSymbols triggered when user click on refresh icon of the symbols addon
- * @prop {function} onSetErrorSymbol set a flag in the state to say if the default symbols exists
- * @prop {number} width of the annotation panel
- * @prop {string} pointType the type of the point, values are "marker" or "symbol"
- * @prop {object[]} lineDashOptions list of options for dashed lines
- * @prop {object[]} symbolList list of symbols
- * @prop {string} symbolsPath path to the svg folder
- * @prop {string} defaultShape default shape for symbol
- * @prop {string} defaultShapeStrokeColor default symbol stroke color
- * @prop {string} defaultShapeFillColor default symbol fill color
- * @prop {string} defaultShapeSize default symbol shape size in px
- * @prop {object} defaultStyles object with default symbol styles
- * @prop {number} textRotationStep rotation step of text styler
- * @prop {function} onSetAnnotationMeasurement triggered on click of edit measurement button when annotation is of type 'Measure'
- * @prop {function} onFilterMarker triggered when marker/glyph name is specified for filtering
- * @prop {object[]} annotations list of annotations
- * @prop {boolean} measurementAnnotationEdit flag for measurement specific annotation features
- * @prop {boolean} geodesic enable to draw a geodesic geometry (supported only for Circle)
- * @prop {function} onHideMeasureWarning triggered when warning is ignored with "Don't show again" flag
- * @prop {boolean} showAgain flag for checkbox on the measure annotation popup warning
- * @prop {boolean} showPopupWarning flag to show warning modal on navigating to measurement panel from annotation
- * @prop {function} onToggleShowAgain triggered when interacting with the checkbox on measure annotation warning popup
- * @prop {function} onInitPlugin triggered when annotation editor is mounted
- * @prop {function} onGeometryHighlight triggered onMouseEnter and onMouseLeave of the geometry card
- * @prop {function} onUnSelectFeature triggered on unselecting a geometry card
- *
- * In addition, as the Identify viewer interface mandates, every feature attribute is mapped as a component property (in addition to the feature object).
- */
-class AnnotationsEditor extends React.Component {
- static displayName = 'AnnotationsEditor';
-
- static propTypes = {
- id: PropTypes.string,
- onEdit: PropTypes.func,
- onCancelEdit: PropTypes.func,
- onCancelStyle: PropTypes.func,
- onCleanHighlight: PropTypes.func,
- onHighlight: PropTypes.func,
- onAddText: PropTypes.func,
- onCancel: PropTypes.func,
- onConfirmDeleteFeature: PropTypes.func,
- onRemove: PropTypes.func,
- onSave: PropTypes.func,
- onSaveStyle: PropTypes.func,
- onError: PropTypes.func,
- onAddGeometry: PropTypes.func,
- onToggleUnsavedChangesModal: PropTypes.func,
- onToggleUnsavedGeometryModal: PropTypes.func,
- onToggleUnsavedStyleModal: PropTypes.func,
- onToggleDeleteFtModal: PropTypes.func,
- onSetUnsavedChanges: PropTypes.func,
- onSetUnsavedStyle: PropTypes.func,
- onChangeProperties: PropTypes.func,
- onChangeSelected: PropTypes.func,
- onConfirmClose: PropTypes.func,
- onCancelRemove: PropTypes.func,
- onConfirmRemove: PropTypes.func,
- onChangeRadius: PropTypes.func,
- onChangeText: PropTypes.func,
- onChangeGeometryTitle: PropTypes.func,
- onCancelClose: PropTypes.func,
- onSetInvalidSelected: PropTypes.func,
- onDeleteGeometry: PropTypes.func,
- onAddNewFeature: PropTypes.func,
- onStyleGeometry: PropTypes.func,
- onResetCoordEditor: PropTypes.func,
- onHighlightPoint: PropTypes.func,
- onSetStyle: PropTypes.func,
- onStartDrawing: PropTypes.func,
- onZoom: PropTypes.func,
- editing: PropTypes.object,
- editedFields: PropTypes.object,
- drawingText: PropTypes.object,
- drawing: PropTypes.bool,
- unsavedChanges: PropTypes.bool,
- unsavedGeometry: PropTypes.bool,
- unsavedStyle: PropTypes.bool,
- mouseHoverEvents: PropTypes.bool,
- coordinateEditorEnabled: PropTypes.bool,
- styling: PropTypes.bool,
- closing: PropTypes.bool,
- removing: PropTypes.bool,
- errors: PropTypes.object,
- stylerType: PropTypes.string,
- featureType: PropTypes.string,
- showBack: PropTypes.bool,
- showEdit: PropTypes.bool,
- showUnsavedChangesModal: PropTypes.bool,
- showUnsavedStyleModal: PropTypes.bool,
- showDeleteFeatureModal: PropTypes.bool,
- showUnsavedGeometryModal: PropTypes.bool,
- config: PropTypes.object,
- feature: PropTypes.object,
- features: PropTypes.object,
- selected: PropTypes.object,
- mode: PropTypes.string,
- maxZoom: PropTypes.number,
- width: PropTypes.number,
- onDownload: PropTypes.func,
- onChangeFormat: PropTypes.func,
- onSelectFeature: PropTypes.func,
- mapProjection: PropTypes.string,
- format: PropTypes.string,
- aeronauticalOptions: PropTypes.object,
- onDeleteFeature: PropTypes.func,
- pointType: PropTypes.string,
- symbolsPath: PropTypes.string,
- onUpdateSymbols: PropTypes.func,
- onSetErrorSymbol: PropTypes.func,
- symbolErrors: PropTypes.array,
- lineDashOptions: PropTypes.array,
- symbolList: PropTypes.array,
- defaultShape: PropTypes.string,
- defaultShapeSize: PropTypes.number,
- defaultShapeFillColor: PropTypes.string,
- defaultShapeStrokeColor: PropTypes.string,
- defaultStyles: PropTypes.object,
- textRotationStep: PropTypes.number,
- onSetAnnotationMeasurement: PropTypes.func,
- onFilterMarker: PropTypes.func,
- annotations: PropTypes.array,
- measurementAnnotationEdit: PropTypes.bool,
- geodesic: PropTypes.bool,
- onHideMeasureWarning: PropTypes.func,
- showAgain: PropTypes.bool,
- showPopupWarning: PropTypes.bool,
- onToggleShowAgain: PropTypes.func,
- onInitPlugin: PropTypes.func,
- onGeometryHighlight: PropTypes.func,
- onUnSelectFeature: PropTypes.func,
- onValidateFeature: PropTypes.func
- };
-
- static defaultProps = {
- config: defaultConfig,
- errors: {},
- selected: null,
- editedFields: {},
- showBack: false,
- showEdit: true,
- coordinateEditorEnabled: false,
- feature: {},
- maxZoom: 18,
- format: "decimal",
- pointType: "marker",
- stylerType: "marker",
- annotations: [],
- measurementAnnotationEdit: false,
- geodesic: true,
- onInitPlugin: () => {}
- };
- /**
- @prop {object} removing object to remove, it is also a flag that means we are currently asking for removing an annotation / geometry. Toggles visibility of the confirm dialog
- */
- state = {
- editedFields: {},
- removing: null,
- textValue: "",
- tabValue: "coordinates",
- showPopupWarning: false
- };
-
- componentDidMount() {
- this.props.onInitPlugin();
- }
-
- getConfig = () => {
- return {...defaultConfig, ...this.props.config, onFilterMarker: this.props.onFilterMarker};
- };
-
- getBodyItems = (editing) => {
- return this.getConfig().fields
- .filter((field) => !editing || field.editable)
- .map((field) => {
- const isError = editing && this.props.errors[field.name];
- const additionalCls = isError ? 'field-error' : '';
- return (
-
- {field.showLabel ? : null}
- {isError ? this.renderErrorOn(field.name) : ''}
- {this.renderProperty(field, this.props[field.name] || field.value, editing)}
-
- );
- });
- };
-
-
- getValidator = (validator) => {
- if (isFunction(validator)) {
- return validator;
- }
- return handleExpression({}, {}, '{(function(value) {return ' + validator + ';})}');
- };
-
- renderViewButtons = () => {
- return (
-
-
-
- {
- this.props.onCancelEdit(this.props?.feature?.properties);
- this.props.onCancel(); this.props.onCleanHighlight();
- }
- }, {
- glyph: "pencil",
- tooltipId: "annotations.edit",
- visible: this.props.showEdit,
- multiGeometry: this.props.config.multiGeometry,
- onClick: () => { this.props.onEdit(this.props.id); },
- disabled: !this.props.config.multiGeometry && this.props.editing && this.props.editing.features && this.props.editing.features.length,
- bsStyle: this.props.drawing ? "success" : "primary"
- }, {
- glyph: 'trash',
- tooltipId: "annotations.remove",
- visible: true,
- onClick: () => {
- this.setState({removing: this.props.id});
- }
- }, {
- glyph: 'download',
- tooltip: ,
- visible: true,
- onClick: () => { this.props.onDownload(this.props.features); }
- }
- ]} />
-
-
- );
- };
-
- renderEditingCoordButtons = () => {
- const areAllFeaturesValid = this.validateFeatures();
- return (
-
-
- {
- if (this.props.styling && this.isMeasureEditDisabled()) {
- if (this.props.unsavedStyle) {
- this.props.onToggleUnsavedStyleModal();
- } else {
- this.props.onCancelStyle();
- }
- } else if (this.props.unsavedGeometry) {
- this.props.onToggleUnsavedGeometryModal();
- } else if (this.props.unsavedChanges) {
- this.props.onToggleUnsavedChangesModal();
- } else {
- this.props.onResetCoordEditor();
- this.props.onCancelEdit(this.props.editing?.properties);
- // Reset geometry editor tab
- this.setState({...this.state, tabValue: 'coordinates'});
- }
-
- }
- }, {
- glyph: 'trash',
- tooltipId: "annotations.remove",
- tooltipPosition: 'bottom',
- disabled: !this.props.annotations.length,
- visible: !this.props.selected,
- onClick: () => {
- this.setState({removing: this.props.id});
- }
- }, {
- glyph: 'floppy-disk',
- tooltipPosition: 'bottom',
- tooltipId: !areAllFeaturesValid ? "annotations.annotationSaveGeometryError" : !isEmpty(this.props.selected) ? "annotations.saveGeometry" : "annotations.save",
- disabled: (this.props.selected && this.props.selected.properties && !this.props.selected.properties.isValidFeature) || !areAllFeaturesValid,
- onClick: () => this.save()
- },
- {
- glyph: 'download',
- tooltip: ,
- tooltipPosition: 'bottom',
- disabled: Object.keys(this.validate()).length !== 0 || this.props.unsavedChanges,
- visible: !this.props.selected,
- onClick: () => {
- const {newFeature, ...features} = this.props.editing;
- this.props.onDownload(features);
- }
- }
- ]} />
-
-
- );
- };
-
- renderButtons = (editing) => {
- let toolbar;
- if (editing) {
- toolbar = this.renderEditingCoordButtons();
- } else {
- toolbar = this.renderViewButtons();
- }
- return ({toolbar}
);
- };
-
- renderProperty = (field, prop, editing) => {
- const fieldValue = this.props.editedFields[field.name] === undefined ? prop : this.props.editedFields[field.name];
- if (editing) {
- switch (field.type) {
- case 'html':
- return ( { this.change(field.name, val); if (!this.props.unsavedChanges) { this.props.onSetUnsavedChanges(true); } }}
- />);
- case 'component':
- const Component = fieldValue;
- return } onChange={(e) => { this.change(field.name, e.target.value); if (!this.props.unsavedChanges) { this.props.onSetUnsavedChanges(true); } }} />;
- default:
- return { this.change(field.name, e.target.value); if (!this.props.unsavedChanges) { this.props.onSetUnsavedChanges(true); } }} />;
- }
-
- }
- switch (field.type) {
- case 'html':
- return ;
- case 'component':
- const Component = fieldValue;
- return ;
- default:
- return ({fieldValue}
);
- }
- };
-
- renderErrorOn = (field) => {
- return
;
- };
-
- renderMarkers = (markers, prefix = '') => {
- return markers.map((marker) => {
- if (marker.markers) {
- return (
- {this.renderMarkers(marker.markers, marker.name + '-')}
-
);
- }
- return (
- this.selectStyle(marker)}
- className={"mapstore-annotations-info-viewer-marker mapstore-annotations-info-viewer-marker-" + prefix + marker.name +
- (this.isCurrentStyle(marker) ? " mapstore-annotations-info-viewer-marker-selected" : "")} style={marker.thumbnailStyle} />);
- });
- };
-
- renderBody = (editing) => {
- const items = this.getBodyItems(editing);
- if (items.length === 0) {
- return null;
- }
-
- return (
-
- {items}
- {editing &&
- }
-
-
);
- };
-
- renderError = (editing) => {
- return editing ? (Object.keys(this.props.errors)
- .filter(field => this.getConfig().fields.filter(f => f.name === field).length === 0).map(field => this.renderErrorOn(field))) : null;
- };
-
- renderModals = () => {
- if (this.props.closing) {
- return (
this.props.onConfirmClose(this.props.editing?.properties)}
- confirmButtonBSStyle="default"
- closeGlyph="1-close"
- confirmButtonContent={}
- closeText={}>
-
- );
- } else if (this.props.showUnsavedChangesModal) {
- return (
{
- this.props.selected && this.props.onResetCoordEditor();
- this.props.onCancelEdit(this.props.editing?.properties); this.props.onToggleUnsavedChangesModal();
- }}
- confirmButtonBSStyle="default"
- closeGlyph="1-close"
- confirmButtonContent={}
- closeText={}>
-
- );
- } else if (this.props.showUnsavedGeometryModal) {
- return (
{
- this.props.onResetCoordEditor();
- this.props.onCancelEdit(this.props.editing?.properties);
- }}
- confirmButtonBSStyle="default"
- closeGlyph="1-close"
- title={}
- confirmButtonContent={}
- closeText={}>
-
- );
- } else if (this.props.showUnsavedStyleModal) {
- return (
{
- this.props.onCancelStyle();
- this.props.onToggleUnsavedStyleModal();
- if (this.isMeasureEditDisabled()) {
- this.setTabValue('coordinates');
- } else {
- this.setTabValue('style');
- }
- }}
- confirmButtonBSStyle="default"
- closeGlyph="1-close"
- confirmButtonContent={}
- closeText={}>
-
- );
- } else if (this.props.showDeleteFeatureModal) {
- return (
{ this.props.onConfirmDeleteFeature(); this.props.onToggleDeleteFtModal(); }}
- confirmButtonBSStyle="default"
- closeGlyph="1-close"
- confirmButtonContent={}
- closeText={}>
-
- );
- } else if (this.state.removing || this.props.removing) {
- return (
{
- this.state.removing && this.setState({removing: null});
- this.props.onCancelRemove();
- }}
- focusConfirm={this.props.removing}
- onConfirm={() => {
- if (this.state.removing) {
- this.setState({removing: null});
- this.props.onConfirmRemove(this.state.removing, "features");
- } else {
- this.props.onConfirmRemove(this.props.removing, "geometry");
- }
- }}
- confirmButtonBSStyle="default"
- closeGlyph="1-close"
- confirmButtonContent={}
- closeText={}>
- {this.props.mode === 'editing' ? :
- }
- );
- } else if (this.state.showPopupWarning && this.props.showPopupWarning) {
- return (
}
- onClose={this.hideWarning}
- onConfirm={this.setAnnotationMeasurement}
- confirmButtonBSStyle="default"
- closeGlyph="1-close"
- confirmButtonContent={}
- closeText={}>
-
-
-
-
-
-
-
-
- );
- }
-
- return null;
- }
-
- render() {
- const editing = this.props.editing && (this.props.editing.properties.id === this.props.id);
- let mouseHoverEvents = this.props.mouseHoverEvents ? {
- onMouseEnter: () => {
- this.props.onHighlight(this.props.id);
- },
- onMouseLeave: () => {
- this.props.onCleanHighlight();
- }
- } : {};
- const type = this.props.selected ? getGeometryType(this.props.selected) : "";
- const {glyph = "", label = ""} = isEmpty(type) ? {} : getGeometryGlyphInfo(type);
- return (
-
-
- {this.renderButtons(editing)}
- {this.renderError(editing)}
- {this.renderModals()}
- {this.renderBody(editing)}
-
- {!isEmpty(this.props.selected) &&
-
-
-
-
- {
- const valueText = e.target.value.trim();
- this.props.onChangeGeometryTitle(valueText ? valueText : label);
- }}
- type="text"/>
-
-
- {this.props.selected?.properties?.isText &&
-
-
-
- {
- const valueText = e.target.value;
- const components = this.props?.selected?.geometry?.coordinates?.length ?
- getComponents(this.props.selected.geometry) : [];
- if (this.validateText(components, valueText )) {
- this.props.onChangeText(valueText, components.map(coordToArray));
- } else if (valueText !== "") {
- this.props.onChangeText(valueText, components.map(coordToArray));
- } else {
- this.props.onChangeText("", components.map(coordToArray));
- this.props.onSetInvalidSelected("text", components.map(coordToArray));
- }
- }}
- type="text"/>
-
-
-
}
-
-
- {this.state.tabValue === 'coordinates' &&
-
- }
- {this.state.tabValue === 'style' &&
- {
- this.props.onSetStyle(style);
- this.props.onSetUnsavedStyle(true);
- this.props.onSetUnsavedChanges(true);
- }}
- pointType={this.props.pointType}
- style={this.props.selected && this.props.selected.style || this.props.editing.style}
- width={this.props.width}
- symbolsPath={this.props.symbolsPath}
- onSetErrorSymbol={this.props.onSetErrorSymbol}
- symbolErrors={this.props.symbolErrors}
- onUpdateSymbols={this.props.onUpdateSymbols}
- symbolList={this.props.symbolList}
- defaultShape={this.props.defaultShape}
- defaultShapeSize={this.props.defaultShapeSize}
- defaultShapeFillColor={this.props.defaultShapeFillColor}
- defaultShapeStrokeColor={this.props.defaultShapeStrokeColor}
- defaultStyles={this.props.defaultStyles}
- lineDashOptions={this.props.lineDashOptions}
- markersOptions={this.getConfig()}
- textRotationStep={this.props.textRotationStep}
- />
- }
-
-
- }
-
- );
- }
-
- validateFeatures = () => {
- let areAllGeometriesValid = true;
- if (Array.isArray(this.props?.editing?.features)) {
- areAllGeometriesValid = this.props.editing.features.every(feature => feature?.properties?.isValidFeature);
- }
- return areAllGeometriesValid;
- };
-
- change = (field, value) => {
- this.props.onChangeProperties(field, value);
- };
-
- isCurrentStyle = (m) => {
- return this.getConfig().markersConfig.matches(this.props.editing.style.MultiPoint, m.style);
- };
-
- selectStyle = (marker) => {
- return this.props.onSetStyle(assign({}, {
- "Point": {
- ...this.getConfig().markersConfig.getStyle(marker.style),
- iconGlyph: this.props.editing.style.Point && this.props.editing.style.Point.iconGlyph
- },
- "MultiPoint": {
- ...this.getConfig().markersConfig.getStyle(marker.style),
- iconGlyph: this.props.editing.style.MultiPoint && this.props.editing.style.MultiPoint.iconGlyph
- }
- }));
- };
-
- selectGlyph = (option) => {
- return this.props.onSetStyle(
- assign({}, this.props.editing.style, {
- "Point": {
- ...this.props.editing.style.Point,
- iconGlyph: option && option.value || ""
- },
- "MultiPoint": {
- ...this.props.editing.style.MultiPoint,
- iconGlyph: option && option.value || ""
- }
- }));
- };
-
- validate = () => {
- return assign(this.getConfig().fields.filter(field => field.editable).reduce((previous, field) => {
- const value = this.props.editedFields[field.name] === undefined ? this.props[field.name] : this.props.editedFields[field.name];
- if (field.validator && !this.getValidator(field.validator)(value)) {
- return assign(previous, {
- [field.name]: field.validateError
- });
- }
- return previous;
- }, {}), this.props.editing.features && this.props.editing.features.length ? {} : {
- geometry: 'annotations.emptygeometry'
- });
-
- };
-
- validateText = (components, valueText) => {
- if (components && components.length) {
- const cmp = head(components);
- return !!valueText && validateCoords(cmp);
- }
- return false;
- }
-
- save = () => {
- if (!isEmpty(this.props.selected)) {
- this.props.onAddNewFeature();
- } else {
- const errors = this.validate();
- if (Object.keys(errors).length === 0) {
- this.props.onError({});
- this.props.onSave(this.props.id, assign({}, this.props.editedFields),
- this.props.editing.features, this.props.editing.style, this.props.editing.newFeature || false, {
- ...this.props.editing.properties,
- visibility: !isUndefined(this.props.editing.properties.visibility)
- ? this.props.editing.properties.visibility
- : this.props.editing.visibility
- }
- );
- } else {
- this.props.onError(errors);
- }
- }
- };
-
- setTabValue = (tabValue) =>{
- if (this.state.tabValue !== tabValue) {
- this.setState({...this.state, tabValue});
- }
- }
-
- setPopupWarning = (showPopupWarning) =>{
- this.setState({...this.state, showPopupWarning});
- }
-
- isMeasureEditDisabled = () => {
- const isMeasureAnnotation = this.props.editing?.properties?.type === MEASURE_TYPE || false;
- return !this.props.measurementAnnotationEdit || !isMeasureAnnotation;
- }
-
- setAnnotationMeasurement = () => {
- // Excluding geometry types not supported by measurement
- this.props.onSetAnnotationMeasurement(this.props.editing.features.filter(f=> f.geometry.type !== 'Point' && !f.properties.isCircle), this.props.editing?.properties);
- this.hideWarning();
- }
-
- hideWarning = () => {
- if (this.props.showAgain) {
- try {
- getApi().setItem("showPopupWarning", false);
- } catch (e) {
- console.error(e);
- }
- this.props.onHideMeasureWarning();
- }
- this.setPopupWarning(false);
- }
-}
-
-export default AnnotationsEditor;
diff --git a/web/client/components/mapcontrols/annotations/DropdownFeatureType.jsx b/web/client/components/mapcontrols/annotations/DropdownFeatureType.jsx
deleted file mode 100644
index a7c4b76823..0000000000
--- a/web/client/components/mapcontrols/annotations/DropdownFeatureType.jsx
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2018, 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 { Glyphicon, DropdownButton, MenuItem } from 'react-bootstrap';
-
-import tooltip from '../../misc/enhancers/tooltip';
-import { DEFAULT_ANNOTATIONS_STYLES, getStartEndPointsForLinestring } from '../../../utils/LegacyAnnotationsUtils';
-import React from 'react';
-import uuidv1 from 'uuid/v1';
-import assign from 'object-assign';
-
-
-const DropdownButtonT = tooltip(DropdownButton);
-const DropdownFeatureType = ({
- onClick = () => {},
- onStartDrawing = () => {},
- onAddText = () => {},
- onSetStyle = () => {},
- defaultStyles = {},
- defaultPointType = 'marker',
- titles = {},
- glyph = "",
- bsStyle = "primary",
- ...props
-} = {}) => (
-
}
- disabled={!!props.disabled}
- noCaret>
-
-
-
-
-
-
-
-
-
-
-
-);
-
-export default DropdownFeatureType;
diff --git a/web/client/components/mapcontrols/annotations/FeaturesList.jsx b/web/client/components/mapcontrols/annotations/FeaturesList.jsx
deleted file mode 100644
index c69fa022c3..0000000000
--- a/web/client/components/mapcontrols/annotations/FeaturesList.jsx
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright 2020, 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 {Glyphicon, ControlLabel, Tooltip } from 'react-bootstrap';
-import uuidv1 from 'uuid/v1';
-import bbox from '@turf/bbox';
-import Toolbar from '../../misc/toolbar/Toolbar';
-import OverlayTrigger from '../../misc/OverlayTrigger';
-import cs from 'classnames';
-import Message from '../../I18N/Message';
-import {get} from 'lodash';
-import {DEFAULT_ANNOTATIONS_STYLES, getStartEndPointsForLinestring, getGeometryGlyphInfo, getGeometryType} from '../../../utils/LegacyAnnotationsUtils';
-
-/**
- * Feature List component for Annotation Viewer.
- * @memberof components.mapControls.annotations
- * @function
- *
-*/
-const FeaturesList = (props) => {
- const {
- editing,
- onAddGeometry,
- onSetStyle,
- onStartDrawing,
- onAddText,
- onStyleGeometry,
- setTabValue,
- isMeasureEditDisabled,
- onSetAnnotationMeasurement,
- showPopupWarning,
- setPopupWarning,
- geodesic,
- defaultStyles,
- defaultPointType,
- onValidateFeature,
- validateFeatures
- } = props;
- const {features = []} = editing || {};
- const isValidFeature = get(props, "selected.properties.isValidFeature", true);
- const areAllFeaturesValid = validateFeatures();
-
- const onClickGeometry = (type, style) => {
- onStyleGeometry(false);
- onAddGeometry(type);
- type === "Text" && onAddText();
- onSetStyle(style);
- onStartDrawing({geodesic});
- setTabValue('coordinates');
- onValidateFeature();
- };
- const circleCenterStyles = defaultPointType === "symbol" ? defaultStyles.POINT?.[defaultPointType] : DEFAULT_ANNOTATIONS_STYLES.Point;
-
- const linePointStyles = defaultPointType === "symbol" ? [{...defaultStyles.POINT?.[defaultPointType], highlight: true, iconAnchor: [0.5, 0.5], type: "Point", title: "StartPoint Style", geometry: "startPoint", filtering: false, id: uuidv1()},
- {...defaultStyles.POINT?.[defaultPointType], highlight: true, iconAnchor: [0.5, 0.5], type: "Point", title: "EndPoint Style", geometry: "endPoint", filtering: false, id: uuidv1()}] : getStartEndPointsForLinestring();
-
- return (
- <>
-
-
- {
- showPopupWarning ? setPopupWarning(true) : onSetAnnotationMeasurement();
- },
- tooltip:
- },
- {
- glyph: 'point-plus',
- visible: isMeasureEditDisabled,
- disabled: !isValidFeature,
- onClick: () => {
- const style = [{ ...defaultStyles.POINT?.[defaultPointType], highlight: true, id: uuidv1()}];
- onClickGeometry("Point", style);
- },
- tooltip:
- },
- {
- glyph: 'polyline-plus',
- visible: isMeasureEditDisabled,
- disabled: !isValidFeature,
- onClick: () => {
- const style = [{ ...DEFAULT_ANNOTATIONS_STYLES.LineString, highlight: true, id: uuidv1()}]
- .concat(linePointStyles);
- onClickGeometry("LineString", style);
- },
- tooltip:
- },
- {
- glyph: 'polygon-plus',
- visible: isMeasureEditDisabled,
- disabled: !isValidFeature,
- onClick: () => {
- const style = [
- {...DEFAULT_ANNOTATIONS_STYLES.Polygon, highlight: true, id: uuidv1()}];
- onClickGeometry("Polygon", style);
- },
- tooltip:
- },
- {
- glyph: 'font-add',
- visible: isMeasureEditDisabled,
- disabled: !isValidFeature,
- onClick: () => {
- const style = [
- {...DEFAULT_ANNOTATIONS_STYLES.Text, highlight: true, type: "Text", title: "Text Style", id: uuidv1()}];
- onClickGeometry("Text", style);
- },
- tooltip:
- },
- {
- glyph: '1-circle-add',
- visible: isMeasureEditDisabled,
- disabled: !isValidFeature,
- onClick: () => {
- const style = [
- {...DEFAULT_ANNOTATIONS_STYLES.Circle, highlight: true, type: "Circle", title: "Circle Style", id: uuidv1()},
- { ...circleCenterStyles, highlight: true, iconAnchor: [0.5, 0.5], type: "Point", title: "Center Style", filtering: false, geometry: "centerPoint", id: uuidv1()}
- ];
- onClickGeometry("Circle", style);
- },
- tooltip:
- }
- ]}
- />
-
- {features && features.length === 0 &&
}
- {features?.map((feature, key) => {
- return (
-
- );
- })}
- >
- );
-};
-
-/**
- * Feature or Geometry card component for FeatureList.
- * @function
- *
- */
-const FeatureCard = ({
- feature,
- selected,
- disabled,
- onDeleteGeometry,
- onZoom,
- maxZoom,
- onSelectFeature,
- onUnselectFeature,
- setTabValue,
- isMeasureEditDisabled,
- onStyleGeometry,
- onGeometryHighlight,
- onValidateFeature
-}) => {
- const type = getGeometryType(feature);
- const {properties} = feature;
- const {glyph, label} = getGeometryGlyphInfo(type);
- const isSelected = selected?.properties?.id === properties?.id;
-
- const selectedIsValidFeature = get(selected, "properties.isValidFeature", true);
- const isValidFeature = properties?.isValidFeature;
- const allowCardMouseEvent = !isSelected && selectedIsValidFeature;
-
- const overlayWrapper = (content) => (
-
}>
- {content}
-
- );
-
- const content = (
-
allowCardMouseEvent && onGeometryHighlight(properties.id)}
- onMouseLeave={() => allowCardMouseEvent && onGeometryHighlight(properties.id, false)}
- onClick={() =>{
-
- if (isSelected && isValidFeature) {
- onUnselectFeature();
- onGeometryHighlight(properties.id);
- } else if (!disabled) {
- onSelectFeature([feature]);
- setTabValue(isMeasureEditDisabled ? 'coordinates' : 'style');
- onStyleGeometry(!isMeasureEditDisabled);
- }
- onValidateFeature();
- } }
- >
-
-
-
-
-
{properties?.geometryTitle || label || properties?.id}
-
-
,
- onClick: (event) => {
- event.stopPropagation();
- const extent = bbox(feature);
- onZoom(extent, 'EPSG:4326', maxZoom);
- }
- },
- {
- glyph: 'trash',
- className: cs({'inactive': disabled && !isSelected, 'square-button-md no-border': true}),
- tooltip:
,
- onClick: (event) => {
- event.stopPropagation();
- onDeleteGeometry(properties?.id);
- }
- }
- ]}
- />
-
- );
-
- return disabled && !isSelected ? overlayWrapper(content) : content;
-};
-
-FeaturesList.defaultProps = {
- onAddGeometry: () => {},
- onSetStyle: () => {},
- onStartDrawing: () => {},
- onAddText: () => {},
- onStyleGeometry: () => {},
- onSetAnnotationMeasurement: () => {},
- onSelectFeature: () => {},
- setTabValue: () => {},
- isMeasureEditDisabled: true,
- defaultPointType: 'marker',
- defaultStyles: {},
- onValidateFeature: () => {},
- validateFeatures: () => { return true; }
-};
-
-export default FeaturesList;
diff --git a/web/client/components/mapcontrols/annotations/SelectAnnotationsFile.jsx b/web/client/components/mapcontrols/annotations/SelectAnnotationsFile.jsx
deleted file mode 100644
index 6eb6595d60..0000000000
--- a/web/client/components/mapcontrols/annotations/SelectAnnotationsFile.jsx
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.
- */
-
-import { Promise } from 'es6-promise';
-import PropTypes from 'prop-types';
-import React from 'react';
-import { Checkbox } from 'react-bootstrap';
-import Dropzone from 'react-dropzone';
-import Spinner from 'react-spinkit';
-
-import { ANNOTATION_TYPE } from '../../../plugins/Annotations/utils/AnnotationsUtils';
-import { readGeoJson } from '../../../utils/FileUtils';
-import Message from '../../I18N/Message';
-import ResizableModal from '../../misc/ResizableModal';
-
-class SelectAnnotationsFile extends React.Component {
- static propTypes = {
- show: PropTypes.bool,
- text: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
- onFileChoosen: PropTypes.func,
- error: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
- errorMessage: PropTypes.string,
- onClose: PropTypes.func,
- title: PropTypes.node,
- closeGlyph: PropTypes.string,
- disableOvveride: PropTypes.bool
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- show: false,
- text:
,
- onFileChoosen: () => {},
- onClose: () => {},
- closeGlyph: "",
- errorMessage: "annotations.loaderror",
- title:
,
- disableOvveride: false
- };
- state = {
- override: false,
- loading: false
- }
- renderError = () => (
-
)
- render() {
- return (
-
-
- {this.state.error && this.renderError()}
-
- {this.state.loading && }{this.props.text}
-
-
- this.setState(() => ({override: !this.state.override}))}>
-
-
-
-
-
- );
- }
- setError = () => {
- this.setState(() => ({error: this.props.errorMessage, loading: false}));
- }
- // Modificare per accettare file json ma non devono per forza avere ext.json
- // inoltre può accettare qualsiasi collezione di features inoltre filtrare le features che hanno medesimo id
- checkfile = (files) => {
- this.setState(() => ({loading: true}));
- Promise.all(files.map(file => readGeoJson(file))).then((contents) => {
- if (this.state.error) {
- this.setState(() => ({error: null}));
- }
- // Get only features
- const annotations = contents.filter(({geoJSON, errors = []}) => errors.length === 0 || geoJSON.type === ANNOTATION_TYPE).reduce((acc, {geoJSON}) => acc.concat(geoJSON.features || geoJSON), []);
- if (annotations.length === 0) {
- throw new Error();
- }
- this.props.onFileChoosen(annotations, this.state.override);
- this.setState(() => ({loading: false}));
- this.props.onClose();
- }).catch(() => {
- this.setError();
- });
- };
-}
-
-export default SelectAnnotationsFile;
diff --git a/web/client/components/mapcontrols/annotations/__tests__/Annotations-test.js b/web/client/components/mapcontrols/annotations/__tests__/Annotations-test.js
deleted file mode 100644
index 5eb466e541..0000000000
--- a/web/client/components/mapcontrols/annotations/__tests__/Annotations-test.js
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright 2015-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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import Annotations from '../Annotations';
-import TestUtils from 'react-dom/test-utils';
-
-describe("test the Annotations Panel", () => {
- beforeEach((done) => {
- document.body.innerHTML = '
';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.body);
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('test default properties', () => {
- const annotations = ReactDOM.render(
, document.getElementById("container"));
- expect(annotations).toBeTruthy();
- const annotationsNode = ReactDOM.findDOMNode(annotations);
- expect(annotationsNode).toBeTruthy();
- });
-
- it('test removing annotations', () => {
- const annotations = ReactDOM.render(
, document.getElementById("container"));
- expect(annotations).toBeTruthy();
-
- const annotationsNode = ReactDOM.findDOMNode(annotations);
- expect(annotationsNode).toBeTruthy();
- });
-
- it('test rendering detail mode', () => {
- const annotationsList = [{
- properties: {
- id: '1',
- title: 'a',
- description: 'b'
- },
- geometry: {
- type: "MultiPoint"
- },
- style: {
- iconShape: 'square',
- iconColor: 'blue'
- }
- }, {
- properties: {
- id: '2',
- title: 'a',
- description: 'b'
- },
- geometry: {
- type: "MultiPoint"
- },
- style: {
- iconShape: 'square',
- iconColor: 'blue'
- }
- }];
-
- const Editor = () => ;
- const annotations = ReactDOM.render(, document.getElementById("container"));
- expect(annotations).toBeTruthy();
- expect(TestUtils.scryRenderedDOMComponentsWithClass(annotations, "mapstore-annotations-panel-card").length).toBe(0);
- expect(TestUtils.scryRenderedDOMComponentsWithClass(annotations, "myeditor").length).toBe(1);
- });
-
- it('test rendering editing mode', () => {
- const Editor = () => ;
- const annotations = ReactDOM.render(, document.getElementById("container"));
- expect(annotations).toBeTruthy();
- expect(TestUtils.scryRenderedDOMComponentsWithClass(annotations, "mapstore-annotations-panel-card").length).toBe(0);
- expect(TestUtils.scryRenderedDOMComponentsWithClass(annotations, "myeditor").length).toBe(1);
- });
-
- it('test rendering custom class', () => {
- const annotationsList = [{
- properties: {
- title: 'a',
- description: 'b'
- },
- geometry: {
- type: "MultiPoint"
- },
- style: {
- iconShape: 'square',
- iconColor: 'blue',
- iconGlyph: 'comment'
- }
- }, {
- properties: {
- external: true,
- title: 'c',
- description: 'd'
- },
- geometry: {
- type: "MultiPoint"
- },
- style: {
- iconShape: 'square',
- iconColor: 'blue',
- iconGlyph: 'comment'
- }
- }];
-
- const classNameSelector = (annotation) => {
- if (annotation && annotation.properties && annotation.properties.external) {
- return 'external';
- }
- return '';
- };
-
- const annotations = ReactDOM.render(, document.getElementById("container"));
-
- expect(annotations).toBeTruthy();
-
- /*
- TODO verify the external properties
- const cardsExternal = TestUtils.scryRenderedDOMComponentsWithClass(annotations, "mapstore-annotations-panel-card external");
- expect(cardsExternal.length).toBe(1);*/
- });
-
- it('test custom editor', () => {
- const annotationsList = [{
- properties: {
- id: '1',
- title: 'a',
- description: 'b'
- },
- style: {
- iconShape: 'square',
- iconColor: 'blue'
- }
- }, {
- properties: {
- id: '2',
- title: 'a',
- description: 'b'
- },
- style: {
- iconShape: 'square',
- iconColor: 'blue'
- }
- }];
-
- const Editor = (props) => {
- return This is my editor;
- };
- const annotations = ReactDOM.render(, document.getElementById("container"));
- expect(annotations).toBeTruthy();
- expect(TestUtils.scryRenderedDOMComponentsWithClass(annotations, "mapstore-annotations-panel-card").length).toBe(0);
- expect(TestUtils.scryRenderedDOMComponentsWithClass(annotations, "myeditor1").length).toBe(1);
- });
-
- it('test annotation card', ()=> {
- const actions = {
- onZoom: () => {},
- onToggleVisibility: () => {},
- onHighlight: () => {}
- };
- const spyOnToggleVisibility = expect.spyOn(actions, 'onToggleVisibility');
- const spyOnHighlight = expect.spyOn(actions, 'onHighlight');
- const spyOnZoom = expect.spyOn(actions, 'onZoom');
- const annotations = [{
- "type": "FeatureCollection",
- "properties": {
- "id": "819b4120-aa2c-11ea-95b6-c74060290256",
- "title": "Poly",
- "description": "Description
Next Line
",
- "visibility": true
- },
- "features": [
- {
- "type": "Feature",
- "geometry": {
- "coordinates": [[[-121.07812513411045, 42.11778385718358],
- [ -116.2265622317791, 44.72175879125132],
- [ -115.87499973177908, 40.773885871584866],
- [ -114.96093589067458, 42.68889580392076],
- [ -121.07812513411045, 42.11778385718358]]
- ],
- "type": "Polygon"
- },
- "properties": {
- "id": "829d47d0-aa2c-11ea-95b6-c74060290256",
- "isValidFeature": true,
- "canEdit": false,
- "geometryTitle": "Polygon-test"
- }
- }
- ]
- }];
- const container = ReactDOM.render(, document.getElementById("container"));
- expect(container).toBeTruthy();
-
- const sideCard = TestUtils.scryRenderedDOMComponentsWithClass(container, "mapstore-side-card");
- expect(sideCard).toBeTruthy();
- expect(sideCard.length).toBe(1);
- const sideCardTitle = TestUtils.scryRenderedDOMComponentsWithClass(container, "mapstore-annotations-panel-card-title");
- expect(sideCardTitle[0].innerText).toBe('Poly');
- const sideCardDescription = TestUtils.scryRenderedDOMComponentsWithClass(container, "mapstore-annotations-panel-card-description");
- expect(sideCardDescription[0].innerText).toBe('Description');
- const sideCardTools = document.querySelectorAll('.mapstore-side-card-tool .btn-group');
- expect(sideCardTools).toBeTruthy();
- const cardButtons = sideCardTools[0].querySelectorAll('button');
- expect(cardButtons.length).toBe(2);
-
- // Zoom to annotation
- const zoomBtn = cardButtons[0];
- TestUtils.Simulate.click(zoomBtn);
- expect(spyOnZoom).toHaveBeenCalled();
-
- // Toggle annotations visibility
- const visibilityBtn = cardButtons[1];
- TestUtils.Simulate.click(visibilityBtn);
- expect(spyOnToggleVisibility).toHaveBeenCalled();
-
- // Toggle annotation highlight
- TestUtils.Simulate.mouseEnter(sideCard[0]);
- expect(spyOnHighlight).toHaveBeenCalled();
- });
-});
diff --git a/web/client/components/mapcontrols/annotations/__tests__/AnnotationsEditor-test.js b/web/client/components/mapcontrols/annotations/__tests__/AnnotationsEditor-test.js
deleted file mode 100644
index 6759f77098..0000000000
--- a/web/client/components/mapcontrols/annotations/__tests__/AnnotationsEditor-test.js
+++ /dev/null
@@ -1,587 +0,0 @@
-/**
- * Copyright 2015-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.
- */
-import expect from 'expect';
-import React from 'react';
-import { DragDropContext as dragDropContext } from 'react-dnd';
-import html5Backend from 'react-dnd-html5-backend';
-import ReactDOM from 'react-dom';
-import TestUtils from 'react-dom/test-utils';
-
-import AnnotationsEditorComp from '../AnnotationsEditor';
-
-const AnnotationsEditor = dragDropContext(html5Backend)(AnnotationsEditorComp);
-
-const actions = {
- onChangeProperties: () => {},
- onSetUnsavedChanges: () => {},
- onEdit: () => {},
- onCancelEdit: () => {},
- onSetUnsavedStyle: () => {},
- onError: () => {},
- onSetAnnotationMeasurement: () => {},
- onDownload: () => {},
- onHideMeasureWarning: () => {},
- onSelectFeature: () => {},
- onUnSelectFeature: () => {},
- onValidateFeature: () => {}
-};
-describe("test the AnnotationsEditor Panel", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.body);
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('test default properties', () => {
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
- const viewerNode = ReactDOM.findDOMNode(viewer);
- expect(viewerNode).toExist();
- });
-
- it('test display annotation', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
-
- const viewerNode = ReactDOM.findDOMNode(viewer);
- expect(viewerNode).toExist();
- expect(viewerNode.innerText.indexOf('mytitle') !== -1).toBe(true);
- expect(viewerNode.innerHTML.indexOf('desc') !== -1).toBe(true);
- });
-
- it('test display annotation with component field', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
- const MyComponent = (props) => {
- return my feature: {props.annotation.id};
- };
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
-
- const viewerNode = ReactDOM.findDOMNode(viewer);
- expect(viewerNode).toExist();
- expect(viewerNode.innerText.indexOf('my feature: 1') !== -1).toBe(true);
- });
-
- it('test editing annotation', () => {
- const properties = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
-
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
- expect(TestUtils.scryRenderedDOMComponentsWithTag(viewer, "input").length).toEqual(1);
- expect(TestUtils.scryRenderedDOMComponentsWithClass(viewer, "quill").length).toEqual(1);
- });
-
- it('test click remove annotation', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
-
- const testHandlers = {
- onRemoveHandler: () => { }
- };
-
- const spyRemove = expect.spyOn(testHandlers, 'onRemoveHandler');
-
- let viewer = ReactDOM.render({}} onSetUnsavedChanges={()=>{}}
- onConfirmRemove={testHandlers.onRemoveHandler}/>, document.getElementById("container"));
- expect(viewer).toExist();
- let btnGroup = document.querySelector(".mapstore-annotations-info-viewer-buttons");
- let toolBarButtons = btnGroup.querySelectorAll('button');
- let removeBtn = toolBarButtons[1];
- expect(toolBarButtons.length).toBe(4);
- expect(removeBtn).toExist();
- TestUtils.Simulate.click(removeBtn);
- const dialog = document.getElementById("confirm-dialog");
- expect(dialog).toExist();
- const confirm = dialog.querySelectorAll('button')[1];
- TestUtils.Simulate.click(confirm);
- expect(spyRemove).toHaveBeenCalled();
-
- // Disable remove button when no annotations present except for the unsaved new annotation
- viewer = ReactDOM.render({}} onSetUnsavedChanges={()=>{}}
- onConfirmRemove={testHandlers.onRemoveHandler}/>, document.getElementById("container"));
- expect(viewer).toExist();
- btnGroup = document.querySelector(".mapstore-annotations-info-viewer-buttons");
- toolBarButtons = btnGroup.querySelectorAll('button');
- removeBtn = toolBarButtons[1];
- expect(toolBarButtons.length).toBe(4);
- expect(removeBtn.classList.contains('disabled')).toBe(true);
-
- });
-
- it('test click save annotation', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
-
- const testHandlers = {
- onSaveHandler: (id) => { return id; },
- onCancelHandler: (id) => { return id; },
- onToggleGeometryEditHandler: (flag) => { return flag; }
- };
-
- const spySave = expect.spyOn(testHandlers, 'onSaveHandler');
- const spyCancel = expect.spyOn(testHandlers, 'onCancelHandler');
-
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
-
- let saveButton = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(viewer, "button")[2]);
-
- expect(saveButton).toExist();
- TestUtils.Simulate.click(saveButton);
- expect(spySave.calls.length).toEqual(1);
- expect(spySave.calls[0].arguments[0]).toEqual(1);
- expect(spySave.calls[0].arguments[5]).toEqual({...feature, visibility: true});
- expect(spyCancel.calls.length).toEqual(0);
- });
-
- it('test click save annotation', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
-
- const testHandlers = {
- onAddNewFeature: () => {}
- };
-
- const spySaveGeometry = expect.spyOn(testHandlers, 'onAddNewFeature');
- const defaultStyles = {POINT: {
- marker: ["Test marker"],
- symbol: ["Test symbol"]
- }};
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
-
- let saveButton = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(viewer, "button")[1]);
-
- expect(saveButton).toExist();
- TestUtils.Simulate.click(saveButton);
- expect(spySaveGeometry).toHaveBeenCalled();
- });
-
- it('test click cancel', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc',
- visibility: false
- };
-
- const testHandlers = {
- onSaveHandler: (id) => { return id; },
- onCancelHandler: (id) => { return id; }
- };
-
- const spySave = expect.spyOn(testHandlers, 'onSaveHandler');
- const spyCancel = expect.spyOn(testHandlers, 'onCancelHandler');
-
- const viewer = ReactDOM.render(null}/>, document.getElementById("container"));
- expect(viewer).toExist();
-
- let cancelButton = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(viewer, "button")[0]);
-
- expect(cancelButton).toExist();
- TestUtils.Simulate.click(cancelButton);
-
- expect(spySave.calls.length).toEqual(0);
- expect(spyCancel.calls.length).toEqual(1);
- const properties = spyCancel.calls[0].arguments[0];
- expect(Object.keys(properties).length > 0).toBe(true);
- expect(spyCancel.calls[0].arguments[0].id).toBe('1');
- expect(spyCancel.calls[0].arguments[0].visibility).toBe(false);
- });
-
- it('test click cancel trigger UnsavedChangesModal', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
-
- const testHandlers = {
- onToggleUnsavedChangesModal: (id) => { return id; }
- };
-
- const spyUnsavedModal = expect.spyOn(testHandlers, 'onToggleUnsavedChangesModal');
-
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
-
- let cancelButton = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(viewer, "button")[0]);
-
- expect(cancelButton).toExist();
- TestUtils.Simulate.click(cancelButton);
-
- expect(spyUnsavedModal.calls.length).toEqual(1);
- });
-
- it('test click save validate title error', () => {
- const feature = {
- id: "1",
- title: '',
- description: 'desc'
- };
-
- const testHandlers = {
- onSaveHandler: (id) => { return id; },
- onErrorHandler: (msg) => { return msg; }
- };
-
- const spySave = expect.spyOn(testHandlers, 'onSaveHandler');
- const spyError = expect.spyOn(testHandlers, 'onErrorHandler');
-
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
-
- let saveButton = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(viewer, "button")[2]);
-
- expect(saveButton).toExist();
- TestUtils.Simulate.click(saveButton);
-
- expect(spySave.calls.length).toEqual(0);
- expect(spyError.calls.length).toEqual(1);
- expect(spyError.calls[0].arguments[0].title).toBe('annotations.mandatory');
- });
-
- it('test click save validate geometry error', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
-
- const testHandlers = {
- onSaveHandler: (id) => { return id; },
- onErrorHandler: (msg) => { return msg; }
- };
-
- const spySave = expect.spyOn(testHandlers, 'onSaveHandler');
- const spyError = expect.spyOn(testHandlers, 'onErrorHandler');
-
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
-
- let saveButton = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(viewer, "button")[2]);
-
- expect(saveButton).toExist();
- TestUtils.Simulate.click(saveButton);
-
- expect(spySave.calls.length).toEqual(0);
- expect(spyError.calls.length).toEqual(1);
- expect(spyError.calls[0].arguments[0].geometry).toBe('annotations.emptygeometry');
- });
-
- it('test edit field', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
- const testHandlers = {
- onChangeProperties: (id) => { return id; }
- };
- const spyChangeProperties = expect.spyOn(testHandlers, 'onChangeProperties');
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
-
- const titleField = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(viewer, "input")[0]);
- titleField.value = 'anothertitle';
- TestUtils.Simulate.change(titleField);
- expect(spyChangeProperties.calls.length).toEqual(2);
-
- });
-
- it('test errors', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
-
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
- const viewerNode = ReactDOM.findDOMNode(viewer);
- expect(viewerNode.innerText.indexOf('myerror') !== -1).toBe(true);
- });
-
- it('test styling', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
-
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toExist();
- const viewerNode = ReactDOM.findDOMNode(viewer);
- expect(viewerNode.className).toBe('mapstore-annotations-info-viewer');
-
- const stylerPanel = TestUtils.findRenderedDOMComponentWithClass(viewer, "mapstore-annotations-info-viewer-styler");
- expect(stylerPanel).toExist();
- });
-
- it('test Measurement annotation', () => {
- const feature = {
- id: "1",
- title: 'Measure Length',
- description: 'Description',
- type: "Measure",
- iconGlyph: "1-measure-length"
- };
- const spyOnSetAnnotationMeasurement = expect.spyOn(actions, "onSetAnnotationMeasurement");
- const spyOnHideMeasureWarning = expect.spyOn(actions, "onHideMeasureWarning");
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toBeTruthy();
- const viewerNode = ReactDOM.findDOMNode(viewer);
- expect(viewerNode.className).toBe('mapstore-annotations-info-viewer');
-
- const annotationInfoViewer = TestUtils.findRenderedDOMComponentWithClass(viewer, "mapstore-annotations-info-viewer-items");
- const geometriesToolbar = document.querySelector('.geometries-toolbar');
- const geometryCard = document.querySelectorAll('.geometry-card');
- expect(annotationInfoViewer).toBeTruthy();
- expect(geometriesToolbar).toBeTruthy();
-
- const geomButton = geometriesToolbar.children[1].getElementsByTagName('button');
- expect(geomButton.length).toBe(1);
- const editMeasureButton = geomButton[0];
- expect(editMeasureButton.children[0].className).toContain(feature.iconGlyph);
- expect(geometryCard.length).toBe(2);
-
- // Edit measurement
- TestUtils.Simulate.click(editMeasureButton);
- expect(spyOnSetAnnotationMeasurement).toHaveBeenCalled();
- expect(spyOnHideMeasureWarning).toHaveBeenCalled();
- expect(spyOnSetAnnotationMeasurement.calls[0].arguments).toBeTruthy();
- expect(spyOnSetAnnotationMeasurement.calls[0].arguments.length).toBe(2);
- const features = spyOnSetAnnotationMeasurement.calls[0].arguments[0];
- const properties = spyOnSetAnnotationMeasurement.calls[0].arguments[1];
- expect(features.length).toBe(1);
- expect(features[0].geometry.type).toBe('LineString');
- expect(properties).toBeTruthy();
- expect(Object.keys(properties).length > 0).toBe(true);
- });
-
- it('test Measurement geometry', () => {
- const properties = {
- id: "1",
- title: 'Measure Length',
- description: 'Description',
- type: "Measure",
- iconGlyph: "1-measure-length"
- };
- const feature = {
- properties,
- features: [{
- type: 'Feature',
- geometry: {type: "LineString"},
- properties: {
- id: 1,
- values: [{
- value: '1511',
- formattedValues: "1,511 m",
- position: [1, 1],
- type: 'length'
- }]
- }
- },
- {type: 'Feature', geometry: {type: "Point"}}],
- style: [{}]
- };
- const viewer = ReactDOM.render(, document.getElementById("container"));
- expect(viewer).toBeTruthy();
- const viewerNode = ReactDOM.findDOMNode(viewer);
- expect(viewerNode.className).toBe('mapstore-annotations-info-viewer');
-
- const annotationInfoViewer = TestUtils.findRenderedDOMComponentWithClass(viewer, "mapstore-annotations-info-viewer-items");
- const geometryCard = document.querySelectorAll('.geometry-card');
- expect(annotationInfoViewer).toBeTruthy();
- expect(geometryCard.length).toBe(2);
-
- // Onclick of measurement geometry
- TestUtils.Simulate.click(geometryCard[0]);
- const navTabs = document.querySelector('.nav-tabs');
- expect(navTabs.children.length).toBe(1);
- const styleTab = navTabs.children[0].childNodes[0].textContent;
- expect(styleTab).toContain('Style');
- });
-
- it('test onDownload annotation', () => {
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
-
- const spyOnDownload = expect.spyOn(actions, 'onDownload');
- let viewer = ReactDOM.render(, document.getElementById("container"));
-
- expect(viewer).toExist();
- let viewerNode = ReactDOM.findDOMNode(viewer);
- expect(viewerNode.className).toBe('mapstore-annotations-info-viewer');
-
- let buttonsRow = viewerNode.querySelector('.mapstore-annotations-info-viewer-buttons .noTopMargin');
- expect(buttonsRow).toBeTruthy();
-
- let buttons = buttonsRow.querySelectorAll('button');
- expect(buttons.length).toBe(4);
-
- let downloadCurrentAnnotation = buttons[3];
- expect(downloadCurrentAnnotation.classList.contains('disabled')).toBe(false);
-
- TestUtils.Simulate.click(downloadCurrentAnnotation);
- expect(spyOnDownload).toHaveBeenCalled();
- expect(spyOnDownload.calls[0].arguments[0]).toEqual({features: [{id: "1"}], properties: feature});
- });
- it('test onDownload when unsavedChanges', ()=>{
- const feature = {
- id: "1",
- title: 'mytitle',
- description: 'desc'
- };
-
- const viewer = ReactDOM.render(, document.getElementById("container"));
-
- expect(viewer).toExist();
- const viewerNode = ReactDOM.findDOMNode(viewer);
- const buttonsRow = viewerNode.querySelector('.mapstore-annotations-info-viewer-buttons .noTopMargin');
- const buttons = buttonsRow.querySelectorAll('button');
- const downloadCurrentAnnotation = buttons[3];
- expect(downloadCurrentAnnotation.classList.contains('disabled')).toBe(true);
- });
-});
diff --git a/web/client/components/mapcontrols/annotations/__tests__/DropdownFeatureType-test.js b/web/client/components/mapcontrols/annotations/__tests__/DropdownFeatureType-test.js
deleted file mode 100644
index ab9aadfa37..0000000000
--- a/web/client/components/mapcontrols/annotations/__tests__/DropdownFeatureType-test.js
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2019, 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 expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import DropdownFeatureType from '../DropdownFeatureType';
-
-const titles = {
- marker: "marker",
- line: "line",
- polygon: "polygon",
- circle: "circle",
- text: "text"
-};
-
-const testSpies = (spies, button) => {
- expect(button).toExist();
- button.click();
- spies.forEach(spy => {
- expect(spy).toHaveBeenCalled();
- });
-};
-
-const resetSpies = (spies) => {
- spies.forEach(spy => {
- spy.restore();
- });
-};
-
-describe("test the DropdownFeatureType Panel", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('DropdownFeatureType rendering with defaults', () => {
- ReactDOM.render(
- , document.getElementById("container")
- );
- const items = document.getElementsByTagName("li");
- expect(items).toExist();
- expect(items.length).toBe(5);
- const spans = document.getElementsByTagName("span");
- expect(spans).toExist();
- expect(spans.length).toBe(6);
- expect(spans[0].className).toBe("glyphicon glyphicon-pencil-add");
- expect(spans[1].className).toBe("glyphicon glyphicon-point");
- expect(spans[2].className).toBe("glyphicon glyphicon-line");
- expect(spans[3].className).toBe("glyphicon glyphicon-polygon");
- expect(spans[4].className).toBe("glyphicon glyphicon-text-colour");
- expect(spans[5].className).toBe("glyphicon glyphicon-1-circle");
- });
-
- it('DropdownFeatureType testing the actions', () => {
-
- const testHandlers = {
- onClick: () => {},
- onStartDrawing: () => {},
- onSetStyle: () => {},
- onAddText: () => {}
- };
-
- const spyOnClick = expect.spyOn(testHandlers, 'onClick');
- const spyOnSetStyle = expect.spyOn(testHandlers, 'onSetStyle');
- const spyOnStartDrawing = expect.spyOn(testHandlers, 'onStartDrawing');
- const spyOnAddText = expect.spyOn(testHandlers, 'onAddText');
-
- const spies = [spyOnClick, spyOnSetStyle, spyOnStartDrawing];
- ReactDOM.render(
- , document.getElementById("container")
- );
- const buttons = document.getElementsByTagName("a");
-
- const marker = buttons[0];
- testSpies(spies, marker);
- expect(spyOnClick).toHaveBeenCalledWith("Point");
- resetSpies(spies);
-
- const line = buttons[1];
- testSpies(spies, line);
- expect(spyOnClick).toHaveBeenCalledWith("LineString");
- resetSpies(spies);
-
- const polygon = buttons[2];
- testSpies(spies, polygon);
- expect(spyOnClick).toHaveBeenCalledWith("Polygon");
- resetSpies(spies);
-
- const text = buttons[3];
- testSpies([...spies, spyOnAddText], text);
- expect(spyOnClick).toHaveBeenCalledWith("Text");
- resetSpies(spies);
-
- const circle = buttons[4];
- testSpies(spies, circle);
- expect(spyOnClick).toHaveBeenCalledWith("Circle");
- resetSpies(spies);
- });
-});
diff --git a/web/client/components/mapcontrols/annotations/__tests__/FeatureList-test.js b/web/client/components/mapcontrols/annotations/__tests__/FeatureList-test.js
deleted file mode 100644
index 6ed0274547..0000000000
--- a/web/client/components/mapcontrols/annotations/__tests__/FeatureList-test.js
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright 2020, 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 ReactDOM from 'react-dom';
-import expect from 'expect';
-import FeaturesList from '../FeaturesList';
-
-import TestUtils from 'react-dom/test-utils';
-
-describe("test FeatureList component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.body);
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('test render FeaturesList', () => {
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- expect(container).toBeTruthy();
- });
-
- it('test render with default properties', () => {
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- expect(container).toBeTruthy();
- const labels = container.querySelectorAll(".control-label");
- expect(labels[0].innerText).toBe('annotations.geometries');
- const buttons = container.querySelectorAll("button");
- expect(buttons.length).toBe(5);
- expect(container.innerText).toContain('annotations.addGeometry');
- });
-
- it('test render with measurement annotation properties', () => {
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- expect(container).toBeTruthy();
- const buttons = container.querySelectorAll("button");
- expect(buttons.length).toBe(1);
- });
- it('test geometries toolbar', () => {
- const editing = {
- features: [{
- properties: {id: '1', isValidFeature: true, geometryTitle: 'Polygon'},
- geometry: {type: "Polygon"}
- }]
- };
- const actions = {
- onAddGeometry: () => {},
- onSetStyle: () => {},
- onStyleGeometry: () => {},
- onStartDrawing: () => {},
- onAddText: () => {}
- };
- const defaultStyle = {POINT: {
- marker: ["Test marker"],
- symbol: ["Test symbol"]
- }};
- const spyOnAddGeometry = expect.spyOn(actions, "onAddGeometry");
- const spyOnSetStyle = expect.spyOn(actions, "onSetStyle");
- const spyOnStyleGeometry = expect.spyOn(actions, "onStyleGeometry");
- const spyOnStartDrawing = expect.spyOn(actions, "onStartDrawing");
- const spyOnAddText = expect.spyOn(actions, "onAddText");
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- expect(container).toBeTruthy();
-
- const geometriesToolbar = document.querySelector('.geometries-toolbar');
- const buttons = geometriesToolbar.children[1].getElementsByTagName('button');
- [...buttons].forEach((btn, index)=>{
- TestUtils.Simulate.click(btn);
- expect(spyOnSetStyle).toHaveBeenCalled();
- if (index === 0) {
- const [style] = spyOnSetStyle.calls[0].arguments[0];
- expect(style["0"]).toEqual('Test symbol');
- }
- index === 3 && expect(spyOnAddText).toHaveBeenCalled();
- expect(spyOnAddGeometry).toHaveBeenCalled();
- expect(spyOnStartDrawing).toHaveBeenCalled();
- expect(spyOnStyleGeometry).toHaveBeenCalled();
- });
- });
- it('test render with feature card', () => {
- const editing = {
- features: [{
- properties: {id: '1', isValidFeature: true, geometryTitle: 'Polygon'},
- geometry: {type: "Polygon"}
- }]
- };
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- expect(container).toBeTruthy();
-
- const cardContainer = document.getElementsByClassName('geometry-card');
- expect(cardContainer).toBeTruthy();
-
- const previewIcon = document.querySelector('.glyphicon-polygon');
- expect(previewIcon).toBeTruthy();
-
- const cardTitle = document.querySelector('.geometry-card-label');
- expect(cardTitle.innerText).toBe('Polygon');
-
- const glyphIcons = document.querySelectorAll('.btn-group .glyphicon');
- expect(glyphIcons.length).toBe(7);
- expect(glyphIcons[5].className).toContain('zoom-to');
- expect(glyphIcons[6].className).toContain('trash');
- });
-
- it('test actions on feature card', () => {
- const editing = {
- features: [{
- type: "Feature",
- properties: {id: '1', isValidFeature: true, geometryTitle: 'Polygon'},
- geometry: {type: "Polygon", coordinates: [
- [
- [-121.07812513411045, 42.11778385718358],
- [-116.2265622317791, 44.72175879125132],
- [-115.87499973177908, 40.773885871584866],
- [-114.96093589067458, 42.68889580392076],
- [-121.07812513411045, 42.11778385718358]
- ]
- ]}
- }]
- };
- const testHandlers = {
- onSelectFeature: () => {},
- onUnselectFeature: () => {},
- onStyleGeometry: () => {},
- onZoom: () => {},
- onDeleteGeometry: () => {},
- setTabValue: () => {}
- };
- const spyOnSelectFeature = expect.spyOn(testHandlers, "onSelectFeature");
- const spyOnZoom = expect.spyOn(testHandlers, "onZoom");
- const spyOnDeleteGeometry = expect.spyOn(testHandlers, "onDeleteGeometry");
- const spyOnStyleGeometry = expect.spyOn(testHandlers, "onStyleGeometry");
- ReactDOM.render(
- , document.getElementById("container"));
- const container = document.getElementById('container');
- expect(container).toBeTruthy();
-
- const featureCard = document.getElementsByClassName('geometry-card');
- expect(featureCard).toBeTruthy();
-
- const buttons = document.querySelectorAll('button');
-
- // OnSelectFeature
- TestUtils.Simulate.click(featureCard[0]);
- expect(spyOnSelectFeature).toHaveBeenCalled();
- expect(spyOnSelectFeature.calls[0].arguments[0]).toEqual(editing.features);
- expect(spyOnStyleGeometry).toHaveBeenCalled();
- expect(spyOnStyleGeometry.calls[0].arguments[0]).toBe(false);
-
- // OnZoomGeometry
- TestUtils.Simulate.click(buttons[5]);
- expect(spyOnZoom).toHaveBeenCalled();
- expect(spyOnZoom.calls[0].arguments[1]).toBe("EPSG:4326");
-
- // OnDeleteGeometry
- TestUtils.Simulate.click(buttons[6]);
- expect(spyOnDeleteGeometry).toHaveBeenCalled();
- expect(spyOnDeleteGeometry.calls[0].arguments[0]).toBe("1");
- });
-
- it('test unselect a geometry', () => {
- const props = {
- editing: {
- features: [{
- type: "Feature",
- properties: {id: '1', isValidFeature: true, geometryTitle: 'Polygon'},
- geometry: {type: "Polygon"}
- }]
- },
- selected: {properties: {id: '1'}}
- };
- const testHandlers = {
- onUnselectFeature: () => {},
- onGeometryHighlight: () => {}
- };
- const spyOnUnselectFeature = expect.spyOn(testHandlers, "onUnselectFeature");
- const spyOnGeometryHighlight = expect.spyOn(testHandlers, "onGeometryHighlight");
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- expect(container).toBeTruthy();
-
- const featureCard = document.getElementsByClassName('geometry-card');
- expect(featureCard).toBeTruthy();
-
- // OnUnSelectFeature
- TestUtils.Simulate.click(featureCard[0]);
- expect(spyOnUnselectFeature).toHaveBeenCalled();
- expect(spyOnGeometryHighlight).toHaveBeenCalled();
- expect(spyOnGeometryHighlight.calls[0].arguments[0]).toBe('1');
- });
-
- it('test geometry highlight', () => {
- let props = {
- editing: {
- features: [{
- type: "Feature",
- properties: {id: '1', isValidFeature: true, geometryTitle: 'Polygon'},
- geometry: {type: "Polygon"}
- }]
- },
- selected: {properties: {id: '1'}}
- };
- const testHandlers = {
- onGeometryHighlight: () => {}
- };
- const spyOnGeometryHighlight = expect.spyOn(testHandlers, "onGeometryHighlight");
- ReactDOM.render(, document.getElementById("container"));
- let container = document.getElementById('container');
- expect(container).toBeTruthy();
-
- let featureCard = document.getElementsByClassName('geometry-card');
- expect(featureCard).toBeTruthy();
-
- TestUtils.Simulate.mouseEnter(featureCard[0]);
- expect(spyOnGeometryHighlight).toNotHaveBeenCalled();
-
- // When geometry card is not selected
- props = {...props, selected: {...props.selected, properties: {id: 2}}};
- ReactDOM.render(, document.getElementById("container"));
- container = document.getElementById('container');
- featureCard = document.getElementsByClassName('geometry-card');
- // OnMouseEnter
- TestUtils.Simulate.mouseEnter(featureCard[0]);
- expect(spyOnGeometryHighlight).toHaveBeenCalled();
- expect(spyOnGeometryHighlight.calls[0].arguments[0]).toBe('1');
-
- // OnMouseLeave
- TestUtils.Simulate.mouseLeave(featureCard[0]);
- expect(spyOnGeometryHighlight).toHaveBeenCalled();
- expect(spyOnGeometryHighlight.calls[1].arguments[0]).toBe('1');
- expect(spyOnGeometryHighlight.calls[1].arguments[1]).toBe(false);
- });
-
- it('test geometry highlight limitations', () => {
- let props = {
- editing: {
- features: [{
- type: "Feature",
- properties: {id: '1', isValidFeature: false, geometryTitle: 'Polygon'},
- geometry: {type: "Polygon"}
- }]
- },
- selected: {properties: {id: '2', isValidFeature: false}}
- };
- const testHandlers = {
- onGeometryHighlight: () => {}
- };
- const spyOnGeometryHighlight = expect.spyOn(testHandlers, "onGeometryHighlight");
- ReactDOM.render(, document.getElementById("container"));
- let container = document.getElementById('container');
- expect(container).toBeTruthy();
-
- let featureCard = document.getElementsByClassName('geometry-card');
- expect(featureCard).toBeTruthy();
-
- ReactDOM.render(, document.getElementById("container"));
- container = document.getElementById('container');
- featureCard = document.getElementsByClassName('geometry-card');
- // OnMouseEnter
- TestUtils.Simulate.mouseEnter(featureCard[0]);
- expect(spyOnGeometryHighlight).toNotHaveBeenCalled();
-
- // OnMouseLeave
- TestUtils.Simulate.mouseLeave(featureCard[0]);
- expect(spyOnGeometryHighlight).toNotHaveBeenCalled();
- });
-
- it('test render defaults with defaultPointType as symbol', () => {
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- expect(container).toBeTruthy();
- const labels = container.querySelectorAll(".control-label");
- expect(labels[0].innerText).toBe('annotations.geometries');
- const buttons = container.querySelectorAll("button");
- expect(buttons.length).toBe(5);
- expect(container.innerText).toContain('annotations.addGeometry');
- });
-});
diff --git a/web/client/components/mapcontrols/annotations/__tests__/SelectAnnotationsFile-test.js b/web/client/components/mapcontrols/annotations/__tests__/SelectAnnotationsFile-test.js
deleted file mode 100644
index e4b228d7a2..0000000000
--- a/web/client/components/mapcontrols/annotations/__tests__/SelectAnnotationsFile-test.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2018, 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 expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import SelectAnnotationsFile from '../SelectAnnotationsFile';
-
-
-describe("test the SelectAnnotationsFile modal", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.body);
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('test default properties', () => {
- const annotations = ReactDOM.render(, document.getElementById("container"));
- expect(annotations).toExist();
- const annotationsNode = ReactDOM.findDOMNode(annotations);
- expect(annotationsNode).toNotExist();
- });
- it('test file selected', (done) => {
- const jsonFile = new File([`{ "coordinates": [
- 4.6142578125,
- 45.67548217560647
- ],
- "type": "Point"
- }`
- ], "file.json", {
- type: "application/json"
- });
- const onFileChoosen = (features, override) => {
- expect(features instanceof Array).toBe(true);
- expect(features.length).toBe(1);
- expect(override).toBe(false);
- done();
- };
- const annotations = ReactDOM.render(, document.getElementById("container"));
- expect(annotations).toExist();
- const annotationsNode = ReactDOM.findDOMNode(annotations);
- expect(annotationsNode).toExist();
- annotations.checkfile([jsonFile]);
- });
-
- it('test file selected to fail', (done) => {
- const jsonFile = new File([`[{
- "geometry": {
- "type": "MultiPolygon"
- },
- "properties": {
- "id": "25cbbbb0-1625-11e8-a091-639e3ca0149f",
- "title": "Pino"
- },
- "style": {
- "highlight": false
- },
- "type": "Feature"
- }]`
- ], "file.txt", {
- type: "text/plain"
- });
- const annotations = ReactDOM.render(, document.getElementById("container"));
- expect(annotations).toExist();
- const annotationsNode = ReactDOM.findDOMNode(annotations);
- expect(annotationsNode).toExist();
- annotations.componentDidUpdate = () => {
- if (annotations.state.error) {
- expect(annotations.state.error).toExist();
- done();
- }
- };
- annotations.checkfile([jsonFile]);
- });
-
-});
diff --git a/web/client/components/mapcontrols/search/geocoding/NominatimResult.jsx b/web/client/components/mapcontrols/search/geocoding/NominatimResult.jsx
deleted file mode 100644
index 32c124f912..0000000000
--- a/web/client/components/mapcontrols/search/geocoding/NominatimResult.jsx
+++ /dev/null
@@ -1,39 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-
-import React from 'react';
-
-
-class NominatimResult extends React.Component {
- static propTypes = {
- item: PropTypes.object,
- onItemClick: PropTypes.func
- };
-
- onClick = () => {
- let item = this.props.item;
- this.props.onItemClick(item);
- };
-
- render() {
- if (this.props.item === undefined) {
- return null;
- }
- let item = this.props.item;
- return (
-
-
- {item.display_name}
-
- );
- }
-}
-
-export default NominatimResult;
diff --git a/web/client/components/mapcontrols/search/geocoding/NominatimResultList.jsx b/web/client/components/mapcontrols/search/geocoding/NominatimResultList.jsx
deleted file mode 100644
index 43c4d56300..0000000000
--- a/web/client/components/mapcontrols/search/geocoding/NominatimResultList.jsx
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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.
- */
-
-import React from 'react';
-
-import PropTypes from 'prop-types';
-import NominatimResult from './NominatimResult';
-import { getZoomForExtent, getCenterForExtent } from '../../../../utils/MapUtils';
-import { reprojectBbox } from '../../../../utils/CoordinatesUtils';
-import I18N from '../../../I18N/I18N';
-
-
-class ResultList extends React.Component {
- static propTypes = {
- results: PropTypes.array,
- mapConfig: PropTypes.object,
- onItemClick: PropTypes.func,
- addMarker: PropTypes.func,
- afterItemClick: PropTypes.func,
- notFoundMessage: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
- };
-
- static defaultProps = {
- onItemClick: () => {},
- addMarker: () => {},
- afterItemClick: () => {}
- };
-
- onItemClick = (item) => {
- // coordinates from nominatim are minY minX maxY maxX as strings
- var nBbox = item.boundingbox.map( (elem) => {return parseFloat(elem); });
- var bbox = [nBbox[2], nBbox[0], nBbox[3], nBbox[1]];
- // zoom by the max. extent defined in the map's config
- var mapSize = this.props.mapConfig.size;
-
- var newZoom = getZoomForExtent(reprojectBbox(bbox, "EPSG:4326", this.props.mapConfig.projection), mapSize, 0, 21, null);
-
- // center by the max. extent defined in the map's config
- var newCenter = getCenterForExtent(bbox, "EPSG:4326");
-
- this.props.onItemClick(newCenter, newZoom, {
- bounds: {
- minx: bbox[0],
- miny: bbox[1],
- maxx: bbox[2],
- maxy: bbox[3]
- },
- crs: "EPSG:4326",
- rotation: 0
- }, this.props.mapConfig.size, null, this.props.mapConfig.projection);
- this.props.addMarker({lat: newCenter.y, lng: newCenter.x});
- this.props.afterItemClick();
- };
-
- renderResults = () => {
- return this.props.results.map((item, idx)=> {return ; });
- };
-
- render() {
- var notFoundMessage = this.props.notFoundMessage;
- if (!notFoundMessage) {
- notFoundMessage = ;
- }
- if (!this.props.results) {
- return null;
- } else if (this.props.results.length === 0) {
- return {notFoundMessage}
;
- }
- return (
-
- {this.renderResults()}
-
- );
- }
-
- purgeResults = () => {
-
- };
-}
-
-export default ResultList;
diff --git a/web/client/components/mapcontrols/search/geocoding/__tests__/NominatimResult-test.jsx b/web/client/components/mapcontrols/search/geocoding/__tests__/NominatimResult-test.jsx
deleted file mode 100644
index c70c39545d..0000000000
--- a/web/client/components/mapcontrols/search/geocoding/__tests__/NominatimResult-test.jsx
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import NominatimResult from '../NominatimResult';
-import TestUtils from 'react-dom/test-utils';
-
-describe("test the NominatimResult", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('test component creation', () => {
- var item = {
- osm_id: 1,
- display_name: "Name",
- boundingbox: []
- };
- const tb = ReactDOM.render(, document.getElementById("container"));
- expect(tb).toExist();
-
- });
-
- it('create component without item', () => {
- const tb = ReactDOM.render(, document.getElementById("container"));
- expect(tb).toExist();
- });
-
- it('test click handler', () => {
- const testHandlers = {
- clickHandler: (pressed) => {return pressed; }
- };
- var item = {
- osm_id: 1,
- display_name: "Name",
- boundingbox: []
- };
- const spy = expect.spyOn(testHandlers, 'clickHandler');
- var tb = ReactDOM.render(, document.getElementById("container"));
- let elem = TestUtils.findRenderedDOMComponentWithClass(tb, "search-result");
-
- expect(elem).toExist();
- ReactDOM.findDOMNode(elem).click();
- expect(spy.calls.length).toEqual(1);
- });
-});
diff --git a/web/client/components/mapcontrols/search/geocoding/__tests__/NominatimResultList-test.jsx b/web/client/components/mapcontrols/search/geocoding/__tests__/NominatimResultList-test.jsx
deleted file mode 100644
index 50fe1e6083..0000000000
--- a/web/client/components/mapcontrols/search/geocoding/__tests__/NominatimResultList-test.jsx
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import NominatimResultList from '../NominatimResultList';
-import NominatimResult from '../NominatimResult';
-import TestUtils from 'react-dom/test-utils';
-
-describe("test the NominatimResultList", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('test component creation', () => {
- var results = [{
- osm_id: 1,
- display_name: "Name",
- boundingbox: []
- }];
- const tb = ReactDOM.render(, document.getElementById("container"));
- expect(tb).toExist();
-
- });
-
- it('create component without items', () => {
- const tb = ReactDOM.render(, document.getElementById("container"));
- expect(tb).toExist();
- });
-
- it('create component with empty items array', () => {
- const tb = ReactDOM.render(, document.getElementById("container"));
- expect(tb).toExist();
- });
-
- it('test click handler', () => {
- const testHandlers = {
- clickHandler: () => {},
- afterClick: () => {}
- };
- var items = [{
- osm_id: 1,
- display_name: "Name",
- boundingbox: [1, 2, 3, 4]
- }];
- const spy = expect.spyOn(testHandlers, 'clickHandler');
- var tb = ReactDOM.render(, document.getElementById("container"));
- let elem = TestUtils.scryRenderedComponentsWithType(tb, NominatimResult);
- expect(elem.length).toBe(1);
-
- let elem1 = TestUtils.findRenderedDOMComponentWithClass(elem[0], "search-result");
- ReactDOM.findDOMNode(elem1).click();
- expect(spy.calls.length).toEqual(1);
- });
-});
diff --git a/web/client/components/maps/MapItem.jsx b/web/client/components/maps/MapItem.jsx
deleted file mode 100644
index df2b7997ef..0000000000
--- a/web/client/components/maps/MapItem.jsx
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.
- */
-
-import { isFunction } from 'lodash';
-import PropTypes from 'prop-types';
-import React from 'react';
-import {
- Glyphicon,
- ListGroupItem,
- Tooltip
-} from 'react-bootstrap';
-
-import I18N from '../I18N/I18N';
-import OverlayTrigger from '../misc/OverlayTrigger';
-import Button from '../misc/Button';
-
-class MapItem extends React.Component {
- static propTypes = {
- map: PropTypes.object,
- viewerUrl: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
- mapType: PropTypes.string
- };
-
- renderButtons = () => {
- if (this.props.viewerUrl) {
- let button = isFunction(this.props.viewerUrl) ?
- :
- ;
- const tooltip = ;
- return (
-
- {button}
-
- );
- }
- return "";
- };
-
- render() {
- return (
- {this.props.map.description} {this.renderButtons()}
- );
- }
-}
-
-export default MapItem;
diff --git a/web/client/components/maps/MapList.jsx b/web/client/components/maps/MapList.jsx
deleted file mode 100644
index 6f11c7c98f..0000000000
--- a/web/client/components/maps/MapList.jsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-
-import React from 'react';
-
-import { ListGroup, Panel } from 'react-bootstrap';
-import MapItem from './MapItem';
-import { MapLibraries } from '../../utils/MapTypeUtils';
-class MapList extends React.Component {
- static propTypes = {
- panelProps: PropTypes.object,
- maps: PropTypes.array,
- viewerUrl: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
- mapType: PropTypes.string
- };
-
- static defaultProps = {
- onChangeMapType: function() {},
- mapType: MapLibraries.OPENLAYERS,
- maps: []
- };
-
- renderMaps = (maps, mapType) => {
- const viewerUrl = this.props.viewerUrl;
- return maps.map((map) => {
- let children = React.Children.count(this.props.children);
- return children === 1 ?
- React.cloneElement(React.Children.only(this.props.children), {viewerUrl, key: map.id, mapType, map}) :
- ;
- });
- };
-
- render() {
- return (
-
-
- {this.renderMaps(this.props.maps, this.props.mapType)}
-
-
- );
- }
-}
-
-export default MapList;
diff --git a/web/client/components/maps/__tests__/MapItem-test.jsx b/web/client/components/maps/__tests__/MapItem-test.jsx
deleted file mode 100644
index d18b252dab..0000000000
--- a/web/client/components/maps/__tests__/MapItem-test.jsx
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * 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.
- */
-import React from 'react';
-
-import ReactDOM from 'react-dom';
-import MapItem from '../MapItem.jsx';
-import expect from 'expect';
-import TestUtils from 'react-dom/test-utils';
-
-describe('This test for MapItem', () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- // test DEFAULTS
- it('creates the component with defaults', () => {
- const mapItem = ReactDOM.render(, document.getElementById("container"));
- expect(mapItem).toExist();
-
- const mapItemDom = ReactDOM.findDOMNode(mapItem);
- expect(mapItemDom).toExist();
-
- expect(mapItemDom.className).toBe('list-group-item');
- const headings = mapItemDom.getElementsByClassName('list-group-item-heading');
- expect(headings.length).toBe(0);
- });
- // test DEFAULTS
- it('creates the component with data', () => {
- const testName = "test";
- const testDescription = "testDescription";
- const mapItem = ReactDOM.render(, document.getElementById("container"));
- expect(mapItem).toExist();
-
- const mapItemDom = ReactDOM.findDOMNode(mapItem);
- expect(mapItemDom).toExist();
-
- expect(mapItemDom.className).toBe('list-group-item');
- const headings = mapItemDom.getElementsByClassName('list-group-item-heading');
- expect(headings.length).toBe(1);
- expect(headings[0].innerHTML).toBe(testName);
- });
-
- it('test viewer url', () => {
- const testName = "test";
- const testDescription = "testDescription";
- var component = TestUtils.renderIntoDocument();
- var a = TestUtils.findRenderedDOMComponentWithTag(
- component, 'a'
- );
- expect(a.href).toContain("viewer?type=leaflet&mapId=1");
- });
-});
diff --git a/web/client/components/maps/__tests__/MapList-test.jsx b/web/client/components/maps/__tests__/MapList-test.jsx
deleted file mode 100644
index bdb77d04bd..0000000000
--- a/web/client/components/maps/__tests__/MapList-test.jsx
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * 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.
- */
-import React from 'react';
-
-import ReactDOM from 'react-dom';
-import MapList from '../MapList.jsx';
-import expect from 'expect';
-
-describe('This test for MapList', () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- // test DEFAULTS
- it('creates the component with defaults', () => {
- const mapList = ReactDOM.render(, document.getElementById("container"));
- expect(mapList).toExist();
-
- const dom = ReactDOM.findDOMNode(mapList);
- expect(dom).toExist();
- // check body existence
- const panelBody = dom.getElementsByClassName('panel-body');
- expect(panelBody.length).toBe(1);
- // check missing header
- const headings = dom.getElementsByClassName('panel-heading');
- expect(headings.length).toBe(0);
- });
-
- it('checks properties', () => {
- const testTitle = "testTitle";
- const mapList = ReactDOM.render(, document.getElementById("container"));
- expect(mapList).toExist();
-
- const dom = ReactDOM.findDOMNode(mapList);
- expect(dom).toExist();
- // check body
- const panelBody = dom.getElementsByClassName('panel-body');
- expect(panelBody.length).toBe(1, "Panel Body Missing");
-
- // check header
- const headings = dom.getElementsByClassName('panel-heading');
- expect(headings.length).toBe(1, "Panel Heading Missing");
- expect(headings[0].innerHTML).toBe(testTitle, "Panel Heading Incorrect");
- });
-
- it('checks data', () => {
- var map1 = {id: 1, name: "a", description: "description"};
- var map2 = {id: 2, name: "b", description: "description"};
- const mapList = ReactDOM.render(, document.getElementById("container"));
- expect(mapList).toExist();
- const dom = ReactDOM.findDOMNode(mapList);
- expect(dom).toExist();
-
- // check body
- const panelBody = dom.getElementsByClassName('panel-body');
- expect(panelBody.length).toBe(1, "Panel Body Missing");
-
- // check list
- const list = panelBody[0].getElementsByClassName("list-group-item");
- expect(list.length).toBe(2, " list missing");
- });
-});
diff --git a/web/client/components/maps/forms/Metadata.jsx b/web/client/components/maps/forms/Metadata.jsx
deleted file mode 100644
index f52e353a57..0000000000
--- a/web/client/components/maps/forms/Metadata.jsx
+++ /dev/null
@@ -1,118 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-/**
- * 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.
- */
-
-import React from 'react';
-
-import { FormControl, FormGroup, ControlLabel } from 'react-bootstrap';
-import moment from 'moment';
-import ConfigUtils from '../../../utils/ConfigUtils';
-
-/**
- * A DropDown menu for user details:
- */
-class Metadata extends React.Component {
- static propTypes = {
- map: PropTypes.object,
- // CALLBACKS
- onChange: PropTypes.func,
-
- // I18N
- nameFieldText: PropTypes.node,
- descriptionFieldText: PropTypes.node,
- namePlaceholderText: PropTypes.string,
- descriptionPlaceholderText: PropTypes.string,
- createdAtFieldText: PropTypes.string,
- modifiedAtFieldText: PropTypes.string
- };
-
- static contextTypes = {
- intl: PropTypes.object
- }
-
- static defaultProps = {
- // CALLBACKS
- onChange: () => {},
-
- // I18N
- nameFieldText: "Name",
- descriptionFieldText: "Description",
- namePlaceholderText: "Map Name",
- descriptionPlaceholderText: "Map Description"
- };
-
-
- renderDate = (date) => {
- if (!date) {
- return '';
- }
- const dateFormat = ConfigUtils.getConfigProp('forceDateFormat');
- const timeFormat = ConfigUtils.getConfigProp('forceTimeFormat');
- const newDate = dateFormat ? moment(date).format(dateFormat) : this.context.intl ? this.context.intl.formatDate(date) : '';
- const time = timeFormat ? moment(date).format(timeFormat) : this.context.intl ? this.context.intl.formatTime(date) : '';
- return `${newDate} ${time}` || '';
- }
-
- render() {
- return ();
- }
-
- changeName = (e) => {
- this.props.onChange('name', e.target.value);
- };
-
- changeDescription = (e) => {
- this.props.onChange('description', e.target.value);
- };
-
- isMapNameValid = () => {
- return (this.props.map && this.props.map.metadata && this.props.map.metadata.name === '') ? 'error' : null;
- };
-}
-
-
-export default Metadata;
diff --git a/web/client/components/maps/forms/__tests__/Metadata-test.jsx b/web/client/components/maps/forms/__tests__/Metadata-test.jsx
deleted file mode 100644
index d5d4a76b59..0000000000
--- a/web/client/components/maps/forms/__tests__/Metadata-test.jsx
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2019, 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 expect from 'expect';
-import React from 'react';
-import ReactDOM from 'react-dom';
-
-import Metadata from '../Metadata';
-
-describe('Metadata component', () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
- it('Metadata rendering with defaults', () => {
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- const el = container.querySelectorAll('input');
- expect(el.length).toBe(2);
- });
- it('Metadata rendering with meta-data', () => {
- const resource = {
- lastUpdate: new Date(),
- metadata: {
- name: "NAME",
- description: "DESCRIPTION"
- }
- };
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- const el = container.querySelectorAll('input');
- expect(el.length).toBe(2);
- expect(el[0].value).toBe("NAME");
- expect(el[1].value).toBe("DESCRIPTION");
- });
-});
diff --git a/web/client/components/maps/modals/css/modals.css b/web/client/components/maps/modals/css/modals.css
deleted file mode 100644
index ccde63f377..0000000000
--- a/web/client/components/maps/modals/css/modals.css
+++ /dev/null
@@ -1,12 +0,0 @@
-
-/* MODAL */
-
-#MetadataModal .modal-dialog {
- width:600px;
-}
-
-@media screen and (max-width: 600px) {
- #MetadataModal .modal-dialog {
- width:100%;
- }
-}
diff --git a/web/client/components/mediaEditor/enhancers/withFilter.js b/web/client/components/mediaEditor/enhancers/withFilter.js
deleted file mode 100644
index ec82a3bffa..0000000000
--- a/web/client/components/mediaEditor/enhancers/withFilter.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2019, 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 {
- compose,
- withState
-} from 'recompose';
-/**
- * holds the state of the text filter in the media editor
- */
-const withFilter = compose(
- withState('filterText', "onFilter", null)
-);
-
-export default withFilter;
diff --git a/web/client/components/misc/DockablePanel.jsx b/web/client/components/misc/DockablePanel.jsx
deleted file mode 100644
index 4ed6ab4079..0000000000
--- a/web/client/components/misc/DockablePanel.jsx
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.
- */
-import React from 'react';
-
-import Dock from 'react-dock';
-import PropTypes from 'prop-types';
-
-/**
- * Component for rendering a dockablePanel panel.
- * @memberof components.dockablePanel
- * @class
- * @prop {string} id. The id value of the dockable panel
- * @prop {string} dimMode. If none - content is not dimmed, if transparent - pointer events are disabled (so you can click through it), if opaque - click on dim area closes the dock. Default is none
- * @prop {number} dockSize. Size of dock panel (width or height, depending on position). Is a % value [0~1]
- * @prop {bool} isVisible. If true, dock is visible. Default is true.
- * @prop {number} maxDockSize. The maximum extension in %. Default 1.0
- * @prop {number} minDockSize. The minimum extension in %. Default 0.1
- * @prop {string} position. Side to dock (left, right, top or bottom). Default is bottom.
- * @prop {bool} fluid. If true, resize dock proportionally on window resize. Default is true.
- * @prop {function} setDockSize. The metod called when the dockable panel is resized
- * @prop {object} toolbar. it contains the toolbar
- * @prop {object} toolbarHeight. the height of the toolbar in px. Default 40
- * @prop {object} wrappedComponent. A connected Component to be rendered inside the dock panel
- * @prop {number} zIndex. Positioned below dialogs, above left menu
- *
- */
-class DockablePanel extends React.Component {
- static propTypes = {
- id: PropTypes.string,
- dimMode: PropTypes.string,
- dockSize: PropTypes.number,
- isVisible: PropTypes.bool,
- fluid: PropTypes.bool,
- maxDockSize: PropTypes.number,
- minDockSize: PropTypes.number,
- position: PropTypes.string,
- setDockSize: PropTypes.func,
- toolbar: PropTypes.object,
- toolbarHeight: PropTypes.number,
- wrappedComponent: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
- zIndex: PropTypes.number
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- dimMode: "none",
- dockSize: 0.35,
- fluid: true,
- isVisible: true,
- maxDockSize: 1.0,
- minDockSize: 0.1,
- position: "bottom",
- setDockSize: () => {},
- toolbar: null,
- toolbarHeight: 40,
- wrappedComponent: {},
- zIndex: 1030
- };
-
- getHeight = (pos) => {
- return pos === "top" || pos === "bottom" ? true : undefined;
- };
-
- getWidth = (pos) => {
- return pos === "left" || pos === "right" ? true : undefined;
- };
-
- render() {
- const WrappedComponent = this.props.wrappedComponent;
- return (
-
-
- {this.props.wrappedComponent !== null ? () : null }
-
- {this.props.toolbar}
-
- );
- }
-
- limitDockHeight = (size) => {
- if (size >= this.props.maxDockSize) {
- this.props.setDockSize(this.props.maxDockSize);
- } else if (size <= this.props.minDockSize) {
- this.props.setDockSize(this.props.minDockSize);
- } else {
- this.props.setDockSize(size);
- }
- };
-}
-
-export default DockablePanel;
diff --git a/web/client/components/misc/LinkToPage.jsx b/web/client/components/misc/LinkToPage.jsx
deleted file mode 100644
index 65f8c88282..0000000000
--- a/web/client/components/misc/LinkToPage.jsx
+++ /dev/null
@@ -1,46 +0,0 @@
-
-/**
- * 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.
- */
-
-import React from 'react';
-import PropTypes from 'prop-types';
-import Button from './Button';
-
-class LinkToPage extends React.Component {
- static propTypes = {
- params: PropTypes.object,
- url: PropTypes.string,
- txt: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
- btProps: PropTypes.object
- };
-
- static defaultProps = {
- params: [],
- url: '',
- btProps: {},
- txt: 'Link'
- };
-
- render() {
- return (
-
- );
- }
-
- buildUrl = () => {
- let urlParams = '?';
- Object.keys(this.props.params).forEach(function(p) {
- urlParams += p + "=" + this.props.params[p] + "&";
- }, this);
- return this.props.url + encodeURI(urlParams);
- };
-}
-
-export default LinkToPage;
diff --git a/web/client/components/misc/ResizableGrid.jsx b/web/client/components/misc/ResizableGrid.jsx
deleted file mode 100644
index 40604e7ec0..0000000000
--- a/web/client/components/misc/ResizableGrid.jsx
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.
- */
-import React from 'react';
-
-import ReactDataGrid from 'react-data-grid';
-import PropTypes from 'prop-types';
-
-/**
- * Component for rendering a feature grid.
- * @memberof components.ResizableGrid
- * @class
- * @prop {object[]} columns. The columns rendered in the header. Each object is composed by key,name,[reizable=true|false].
- * @prop {number} headerRowHeight the height in pixels of the rows in the header. Default 55
- * @prop {number} minHeight the min height of the grid container. Default 250
- * @prop {number} minWidth the min width of the grid container.
- * @prop {string} refGrid the reference to the react-data-grid-component
- * @prop {number} rowHeight the height of the rows in the grid. Default 30
- * @prop {string} rowKey the key used to distinguish rows.
- * @prop {string} rowGetter method to render a row
- * @prop {object} rowSelection The object used to handle selection of rows. It puts a column of check as the first row.
- * @prop {object[]} rows. The features passed to the grid.
- * @prop {number} size. The size of the dock panel wrapping this component.
- *
- */
-class ResizableGrid extends React.Component {
- static propTypes = {
- columns: PropTypes.array.isRequired,
- headerRowHeight: PropTypes.number,
- minHeight: PropTypes.number.isRequired,
- minWidth: PropTypes.number,
- refGrid: PropTypes.string,
- rowHeight: PropTypes.number.isRequired,
- rowKey: PropTypes.string,
- rowSelection: PropTypes.object,
- rowGetter: PropTypes.func,
- selectBy: PropTypes.object,
- rows: PropTypes.array.isRequired,
- size: PropTypes.object,
- onCellsSelected: PropTypes.func,
- onRowsSelected: PropTypes.func,
- onRowsDeselected: PropTypes.func
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- columns: [],
- headerRowHeight: 55,
- minHeight: 250,
- minWidth: null,
- refGrid: "grid",
- rowHeight: 30,
- rowKey: "id",
- rowSelection: {},
- rowGetter: null,
- selectBy: null,
- onRowsSelected: () => {},
- onRowsDeselected: () => {},
- rows: []
- };
-
- state = {
- minHeight: this.props.minHeight,
- minWidth: this.props.minWidth
- };
-
- UNSAFE_componentWillReceiveProps(newProps) {
- if (this.props.size.width !== newProps.size.width ) {
- this.setState({
- minWidth: this.getWidth(this.refs.grid),
- minHeight: this.getHeight(this.refs.grid)}
- );
- }
- if (this.props.size.height !== newProps.size.height ) {
- this.setState({
- minHeight: this.getHeight(this.refs.grid)}
- );
- }
- }
-
- getHeight = (element) => {
- return element && element.getDataGridDOMNode().clientHeight || this.props.minHeight;
- };
-
- getWidth = (element) => {
- return element && element.getDataGridDOMNode().clientWidth || this.props.minWidth;
- };
-
- render() {
- return (
-
- );
- }
-
- rowGetter = (i) => {
- return this.props.rows[i];
- };
-}
-
-export default ResizableGrid;
diff --git a/web/client/components/misc/__tests__/DockablePanel-test.jsx b/web/client/components/misc/__tests__/DockablePanel-test.jsx
deleted file mode 100644
index 182c1db144..0000000000
--- a/web/client/components/misc/__tests__/DockablePanel-test.jsx
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.
- */
-import React from 'react';
-
-import expect from 'expect';
-import ReactDOM from 'react-dom';
-import DockablePanel from '../DockablePanel';
-
-const defaultProps = {
- dockSize: 0.35,
- wrappedComponent: null,
- position: "bottom",
- maxDockSize: 1.0,
- minDockSize: 0.1,
- setDockSize: () => {}
-};
-describe("Test DockablePanel Component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '
';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('Test DockablePanel rendering without tools', () => {
- let comp = ReactDOM.render(
-
, document.getElementById("container"));
- expect(comp).toExist();
-
- });
-
-
-});
diff --git a/web/client/components/misc/__tests__/LinkToPage-test.jsx b/web/client/components/misc/__tests__/LinkToPage-test.jsx
deleted file mode 100644
index b3872c5e89..0000000000
--- a/web/client/components/misc/__tests__/LinkToPage-test.jsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import expect from 'expect';
-import React from 'react';
-import ReactDOM from 'react-dom';
-import LinkToPage from '../LinkToPage';
-
-describe("This test for LinkToPage component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '
';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates componet with defaults', () => {
- const cmp = ReactDOM.render(
, document.getElementById("container"));
- expect(cmp).toExist();
- });
-
- it('creates empty componet with url and params', () => {
- const cmp = ReactDOM.render(
, document.getElementById("container"));
- expect(cmp).toExist();
- let url = cmp.buildUrl();
- expect(url).toBe("testUrl" + encodeURI("?a=testA&b=testB&"));
- });
-});
diff --git a/web/client/components/misc/__tests__/ResizableGrid-test.jsx b/web/client/components/misc/__tests__/ResizableGrid-test.jsx
deleted file mode 100644
index 390710cd5d..0000000000
--- a/web/client/components/misc/__tests__/ResizableGrid-test.jsx
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * 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.
- */
-import React from 'react';
-
-import expect from 'expect';
-import ReactDOM from 'react-dom';
-import ResizableGrid from '../ResizableGrid';
-
-const state = {
- columns: [
- {
- key: 'id',
- name: 'id',
- resizable: true
- }, {
- key: 'name',
- name: 'nome livello',
- resizable: true
- }],
- features: [{
- id: "1",
- name: "Edifici"
- }, {
- id: "2",
- name: "Aiuola"
- }, {
- id: "3",
- name: "Edifici"
- }, {
- id: "4",
- name: "Aiuola"
- }, {
- id: "5",
- name: "Edifici"
- }, {
- id: "6",
- name: "Aiuola"
- }, {
- id: "7",
- name: "Edifici"
- }, {
- id: "8",
- name: "Aiuola"
- }, {
- id: "9",
- name: "Edifici"
- }, {
- id: "10",
- name: "Aiuola"
- }, {
- id: "11",
- name: "Edifici"
- }, {
- id: "12",
- name: "Aiuola"
- }, {
- id: "13",
- name: "Edifici"
- }, {
- id: "14",
- name: "Aiuola"
- }, {
- id: "15",
- name: "extra 15"
- }, {
- id: "16",
- name: "extra 16"
- }],
- open: true,
- selectBy: {
- keys: {
- rowKey: '',
- values: []
- }
- }
-};
-
-const defaultProps = {
- rowsCount: state.features.length,
- minHeight: 250,
- minWidth: 600,
- size: {
- width: true,
- height: false,
- size: 0.35
- },
- position: "bottom",
- columns: state.columns,
- selectBy: state.selectBy,
- rows: state.features
-};
-describe("Test ResizableGrid Component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '
';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('Test ResizableGrid rendering without tools', () => {
- let comp = ReactDOM.render(
-
, document.getElementById("container"));
- expect(comp).toExist();
- });
-
- it('Test ResizableGrid re-rendering for entering in the UNSAFE_componentWillReceiveProps', () => {
- let comp = ReactDOM.render(
-
, document.getElementById("container"));
- expect(comp).toExist();
- let comp2 = ReactDOM.render(
-
, document.getElementById("container"));
- expect(comp2).toExist();
-
- let comp3 = ReactDOM.render(
-
, document.getElementById("container"));
- expect(comp3).toExist();
-
- });
-
-});
diff --git a/web/client/components/misc/datetimepicker/Time.js b/web/client/components/misc/datetimepicker/Time.js
deleted file mode 100644
index f81290ee90..0000000000
--- a/web/client/components/misc/datetimepicker/Time.js
+++ /dev/null
@@ -1,147 +0,0 @@
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-import moment from 'moment';
-import PagedCombobox from '../combobox/PagedCombobox';
-// import localizedProps from '../enhancers/localizedProps';
-
-// const Select = localizedProps(['placeholder', 'clearValueText', 'noResultsText'])(require('react-select').default);
-const getDates = (step) => {
- let min = moment().startOf('day');
- const max = moment().startOf('day').add(1, 'd');
- let times = [];
- let startDay = min.date();
-
- while (min.date() === startDay && min.isBefore(max)) {
- times.push({
- value: min.toDate(),
- label: min.format('LT')
- });
- min = min.add(step || 30, 'm');
- }
- return times;
-};
-
-class TimePicker extends Component {
-
- static propTypes = {
- onSelect: PropTypes.func,
- onMouseDown: PropTypes.func,
- disabled: PropTypes.bool
- }
- static defaultProps = {
- onSelect: () => { },
- onMouseDown: () => { },
- disabled: false
- }
-
- state = { focusedItemIndex: 0, times: [], selectedMember: "", openSelectMember: false };
-
- componentDidMount() {
- this.setState({ times: getDates() });
- }
-
- render() {
- // const { times } = this.state;
- // const { onMouseDown, onSelect, disabled } = this.props;
- const placeholder = this.context.intl ? this.context.intl.formatMessage({ id: 'usergroups.selectMemberPlaceholder' }) : 'Select time from list';
-
- return (
- //
-
- //
- //
-
{
- if (typeof selected === 'string') {
- this.selectMemberPage = 0;
- this.setState({selectedMember: selected});
- this.searchUsers(selected, true);
- return;
- }
- if (selected.value) {
- this.setState({selectedMember: selected.label});
- // this.selectMemberPage = 0;
- }
- }}
- placeholder={placeholder}
- // pagination={pagination}
- selectedValue={this.state.selectedMember}
- onSelect={() => {}}
- stopPropagation
- // dropUp
-
- />
- //
- // {times.map((time, index) => - {} : onMouseDown} onClick={disabled ? () => {} : () => onSelect(time)} ref={instance => {this.itemsRef[index] = instance;}} role="option" tabIndex="0" aria-selected="false" className={`rw-list-option ${focusedItemIndex === index && !disabled ? 'rw-state-focus' : ''} ${disabled ? 'rw-state-disabled' : ''}`} id="rw_1_time_listbox__option__0">{time.label}
)}
- //
- );
- }
- handleToggleSelectMember = () => {
- this.setState(prevState => ({
- openSelectMember: !prevState.openSelectMember
- }));
- }
- handleKeyDown = event => {
- let { key } = event;
- let { focusedItemIndex, times } = this.state;
- if (key === 'Enter') {
- const focusedItem = times[focusedItemIndex];
- this.props.onSelect(focusedItem);
- event.preventDefault();
- } else if (key === 'ArrowDown') {
- event.preventDefault();
- const index = focusedItemIndex + 1;
- this.scrollDown(index);
- if (index < times.length) {
- this.setState({ focusedItemIndex: index });
- }
- } else if (key === 'ArrowUp') {
- event.preventDefault();
- const index = focusedItemIndex - 1;
- this.scrollUp(index);
- if (index > -1) {
- this.setState({ focusedItemIndex: index });
- }
- }
- }
-
- scrollDown = index => {
- const item = this.itemsRef[index];
- if (item && item.offsetTop > this.listRef.offsetHeight) {
- this.listRef.scrollTop = item.offsetTop - this.listRef.offsetTop;
- }
- }
-
- scrollUp = index => {
- const item = this.itemsRef[index];
- if (item) {
- const topScroll = this.listRef.scrollTop;
- const itemTop = item.offsetTop;
- if (topScroll && (itemTop < topScroll)) {
- this.listRef.scrollTop = item.offsetTop - this.listRef.offsetTop;
- }
- }
- }
-
- attachListRef = ref => (this.listRef = ref)
-
- itemsRef = {};
-}
-
-export default TimePicker;
diff --git a/web/client/components/misc/enhancers/__tests__/debounce-test.jsx b/web/client/components/misc/enhancers/__tests__/debounce-test.jsx
deleted file mode 100644
index 1bd6d047cb..0000000000
--- a/web/client/components/misc/enhancers/__tests__/debounce-test.jsx
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2018, 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 ReactDOM from 'react-dom';
-import { createSink, compose } from 'recompose';
-import expect from 'expect';
-import debounce from '../debounce';
-
-describe('debounce enhancer', () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
- it('debounce call only last action', (done) => {
- const action = (status, method, owner, features) => {
- expect(status).toExist();
- expect(status).toBe("replace");
- expect(method).toNotExist();
- expect(owner).toExist();
- expect(owner).toBe("queryform");
- expect(features).toExist();
- expect(features).toBe("geom2");
- done();
- };
- const Sink = compose(debounce("onChangeDrawingStatus", 800))(createSink( props => {
- expect(props).toExist();
- expect(props.onChangeDrawingStatus).toExist();
- props.onChangeDrawingStatus("geom");
- props.onChangeDrawingStatus("geom1");
- props.onChangeDrawingStatus("replace", undefined, "queryform", "geom2");
- }));
- ReactDOM.render((), document.getElementById("container"));
- });
-});
diff --git a/web/client/components/misc/enhancers/debounce.js b/web/client/components/misc/enhancers/debounce.js
deleted file mode 100644
index 200e07b211..0000000000
--- a/web/client/components/misc/enhancers/debounce.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
-* Copyright 2018, 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 { withHandlers } from 'recompose';
-
-import { debounce } from 'lodash';
-const emptyFunc = () => {};
-
-/**
- * This enhancer de-bounce a method passed as prop of the given time.
- * The action should be present in the props passed to the component
- * @memberof components.misc.enhancers
- * @function
- * @name debounce
- * @example
- * // example: every props change increment the *count* prop
- * compose(debounce("onChangeDrawingStatus", 800));
- * the onChangeDrawingStatus action is debounced by 800 ms
- */
-export default (action = "", debounceTime = 1000) => withHandlers((initProp = {}) => {
- const debounced = debounce(initProp[action] || emptyFunc, debounceTime);
- return {
- [action]: () => debounced
- };
-});
diff --git a/web/client/components/misc/enhancers/withPropsStream.js b/web/client/components/misc/enhancers/withPropsStream.js
deleted file mode 100644
index d73b768a17..0000000000
--- a/web/client/components/misc/enhancers/withPropsStream.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2018, 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 { mapPropsStreamWithConfig } from 'recompose';
-
-import rxjsConfig from 'recompose/rxjsObservableConfig';
-import Rx from 'rxjs';
-const mapPropsStream = mapPropsStreamWithConfig(rxjsConfig);
-
-/**
- * implements the stream version of withProps
- * as the mapPropsStream implements mapProps with stream.
- * For the moment the argument is only a function, the stream returns the props
- * that have be merged with upcoming props.
- * You can also return falsy value to use the props stream only as a trigger for actions
- * @param {function} propStreamFactory a function that gets the stream of props and returns the stream of props to add to the enhanced component
- */
-
-export default propStreamFactory => mapPropsStream(props$ => {
- const newProps$ = propStreamFactory(props$) || Rx.Observable.empty();
- return newProps$.startWith({}).combineLatest(props$, (overrides = {}, props = {}) => ({
- ...props,
- ...overrides
- }));
-});
-
diff --git a/web/client/components/misc/sidebar/Sidebar.jsx b/web/client/components/misc/sidebar/Sidebar.jsx
deleted file mode 100644
index 0c11596e6d..0000000000
--- a/web/client/components/misc/sidebar/Sidebar.jsx
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.
- */
-
-import React from 'react';
-
-import Sidebar from 'react-sidebar';
-
-/**
- * MapStore generic sidebar component with good defaults
- * @class Sidebar
- * @memberof components.misc.sidebar
- * @param {boolean} open Open flag
- * @param {Number} [width=600] Width of the sidebar
- * @param {node} children Content
- */
-export default ({open, width = 600, children, ...props} = {}) => (
-
-);
diff --git a/web/client/components/misc/sidebar/SidebarHeader.jsx b/web/client/components/misc/sidebar/SidebarHeader.jsx
deleted file mode 100644
index 14d1d69784..0000000000
--- a/web/client/components/misc/sidebar/SidebarHeader.jsx
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * 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.
- */
-import React from 'react';
-
-export default ({title} = {}) => {title}
;
diff --git a/web/client/components/misc/sidebar/__tests__/Sidebar-test.jsx b/web/client/components/misc/sidebar/__tests__/Sidebar-test.jsx
deleted file mode 100644
index 0e9dc646a2..0000000000
--- a/web/client/components/misc/sidebar/__tests__/Sidebar-test.jsx
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-
-import expect from 'expect';
-import React from 'react';
-import ReactDOM from 'react-dom';
-
-import Sidebar from '../Sidebar';
-import SidebarHeader from '../SidebarHeader';
-
-describe("Sidebar component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
- it('create Sidebar with content', () => {
- ReactDOM.render(
-
- , document.getElementById("container"));
- const el = document.getElementById('content');
- expect(el).toExist();
- });
- it('create Sidebar wjth title and content', () => {
- ReactDOM.render(
- content} />
- , document.getElementById("container"));
- const titleContainer = document.getElementsByClassName('sidebar-title')[0];
- expect(titleContainer).toExist();
- const content = document.getElementById("content");
- expect(content).toExist();
- });
-
-});
diff --git a/web/client/components/misc/sidebar/index.js b/web/client/components/misc/sidebar/index.js
deleted file mode 100644
index b16202021f..0000000000
--- a/web/client/components/misc/sidebar/index.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * 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.
- */
-
-import Sidebar from './Sidebar';
-
-import SidebarHeader from './SidebarHeader';
-
-export default {
- Sidebar,
- SidebarHeader
-};
diff --git a/web/client/components/misc/spinners/InlineSpinner/InlineSpinner.jsx b/web/client/components/misc/spinners/InlineSpinner/InlineSpinner.jsx
deleted file mode 100644
index 442fc4231d..0000000000
--- a/web/client/components/misc/spinners/InlineSpinner/InlineSpinner.jsx
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.
- */
-
-import {isFunction} from 'lodash';
-import PropTypes from 'prop-types';
-import React from 'react';
-
-import defaultIcon from './img/spinner.gif';
-
-class InlineSpinner extends React.Component {
- static propTypes = {
- className: PropTypes.string,
- loading: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
- icon: PropTypes.string
- };
-
- static defaultProps = {
- loading: false,
- icon: defaultIcon,
- className: "inline-spinner"
- };
-
- getDisplayStyle = () => {
- let loading;
- if (isFunction(this.props.loading)) {
- loading = this.props.loading(this.props);
- } else {
- loading = this.props.loading;
- }
- return loading ? 'inline-block' : 'none';
- };
-
- render() {
- return (
-
- );
- }
-}
-
-export default InlineSpinner;
diff --git a/web/client/components/misc/spinners/InlineSpinner/__tests__/InlineSpinner-test.jsx b/web/client/components/misc/spinners/InlineSpinner/__tests__/InlineSpinner-test.jsx
deleted file mode 100644
index 03041c850d..0000000000
--- a/web/client/components/misc/spinners/InlineSpinner/__tests__/InlineSpinner-test.jsx
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.
- */
-
-import expect from 'expect';
-import React from 'react';
-import ReactDOM from 'react-dom';
-
-import InlineSpinner from '../InlineSpinner';
-
-describe('InlineSpinner', () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('test defaults', () => {
- const spinner = ReactDOM.render(, document.getElementById("container"));
- expect(spinner).toExist();
-
- const domNode = ReactDOM.findDOMNode(spinner);
- expect(domNode).toExist();
-
- expect(domNode.style.display).toBe('none');
- });
-
- it('test loading animation', () => {
- const spinner = ReactDOM.render(, document.getElementById("container"));
- expect(spinner).toExist();
-
- const domNode = ReactDOM.findDOMNode(spinner);
- expect(domNode).toExist();
-
- expect(domNode.style.display).toBe('inline-block');
- });
-
-});
diff --git a/web/client/components/print/PrintSubmit.jsx b/web/client/components/print/PrintSubmit.jsx
deleted file mode 100644
index 782aeab1c5..0000000000
--- a/web/client/components/print/PrintSubmit.jsx
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.
- */
-
-import React from 'react';
-import PropTypes from 'prop-types';
-
-import { Glyphicon } from 'react-bootstrap';
-import Spinner from 'react-spinkit';
-import Message from '../I18N/Message';
-import Button from '../misc/Button';
-
-class PrintSubmit extends React.Component {
- static propTypes = {
- loading: PropTypes.bool,
- onPrint: PropTypes.func,
- disabled: PropTypes.bool,
- buttonConfig: PropTypes.object,
- glyph: PropTypes.string
- };
-
- static defaultProps = {
- loading: false,
- onPrint: () => {},
- disabled: false,
- buttonConfig: {
- bsSize: "large"
- },
- glyph: "print"
- };
-
- render() {
- const glyph = this.props.glyph ? : ;
- return (
-
- );
- }
-}
-
-export default PrintSubmit;
diff --git a/web/client/components/print/__tests__/PrintSubmit-test.jsx b/web/client/components/print/__tests__/PrintSubmit-test.jsx
deleted file mode 100644
index c419b4fb7d..0000000000
--- a/web/client/components/print/__tests__/PrintSubmit-test.jsx
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.
- */
-
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import PrintSubmit from '../PrintSubmit';
-import ReactTestUtils from 'react-dom/test-utils';
-
-describe("Test the PrintSubmit component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates component with defaults', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
-
- const node = ReactDOM.findDOMNode(cmp);
- expect(node).toExist();
- expect(node.tagName.toLowerCase()).toBe('button');
- expect(node.disabled).toNotExist();
- });
-
- it('creates component disabled', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
-
- const node = ReactDOM.findDOMNode(cmp);
- expect(node).toExist();
- expect(node.tagName.toLowerCase()).toBe('button');
- expect(node.classList.contains('disabled')).toBe(true);
- });
-
- it('creates component loading', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- const node = ReactDOM.findDOMNode(cmp);
- expect(node.getElementsByClassName('spinner').length).toBe(1);
- });
-
- it('pdf onPrint', (done) => {
- const handler = (e) => {
- expect(e).toExist();
- done();
- };
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- const node = ReactDOM.findDOMNode(cmp);
- ReactTestUtils.Simulate.click(node);
- });
-});
diff --git a/web/client/components/security/PermissionEditor.jsx b/web/client/components/security/PermissionEditor.jsx
deleted file mode 100644
index 4a877ff28c..0000000000
--- a/web/client/components/security/PermissionEditor.jsx
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
-* 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.
-*/
-
-import React from 'react';
-
-import PropTypes from 'prop-types';
-import assign from 'object-assign';
-import {find, findIndex, head} from 'lodash';
-import Select from 'react-select';
-import Spinner from 'react-spinkit';
-import { Table, Glyphicon } from 'react-bootstrap';
-import Message from '../I18N/Message';
-import { getMessageById } from '../../utils/LocaleUtils';
-import Button from '../misc/Button';
-
-/**
-* Map permission editor
-*/
-class PermissionEditor extends React.Component {
- static propTypes = {
- // props
- id: PropTypes.string,
- user: PropTypes.object,
- buttonSize: PropTypes.string,
- includeCloseButton: PropTypes.bool,
- disabled: PropTypes.bool,
- map: PropTypes.object,
- style: PropTypes.object,
- fluid: PropTypes.bool,
- // CALLBACKS
- onGroupsChange: PropTypes.func,
- onAddPermission: PropTypes.func,
- onErrorCurrentMap: PropTypes.func,
- onUpdateCurrentMap: PropTypes.func,
- onNewGroupChoose: PropTypes.func,
- onNewPermissionChoose: PropTypes.func,
- availablePermissions: PropTypes.arrayOf(PropTypes.string),
- availableGroups: PropTypes.arrayOf(PropTypes.object),
- updatePermissions: PropTypes.func,
- groups: PropTypes.arrayOf(PropTypes.object),
- newGroup: PropTypes.object,
- newPermission: PropTypes.string
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- disabled: true,
- id: "PermissionEditor",
- user: {
- name: "Guest"
- },
- style: {},
- buttonSize: "small",
- // CALLBACKS
- onGroupsChange: ()=> {},
- onAddPermission: ()=> {},
- onNewGroupChoose: ()=> {},
- onNewPermissionChoose: ()=> {},
- onErrorCurrentMap: ()=> {},
- onUpdateCurrentMap: ()=> {},
- availablePermissions: ["canRead", "canWrite"],
- availableGroups: [],
- updatePermissions: () => {},
- groups: []
- };
-
- onNewGroupChoose = (selected) => {
- // TODO: use find(this.props.availableGroups,['id', toInteger(id)]) when lodash will be updated to version 4
- this.props.onNewGroupChoose(find(this.props.availableGroups, (o)=> o.id === selected.value));
- };
-
- onAddPermission = () => {
- // Check if the new permission will edit ad existing one
- if (this.isPermissionPresent(this.props.newGroup.groupName)) {
- this.props.onGroupsChange(
- {
- SecurityRuleList: {
- SecurityRule: this.props.map.permissions.SecurityRuleList.SecurityRule.map(
- function(rule) {
- if (rule.group && rule.group.groupName === this.props.newGroup.groupName) {
- if (this.props.newPermission === "canWrite") {
- return assign({}, rule, {canRead: true, canWrite: true});
- }
- return assign({}, rule, {canRead: true, canWrite: false});
- }
- return rule;
- }, this
- ).filter(rule => rule.canRead || rule.canWrite)
- }
- }
- );
-
- } else {
- this.props.onAddPermission({
- canRead: true,
- canWrite: this.props.newPermission === "canWrite",
- group: this.props.newGroup
- });
- }
- };
-
- onChangePermission = (index, input) => {
- if (this.props.map.permissions) {
- this.props.onGroupsChange(
- {
- SecurityRuleList: {
- SecurityRule: this.props.map.permissions.SecurityRuleList.SecurityRule.map(
- function(rule) {
- if (rule.group && rule.group.groupName === this.localGroups[index].name) {
- if (input === "canWrite") {
- return assign({}, rule, {canRead: true, canWrite: true});
- } else if (input === "canRead") {
- return assign({}, rule, {canRead: true, canWrite: false});
- }
- // TODO: this entry is useless, it should be removed from the array
- return assign({}, rule, {canRead: false, canWrite: false});
- }
- return rule;
- }, this
- ).filter(rule => rule.canRead || rule.canWrite)
- }
- }
- );
- }
- };
-
- getSelectableGroups = () => {
- return this.props.availableGroups && this.props.availableGroups.filter( (group) => {
- return !this.isPermissionPresent(group.groupName);
- }).map((group) => ({label: group.groupName, value: group.id}));
- };
-
- getPermissonLabel = (perm) => {
- switch (perm) {
- case "canRead":
- return getMessageById(this.context.messages, "map.permissions.canView");
- case "canWrite":
- return getMessageById(this.context.messages, "map.permissions.canWrite");
- default:
- return perm;
- }
- };
-
- getAvailablePermissions = () => {
- return this.props.availablePermissions.map((perm) => ({value: perm, label: this.getPermissonLabel(perm)}));
- };
-
- renderPermissionRows = () => {
- if (this.localGroups.length === 0) {
- return |
;
- }
- return this.localGroups.map((group, index) => {
- return (
-
- {group.name} |
-
- |
- {
- // | TODO: Add a Group Editor
- }
- {
- //
- }
-
- |
-
- );
- });
- };
- render() {
- // Hack to convert map permissions to a simpler format, TODO: remove this
- if (this.props.map && this.props.map.permissions && this.props.map.permissions.SecurityRuleList && this.props.map.permissions.SecurityRuleList.SecurityRule) {
- this.localGroups = this.props.map.permissions.SecurityRuleList.SecurityRule
- .map(function(rule) {
- if (rule && rule.group && rule.canRead) {
- return {name: rule.group.groupName, permission: rule.canWrite ? "canWrite" : "canRead" };
- }
- return null;
- }
- ).filter(rule => rule); // filter out undefined values
- } else {
- this.localGroups = this.props.groups;
- }
- return (
-
-
-
-
- |
-
-
-
- {this.props.map && this.props.map.permissionLoading ?
-
|
- : this.renderPermissionRows()}
-
-
-
- |
-
-
-
-
-
- |
-
- |
-
-
- |
-
-
-
-
- );
- }
-
- disablePermission(a, b) {
- return a || !b;
- }
- isPermissionPresent = (group) => {
- return this.props.map && this.props.map.permissions && this.props.map.permissions.SecurityRuleList && this.props.map.permissions.SecurityRuleList.SecurityRule &&
- findIndex(this.props.map.permissions.SecurityRuleList.SecurityRule, (o) => o.group && o.group.groupName === group) >= 0;
- };
-}
-
-export default PermissionEditor;
diff --git a/web/client/components/security/__tests__/PermissionEditor-test.jsx b/web/client/components/security/__tests__/PermissionEditor-test.jsx
deleted file mode 100644
index ea24feff91..0000000000
--- a/web/client/components/security/__tests__/PermissionEditor-test.jsx
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * 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.
- */
-
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import ReactTestUtils from 'react-dom/test-utils';
-import PermissionEditor from '../PermissionEditor';
-
-let setupEditor = (docElement, actions) => {
- return ReactDOM.render(, docElement);
-};
-
-describe("Test the permission editor component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates component with defaults', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
-
- it('creates component with some existing permission rules', () => {
- const cmp = setupEditor(document.getElementById("container"));
- expect(cmp).toExist();
- expect(cmp.localGroups.length).toBe(2);
- const nodeEven = ReactTestUtils.scryRenderedDOMComponentsWithClass(cmp, "even");
- expect(nodeEven.length).toBe(1);
- const nodeOdd = ReactTestUtils.scryRenderedDOMComponentsWithClass(cmp, "odd");
- expect(nodeOdd.length).toBe(1);
- });
-
- it('changes a security rule', () => {
- let actions = {
- onGroupsChange: (c) => {
- return {c};
- },
- onNewGroupChoose: () => {}
- };
- let groupChangeSpy = expect.spyOn(actions, "onGroupsChange");
-
- const cmp = setupEditor(document.getElementById("container"), actions);
- expect(cmp).toExist();
-
- const cmpDom = cmp.refs.permChoice1;
- expect(cmpDom).toExist();
-
- cmpDom.selectValue("canWrite");
- cmpDom.selectValue("canRead");
-
- expect(groupChangeSpy.calls.length).toBe(2);
- });
-
-
- it('adds a new groups rules clicking the Add permission button', () => {
- let actions = {
- onGroupsChange: (c) => {
- return {c};
- },
- onNewPermissionChoose: () => {},
- onAddPermission: () => {},
- newGroup: { groupName: "g22", id: 22}
- };
- let newPermissionChangeSpy = expect.spyOn(actions, "onNewPermissionChoose");
- let groupChangeCallbackSpy = expect.spyOn(actions, "onGroupsChange");
- let groupAddCallbackSpy = expect.spyOn(actions, "onAddPermission");
-
- const cmp = setupEditor(document.getElementById("container"), actions);
- expect(cmp).toExist();
-
- const cmpDom = cmp.refs.newChoice;
- expect(cmpDom).toExist();
-
- cmpDom.selectValue("canWrite");
-
- expect(newPermissionChangeSpy.calls.length).toBe(1);
-
- const addBtnDom = cmp.refs.buttonAdd;
- expect(addBtnDom).toExist();
- ReactDOM.findDOMNode(addBtnDom).click();
-
- expect(groupChangeCallbackSpy.calls.length).toBe(0);
- expect(groupAddCallbackSpy.calls.length).toBe(1);
- });
-});
diff --git a/web/client/components/style/BandSelector.jsx b/web/client/components/style/BandSelector.jsx
deleted file mode 100644
index da5722df1e..0000000000
--- a/web/client/components/style/BandSelector.jsx
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- * 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.
- */
-
-import PropTypes from 'prop-types';
-import React from 'react';
-import { Col, Grid, Row } from 'react-bootstrap';
-import { Combobox, NumberPicker } from 'react-widgets';
-import numberLocalizer from 'react-widgets/lib/localizers/simple-number';
-
-import { getMessageById } from '../../utils/LocaleUtils';
-import Message from '../I18N/Message';
-
-numberLocalizer();
-
-
-class BandSelector extends React.Component {
- static propTypes = {
- band: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
- bands: PropTypes.array,
- min: PropTypes.number,
- max: PropTypes.number,
- contrast: PropTypes.oneOf(['none', 'Normalize', 'Histogram', 'GammaValue']),
- algorithm: PropTypes.oneOf(['none', 'StretchToMinimumMaximum', 'ClipToMinimumMaximum', 'ClipToZero']),
- gammaValue: PropTypes.number,
- onChange: PropTypes.func,
- bandsComboOptions: PropTypes.object
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- band: '1',
- contrast: "none",
- algorithm: "none",
- gammaValue: 1,
- min: 0,
- max: 255,
- bandsComboOptions: {},
- onChange: () => {},
- bands: ['1', '2', '3']
- };
-
- render() {
- return (
-
-
-
-
- {this.props.contrast === "GammaValue" ? : null }
- {this.props.contrast === "Normalize" ? : null }
-
-
-
- this.props.onChange("band", v)}
- {...this.props.bandsComboOptions}/>
-
-
- this.props.onChange("contrast", v.value)}/>
-
- { this.props.contrast === "GammaValue" ?
- this.props.onChange("gammaValue", v)}/> : null}
- { this.props.contrast === "Normalize" ?
-
- this.props.onChange("algorithm", v.value)}/>
-
- : null}
-
- {this.props.contrast === "Normalize" && this.props.algorithm !== "none" ?
-
-
-
-
: null }
- {this.props.contrast === "Normalize" && this.props.algorithm !== "none" ?
-
-
- this.props.onChange("min", v)}
- />
-
- this.props.onChange("max", v)}
- />
-
: null }
- );
- }
-}
-
-export default BandSelector;
diff --git a/web/client/components/style/CircleStyler.jsx b/web/client/components/style/CircleStyler.jsx
deleted file mode 100644
index bcf6b74aa8..0000000000
--- a/web/client/components/style/CircleStyler.jsx
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-import React from 'react';
-import assign from 'object-assign';
-import { Grid, Row, Col } from 'react-bootstrap';
-import ColorSelector from './ColorSelector';
-import StyleCanvas from './StyleCanvas';
-import Slider from 'react-nouislider';
-import numberLocalizer from 'react-widgets/lib/localizers/simple-number';
-numberLocalizer();
-import { isNil } from 'lodash';
-import Message from '../I18N/Message';
-import tinycolor from 'tinycolor2';
-
-class StylePolygon extends React.Component {
- static propTypes = {
- shapeStyle: PropTypes.object,
- width: PropTypes.number,
- setStyleParameter: PropTypes.func
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- shapeStyle: {},
- setStyleParameter: () => {}
- };
-
- render() {
- const styleType = "Circle";
- const style = this.props.shapeStyle[styleType] || this.props.shapeStyle; // in case of old version of style.
- return (
-
-
-
-
-
-
-
-
-
-
-
-
- {
- if (!isNil(c)) {
- const fillColor = tinycolor(c).toHexString();
- const fillOpacity = c.a;
- const newStyle = assign({}, this.props.shapeStyle, {
- [styleType]: assign({}, style, {fillColor, fillOpacity})
- });
- this.props.setStyleParameter(newStyle);
- }
- }}/>
-
-
-
-
-
-
-
- {
- if (!isNil(c)) {
- const color = tinycolor(c).toHexString();
- const opacity = c.a;
- const newStyle = assign({}, this.props.shapeStyle, {
- [styleType]: assign({}, style, {color, opacity})
- });
- this.props.setStyleParameter(newStyle);
- }
- }}/>
-
-
-
-
-
-
-
-
- Math.round(value),
- to: value => Math.round(value) + ' px'
- }}
- range={{min: 1, max: 15}}
- onChange={(values) => {
- const weight = parseInt(values[0].replace(' px', ''), 10);
- const newStyle = assign({}, this.props.shapeStyle, {
- [styleType]: assign({}, style, {weight})
- });
- this.props.setStyleParameter(newStyle);
- }}
- />
-
-
-
- );
- }
- addOpacityToColor = (color, opacity) => {
- return assign({}, color, {
- a: opacity
- });
- }
-}
-
-export default StylePolygon;
diff --git a/web/client/components/style/ColorMapGrid.jsx b/web/client/components/style/ColorMapGrid.jsx
deleted file mode 100644
index d9208978c3..0000000000
--- a/web/client/components/style/ColorMapGrid.jsx
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * 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.
- */
-
-import React from 'react';
-
-import { isEqual } from 'lodash';
-import { AgGridReact } from 'ag-grid-react';
-import PropTypes from 'prop-types';
-import reactCellRendererFactory from './ColorMapGridComponents/ReactCellRendererFactoryParams';
-import ColorPickerRenderer from './ColorMapGridComponents/ColorPickerRenderer';
-import assign from 'object-assign';
-import NumberRenderer from './ColorMapGridComponents/NumberRenderer';
-import { getMessageById } from '../../utils/LocaleUtils';
-import 'ag-grid-community/dist/styles/ag-grid.css';
-import 'ag-grid-community/dist/styles/ag-theme-blue.css';
-
-class ColorMapGrid extends React.Component {
- static propTypes = {
- entries: PropTypes.array,
- style: PropTypes.object,
- selectEntry: PropTypes.func,
- valueChanged: PropTypes.func
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- entries: [],
- style: {height: "200px"},
- selectEntry: () => {},
- valueChanged: () => {}
- };
-
- shouldComponentUpdate(nextProps) {
- return !isEqual(nextProps.entries, this.props.entries);
- }
-
- componentDidUpdate() {
- this.api.sizeColumnsToFit();
- }
-
- onGridReady = (params) => {
- this.api = params.api;
- this.api.sizeColumnsToFit();
- this.columnApi = params.columnApi;
- };
-
- render() {
- return (
- );
- }
-
- selectEntry = (row) => {
- if (row) {
- this.props.selectEntry(row.node.childIndex);
- }
- };
-
- valueChanged = () => {
- let newData = [];
- this.api.getModel().forEachNode((node) => {newData.push(node.data); });
- this.props.valueChanged(newData);
- };
-
- changeColor = (node, colorOpacity) => {
- let newData = [];
- this.api.getModel().forEachNode((n, idx) => {
- let data = idx === node.childIndex ? assign({}, n.data, colorOpacity) : n.data;
- newData.push(data);
- });
- this.props.valueChanged(newData);
- };
-
- changeQuantity = (node, value) => {
- let newData = [];
- this.api.getModel().forEachNode((n, idx) => {
- let data = idx === node.childIndex ? assign({}, n.data, {quantity: value}) : n.data;
- newData.push(data);
- });
- this.props.valueChanged(newData);
- };
-}
-
-export default ColorMapGrid;
diff --git a/web/client/components/style/ColorMapGridComponents/ColorPickerRenderer.jsx b/web/client/components/style/ColorMapGridComponents/ColorPickerRenderer.jsx
deleted file mode 100644
index bc175b5877..0000000000
--- a/web/client/components/style/ColorMapGridComponents/ColorPickerRenderer.jsx
+++ /dev/null
@@ -1,98 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-import React from 'react';
-
-import { SketchPicker } from 'react-color';
-import './colorenderer.css';
-import { getWindowSize } from '../../../utils/AgentUtils';
-
-class ColorPickerRenderer extends React.Component {
- static propTypes = {
- params: PropTypes.object,
- onChangeColor: PropTypes.func,
- disabled: PropTypes.bool
- };
-
- static defaultProps = {
- disabled: false,
- onChangeColor: () => {}
- };
-
- state = {
- displayColorPicker: false
- };
-
- onChangeColor = () => {
- if ( this.state.color) {
- let opacity = this.state.color.rgb.a !== 1 ? this.state.color.rgb.a : undefined;
- let color = this.state.color.hex.indexOf("#") === 0 ? this.state.color.hex : "#" + this.state.color.hex;
- this.props.onChangeColor( this.props.params.node, {color: color, opacity: opacity});
- }
- };
-
- getBackgroundColor = (data) => {
- let color = 'blue';
- if ( data && data.color) {
- let rgb = this.hexToRgb(data.color);
- let opacity = data.opacity !== undefined ? data.opacity : 1;
- color = rgb ? `rgba(${ rgb.r }, ${ rgb.g }, ${ rgb.b }, ${ opacity })` : 'blue';
- }
- return color;
- };
-
- render() {
- let data = this.props.params.data;
- let colorValue = data && data.color ? this.hexToRgb(data.color) : {r: 0, g: 0, b: 255};
- colorValue.a = data.opacity !== undefined ? data.opacity : 1;
- let bkgColor = this.getBackgroundColor(data);
- return (
-
-
{
- if (!this.props.disabled) {
- this.setState({
- displayColorPicker: !this.state.displayColorPicker,
- y: e.pageY
- });
- }
- }}
- />
- { this.state.displayColorPicker ?
-
-
{
- this.setState({ displayColorPicker: false});
- this.onChangeColor();
- }}/>
- { this.setState({ color: color }); }} />
-
- : null }
-
- );
- }
-
- calculateTop = (y) => {
- let h = getWindowSize().maxHeight;
- return (y + 300 > h ? h - 305 : y ) - 300;
- };
-
- hexToRgb = (hex) => {
- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
- return result ? {
- r: parseInt(result[1], 16),
- g: parseInt(result[2], 16),
- b: parseInt(result[3], 16)
- } : null;
- };
-}
-
-export default ColorPickerRenderer;
diff --git a/web/client/components/style/ColorMapGridComponents/NumberRenderer.jsx b/web/client/components/style/ColorMapGridComponents/NumberRenderer.jsx
deleted file mode 100644
index 6573d3e796..0000000000
--- a/web/client/components/style/ColorMapGridComponents/NumberRenderer.jsx
+++ /dev/null
@@ -1,113 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-
-import React from 'react';
-
-import { findDOMNode } from 'react-dom';
-import { Popover, Label, Overlay } from 'react-bootstrap';
-import numberLocalizer from 'react-widgets/lib/localizers/simple-number';
-numberLocalizer();
-import { NumberPicker } from 'react-widgets';
-import './numberpicker.css';
-
-class NumberRenderer extends React.Component {
- static propTypes = {
- params: PropTypes.object,
- onChangeValue: PropTypes.func,
- errorMessage: PropTypes.string
- };
-
- static defaultProps = {
- onChangeValue: () => {},
- errorMessage: "Value not valid"
- };
-
- state = {
- displayNumberPicker: false,
- showError: false
- };
-
- componentDidMount() {
- this.props.params.api.addEventListener('cellClicked', this.cellClicked);
- }
-
- componentWillUnmount() {
- this.props.params.api.removeEventListener('cellClicked', this.cellClicked);
- }
-
- getRange = () => {
- let data = [];
- this.props.params.api.forEachNode((node) => {data.push(node.data); });
- let idx = this.props.params.node.childIndex;
- let min = data[idx - 1] ? data[idx - 1].quantity + 0.01 : -Infinity;
- let max = data[idx + 1] ? data[idx + 1].quantity - 0.01 : Infinity;
- return {min: min, max: max};
- };
-
- render() {
-
- return (
-
{
- if (!this.state.displayNumberPicker) {
- this.setState({displayNumberPicker: !this.state.displayNumberPicker});
- }
- } }
- >
- { this.state.displayNumberPicker ?
-
-
-
{e.stopPropagation(); }}>
-
-
findDOMNode(this.refs.colorMapNumberPicker)}
- show={this.state.showError} placement="top" >
-
-
-
-
-
-
:
-
{this.props.params.value.toFixed ? this.props.params.value.toFixed(2) : this.props.params.value} }
-
- );
- }
-
- cellClicked = (e) => {
- if (this.props.params.value !== e.value && this.state.displayNumberPicker) {
- this.stopEditing();
- }
- };
-
- stopEditing = () => {
- let range = this.getRange();
- let newValue = this.state.value === undefined ? this.props.params.value : this.state.value;
- if (range.min < newValue && newValue < range.max) {
- this.setState({ displayNumberPicker: false, showError: false});
- if (newValue !== this.props.params.value) {
- this.props.onChangeValue(this.props.params.node, newValue);
- }
- } else {
- this.setState({showError: true});
- }
-
- };
-
- changeNumber = (value) => {
- this.setState({value: value, showError: false});
- };
-}
-
-export default NumberRenderer;
diff --git a/web/client/components/style/ColorMapGridComponents/ReactCellRendererFactoryParams.jsx b/web/client/components/style/ColorMapGridComponents/ReactCellRendererFactoryParams.jsx
deleted file mode 100644
index c6ab15917f..0000000000
--- a/web/client/components/style/ColorMapGridComponents/ReactCellRendererFactoryParams.jsx
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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.
- */
-import React from 'react';
-
-import ReactDOM from 'react-dom';
-function reactCellRendererFactoryParams(ReactComponent, compParams) {
- return function(params) {
- if (params.eParentOfValue.addElementAttachedListener) {
- params.eParentOfValue.addElementAttachedListener(function(eCell) {
- ReactDOM.render(
, eCell);
- params.api.addVirtualRowListener('virtualRowRemoved', params.rowIndex, function() {
- ReactDOM.unmountComponentAtNode(eCell);
- });
- });
- }
- // return null to the grid, as we don't want it responsible for rendering
- return null;
- };
-}
-export default reactCellRendererFactoryParams;
diff --git a/web/client/components/style/ColorMapGridComponents/colorenderer.css b/web/client/components/style/ColorMapGridComponents/colorenderer.css
deleted file mode 100644
index 702fc25e97..0000000000
--- a/web/client/components/style/ColorMapGridComponents/colorenderer.css
+++ /dev/null
@@ -1,28 +0,0 @@
-.cpr-color
- {
- box-sizing: border-box;
- width: 100%;
- min-height: 28px;
- -webkit-border-radius: 3px;
- -moz-border-radius: 3px;
- border-radius: 3px;
- padding: 2px;
-
-}
-.cpe-popover
-{
- white-space: normal;
- position: fixed;
- z-index: 1000;
-}
-.cpe-cover
-{
- position: fixed;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
-}
-.cpe-popover > div > div {
- position: relative;
-}
diff --git a/web/client/components/style/ColorMapGridComponents/numberpicker.css b/web/client/components/style/ColorMapGridComponents/numberpicker.css
deleted file mode 100644
index 85f3585a0a..0000000000
--- a/web/client/components/style/ColorMapGridComponents/numberpicker.css
+++ /dev/null
@@ -1,7 +0,0 @@
-.numberpicker {
- font-size: small;
- -ms-transform: scaleY(0.9) translateY(-2px); /* IE 9 */
- -webkit-transform: scaleY(0.9) translateY(-2px); /* Chrome, Safari, Opera */
- transform: scaleY(0.9) translateY(-2px);
-
-}
\ No newline at end of file
diff --git a/web/client/components/style/ColorRampSelector.jsx b/web/client/components/style/ColorRampSelector.jsx
deleted file mode 100644
index 10314f00a5..0000000000
--- a/web/client/components/style/ColorRampSelector.jsx
+++ /dev/null
@@ -1,72 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import colorsSchema from './EqualIntervalComponents/ColorRamp';
-import ColorRampItem from './EqualIntervalComponents/ColorRampItem';
-import colors from './EqualIntervalComponents/ExtendColorBrewer';
-import { Combobox } from 'react-widgets';
-
-class ColorRampSelector extends React.Component {
-
- static propTypes = {
- colorsSchema: PropTypes.array,
- colors: PropTypes.object,
- classes: PropTypes.number,
- ramp: PropTypes.string
- };
-
- static defaultProps = {
- colorsSchema,
- colors,
- classes: 5,
- ramp: 'Blues'
- };
-
- UNSAFE_componentWillMount() {
- this.setState({
- ramp: this.props.ramp
- });
- }
-
- getColorsSchema = () => {
- return this.props.classes ?
- this.props.colorsSchema.filter((c) => {
- return c.max >= this.props.classes;
- }, this) : this.props.colorsSchema;
- };
-
- getRampValue = () => {
- let ramp = this.state.ramp;
- if (!this.props.colors[this.state.ramp][this.props.classes]) {
- ramp = this.props.colorsSchema.filter((color) => { return color.max >= this.props.classes; }, this)[0].name;
- }
- return ramp;
- };
-
- getRamp = () => {
- return this.props.colors[this.state.ramp] ? (
- this.props.colors[this.state.ramp][5].map(c => {
- return
;
- })
- ) : null;
- }
-
- render() {
- return (
-
- {this.getRamp()}
-
-
{
- this.setState({
- ramp: ramp.name
- });
- }}/>
- );
- }
-}
-
-export default ColorRampSelector;
diff --git a/web/client/components/style/ColorRangeSelector.jsx b/web/client/components/style/ColorRangeSelector.jsx
deleted file mode 100644
index cab4a35ba4..0000000000
--- a/web/client/components/style/ColorRangeSelector.jsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import React from 'react';
-import PropTypes from 'prop-types';
-import { sameToneRangeColors } from '../../utils/ColorUtils';
-import ColorRampItem from './EqualIntervalComponents/ColorRampItem';
-import { DropdownList } from 'react-widgets';
-import { head } from 'lodash';
-
-class ColorRangeSelector extends React.Component {
-
- static propTypes = {
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
- samples: PropTypes.number,
- onChange: PropTypes.func,
- items: PropTypes.array,
- rampFunction: PropTypes.func,
- disabled: PropTypes.bool
- };
- static contextTypes = {
- messages: PropTypes.object
- };
- static defaultProps = {
- samples: 5,
- onChange: () => {},
- items: [{
- name: 'global.colors.blue',
- schema: 'sequencial',
- options: {base: 190, range: 20}
- }, {
- name: 'global.colors.red',
- schema: 'sequencial',
- options: {base: 10, range: 4}
- }, {
- name: 'global.colors.green',
- schema: 'sequencial',
- options: {base: 120, range: 4}
- }, {
- name: 'global.colors.brown',
- schema: 'sequencial',
- options: {base: 30, range: 4, s: 1, v: 0.5}
- }, {
- name: 'global.colors.purple',
- schema: 'sequencial',
- options: {base: 300, range: 4}
- }, {
- name: 'global.colors.random',
- schema: 'qualitative',
- options: {base: 190, range: 340, options: {base: 10, range: 360, s: 0.67, v: 0.67}}
- }],
- disabled: false
- };
- getValue = () => {
- return head(this.getItems().filter( (i = {}) => i === this.props.value || i.name === (this.props.value && this.props.value.name)));
- }
- getItems = () => {
- return this.props.items.map(({options = {}, ...item}) => ({
- ...item,
- options,
- ramp: this.props.rampFunction ? this.props.rampFunction(item, options) : (sameToneRangeColors(options.base, options.range, this.props.samples + 1, options.options) || ["#AAA"]).splice(1)
- }));
- }
-
- render() {
- const items = this.getItems();
- return (
-
}
- itemComponent={ColorRampItem}
- value={this.getValue()}
- onChange={(ramp) => {
- this.props.onChange(ramp);
- }}/>
- );
- }
-}
-
-export default ColorRangeSelector;
diff --git a/web/client/components/style/EqualInterval.jsx b/web/client/components/style/EqualInterval.jsx
deleted file mode 100644
index cda76103f3..0000000000
--- a/web/client/components/style/EqualInterval.jsx
+++ /dev/null
@@ -1,204 +0,0 @@
-
-/**
- * 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.
- */
-
-import PropTypes from 'prop-types';
-import React from 'react';
-import { Col, Grid, Label, Overlay, Popover, Row } from 'react-bootstrap';
-import { findDOMNode } from 'react-dom';
-import { Combobox, NumberPicker } from 'react-widgets';
-import numberLocalizer from 'react-widgets/lib/localizers/simple-number';
-
-import Message from '../I18N/Message';
-import colorsSchema from './EqualIntervalComponents/ColorRamp';
-import ColorRampItem from './EqualIntervalComponents/ColorRampItem';
-import colors from './EqualIntervalComponents/ExtendColorBrewer';
-import Button from '../misc/Button';
-
-numberLocalizer();
-
-
-class EqualInterval extends React.Component {
- static propTypes = {
- min: PropTypes.number,
- max: PropTypes.number,
- classes: PropTypes.number,
- onChange: PropTypes.func,
- onClassify: PropTypes.func,
- ramp: PropTypes.string,
- error: PropTypes.object
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- min: 0,
- max: 100,
- classes: 5,
- ramp: "Blues",
- onChange: () => {},
- onClassify: () => {},
- error: null
- };
-
- shouldComponentUpdate() {
- return true;
- }
-
- getColorsSchema = () => {
- return this.props.classes ?
- colorsSchema.filter((c) => {
- return c.max >= this.props.classes;
- }, this) : colorsSchema;
- };
-
- getRampValue = () => {
- let ramp = this.props.ramp;
- if (!colors[this.props.ramp][this.props.classes]) {
- ramp = colorsSchema.filter((color) => { return color.max >= this.props.classes; }, this)[0].name;
- }
- return ramp;
- };
-
- renderErrorPopOver = () => {
- return (
- findDOMNode(this.refs[this.props.error.type])}
- show placement="top" >
-
-
-
-
- );
- };
-
- render() {
- return (
-
-
-
-
-
-
-
-
- {this.props.error && this.props.error.type === 'min' ? this.renderErrorPopOver() : null}
-
-
-
-
-
-
-
-
- {this.props.error && this.props.error.type === 'max' ? this.renderErrorPopOver() : null}
-
-
-
-
-
-
-
-
-
-
- this.props.onChange("classes", number)}
- precision={0} min={3} max={12} step={1}
- value={this.props.classes}
- />
-
-
-
-
-
-
-
-
-
-
- this.props.onChange("ramp", value.name)}
- textField="name"
- itemComponent={ColorRampItem} value={this.getRampValue()}/>
-
-
-
-
-
-
-
-
-
- );
- }
-
- classifyDisabled = () => {
- return this.props.error && this.props.error.type ? true : false;
- };
-
- generateEqualIntervalRamp = () => {
- let ramp = colors[this.getRampValue()][this.props.classes];
- let min = this.props.min;
- let max = this.props.max;
- let step = (max - min) / this.props.classes;
- let colorRamp = ramp.map((color, idx) => {
- return {color: color, quantity: min + idx * step};
- });
- this.props.onClassify("colorRamp", colorRamp);
- };
-
- changeMin = (value) => {
- if (value < this.props.max) {
- if (this.props.error) {
- this.props.onChange("error", {});
- }
- this.props.onChange("min", value);
- } else {
- this.props.onChange("error", {
- type: "min",
- msg: "equalinterval.minerror"
- });
- }
-
- };
-
- changeMax = (value) => {
- if (value > this.props.min) {
- if (this.props.error) {
- this.props.onChange("error", {});
- }
- this.props.onChange("max", value);
- } else {
- this.props.onChange("error", {
- type: "max",
- msg: "equalinterval.maxerror"
- });
- }
- };
-}
-
-export default EqualInterval;
diff --git a/web/client/components/style/EqualIntervalComponents/ColorRamp.js b/web/client/components/style/EqualIntervalComponents/ColorRamp.js
deleted file mode 100644
index 5d04aa786a..0000000000
--- a/web/client/components/style/EqualIntervalComponents/ColorRamp.js
+++ /dev/null
@@ -1,17 +0,0 @@
-const colorsSchema = [
- {name: "BuGn", schema: "Sequential", max: 9}, {name: "BuPu", schema: "Sequential", max: 9}, {name: "GnBu", schema: "Sequential", max: 9},
- {name: "OrRd", schema: "Sequential", max: 9}, {name: "PuBu", schema: "Sequential", max: 9}, {name: "PuBuGn", schema: "Sequential", max: 9},
- {name: "PuRd", schema: "Sequential", max: 9}, {name: "RdPu", schema: "Sequential", max: 9}, {name: "YlGn", schema: "Sequential", max: 9},
- {name: "YlGnBu", schema: "Sequential", max: 9}, {name: "YlOrBr", schema: "Sequential", max: 9}, {name: "YlOrRd", schema: "Sequential", max: 9},
- {name: "Blues", schema: "Singlehue", max: 9}, {name: "Greens", schema: "Singlehue", max: 9}, {name: "Greys", schema: "Singlehue", max: 9},
- {name: "Oranges", schema: "Singlehue", max: 9}, {name: "Purples", schema: "Singlehue", max: 9}, {name: "Reds", schema: "Singlehue", max: 9},
- {name: "BrBG", schema: "Diverging", max: 11}, {name: "PiYG", schema: "Diverging", max: 11}, {name: "PRGn", schema: "Diverging", max: 11},
- {name: "PuOr", schema: "Diverging", max: 11}, {name: "RdBu", schema: "Diverging", max: 11}, {name: "RdGy", schema: "Diverging", max: 11},
- {name: "RdYlBu", schema: "Diverging", max: 11}, {name: "RdYlGn", schema: "Diverging", max: 11}, {name: "Spectral", schema: "Diverging", max: 11},
- {name: "Accent", schema: "Qualitative", max: 8}, {name: "Dark2", schema: "Qualitative", max: 8}, {name: "Paired", schema: "Qualitative", max: 12},
- {name: "Pastel1", schema: "Qualitative", max: 9}, {name: "Pastel2", schema: "Qualitative", max: 8}, {name: "Set1", schema: "Qualitative", max: 9},
- {name: "Set2", schema: "Qualitative", max: 8}, {name: "Set3", schema: "Qualitative", max: 12}, {name: "Earth", schema: "Dem", max: 12},
- {name: "Land", schema: "Dem", max: 12}, {name: "Water", schema: "Dem", max: 12}, {name: "CDA", schema: "Dem", max: 12},
- {name: "Simple", schema: "Dem", max: 7}];
-
-export default colorsSchema;
diff --git a/web/client/components/style/EqualIntervalComponents/ColorRampItem.jsx b/web/client/components/style/EqualIntervalComponents/ColorRampItem.jsx
deleted file mode 100644
index e7b78d4f7f..0000000000
--- a/web/client/components/style/EqualIntervalComponents/ColorRampItem.jsx
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright 2019, 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 PropTypes from 'prop-types';
-import colors from './ExtendColorBrewer';
-import Message from '../../I18N/Message';
-
-/**
- * @name ColorRampItem
- * @description Simple component to display color label
- */
-const ColorRampItem = ({ item }) => {
- let ramp = item && (item.ramp || colors[item.name] && colors[item.name][5]) || [];
- return (
-
- {ramp.map(cell =>
)}
-
- {item && ( item.label || item.name )
- ?
- : item}
-
-
- );
-};
-
-ColorRampItem.propTypes = {
- item: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
-};
-
-export default ColorRampItem;
diff --git a/web/client/components/style/EqualIntervalComponents/ExtendColorBrewer.js b/web/client/components/style/EqualIntervalComponents/ExtendColorBrewer.js
deleted file mode 100644
index b539a09ebe..0000000000
--- a/web/client/components/style/EqualIntervalComponents/ExtendColorBrewer.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * 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 extendColorBrewer = {
- Earth: {
- 3: ["#3e2f8d", "#d3e1b2", "#f1e8dd"],
- 4: ["#3e2f8d", "#a4cef4", "#676c52", "#f1e8dd"],
- 5: ["#3e2f8d", "#87b2f1", "#d3e1b2", "#615742", "#f1e8dd"],
- 6: ["#3e2f8d", "#739cd3", "#cbe1da", "#8e9f79", "#7e6d4f", "#f1e8dd"],
- 7: ["#3e2f8d", "#6a8dc7", "#a4cef4", "#d3e1b2", "#676c52", "#89795d", "#f1e8dd"],
- 8: ["#3e2f8d", "#6783c7", "#94c0fb", "#e1e9ca", "#a3b990", "#524d3d", "#908169", "#f1e8dd"],
- 9: ["#3e2f8d", "#657bc7", "#87b2f1", "#b9dae8", "#d3e1b2", "#7b8965", "#615742", "#948671", "#f1e8dd"],
- 10: ["#3e2f8d", "#6375c7", "#7ca6e0", "#a4cef4", "#eceec1", "#afc79c", "#676c52", "#716349", "#988b78", "#f1e8dd"],
- 11: ["#3e2f8d", "#6271c7", "#739cd3", "#99c4f9", "#cbe1da", "#d3e1b2", "#8e9f79", "#585743", "#7e6d4f", "#9b8f7e", "#f1e8dd"],
- 12: ["#3e2f8d", "#616dc7", "#6c93c7", "#8fbcfe", "#aed6f1", "#f1f0be", "#bbd5a9", "#788562", "#504a3b", "#847252", "#9b8f7e", "#f1e8dd"]
- },
- Land: {
- 3: ["#c3e2df", "#2f412c", "#e7e9dd"],
- 4: ["#c3e2df", "#5d7a65", "#3f3633", "#e7e9dd"],
- 5: ["#c3e2df", "#868f65", "#2f412c", "#5c4e4b", "#e7e9dd"],
- 6: ["#c3e2df", "#979f72", "#446553", "#302f26", "#6e5d56", "#e7e9dd"],
- 7: ["#c3e2df", "#a5ac7d", "#5d7a65", "#2f412c", "#3f3633", "#7b695a", "#e7e9dd"],
- 8: ["#c3e2df", "#b0b788", "#768562", "#3c5a46", "#2d3123", "#4f4342", "#84715c", "#e7e9dd"],
- 9: ["#c3e2df", "#b8c091", "#868f65", "#4b6e5f", "#2f412c", "#322d28", "#5c4e4b", "#8c775d", "#e7e9dd"],
- 10: ["#c3e2df", "#bfc697", "#8f986c", "#5d7a65", "#37553e", "#2b3221", "#3f3633", "#665651", "#917c5e", "#e7e9dd"],
- 11: ["#c3e2df", "#c4cc9d", "#979f72", "#6f8263", "#446553", "#2f412c", "#302f26", "#4a3f3d", "#6e5d56", "#96805f", "#e7e9dd"],
- 12: ["#c3e2df", "#c8d0a1", "#9ea576", "#7d8861", "#4e7265", "#35513a", "#2a3320", "#352e2a", "#534745", "#756359", "#9d896a", "#e7e9dd"]
- },
- Water: {
- 3: ["#1f373d", "#4cc1b2", "#dee2b6"],
- 4: ["#1f373d", "#309590", "#85dfce", "#dee2b6"],
- 5: ["#1f373d", "#2a8180", "#4cc1b2", "#a1f3dc", "#dee2b6"],
- 6: ["#1f373d", "#2f6f79", "#30a8a2", "#76d1c6", "#c1fdf6", "#dee2b6"],
- 7: ["#1f373d", "#306573", "#309590", "#4cc1b2", "#85dfce", "#c8f3dc", "#dee2b6"],
- 8: ["#1f373d", "#305f6b", "#2a8b86", "#2fb2aa", "#6eccbd", "#8deccd", "#c8e6bb", "#dee2b6"],
- 9: ["#1f373d", "#2f5b66", "#2a8180", "#32a09a", "#4cc1b2", "#7dd5ce", "#a1f3dc", "#c8dda3", "#dee2b6"],
- 10: ["#1f373d", "#2f5862", "#2d777c", "#309590", "#2eb8af", "#69cab8", "#85dfce", "#b3f8eb", "#c8d690", "#dee2b6"],
- 11: ["#1f373d", "#2f555f", "#2f6f79", "#2c8e89", "#30a8a2", "#4cc1b2", "#76d1c6", "#8ae8cd", "#c1fdf6", "#c8d181", "#dee2b6"],
- 12: ["#1f373d", "#2f535c", "#306977", "#298883", "#329c97", "#30bab1", "#66c8b4", "#80d7cf", "#92efd0", "#c8faf0", "#cad285", "#dee2b6"]
- },
- CDA: {
- 3: ["#18c6ca", "#fed873", "#ffffff"],
- 4: ["#18c6ca", "#fffbc3", "#e3ce9b", "#ffffff"],
- 5: ["#18c6ca", "#e9feb4", "#fed873", "#d0c6b0", "#ffffff"],
- 6: ["#18c6ca", "#cffea9", "#fef5af", "#efd28b", "#c8c2b6", "#ffffff"],
- 7: ["#18c6ca", "#bafea1", "#fffbc3", "#fed873", "#e3ce9b", "#ccc8c1", "#ffffff"],
- 8: ["#18c6ca", "#affe9d", "#f0feb8", "#fef3a8", "#f3d486", "#d8c9a8", "#d3d0ca", "#ffffff"],
- 9: ["#18c6ca", "#affe9d", "#e9feb4", "#fef7b5", "#fed873", "#e7cf96", "#d0c6b0", "#dad8d2", "#ffffff"],
- 10: ["#18c6ca", "#a3fe9a", "#d8feac", "#fffbc3", "#feee9b", "#f7d580", "#e3ce9b", "#ccc4b3", "#dad8d2", "#ffffff"],
- 11: ["#18c6ca", "#97fe96", "#cffea9", "#f7febb", "#fef5af", "#fed873", "#efd28b", "#dccaa4", "#c8c2b6", "#e1dfdb", "#ffffff"],
- 12: ["#18c6ca", "#97fe96", "#c5fea5", "#f0feb8", "#fef9bc", "#feee9b", "#f7d580", "#e7cf96", "#d8c9a8", "#c4c1b9", "#e1dfdb", "#ffffff"]
- },
- Simple: {
- 3: ["#000000", "#7fff00", "#bf7f3f"],
- 4: ["#000000", "#38ff38", "#ffd400", "#bf7f3f"],
- 5: ["#000000", "#7fff7f", "#7fff00", "#ff9f00", "#bf7f3f"],
- 6: ["#000000", "#aaffaa", "#00ff00", "#ffff00", "#ff7f00", "#bf7f3f"],
- 7: ["#000000", "#8dd48d", "#38ff38", "#7fff00", "#ffd400", "#f47f0a", "#bf7f3f"]
- }
-};
-
-import assign from 'object-assign';
-
-export default assign({}, require("colorbrewer"), extendColorBrewer);
diff --git a/web/client/components/style/EqualIntervalComponents/__tests__/ColorRampItem-test.jsx b/web/client/components/style/EqualIntervalComponents/__tests__/ColorRampItem-test.jsx
deleted file mode 100644
index 2c503c8b91..0000000000
--- a/web/client/components/style/EqualIntervalComponents/__tests__/ColorRampItem-test.jsx
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright 2019, 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 expect from 'expect';
-import React from 'react';
-import ReactDOM from 'react-dom';
-
-import ColorRampItem from '../ColorRampItem';
-
-describe("Test the ColorRampItem", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates colorRamp with defaults', () => {
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- const colorRamp = container.querySelector('.color-ramp-item');
- expect(colorRamp).toExist();
- });
- it('ColorRampItem with string item equal to blue', () => {
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- const colorRamp = container.querySelector('.colorname-cell');
- expect(colorRamp.innerHTML).toEqual('blue');
- });
- it('ColorRampItem with object item contain name', () => {
- const color = 'global.colors.blue';
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- const colorRamp = container.querySelector('span');
- expect(colorRamp.innerHTML).toEqual(color);
- });
- it('ColorRampItem with object item contain label', () => {
- const name = 'blue';
- const label = 'global.colors.blue';
- ReactDOM.render(, document.getElementById("container"));
- const container = document.getElementById('container');
- const colorRamp = container.querySelector('span');
- expect(colorRamp.innerHTML).toEqual(label);
- });
-});
diff --git a/web/client/components/style/MarkerPropertyPicker.jsx b/web/client/components/style/MarkerPropertyPicker.jsx
deleted file mode 100644
index 109862ab80..0000000000
--- a/web/client/components/style/MarkerPropertyPicker.jsx
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2020, 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 PropTypes from 'prop-types';
-import Popover from '../styleeditor/Popover';
-function MarkerPropertyPicker({
- disabled,
- containerNode,
- onOpen,
- placement,
- children,
- triggerNode
-}) {
-
- const disabledClassName = disabled ? ' ms-disabled' : '';
-
- return (
- onOpen(isOpen)}
- content={
-
- {children}
-
- }
- >
-
-
- );
-}
-
-MarkerPropertyPicker.propTypes = {
- value: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.shape({r: PropTypes.number, g: PropTypes.number, b: PropTypes.number, a: PropTypes.number})
- ]),
- format: PropTypes.string,
- onChangeColor: PropTypes.func,
- text: PropTypes.string,
- line: PropTypes.bool,
- disabled: PropTypes.bool,
- pickerProps: PropTypes.object,
- containerNode: PropTypes.node,
- onOpen: PropTypes.function,
- placement: PropTypes.string
-};
-
-MarkerPropertyPicker.defaultProps = {
- disabled: false,
- line: false,
- onChangeColor: () => {},
- pickerProps: {},
- onOpen: () => {}
-};
-
-export default MarkerPropertyPicker;
diff --git a/web/client/components/style/OpacityPicker.jsx b/web/client/components/style/OpacityPicker.jsx
deleted file mode 100644
index 3b2538a791..0000000000
--- a/web/client/components/style/OpacityPicker.jsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import PropTypes from 'prop-types';
-
-/**
- * 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.
- */
-
-import React from 'react';
-
-import Slider from 'react-nouislider';
-import 'react-nouislider/example/nouislider.css';
-import './opacitypicker.css';
-
-class OpacityPicker extends React.Component {
- static propTypes = {
- opacity: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
- onChange: PropTypes.func,
- disabled: PropTypes.bool
- };
-
- static defaultProps = {
- opacity: "1",
- onChange: () => {},
- disabled: false
- };
-
- render() {
- return (
-
- this.props.onChange("opacity", (v / 100).toFixed(2))}
- connect="lower"
- tooltips={[ {
- to: function( value ) {
- return Math.round(value) + '%';
- }
- }
- ]}
- />
-
);
- }
-}
-
-export default OpacityPicker;
diff --git a/web/client/components/style/PolygonStyler.jsx b/web/client/components/style/PolygonStyler.jsx
deleted file mode 100644
index d16aedaaa7..0000000000
--- a/web/client/components/style/PolygonStyler.jsx
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-import React from 'react';
-import assign from 'object-assign';
-import { Grid, Row, Col } from 'react-bootstrap';
-import ColorSelector from './ColorSelector';
-import StyleCanvas from './StyleCanvas';
-import Slider from 'react-nouislider';
-import numberLocalizer from 'react-widgets/lib/localizers/simple-number';
-numberLocalizer();
-import Message from '../I18N/Message';
-import { isNil } from 'lodash';
-import tinycolor from 'tinycolor2';
-
-class StylePolygon extends React.Component {
- static propTypes = {
- shapeStyle: PropTypes.object,
- width: PropTypes.number,
- setStyleParameter: PropTypes.func
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- shapeStyle: {},
- setStyleParameter: () => {}
- };
-
- render() {
- const styleType = !!this.props.shapeStyle.MultiPolygon ? "MultiPolygon" : "Polygon";
- const otherStyleType = !this.props.shapeStyle.MultiPolygon ? "MultiPolygon" : "Polygon";
- const style = this.props.shapeStyle[styleType] || this.props.shapeStyle; // in case of old version of style.
- return (
-
-
-
-
-
-
-
-
-
-
-
-
- {
- if (!isNil(c)) {
- const fillColor = tinycolor(c).toHexString();
- const fillOpacity = c.a;
- const newStyle = assign({}, this.props.shapeStyle, {
- [styleType]: assign({}, style, {fillColor, fillOpacity}),
- [otherStyleType]: assign({}, style, {fillColor, fillOpacity})
- });
- this.props.setStyleParameter(newStyle);
- }
- }}/>
-
-
-
-
-
-
-
- {
- if (!isNil(c)) {
- const color = tinycolor(c).toHexString();
- const opacity = c.a;
- const newStyle = assign({}, this.props.shapeStyle, {
- [styleType]: assign({}, style, {color, opacity}),
- [otherStyleType]: assign({}, style, {color, opacity})
- });
- this.props.setStyleParameter(newStyle);
- }
- }}/>
-
-
-
-
-
-
-
-
- Math.round(value),
- to: value => Math.round(value) + ' px'
- }}
- range={{min: 1, max: 15}}
- onChange={(values) => {
- const weight = parseInt(values[0].replace(' px', ''), 10);
- const newStyle = assign({}, this.props.shapeStyle, {
- [styleType]: assign({}, style, {weight}),
- [otherStyleType]: assign({}, style, {weight})
- });
- this.props.setStyleParameter(newStyle);
- }}
- />
-
-
-
- );
- }
- addOpacityToColor = (color, opacity) => {
- return assign({}, color, {
- a: opacity
- });
- }
-}
-
-export default StylePolygon;
diff --git a/web/client/components/style/PolylineStyler.jsx b/web/client/components/style/PolylineStyler.jsx
deleted file mode 100644
index 50e3757ccd..0000000000
--- a/web/client/components/style/PolylineStyler.jsx
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-import React from 'react';
-import { Grid, Row, Col } from 'react-bootstrap';
-import assign from 'object-assign';
-import ColorSelector from './ColorSelector';
-import StyleCanvas from './StyleCanvas';
-import Slider from 'react-nouislider';
-import numberLocalizer from 'react-widgets/lib/localizers/simple-number';
-numberLocalizer();
-import Message from '../I18N/Message';
-import { isNil } from 'lodash';
-import tinycolor from 'tinycolor2';
-
-class StylePolyline extends React.Component {
- static propTypes = {
- width: PropTypes.number,
- shapeStyle: PropTypes.object,
- setStyleParameter: PropTypes.func
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- shapeStyle: {},
- setStyleParameter: () => {}
- };
-
- render() {
- const styleType = !!this.props.shapeStyle.MultiLineString ? "MultiLineString" : "LineString";
- const otherStyleType = !this.props.shapeStyle.MultiLineString ? "MultiLineString" : "LineString";
- const style = this.props.shapeStyle[styleType];
- return (
-
-
-
-
-
-
-
-
-
-
-
-
- {
- if (!isNil(c)) {
- const color = tinycolor(c).toHexString();
- const opacity = c.a;
- const newStyle = assign({}, this.props.shapeStyle, {
- [styleType]: assign({}, style, {color, opacity}),
- [otherStyleType]: assign({}, style, {color, opacity})
- });
- this.props.setStyleParameter(newStyle);
- }
- }}/>
-
-
-
-
-
-
-
-
- Math.round(value),
- to: value => Math.round(value) + ' px'
- }}
- range={{min: 1, max: 15}}
- onChange={(values) => {
- const weight = parseInt(values[0].replace(' px', ''), 10);
- const newStyle = assign({}, this.props.shapeStyle, {
- [styleType]: assign({}, style, {weight}),
- [otherStyleType]: assign({}, style, {weight})
- });
- this.props.setStyleParameter(newStyle);
- }}
- />
-
-
-
- );
- }
- addOpacityToColor = (color, opacity) => {
- return assign({}, color, {
- a: opacity
- });
- }
-}
-
-export default StylePolyline;
diff --git a/web/client/components/style/PseudoColorSettings.jsx b/web/client/components/style/PseudoColorSettings.jsx
deleted file mode 100644
index 191b79ef70..0000000000
--- a/web/client/components/style/PseudoColorSettings.jsx
+++ /dev/null
@@ -1,108 +0,0 @@
-
-/**
- * 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.
- */
-
-import PropTypes from 'prop-types';
-import React from 'react';
-import { Grid, Row, Col} from 'react-bootstrap';
-import { Combobox } from 'react-widgets';
-
-import Button from '../misc/Button';
-import ColorMapGrid from './ColorMapGrid';
-import Message from '../I18N/Message';
-
-class PseudoColorSettings extends React.Component {
- static propTypes = {
- type: PropTypes.oneOf(['ramp', 'intervals', 'values']),
- opacity: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
- selected: PropTypes.number,
- colorMapEntry: PropTypes.array,
- onChange: PropTypes.func,
- extended: PropTypes.bool
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- type: 'ramp',
- opacity: "1",
- selected: null,
- colorMapEntry: [],
- onChange: () => {},
- extended: false
- };
-
- render() {
- return (
-
-
-
-
-
-
-
- this.props.onChange("type", v)} />
-
-
- this.props.onChange("extended", e.target.checked)} checked={this.props.extended} />
-
-
-
-
-
- this.props.onChange("colorMapEntry", colorMap)}
- entries={this.props.colorMapEntry}/>
-
-
-
-
-
-
-
-
-
-
-
-
- );
- }
-
- addEntry = () => {
- let colorMapEntry = this.props.colorMapEntry ? this.props.colorMapEntry.slice() : [];
- let quantity = colorMapEntry.length > 0 ? colorMapEntry[colorMapEntry.length - 1].quantity + 0.01 : 0;
- let label = quantity.toFixed ? quantity.toFixed(2) : quantity;
- colorMapEntry.push({color: '#AA34FF', quantity: quantity, label: label });
- this.props.onChange("colorMapEntry", colorMapEntry);
- };
-
- removeEntry = () => {
- let colorMapEntry = this.props.colorMapEntry.filter((e, idx) => {
- return idx !== this.props.selected;
- });
- this.props.onChange("selected", null);
- this.props.onChange("colorMapEntry", colorMapEntry);
- };
-
- selectEntry = (id) => {
- if ( id !== this.props.selected) {
- this.props.onChange("selected", id);
- }
- };
-}
-
-export default PseudoColorSettings;
diff --git a/web/client/components/style/RasterStyleTypePicker.jsx b/web/client/components/style/RasterStyleTypePicker.jsx
deleted file mode 100644
index 2ab2610588..0000000000
--- a/web/client/components/style/RasterStyleTypePicker.jsx
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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.
- */
-
-import React from 'react';
-
-import { Combobox } from 'react-widgets';
-import PropTypes from 'prop-types';
-import { getMessageById } from '../../utils/LocaleUtils';
-
-class RasterStyleTypePicker extends React.Component {
- static propTypes = {
- styletype: PropTypes.oneOf(['rgb', 'gray', 'pseudo']),
- onChange: PropTypes.func
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- render() {
- return (
- this.props.onChange("styletype", v.value)}
- value={this.props.styletype} />
- );
- }
-}
-
-export default RasterStyleTypePicker;
diff --git a/web/client/components/style/ScaleDenominator.jsx b/web/client/components/style/ScaleDenominator.jsx
deleted file mode 100644
index 3f59de5317..0000000000
--- a/web/client/components/style/ScaleDenominator.jsx
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * 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.
- */
-
-import React from 'react';
-
-import PropTypes from 'prop-types';
-import { getGoogleMercatorScales } from '../../utils/MapUtils';
-import { findDOMNode } from 'react-dom';
-import { DropdownList } from 'react-widgets';
-import { Row, Col, Overlay, Popover, Label } from 'react-bootstrap';
-import { getMessageById } from '../../utils/LocaleUtils';
-import Message from '../I18N/Message';
-
-class ScaleDenominator extends React.Component {
- static propTypes = {
- minValue: PropTypes.number,
- maxValue: PropTypes.number,
- onChange: PropTypes.func.isRequired
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- minValue: null,
- maxValue: null,
- onChange: () => null
- };
-
- state = {error: false};
-
- UNSAFE_componentWillMount() {
- let scales = getGoogleMercatorScales(0, 21);
- this.scales = [{value: null, text: getMessageById(this.context.messages, "scaledenominator.none") || 'None'}, ...scales.map((v) => ({value: v, text: `${v.toFixed(0)}`}))];
- }
-
- onChange = (t, {value: v}) => {
- if (t === 'minDenominator' && this.props.maxValue && v >= this.props.maxValue) {
- this.setState({error: {type: t, msg: "scaledenominator.minerror"}});
- } else if (t === 'maxDenominator' && this.props.minValue && v <= this.props.minValue) {
- this.setState({error: {type: t, msg: "scaledenominator.maxerror"}});
- } else {
- if (this.state.error) {
- this.setState({error: false});
- }
- this.props.onChange(t, v);
- }
- };
-
- renderErrorPopOver = () => {
- return (
- findDOMNode(this.refs[this.state.error.type])}
- show placement="top" >
-
-
-
-
- );
- };
-
- render() {
- return (
-
-
- this.onChange("minDenominator", v)}
- />
-
-
-
- this.onChange("maxDenominator", v)}
- />
-
- {(this.state.error) ? this.renderErrorPopOver() : null}
-
)
- ;
- }
-}
-
-export default ScaleDenominator;
diff --git a/web/client/components/style/TextStyler.jsx b/web/client/components/style/TextStyler.jsx
deleted file mode 100644
index 67bc560ec6..0000000000
--- a/web/client/components/style/TextStyler.jsx
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-import { Grid, Row, Col } from 'react-bootstrap';
-import { Combobox } from 'react-widgets';
-import assign from 'object-assign';
-import ColorSelector from './ColorSelector';
-import StyleCanvas from './StyleCanvas';
-import numberLocalizer from 'react-widgets/lib/localizers/simple-number';
-numberLocalizer();
-import { getMessageById } from '../../utils/LocaleUtils';
-import { createFont } from '../../utils/LegacyAnnotationsUtils';
-import Message from '../I18N/Message';
-import tinycolor from 'tinycolor2';
-import IntlNumberFormControl from '../I18N/IntlNumberFormControl';
-
-class TextStyler extends React.Component {
- static propTypes = {
- width: PropTypes.number,
- uomValues: PropTypes.array,
- alignValues: PropTypes.array,
- fontStyleValues: PropTypes.array,
- fontWeightValues: PropTypes.array,
- fontFamilyValues: PropTypes.array,
- shapeStyle: PropTypes.object,
- setStyleParameter: PropTypes.func,
- styleType: PropTypes.String
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- styleType: "Text",
- uomValues: [{value: "px"}, {value: "em"}],
- fontWeightValues: [{value: "normal"}, {value: "bold"}],
- alignValues: [{value: "start", label: "left"}, {value: "center", label: "center"}, {value: "end", label: "right"}],
- fontStyleValues: [{value: "normal"}, {value: "italic"}],
- fontFamilyValues: [{value: "Arial"}, {value: "Helvetica"}, {value: "sans-serif"}, {value: "Courier"}],
- shapeStyle: {},
- setStyleParameter: () => {}
- };
-
- state = {
- fontFamily: "Arial"
- };
-
- render() {
- const messages = {
- emptyList: getMessageById(this.context.messages, "queryform.attributefilter.autocomplete.emptyList"),
- open: getMessageById(this.context.messages, "queryform.attributefilter.autocomplete.open"),
- emptyFilter: getMessageById(this.context.messages, "queryform.attributefilter.autocomplete.emptyFilter")
- };
- const {styleType, shapeStyle} = this.props;
- const style = shapeStyle[styleType];
- return (
-
-
-
- {}
-
-
-
-
-
-
-
-
- {
- const color = tinycolor(c).toHexString();
- const opacity = c.a;
- const newStyle = assign({}, shapeStyle, {
- [styleType]: assign({}, style, {color, opacity})
- });
- this.props.setStyleParameter(newStyle);
- }}/>
-
-
-
-
-
-
-
- {
- let fontFamily = e.value ? e.value : e;
- if (fontFamily === "") {
- fontFamily = "Arial";
- }
- this.setState({fontFamily});
- const font = createFont({...style, fontFamily});
- const newStyle = assign({}, shapeStyle, {
- [styleType]: assign({}, style, {fontFamily, font})
- });
- this.props.setStyleParameter(newStyle);
- }}
- />
-
-
-
-
-
-
-
- {
- const fontSize = val;
- const font = createFont({...style, fontSize});
- const newStyle = assign({}, shapeStyle, {
- [styleType]: assign({}, style, {fontSize, font})
- });
- this.props.setStyleParameter(newStyle);
- }}
- type="number"/>
-
-
- {
- let fontSizeUom = e.value ? e.value : e;
- if (this.props.uomValues.map(f => f.value).indexOf(fontSizeUom) === -1) {
- fontSizeUom = "px";
- }
- const font = createFont({...style, fontSizeUom});
- const newStyle = assign({}, shapeStyle, {
- [styleType]: assign({}, style, {fontSizeUom, font})
- });
- this.props.setStyleParameter(newStyle);
- }}
- />
-
-
-
-
-
-
-
- {
- let textAlign = e.value ? e.value : e;
- if (this.props.alignValues.map(f => f.value).indexOf(textAlign) === -1) {
- textAlign = "center";
- }
- const newStyle = assign({}, shapeStyle, {
- [styleType]: assign({}, style, {textAlign})
- });
- this.props.setStyleParameter(newStyle);
- }}
- />
-
-
-
-
-
-
-
- {
- let fontStyle = e.value ? e.value : e;
- if (this.props.fontStyleValues.map(f => f.value).indexOf(fontStyle) === -1) {
- fontStyle = style.fontStyle;
- }
- const font = createFont({...style, fontStyle});
- const newStyle = assign({}, shapeStyle, {
- [styleType]: assign({}, style, {fontStyle, font})
- });
- this.props.setStyleParameter(newStyle);
- }}
- />
-
-
-
-
-
-
-
- {
- let fontWeight = e.value ? e.value : e;
- if (this.props.fontWeightValues.map(f => f.value).indexOf(fontWeight) === -1) {
- fontWeight = style.fontWeight;
- }
- const font = createFont({...style, fontWeight});
- const newStyle = assign({}, shapeStyle, {
- [styleType]: assign({}, style, {fontWeight, font})
- });
- this.props.setStyleParameter(newStyle);
- }}
- />
-
-
- );
- }
- addOpacityToColor = (color, opacity) => {
- return assign({}, color, {
- a: opacity
- });
- }
-}
-
-export default TextStyler;
diff --git a/web/client/components/style/__tests__/BandSelector-test.jsx b/web/client/components/style/__tests__/BandSelector-test.jsx
deleted file mode 100644
index f582a69472..0000000000
--- a/web/client/components/style/__tests__/BandSelector-test.jsx
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import BandSelector from '../BandSelector';
-
-describe("Test the BandSelector component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates component with defaults', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- cmp.props.onChange();
- });
-
- it('creates component contrast', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
- it('creates component algorithm', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
-
-});
diff --git a/web/client/components/style/__tests__/ColorMapGrid-test.jsx b/web/client/components/style/__tests__/ColorMapGrid-test.jsx
deleted file mode 100644
index b7c0adb0a2..0000000000
--- a/web/client/components/style/__tests__/ColorMapGrid-test.jsx
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import ColorMap from '../ColorMapGrid';
-
-describe("Test the ColorMap component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates component with defaults', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
-
- it('creates component with element', (done) => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- cmp.selectEntry({node: {childIndex: 0}});
- setTimeout(() => {
- cmp.valueChanged();
- done();
- }, 0);
- });
-
-});
diff --git a/web/client/components/style/__tests__/EqualInterval-test.jsx b/web/client/components/style/__tests__/EqualInterval-test.jsx
deleted file mode 100644
index 3f92bb353e..0000000000
--- a/web/client/components/style/__tests__/EqualInterval-test.jsx
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import EqualInterval from '../EqualInterval';
-
-describe("Test the EqualInterval component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates component with defaults', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- cmp.generateEqualIntervalRamp();
- cmp.props.onChange();
- });
-
-});
diff --git a/web/client/components/style/__tests__/OpacityPicker-test.jsx b/web/client/components/style/__tests__/OpacityPicker-test.jsx
deleted file mode 100644
index 293865afb3..0000000000
--- a/web/client/components/style/__tests__/OpacityPicker-test.jsx
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import OpacityPicker from '../OpacityPicker';
-
-describe("Test the OpacityPicker component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates component with defaults', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
-
-});
diff --git a/web/client/components/style/__tests__/PseudoColorSettings-test.jsx b/web/client/components/style/__tests__/PseudoColorSettings-test.jsx
deleted file mode 100644
index 43a7d60bb6..0000000000
--- a/web/client/components/style/__tests__/PseudoColorSettings-test.jsx
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import PseudoColorSettings from '../PseudoColorSettings';
-
-describe("Test the PseudoColorSettings component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates component with defaults', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
-
- it('creates component add entry', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- cmp.addEntry();
- });
- it('creates component remove entry', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- cmp.removeEntry();
- cmp.selectEntry(2);
- });
-
-});
diff --git a/web/client/components/style/__tests__/RasterStyleTypePicker-test.jsx b/web/client/components/style/__tests__/RasterStyleTypePicker-test.jsx
deleted file mode 100644
index dfaa5f2692..0000000000
--- a/web/client/components/style/__tests__/RasterStyleTypePicker-test.jsx
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import RasterStyleTypePicker from '../RasterStyleTypePicker';
-
-describe("Test the RasterStyleTypePicker component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('creates component with defaults', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
-
-});
diff --git a/web/client/components/style/__tests__/ScaleDenominator-test.jsx b/web/client/components/style/__tests__/ScaleDenominator-test.jsx
deleted file mode 100644
index 3bcc501149..0000000000
--- a/web/client/components/style/__tests__/ScaleDenominator-test.jsx
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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.
- */
-import expect from 'expect';
-
-import React from 'react';
-import ReactDOM from 'react-dom';
-import ScaleDenominator from '../ScaleDenominator';
-
-describe('ScaleDenominator', () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
- it('create component with defaults', () => {
- const sb = ReactDOM.render(, document.getElementById("container"));
- expect(sb).toExist();
- const domNode = ReactDOM.findDOMNode(sb);
- expect(domNode).toExist();
-
- const comboItems = sb.scales;
- expect(comboItems.length).toBe(23);
- sb.onChange("minDenominator", {value: 1000});
- sb.onChange("minDenominator", {value: 100000});
- sb.onChange("maxDenominator", {value: 100});
- });
-});
diff --git a/web/client/components/style/opacitypicker.css b/web/client/components/style/opacitypicker.css
deleted file mode 100644
index eeda0d82a0..0000000000
--- a/web/client/components/style/opacitypicker.css
+++ /dev/null
@@ -1,22 +0,0 @@
-.opacity-picker .noUi-tooltip {
- display: block;
- position: absolute;
- border: 1px solid #D9D9D9;
- border-radius: 3px;
- background: #fff;
- padding: 5px;
- left: -1px;
- text-align: center;
- width: 34px;
- font-style: normal;
- font-variant: normal;
- font-weight: 700;
- font-stretch: normal;
- font-size: 10px;
- line-height: 12px;
- font-family: Arial;
- }
-
-.opacity-picker .noUi-handle-lower .noUi-tooltip {
- top: 28px;
-}
diff --git a/web/client/components/style/thumbGeoms/CircleThumb.jsx b/web/client/components/style/thumbGeoms/CircleThumb.jsx
deleted file mode 100644
index 43f3e55c85..0000000000
--- a/web/client/components/style/thumbGeoms/CircleThumb.jsx
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-class CircleThumb extends React.Component {
-
- static propTypes = {
- linecap: PropTypes.string,
- linejoin: PropTypes.string,
- stroke: PropTypes.string,
- fillColor: PropTypes.string,
- strokeWidth: PropTypes.number,
- styleRect: PropTypes.object
- };
-
- static defaultProps = {
- styleRect: {},
- linecap: 'round', // butt round square
- linejoin: 'round', // miter round bevel
- strokeWidth: 3,
- stroke: '#ffcc33',
- fillColor: '#FFFFFF'
- };
-
- render() {
- const {color, weight, fillColor} = this.props.styleRect;
- return (
-
- );
- }
-}
-
-export default CircleThumb;
diff --git a/web/client/components/style/thumbGeoms/LineThumb.jsx b/web/client/components/style/thumbGeoms/LineThumb.jsx
deleted file mode 100644
index 57a004c907..0000000000
--- a/web/client/components/style/thumbGeoms/LineThumb.jsx
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-class LineThumb extends React.Component {
-
- static propTypes = {
- linecap: PropTypes.string,
- linejoin: PropTypes.string,
- stroke: PropTypes.string,
- fillColor: PropTypes.string,
- strokeWidth: PropTypes.number,
- style: PropTypes.object
- };
-
- static defaultProps = {
- style: {},
- linecap: 'round', // butt round square
- linejoin: 'round', // miter round bevel
- strokeWidth: 3,
- stroke: '#ffcc33',
- fillColor: '#FFFFFF'
- };
-
- render() {
- const {color, weight, fillColor} = this.props.style;
- return (
-
- );
- }
-}
-
-export default LineThumb;
diff --git a/web/client/components/style/thumbGeoms/MultiGeomThumb.jsx b/web/client/components/style/thumbGeoms/MultiGeomThumb.jsx
deleted file mode 100644
index 08ca532679..0000000000
--- a/web/client/components/style/thumbGeoms/MultiGeomThumb.jsx
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-import markerIcon from '../../map/openlayers/img/marker-icon.png';
-
-class MultiGeomThumb extends React.Component {
-
- static propTypes = {
- linecap: PropTypes.string,
- linejoin: PropTypes.string,
- stroke: PropTypes.string,
- strokeWidth: PropTypes.number,
- styleMultiGeom: PropTypes.object,
- geometry: PropTypes.object,
- properties: PropTypes.object
- };
-
- static defaultProps = {
- linecap: 'round', // butt round square
- linejoin: 'round', // miter round bevel
- stroke: '#ffcc33',
- strokeWidth: 3,
- styleMultiGeom: {},
- geometry: {
- features: []
- },
- properties: {}
- };
-
- getGeoms() {
- return this.props.geometry && this.props.geometry.features.reduce((p, c) => {
- if (c.properties && c.properties.isCircle) {
- return {...p, "Circle": true};
- }
- if (c.properties && c.properties.isText) {
- return {...p, "Text": true};
- }
- return {...p, [c.geometry.type]: true};
- }, {"Circle": false, "Text": false});
- }
- render() {
- let geoms = this.getGeoms();
- const stroke = {color: "#ffcc33", opacity: 1, weight: 2 };
- const fill = {fillColor: "#FFFFFF", fillOpacity: 0 };
- let textPresent = geoms.Text;
- let circlePresent = geoms.Circle;
- let polygonPresent = geoms.Polygon || geoms.MultiPolygon;
- let lineStringPresent = geoms.LineString || geoms.MultiLineString;
- let pointPresent = geoms.Point || geoms.MultiPoint; // this can be a symbol tho..
-
- let styleLine = {...stroke};
- let stylePolygon = {...stroke, ...fill};
- let styleCircle = {...stroke, ...fill};
- let styleText = textPresent ? {
- fontStyle: 'normal',
- fontSize: '14',
- fontSizeUom: 'px',
- fontFamily: 'Arial',
- fontWeight: 'normal',
- font: "14px Arial",
- textAlign: 'center',
- ...stroke, ...fill} : {};
- return (
-
-
- {pointPresent &&
}
-
- );
- }
-}
-
-export default MultiGeomThumb;
diff --git a/web/client/components/style/thumbGeoms/PolygonThumb.jsx b/web/client/components/style/thumbGeoms/PolygonThumb.jsx
deleted file mode 100644
index 085d10df15..0000000000
--- a/web/client/components/style/thumbGeoms/PolygonThumb.jsx
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-class PolygonThumb extends React.Component {
-
- static propTypes = {
- stroke: PropTypes.string,
- fill: PropTypes.string,
- fillOpacity: PropTypes.number,
- strokeWidth: PropTypes.number,
- opacity: PropTypes.number,
- styleRect: PropTypes.object,
- viewBox: PropTypes.string,
- rectParams: PropTypes.object
- };
-
- static defaultProps = {
- stroke: '#ffcc33',
- fill: '#FFFFFF',
- fillOpacity: 0.2,
- strokeWidth: 3,
- opacity: 1,
- styleRect: {},
- viewBox: "0 0 100 100",
- rectParams: {
- height: "50",
- width: "50",
- x: "25",
- y: "25"
- }
- };
-
- render() {
- const {color, weight, fillColor, fillOpacity, opacity} = this.props.styleRect;
- const {height, width, x, y} = this.props.rectParams;
- return (
-
-
-
- );
- }
-}
-
-export default PolygonThumb;
diff --git a/web/client/components/style/thumbGeoms/__tests__/LineThumb-test.js b/web/client/components/style/thumbGeoms/__tests__/LineThumb-test.js
deleted file mode 100644
index 77011584ee..0000000000
--- a/web/client/components/style/thumbGeoms/__tests__/LineThumb-test.js
+++ /dev/null
@@ -1,40 +0,0 @@
-import expect from 'expect';
-import React from 'react';
-import ReactDOM from 'react-dom';
-import TestUtils from 'react-dom/test-utils';
-
-import {DEFAULT_ANNOTATIONS_STYLES} from '../../../../plugins/Annotations/utils/AnnotationsUtils';
-import LineThumb from '../LineThumb';
-
-describe("Test the LineThumb component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('create component with default', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
- it('create component with default style from annotation utils', () => {
- const style = DEFAULT_ANNOTATIONS_STYLES.LineString;
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- const path = TestUtils.findRenderedDOMComponentWithTag(cmp, 'path');
- expect(path).toExist();
- expect(path.attributes.d.value).toBe("M25 75 L50 50 L75 75 L100 75");
- expect(path.attributes["stroke-linecap"].value).toBe("round");
- expect(path.attributes["stroke-linejoin"].value).toBe("round");
- expect(path.attributes["stroke-width"].value).toBe(style.weight.toString());
- expect(path.attributes.stroke.value).toBe(style.color.toString());
-
- });
-
-
-});
diff --git a/web/client/components/style/thumbGeoms/__tests__/MultiGeomThumb-test.js b/web/client/components/style/thumbGeoms/__tests__/MultiGeomThumb-test.js
deleted file mode 100644
index 15dfba7b1a..0000000000
--- a/web/client/components/style/thumbGeoms/__tests__/MultiGeomThumb-test.js
+++ /dev/null
@@ -1,81 +0,0 @@
-import expect from 'expect';
-import React from 'react';
-import ReactDOM from 'react-dom';
-import TestUtils from 'react-dom/test-utils';
-
-import {DEFAULT_ANNOTATIONS_STYLES} from '../../../../utils/LegacyAnnotationsUtils';
-import MultiGeomThumb from '../MultiGeomThumb';
-
-describe("Test the MultiGeomThumb component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('create component with default', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
- it('create component with only Polygon', () => {
- const style = DEFAULT_ANNOTATIONS_STYLES;
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- const rect = TestUtils.findRenderedDOMComponentWithTag(cmp, 'rect');
- const svg = TestUtils.findRenderedDOMComponentWithTag(cmp, 'svg');
- expect(rect).toExist();
- const path = TestUtils.scryRenderedDOMComponentsWithTag(cmp, 'path');
- expect(path.length).toBe(0);
- expect(rect.attributes.width.value).toBe("50");
- expect(rect.attributes.height.value).toBe("50");
- expect(rect.attributes.x.value).toBe("20");
- expect(rect.attributes.y.value).toBe("15");
- expect(svg.attributes.xmlns.value).toBe("http://www.w3.org/2000/svg");
- expect(svg.attributes.viewBox.value).toBe("0 0 100 100");
-
- });
- it('create component with only MultiPolygon LineString', () => {
-
- const stroke = {color: "#ffcc33", opacity: 1, weight: 2 };
- const fill = {fillColor: "#FFFFFF", fillOpacity: 0 };
- const style = {...stroke, ...fill};
-
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- const rect = TestUtils.findRenderedDOMComponentWithTag(cmp, 'rect');
-
- const svg = TestUtils.findRenderedDOMComponentWithTag(cmp, 'svg');
- expect(rect).toExist();
- expect(rect.attributes.width.value).toBe("50");
- expect(rect.attributes.height.value).toBe("50");
- expect(rect.attributes.x.value).toBe("40");
- expect(rect.attributes.y.value).toBe("15");
- expect(svg.attributes.xmlns.value).toBe("http://www.w3.org/2000/svg");
- expect(svg.attributes.viewBox.value).toBe("0 0 100 100");
-
- });
- it('create component with only Circle', () => {
- const style = DEFAULT_ANNOTATIONS_STYLES;
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- const circle = TestUtils.findRenderedDOMComponentWithTag(cmp, 'circle');
-
- expect(circle).toExist();
- expect(circle.attributes.cx.value).toBe("50");
- expect(circle.attributes.cy.value).toBe("50");
- expect(circle.attributes.r.value).toBe("25");
- expect(circle.attributes.stroke.value).toBe("#ffcc33");
- expect(circle.attributes.fill.value).toBe("#FFFFFF");
- expect(circle.attributes.opacity.value).toBe("1");
- expect(circle.attributes["stroke-width"].value).toBe("2");
- expect(circle.attributes["fill-opacity"].value).toBe("0");
-
- });
-
-
-});
diff --git a/web/client/components/style/thumbGeoms/__tests__/PolygonThumb-test.js b/web/client/components/style/thumbGeoms/__tests__/PolygonThumb-test.js
deleted file mode 100644
index 93691d931f..0000000000
--- a/web/client/components/style/thumbGeoms/__tests__/PolygonThumb-test.js
+++ /dev/null
@@ -1,43 +0,0 @@
-import expect from 'expect';
-import React from 'react';
-import ReactDOM from 'react-dom';
-import TestUtils from 'react-dom/test-utils';
-
-import {DEFAULT_ANNOTATIONS_STYLES} from '../../../../plugins/Annotations/utils/AnnotationsUtils';
-import PolygonThumb from '../PolygonThumb';
-
-describe("Test the PolygonThumb component", () => {
- beforeEach((done) => {
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- afterEach((done) => {
- ReactDOM.unmountComponentAtNode(document.getElementById("container"));
- document.body.innerHTML = '';
- setTimeout(done);
- });
-
- it('create component with default', () => {
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- });
- it('create component with default style from annotation utils', () => {
- const style = DEFAULT_ANNOTATIONS_STYLES;
- const featureType = "MultiPolygon";
- const cmp = ReactDOM.render(, document.getElementById("container"));
- expect(cmp).toExist();
- const rect = TestUtils.findRenderedDOMComponentWithTag(cmp, 'rect');
- const svg = TestUtils.findRenderedDOMComponentWithTag(cmp, 'svg');
- expect(rect).toExist();
- expect(rect.attributes.width.value).toBe("50");
- expect(rect.attributes.height.value).toBe("50");
- expect(rect.attributes.x.value).toBe("25");
- expect(rect.attributes.y.value).toBe("25");
- expect(svg.attributes.xmlns.value).toBe("http://www.w3.org/2000/svg");
- expect(svg.attributes.viewBox.value).toBe("0 0 100 100");
-
- });
-
-
-});
diff --git a/web/client/components/style/vector/Fill.jsx b/web/client/components/style/vector/Fill.jsx
deleted file mode 100644
index 917114d6d4..0000000000
--- a/web/client/components/style/vector/Fill.jsx
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-import React from 'react';
-import { Row, Col } from 'react-bootstrap';
-import { isNil } from 'lodash';
-import tinycolor from 'tinycolor2';
-
-// number localizer?
-import numberLocalizer from 'react-widgets/lib/localizers/simple-number';
-
-// not sure this is needed, TODO check!
-numberLocalizer();
-
-import Message from '../../I18N/Message';
-import OpacitySlider from '../../../plugins/TOC/components/OpacitySlider';
-import ColorSelector from '../ColorSelector';
-import { addOpacityToColor } from '../../../utils/VectorStyleUtils';
-
-/**
- * Styler for the stroke properties of a vector style
-*/
-class Fill extends React.Component {
- static propTypes = {
- style: PropTypes.object,
- defaultColor: PropTypes.string,
- onChange: PropTypes.func,
- width: PropTypes.number
- };
-
- static defaultProps = {
- style: {},
- onChange: () => {}
- };
-
- render() {
- const {style} = this.props;
- return (
-
-
-
-
-
-
-
-
-
-
- {
- if (!isNil(c)) {
- const fillColor = tinycolor(c).toHexString();
- const fillOpacity = c.a;
- this.props.onChange(style.id, {fillColor, fillOpacity});
- }
- }}/>
-
-
-
-
-
-
-
- {
- this.props.onChange(style.id, {fillOpacity});
- }}/>
-
-
-
);
- }
-}
-
-export default Fill;
diff --git a/web/client/components/style/vector/Manager.jsx b/web/client/components/style/vector/Manager.jsx
deleted file mode 100644
index 1e072d1224..0000000000
--- a/web/client/components/style/vector/Manager.jsx
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright 2018, 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 axios from 'axios';
-import { castArray, filter, find, findIndex, isNil } from 'lodash';
-import assign from 'object-assign';
-import PropTypes from 'prop-types';
-import React from 'react';
-import { Grid } from 'react-bootstrap';
-import tinycolor from 'tinycolor2';
-import uuidv1 from 'uuid/v1';
-
-import { DEFAULT_PATH, DEFAULT_SHAPE, checkSymbolsError } from '../../../utils/LegacyAnnotationsUtils';
-import { arrayUpdate } from '../../../utils/ImmutableUtils';
-import {
- addOpacityToColor,
- createSvgUrl,
- fetchStyle,
- getStylerTitle,
- hashAndStringify,
- isFillStyle,
- isMarkerStyle,
- isStrokeStyle,
- isSymbolStyle,
- isTextStyle,
- registerStyle
-} from '../../../utils/VectorStyleUtils';
-import SwitchPanel from '../../misc/switch/SwitchPanel';
-import StyleCanvas from '../StyleCanvas';
-import Fill from './Fill';
-import MarkerGlyph from './marker/MarkerGlyph';
-import MarkerType from './marker/MarkerType';
-import SymbolLayout from './marker/SymbolLayout';
-import Stroke from './Stroke';
-import Text from './Text';
-
-class Manager extends React.Component {
- static propTypes = {
- style: PropTypes.object,
- switchPanelOptions: PropTypes.array,
- lineDashOptions: PropTypes.array,
- onChangeStyle: PropTypes.func,
- pointType: PropTypes.string,
- onUpdateSymbols: PropTypes.func,
- onSetErrorSymbol: PropTypes.func,
- width: PropTypes.number,
- symbolsPath: PropTypes.string,
- defaultShape: PropTypes.string,
- defaultShapeSize: PropTypes.number,
- defaultShapeFillColor: PropTypes.string,
- defaultShapeStrokeColor: PropTypes.string,
- defaultStyles: PropTypes.object,
- symbolList: PropTypes.array,
- symbolErrors: PropTypes.array,
- defaultSymbol: PropTypes.object,
- defaultMarker: PropTypes.object,
- markersOptions: PropTypes.object,
- textRotationStep: PropTypes.number
- };
-
- static defaultProps = {
- style: {},
- defaultShape: DEFAULT_SHAPE,
- symbolsPath: DEFAULT_PATH,
- defaultShapeSize: 64,
- defaultShapeFillColor: '#000000',
- defaultShapeStrokeColor: '#000000',
- symbolErrors: [],
- onChangeStyle: () => {},
- onUpdateSymbols: () => {},
- defaultStyles: {},
- switchPanelOptions: []
- };
-
- state = {}
-
-
- UNSAFE_componentWillMount() {
- // we assume that the default symbols shape is correctly configured
-
- const styles = castArray(this.props.style);
- const expanded = styles.map((s, i) => i === 0 || s.filtering );
- const locked = styles.map((s, i) => i === 0 );
- this.setState({expanded, locked});
- styles.filter(({type}) => type === 'Point').forEach(style => {
- this.checkSymbolUrl({...this.props, style});
- });
- }
-
- /**
- * it renders a switch panel styler
- * @prop {object} style
- * @prop {object} switchPanelOptions
- */
- renderPanelStyle = (style = {}, switchPanelOptions = {}, i) => {
-
- const stylerProps = {
- style,
- onChange: this.change,
- width: this.props.width
- };
-
- /* getting pieces to render in the styler
- // only for marker there is no preview
- // TODO move into separate functions the checks for showing the various pieces of styler
- */
- const isTextOrSymbol = isTextStyle(style) || isSymbolStyle(style);
- const preview = !(isMarkerStyle(style) || isSymbolStyle(style) && (checkSymbolsError(this.props.symbolErrors) ||
- checkSymbolsError(this.props.symbolErrors, "loading_symbol" + style.shape))) && (
-
-
);
- // TODO improve conditions to show the stroke and fill
- const stroke = isStrokeStyle(style) && isSymbolStyle(style) &&
- (checkSymbolsError(this.props.symbolErrors) ||
- checkSymbolsError(this.props.symbolErrors, "loading_symbol" + style.shape))
- ? null : isStrokeStyle(style) ? : null;
- const fill = isFillStyle(style) && isSymbolStyle(style) &&
- (checkSymbolsError(this.props.symbolErrors) ||
- checkSymbolsError(this.props.symbolErrors, "loading_symbol" + style.shape))
- ? null : isFillStyle(style) && || null;
- const text = isTextStyle(style) && || null;
- const markerType = (isMarkerStyle(style) || isSymbolStyle(style)) && || null;
- const markerGlyph = isMarkerStyle(style) && || null;
- const symbolLayout = isSymbolStyle(style) && (
- {
- this.props.onUpdateSymbols(symbols);
- }}
- options={this.props.symbolList}
- symbolErrors={this.props.symbolErrors}
- onLoadingError={this.props.onSetErrorSymbol}/>) || null;
- const separator =
;
-
- const sections = [markerType, preview, symbolLayout, markerGlyph, text, fill, stroke];
-
- return (
-
- {
- /* adding the separator between sections */
- sections.reduce((prev, curr, k) => [prev, prev && curr && {separator}, curr])
- }
-
- );
- }
-
- render() {
- const styles = castArray(this.props.style);
- return ({styles.map((style, i) => this.renderPanelStyle(
- {...style, id: style.id || uuidv1()},
- {
- expanded: this.state.expanded[i],
- locked: this.state.locked[i],
- onSwitch: () => {
- this.setState(() => {
- const expanded = this.state.expanded.map((e, k) => i === k ? !this.state.expanded[i] : this.state.expanded[k]);
- return {expanded};
- });
- let newStyles = styles.map((s, k) => k === i ? {...s, "filtering": !this.state.expanded[i]} : s);
- this.props.onChangeStyle(newStyles);
- },
- title: style.title || getStylerTitle(style) + " Style"},
- i))}
);
- }
- change = (id, values) => {
- const styles = castArray(this.props.style);
- let styleChanged = {...find(styles, { 'id': id }), ...values};
-
- if (isSymbolStyle(styleChanged)) {
- if (!fetchStyle(hashAndStringify(styleChanged))) {
- createSvgUrl(styleChanged, styleChanged.symbolUrl)
- .then(symbolUrlCustomized => {
- this.updateStyles(id, {...styleChanged, symbolUrlCustomized}, styles, true);
- });
- } else {
- this.updateStyles(id, fetchStyle(hashAndStringify(styleChanged)), styles, true);
- }
- } else {
- this.updateStyles(id, styleChanged, styles, true);
- }
- }
- updateStyles = (id, style, styles, register = true) => {
- if (register) {
- registerStyle(hashAndStringify(style), style);
- }
- let newStyles = arrayUpdate(false, style, { 'id': id }, styles );
- this.props.onChangeStyle(newStyles);
- }
- changeSymbolType = (id, pointType) => {
- this.updateStylesAndType(id, pointType, this.props.defaultStyles.POINT?.[pointType]);
- }
-
- updateStylesAndType = (id, pointType, pointStyle) => {
- const styles = castArray(this.props.style);
- const styleChangedIndex = findIndex(styles, { 'id': id});
- if (styleChangedIndex !== -1) {
- let newStyles = styles.map((s, k) => k === styleChangedIndex ? {...pointStyle, id: s.id, title: s.title, geometry: s.geometry, filtering: s.filtering} : s);
- this.props.onChangeStyle(newStyles);
- }
- }
- checkSymbolUrl = ({style, symbolErrors, onLoadingError = this.props.onSetErrorSymbol}) => {
- axios.get(style.symbolUrl)
- .then(() => {
- if (!checkSymbolsError(this.props.symbolErrors, "loading_symbol" + style.shape )) {
- const errors = filter(symbolErrors, s => s !== "loading_symbol" + style.shape);
- onLoadingError(errors);
- }
- })
- .catch(() => {
- if (!checkSymbolsError(this.props.symbolErrors, "loading_symbol" + style.shape )) {
- onLoadingError(symbolErrors.concat(["loading_symbol" + style.shape]));
- }
- });
- }
-}
-
-export default Manager;
diff --git a/web/client/components/style/vector/Stroke.jsx b/web/client/components/style/vector/Stroke.jsx
deleted file mode 100644
index dab70b50ab..0000000000
--- a/web/client/components/style/vector/Stroke.jsx
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-import React from 'react';
-import { Row, Col } from 'react-bootstrap';
-import { isNil, isEqual } from 'lodash';
-import tinycolor from 'tinycolor2';
-import Slider from 'react-nouislider';
-
-// number localizer?
-import numberLocalizer from 'react-widgets/lib/localizers/simple-number';
-
-// not sure this is needed, TODO check!
-numberLocalizer();
-import Message from '../../I18N/Message';
-import OpacitySlider from '../../../plugins/TOC/components/OpacitySlider';
-import ColorSelector from '../ColorSelector';
-import DashArray from './DashArray';
-import { addOpacityToColor } from '../../../utils/VectorStyleUtils';
-
-/**
- * Styler for the stroke properties of a vector style
-*/
-class Stroke extends React.Component {
- static propTypes = {
- style: PropTypes.object,
- defaultColor: PropTypes.string,
- lineDashOptions: PropTypes.array,
- onChange: PropTypes.func,
- width: PropTypes.number,
- constraints: PropTypes.object
- };
-
- static defaultProps = {
- style: {},
- constraints: {
- maxWidth: 15,
- minWidth: 1
- },
- onChange: () => {}
- };
-
- shouldComponentUpdate(nextProps) {
- return !isEqual(this.props.style, nextProps.style)
- || !isEqual(this.props.lineDashOptions, nextProps.lineDashOptions);
- }
- render() {
- const {style} = this.props;
- return (
-
-
-
-
-
-
-
-
-
-
- {
- this.props.onChange(style.id, {dashArray});
- }}
- />
-
-
-
-
-
-
-
- {
- if (!isNil(c)) {
- const color = tinycolor(c).toHexString();
- const opacity = c.a;
- this.props.onChange(style.id, {color, opacity});
- }
- }}/>
-
-
-
-
-
-
-
- {
- this.props.onChange(style.id, {opacity});
- }}/>
-
-
-
-
-
-
-
-
- Math.round(value),
- to: value => Math.round(value) + ' px'
- }}
- range={{
- min: isNil(this.props.constraints && this.props.constraints.minWidth) ? 1 : this.props.constraints.maxWidth,
- max: this.props.constraints && this.props.constraints.maxWidth || 15
- }}
- onChange={(values) => {
- const weight = parseInt(values[0].replace(' px', ''), 10);
- this.props.onChange(style.id, {weight});
- }}
- />
-
-
-
-
);
- }
-}
-
-export default Stroke;
diff --git a/web/client/components/style/vector/Text.jsx b/web/client/components/style/vector/Text.jsx
deleted file mode 100644
index d131df60d6..0000000000
--- a/web/client/components/style/vector/Text.jsx
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-import React from 'react';
-import { Combobox } from 'react-widgets';
-import Slider from 'react-nouislider';
-import IntlNumberFormControl from '../../I18N/IntlNumberFormControl';
-import numberLocalizer from 'react-widgets/lib/localizers/simple-number';
-// not sure this is needed, TODO check!
-numberLocalizer();
-
-import Message from '../../I18N/Message';
-import { getMessageById } from '../../../utils/LocaleUtils';
-import { createFont } from '../../../utils/LegacyAnnotationsUtils';
-
-/**
- * Styler for the stroke properties of a vector style
-*/
-class Text extends React.Component {
- static propTypes = {
- style: PropTypes.object,
- onChange: PropTypes.func,
- addOpacityToColor: PropTypes.func,
- width: PropTypes.number,
- uomValues: PropTypes.array,
- alignValues: PropTypes.array,
- fontStyleValues: PropTypes.array,
- fontWeightValues: PropTypes.array,
- fontFamilyValues: PropTypes.array,
- shapeStyle: PropTypes.object,
- rotationStep: PropTypes.number
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- style: {},
- onChange: () => {},
- uomValues: [{value: "px"}, {value: "em"}],
- fontWeightValues: [{value: "normal"}, {value: "bold"}],
- alignValues: [{value: "start", label: "left"}, {value: "center", label: "center"}, {value: "end", label: "right"}],
- fontStyleValues: [{value: "normal"}, {value: "italic"}],
- fontFamilyValues: [{value: "Arial"}, {value: "Helvetica"}, {value: "sans-serif"}, {value: "Courier"}],
- shapeStyle: {},
- rotationStep: 5
- };
-
- state = {
- fontFamily: "Arial"
- };
-
- render() {
- const messages = {
- emptyList: getMessageById(this.context.messages, "queryform.attributefilter.autocomplete.emptyList"),
- open: getMessageById(this.context.messages, "queryform.attributefilter.autocomplete.open"),
- emptyFilter: getMessageById(this.context.messages, "queryform.attributefilter.autocomplete.emptyFilter")
- };
- const {style} = this.props;
- return (
-
-
-
-
-
-
-
-
- {
- let fontFamily = e.value ? e.value : e;
- if (fontFamily === "") {
- fontFamily = "Arial";
- }
- this.setState({fontFamily});
- const font = createFont({...style, fontFamily});
- this.props.onChange(style.id, {fontFamily, font});
- }}
- />
-
-
-
-
-
-
-
-
- {
- const fontSize = val || 14;
- const font = createFont({...style, fontSize});
- this.props.onChange(style.id, {fontSize, font});
- }}
- type="number"/>
-
-
{
- let fontSizeUom = e.value ? e.value : e;
- if (this.props.uomValues.map(f => f.value).indexOf(fontSizeUom) === -1) {
- fontSizeUom = "px";
- }
- const font = createFont({...style, fontSizeUom});
- this.props.onChange(style.id, {fontSizeUom, font});
- }}
- />
-
-
-
-
-
-
-
- {
- let fontStyle = e.value ? e.value : e;
- if (this.props.fontStyleValues.map(f => f.value).indexOf(fontStyle) === -1) {
- fontStyle = style.fontStyle;
- }
- const font = createFont({...style, fontStyle});
- this.props.onChange(style.id, {fontStyle, font});
- }}
- />
-
-
-
-
-
-
-
- {
- let fontWeight = e.value ? e.value : e;
- if (this.props.fontWeightValues.map(f => f.value).indexOf(fontWeight) === -1) {
- fontWeight = style.fontWeight;
- }
- const font = createFont({...style, fontWeight});
- this.props.onChange(style.id, {fontWeight, font});
- }}
- />
-
-
-
-
-
-
-
-
- {
- let textAlign = e.value ? e.value : e;
- if (this.props.alignValues.map(f => f.value).indexOf(textAlign) === -1) {
- textAlign = "center";
- }
- this.props.onChange(style.id, {textAlign});
- }}
- />
-
-
-
-
-
-
-
-
- Math.round(parseFloat(value)),
- to: value => Math.round(value) + ' °'
- }}
- range={{
- min: 0,
- max: 359
- }}
- onChange={(values) => {
- const rotationDeg = parseInt(values[0].replace(' °', ''), 10);
- this.props.onChange(style.id, {textRotationDeg: rotationDeg});
- }}
- />
-
-
-
-
);
- }
-}
-
-export default Text;
diff --git a/web/client/components/style/vector/marker/MarkerGlyph.jsx b/web/client/components/style/vector/marker/MarkerGlyph.jsx
deleted file mode 100644
index ba268bfc45..0000000000
--- a/web/client/components/style/vector/marker/MarkerGlyph.jsx
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-import React from 'react';
-import Filter from '../../../misc/Filter';
-import MarkerPropertyPicker from '../../MarkerPropertyPicker';
-import Message from '../../../I18N/Message';
-
-/**
- * Styler for the glyph, color and shape
-*/
-class MarkerGlyph extends React.Component {
- static propTypes = {
- style: PropTypes.object,
- markersOptions: PropTypes.object,
- onChange: PropTypes.func,
- width: PropTypes.number
- };
-
- static defaultProps = {
- style: {},
- onChange: () => {}
- };
-
- // eslint-disable-next-line no-unused-vars
- renderMarkers = (markers, prefix = '') => {
- return markers.map((marker) => {
- if (marker.markers) {
- return this.renderMarkers(marker.markers, marker.name + '-');
- }
- return (
- this.selectStyle(marker)}
- className={this.isCurrentStyle(marker) ? 'ms-marker-selected' : ''}
- style={{
- ...marker.thumbnailStyle
- }}
- />);
- });
- };
-
- render() {
- const selectedMarker = this.props.markersOptions.markers.reduce((acc, { markers }) => [...acc, ...markers], []).find((marker) => this.isCurrentStyle(marker)) || {};
- return (
-
-
-
-
-
-
-
-
-
- }>
-
-
-
-
-
- {this.props.markersOptions.glyphs.map(glyph => {
- if (this.filterMarkerGlyph(glyph)) {
- return (
-
{
- this.props.onChange(this.props.style.id, {iconGlyph: glyph});
- }}>
-
-
- );
- }
- return null;
- })}
-
-
-
-
-
-
-
-
-
-
-
-
- }>
-
- {this.renderMarkers(this.props.markersOptions.markers)}
-
-
-
-
-
- );
- }
-
- isCurrentStyle = (m) => {
- // TODO change this
- return this.props.markersOptions.markersConfig.matches(this.props.style, m.style);
- }
-
- selectStyle = (marker) => {
- return this.props.onChange(this.props.style.id, {...this.props.markersOptions.markersConfig.getStyle(marker.style)});
- };
-
- filterMarkerGlyph = (marker) =>{
- return marker && marker.toLowerCase().indexOf(this.props.markersOptions?.filter?.toLowerCase() || '') !== -1;
- };
-}
-
-export default MarkerGlyph;
diff --git a/web/client/components/style/vector/marker/MarkerType.jsx b/web/client/components/style/vector/marker/MarkerType.jsx
deleted file mode 100644
index 0e2591ab94..0000000000
--- a/web/client/components/style/vector/marker/MarkerType.jsx
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-import React from 'react';
-import { Row, Col } from 'react-bootstrap';
-import Select from 'react-select';
-import Message from '../../../I18N/Message';
-
-/**
- * Styler for the gliph, color and shape
-*/
-class MarkerType extends React.Component {
- static propTypes = {
- style: PropTypes.object,
- pointType: PropTypes.string,
- options: PropTypes.array,
- onChangeType: PropTypes.func,
- width: PropTypes.number
- };
-
- static defaultProps = {
- style: {},
- options: [{
- label: 'Marker',
- value: 'marker'
- }, {
- label: 'Symbol',
- value: 'symbol'
- }],
- pointType: "marker",
- onChangeType: () => {}
- };
-
- render() {
- return (
-
-
-
-
-
-
-
-
- );
- }
-
-}
-
-export default MarkerType;
diff --git a/web/client/components/style/vector/marker/SymbolLayout.jsx b/web/client/components/style/vector/marker/SymbolLayout.jsx
deleted file mode 100644
index dae6018bea..0000000000
--- a/web/client/components/style/vector/marker/SymbolLayout.jsx
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright 2018, 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 PropTypes from 'prop-types';
-
-import React from 'react';
-import Select from 'react-select';
-import { Row, Col, InputGroup, Glyphicon, Alert } from 'react-bootstrap';
-import { isArray, find, filter, isEqual } from 'lodash';
-import axios from 'axios';
-import Slider from '../../../misc/Slider';
-import Message from '../../../I18N/Message';
-import { DEFAULT_SHAPE, DEFAULT_PATH, checkSymbolsError } from '../../../../utils/LegacyAnnotationsUtils';
-import { randomInt } from '../../../../utils/RandomUtils';
-
-/**
- * Styler for the layout of the symbol
-*/
-class SymbolLayout extends React.Component {
- static propTypes = {
- style: PropTypes.object,
- options: PropTypes.array,
- defaultShape: PropTypes.string,
- defaultShapeSize: PropTypes.number,
- onChange: PropTypes.func,
- onUpdateOptions: PropTypes.func,
- onLoadingError: PropTypes.func,
- symbolErrors: PropTypes.array,
- width: PropTypes.number,
- symbolsPath: PropTypes.string
- };
-
- static contextTypes = {
- messages: PropTypes.object
- };
-
- static defaultProps = {
- symbolsPath: DEFAULT_PATH,
- style: {},
- defaultShape: DEFAULT_SHAPE,
- defaultShapeSize: 64,
- options: [],
- symbolErrors: [],
- onChange: () => {},
- onUpdateOptions: () => {}
- };
-
- UNSAFE_componentWillMount() {
- if (isArray(this.props.options) && this.props.options.length === 0) {
- const shapeDefault = this.props.options && this.props.options.length ? find(this.props.options, (s) => s.value === this.props.defaultShape) && this.props.defaultShape : DEFAULT_SHAPE;
- this.loadSymbolsList(shapeDefault);
- }
- // this.checkSymbolUrl(this.props);
- }
- UNSAFE_componentWillReceiveProps(newProps) {
- if (!isEqual(newProps.style, this.props.style)) {
- this.checkSymbolUrl(newProps);
- }
- if (!isEqual(newProps.symbolErrors, this.props.symbolErrors)) {
- const shapeDefault = this.props.options && this.props.options.length ? find(this.props.options, (s) => s.value === this.props.defaultShape) && this.props.defaultShape : DEFAULT_SHAPE;
- this.loadSymbolsList(shapeDefault);
- }
- }
- render() {
- // maybe we can use the original svg as the preview in the