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

geosolutions-it / MapStore2 / 19710972030

26 Nov 2025 03:38PM UTC coverage: 76.665% (-0.3%) from 76.929%
19710972030

Pull #11119

github

web-flow
Fix maven publish (#11739)
Pull Request #11119: Layer Selection Plugin on ArcGIS, WFS & WMS layers

32272 of 50209 branches covered (64.28%)

3 of 3 new or added lines in 2 files covered. (100.0%)

3018 existing lines in 249 files now uncovered.

40157 of 52380 relevant lines covered (76.66%)

37.9 hits per line

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

31.82
/web/client/components/import/SelectShape.jsx
1
/**
2
 * Copyright 2016, 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

11
import PropTypes from 'prop-types';
12
import Dropzone from 'react-dropzone';
13
import Spinner from 'react-spinkit';
14
import { getMessageById } from '../../utils/LocaleUtils';
15
import JSZip from 'jszip';
16
import { readZip, recognizeExt, MIME_LOOKUPS } from '../../utils/FileUtils';
17

18
class SelectShape extends React.Component {
19
    static propTypes = {
1✔
20
        text: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
21
        loading: PropTypes.bool,
22
        onShapeChoosen: PropTypes.func,
23
        onShapeError: PropTypes.func,
24
        error: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
25
        errorMessage: PropTypes.string
26
    };
27

28
    static contextTypes = {
1✔
29
        messages: PropTypes.object
30
    };
31

32
    static defaultProps = {
1✔
33
        text: "Drop or click to import a local Shape",
34
        onShapeChoosen: () => {},
35
        onShapeError: () => {},
36
        errorMessage: "shapefile.error.select"
37
    };
38

39
    render() {
40
        return (
5✔
41
            this.props.loading ? <div className="btn btn-info" style={{"float": "center"}}> <Spinner spinnerName="circle" noFadeIn overrideSpinnerClassName="spinner"/></div> :
5!
42
                <Dropzone rejectClassName="alert-danger" className="alert alert-info" onDrop={this.checkfile}>
43
                    <div className="dropzone-content" style={{textAlign: "center"}}>{this.props.text}</div>
44
                </Dropzone>
45
        );
46
    }
47

48
    tryUnzip = (file) => {
5✔
UNCOV
49
        return readZip(file).then((buffer) => {
×
50
            var zip = new JSZip();
×
51
            return zip.loadAsync(buffer);
×
52
        });
53
    };
54

55
    checkFileType = (file) => {
5✔
UNCOV
56
        return new Promise((resolve, reject) => {
×
57
            const ext = recognizeExt(file.name);
×
58
            const type = file.type || MIME_LOOKUPS[ext];
×
59
            if (type === 'application/x-zip-compressed' ||
×
60
                type === 'application/zip' ||
61
                type === 'application/vnd.google-earth.kml+xml' ||
62
                type === 'application/vnd.google-earth.kmz' ||
63
                type === 'application/gpx+xml') {
UNCOV
64
                resolve();
×
65
            } else {
UNCOV
66
                this.tryUnzip(file).then(resolve).catch(reject);
×
67
            }
68
        });
69
    };
70

71
    checkfile = (files) => {
5✔
UNCOV
72
        Promise.all(files.map(file => this.checkFileType(file))).then(() => {
×
73
            if (this.props.error) {
×
74
                this.props.onShapeError(null);
×
75
            }
UNCOV
76
            this.props.onShapeChoosen(files);
×
77
        }).catch(() => {
UNCOV
78
            const error = getMessageById(this.context.messages, this.props.errorMessage);
×
79
            this.props.onShapeError(error);
×
80
        });
81
    };
82
}
83

84
export default SelectShape;
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

© 2025 Coveralls, Inc