• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 13458068004

21 Feb 2025 01:37PM UTC coverage: 76.803% (+0.01%) from 76.791%
13458068004

push

github

mahmoudadel54
#10737: Interactive legend for TOC layers [Vector Layer part] (#10798)

31285 of 48897 branches covered (63.98%)

25 of 40 new or added lines in 6 files covered. (62.5%)

45 existing lines in 4 files now uncovered.

39022 of 50808 relevant lines covered (76.8%)

33.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

26.32
/web/client/plugins/map/mapsettings/MapSettings.jsx
1
/*
2
 * Copyright 2022, GeoSolutions Sas.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under the BSD-style license found in the
6
 * LICENSE file in the root directory of this source tree.
7
 */
8

9
import React from 'react';
10
import { connect } from 'react-redux';
11
import { FormGroup, Checkbox, ControlLabel } from 'react-bootstrap';
12
import Select from 'react-select';
13
import { createSelector } from 'reselect';
14
import Message from '../../../components/I18N/Message';
15
import { updateMapOptions } from '../../../actions/map';
16
import ConfigUtils from '../../../utils/ConfigUtils';
17

18
import { mapSelector } from '../../../selectors/map';
19
import { mapTypeSelector, isCesium as isCesiumSelector } from '../../../selectors/maptype';
20
import localizedProps from '../../../components/misc/enhancers/localizedProps';
21
import utcDateWrapper from '../../../components/misc/enhancers/utcDateWrapper';
22
import { getMessageById } from '../../../utils/LocaleUtils';
23
import PropTypes from 'prop-types';
24
import DateTimePicker from '../../../components/misc/datetimepicker';
25

26
const mapStateToProps = createSelector(
1✔
27
    mapSelector,
28
    mapTypeSelector,
29
    isCesiumSelector,
UNCOV
30
    (map, mapType, isCesium) => ( { map, mapType, isCesium })
×
31
);
32

33
const actions = {
1✔
34
    updateConfigAction: updateMapOptions
35
};
36

37
const UTCDateTimePicker = utcDateWrapper({
1✔
38
    dateProp: "value",
39
    dateTypeProp: "type",
40
    setDateProp: "onChange"
41
})(DateTimePicker);
42

43
const Component = ({
1✔
44
    map,
45
    mapType,
46
    isCesium,
47
    updateConfigAction,
48
    mapOptions: defaultMapOptions
49
}, { messages }) => {
UNCOV
50
    const SelectLocalized = localizedProps(["placeholder", "options"])(Select);
×
51

UNCOV
52
    const mapOptions = {
×
53
        ...(defaultMapOptions && defaultMapOptions[mapType]
×
54
            || ConfigUtils.getConfigProp("defaultMapOptions") && ConfigUtils.getConfigProp("defaultMapOptions")[mapType] || {}),
55
        ...map?.mapOptions
56
    };
57

58
    const handleConfigUpdate = (options, key) => {
×
UNCOV
59
        updateConfigAction({[key]: !options[key]});
×
60
    };
61

UNCOV
62
    return isCesium ? (
×
63
        <form>
64
            <FormGroup>
65
                <ControlLabel>
66
                    <Message msgId="map.settings.title" />
67
                </ControlLabel>
68
            </FormGroup>
69
            <Checkbox
70
                checked={mapOptions.showSkyAtmosphere}
UNCOV
71
                onChange={() => handleConfigUpdate(mapOptions, 'showSkyAtmosphere')}
×
72
            >
73
                <Message msgId="map.settings.skyAtmosphere" />
74
            </Checkbox>
75
            <Checkbox
76
                checked={mapOptions.showGroundAtmosphere}
UNCOV
77
                onChange={() => handleConfigUpdate(mapOptions, 'showGroundAtmosphere')}
×
78
            >
79
                <Message msgId="map.settings.groundAtmosphere" />
80
            </Checkbox>
81
            <Checkbox
82
                checked={mapOptions.enableFog}
UNCOV
83
                onChange={() => handleConfigUpdate(mapOptions, 'enableFog')}
×
84
            >
85
                <Message msgId="map.settings.fog" />
86
            </Checkbox>
87
            <Checkbox
88
                checked={mapOptions.depthTestAgainstTerrain}
UNCOV
89
                onChange={() => handleConfigUpdate(mapOptions, 'depthTestAgainstTerrain')}
×
90
            >
91
                <Message msgId="map.settings.depthTest" />
92
            </Checkbox>
93
            <FormGroup>
94
                <ControlLabel><Message msgId="map.settings.lightings.title"/></ControlLabel>
95
                <SelectLocalized
96
                    options={[
97
                        {label: "map.settings.lightings.sunlightOption", value: "sunlight"},
98
                        {label: "map.settings.lightings.flashlightOption", value: "flashlight"},
99
                        {label: "map.settings.lightings.dateTimeOption", value: "dateTime"}
100
                    ]}
101
                    wrapperStyle = {{ marginTop: "10px"}}
102
                    value={mapOptions && mapOptions.lighting?.value || "sunlight"}
×
103
                    clearable={false}
104
                    onChange={(val) => {
UNCOV
105
                        if (val !== 'dateTime') {
×
UNCOV
106
                            updateConfigAction({"lighting": {value: val.value}});
×
107
                        } else {
UNCOV
108
                            updateConfigAction({"lighting": {value: val.value, dateTime: new Date().toISOString()}});
×
109
                        }
110
                    }}
111
                    placeholder="map.settings.lightings.placeholder"
112
                />
113
                {mapOptions?.lighting?.value === 'dateTime' ?
×
114
                    <div className="lighting-dateTime-picker">
115
                        <UTCDateTimePicker
116
                            value={mapOptions.lighting?.dateTime ? new Date(mapOptions.lighting?.dateTime) : new Date()}
×
117
                            hideOperator
118
                            time
119
                            popupPosition={"top"}
120
                            calendar
121
                            type={'date-time'}
122
                            onChange={(date) => {
UNCOV
123
                                updateConfigAction({"lighting": {...mapOptions.lighting, dateTime: date}});
×
124
                            }}
125
                            placeholder={getMessageById(messages, "map.settings.lightings.dateTimePlaceholder")} />
126
                    </div> :
127
                    null}
128
            </FormGroup>
129
        </form>
130
    ) : null;
131
};
132
Component.contextTypes = {
1✔
133
    messages: PropTypes.object
134
};
135
export default connect(mapStateToProps, actions)(Component);
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc