Skip to content

Commit

Permalink
Merge branch 'master' into fix_#2660
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz authored Apr 23, 2018
2 parents 37fd0bb + a7f2161 commit b5984f1
Show file tree
Hide file tree
Showing 62 changed files with 1,734 additions and 477 deletions.
46 changes: 44 additions & 2 deletions web/client/api/GeoStoreDAO.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const _ = require('lodash');
const assign = require('object-assign');
const uuidv1 = require('uuid/v1');
const ConfigUtils = require('../utils/ConfigUtils');

const xml2js = require('xml2js');
const xmlBuilder = new xml2js.Builder();
const {registerErrorParser} = require('../utils/LocaleUtils');

let parseOptions = (opts) => opts;
Expand Down Expand Up @@ -80,7 +81,7 @@ const Api = {
},
getResourcesByCategory: function(category, query, options) {
const q = query || "*";
const url = "extjs/search/category/" + category + "/*" + q + "*/thumbnail,details"; // comma-separated list of wanted attributes
const url = "extjs/search/category/" + category + "/*" + q + "*/thumbnail,details,featured"; // comma-separated list of wanted attributes
return axios.get(url, this.addBaseUrl(parseOptions(options))).then(function(response) {return response.data; });
},
getUserDetails: function(username, password, options) {
Expand Down Expand Up @@ -396,6 +397,47 @@ const Api = {
return response.data;
});
},
/**
* send a request to /extjs/search/list
* @param {object} filters
* @param {object} options additional axios options
* @return {object}
* @example
*
* const filters = {
* AND: {
* ATTRIBUTE: [
* {
* name: ['featured'],
* operator: ['EQUAL_TO'],
* type: ['STRING'],
* value: [true]
* }
* ]
* }
* }
*
* searchListByAttributes(filters)
* .then(results => results)
* .catch(error => error);
*
*/
searchListByAttributes: (filter, options) => {
const url = "/extjs/search/list";
const xmlFilter = xmlBuilder.buildObject(filter);
return axios.post(
url,
xmlFilter,
Api.addBaseUrl({
...parseOptions(options),
headers: {
"Content-Type": "application/xml",
"Accept": "application/json"
}
})
)
.then(response => response.data);
},
utils: {
/**
* initialize User with newPassword and UUID
Expand Down
22 changes: 12 additions & 10 deletions web/client/components/I18N/FlagButton.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

const 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');
var {Button, Tooltip} = require('react-bootstrap');
const React = require('react');
const PropTypes = require('prop-types');
const {Button, Tooltip} = require('react-bootstrap');
const OverlayTrigger = require('../misc/OverlayTrigger');
var LocaleUtils = require('../../utils/LocaleUtils');
const LocaleUtils = require('../../utils/LocaleUtils');


class LangBar extends React.Component {
Expand All @@ -21,25 +20,28 @@ class LangBar extends React.Component {
active: PropTypes.bool,
label: PropTypes.string,
description: PropTypes.string,
onFlagSelected: PropTypes.func
onFlagSelected: PropTypes.func,
tooltipPlacement: PropTypes.string
};

static defaultProps = {
locales: LocaleUtils.getSupportedLocales(),
code: 'en-US',
onLanguageChange: function() {}
onLanguageChange: function() {},
onFlagSelected: () => {},
tooltipPlacement: 'bottom'
};

render() {
let tooltip = <Tooltip id={"flag-button." + this.props.code}>{this.props.label}</Tooltip>;
let tooltip = <Tooltip id={"flag-button." + this.props.code} >{this.props.label}</Tooltip>;
let imgSrc;
try {
imgSrc = require('./images/flags/' + this.props.code + '.png');
} catch(e) {
imgSrc = null;
}

return imgSrc ? (<OverlayTrigger key={"overlay-" + this.props.code} overlay={tooltip}>
return imgSrc ? (<OverlayTrigger key={"overlay-" + this.props.code} overlay={tooltip} placement={this.props.tooltipPlacement}>
<Button
key={this.props.code}
onClick={this.launchFlagAction.bind(this, this.props.code)}
Expand Down
79 changes: 50 additions & 29 deletions web/client/components/I18N/LangBar.jsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,77 @@

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');
var {ButtonGroup} = require('react-bootstrap');
var LocaleUtils = require('../../utils/LocaleUtils');
var FlagButton = require('./FlagButton');
const React = require('react');
const PropTypes = require('prop-types');
const {DropdownButton, MenuItem, ButtonGroup} = require('react-bootstrap');
const {head} = require('lodash');
const LocaleUtils = require('../../utils/LocaleUtils');
const FlagButton = require('./FlagButton');

class LangBar extends React.Component {
static propTypes = {
id: PropTypes.string,
className: PropTypes.string,
locales: PropTypes.object,
currentLocale: PropTypes.string,
onLanguageChange: PropTypes.func
onLanguageChange: PropTypes.func,
dropdown: PropTypes.bool
};

static defaultProps = {
id: "mapstore-langselector",
id: 'mapstore-langselector',
className: 'mapstore-langselector',
locales: {},
currentLocale: 'en-US',
onLanguageChange: function() {}
onLanguageChange: function() {},
dropdown: true
};

render() {
var code;
var label;
var list = [];
let locales = LocaleUtils.getSupportedLocales();
for (let lang in locales) {
if (locales.hasOwnProperty(lang)) {
code = locales[lang].code;
label = locales[lang].description;
list.push(
const locales = LocaleUtils.getSupportedLocales();
const currentLanguage = head(Object.keys(locales).filter(lang => locales[lang].code === this.props.currentLocale));
return this.props.dropdown ? (
<div
className={this.props.className}>
<DropdownButton
pullRight
id={this.props.id}
title={
<FlagButton
key={currentLanguage}
code={this.props.currentLocale}
label={locales[currentLanguage] && locales[currentLanguage].description}
lang={currentLanguage}/>
}>
{Object.keys(locales).filter(lang => locales[lang].code !== this.props.currentLocale).map(lang =>
<MenuItem key={lang} eventKey={lang} onClick={() => this.props.onLanguageChange(locales[lang].code)}>
<FlagButton
key={lang}
code={locales[lang].code}
label={locales[lang].description}
lang={lang}
active={locales[lang].code === this.props.currentLocale}
/>{' ' + locales[lang].description}</MenuItem>)
}
</DropdownButton>
</div>
) : (
<ButtonGroup id={this.props.id} type="select" bsSize="small">
{Object.keys(locales).map(lang => (
<FlagButton
key={lang}
code={code}
label={label}
code={locales[lang].code}
label={locales[lang].description}
lang={lang}
active={code === this.props.currentLocale}
active={locales[lang].code === this.props.currentLocale}
onFlagSelected={this.props.onLanguageChange}
/>);
}
}
return (
<ButtonGroup id={this.props.id} type="select" bsSize="small">
{list}
</ButtonGroup>
/>
))}
</ButtonGroup>
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion web/client/components/I18N/__tests__/LangBar-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('LangBar', () => {

it('checks button click fires the proper action', () => {
let newLang;
const cmp = ReactDOM.render(<LangBar onLanguageChange={ (lang) => {newLang = lang; }}/>, document.getElementById("container"));
const cmp = ReactDOM.render(<LangBar dropdown={false} onLanguageChange={ (lang) => {newLang = lang; }}/>, document.getElementById("container"));
const cmpDom = ReactDOM.findDOMNode(cmp);
const select = cmpDom.getElementsByTagName("button").item(0);

Expand Down
4 changes: 1 addition & 3 deletions web/client/components/manager/users/GroupGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ class GroupsGrid extends React.Component {
<Row key="users">
{this.renderGroups(this.props.groups || [])}
</Row>
<Row key="bottom">
{this.props.bottom}
</Row>
{this.props.bottom}
</Grid>
);
}
Expand Down
4 changes: 1 addition & 3 deletions web/client/components/manager/users/UserGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ class UsersGrid extends React.Component {
<Row key="users">
{this.renderUsers(this.props.users || [])}
</Row>
<Row key="bottom">
{this.props.bottom}
</Row>
{this.props.bottom}
</Grid>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ describe("Test GroupGrid Component", () => {
"row"
);
expect(rows).toExist();
expect(rows.length).toBe(2);
expect(rows.length).toBe(1);
let card = ReactTestUtils.scryRenderedDOMComponentsWithClass(comp, "gridcard");
expect(card).toExist();
expect(card.length).toBe(1);
let buttons = ReactTestUtils.scryRenderedDOMComponentsWithClass(
comp,
"gridcard-button"
"square-button-md"
);
ReactTestUtils.Simulate.click(buttons[0]);
ReactTestUtils.Simulate.click(buttons[1]);
Expand All @@ -67,7 +67,7 @@ describe("Test GroupGrid Component", () => {
expect(domNode.className).toBe("container-fluid");
let buttons = ReactTestUtils.scryRenderedDOMComponentsWithClass(
comp,
"gridcard-button"
"square-button-md"
);
expect(buttons.length).toBe(0);
});
Expand All @@ -85,7 +85,7 @@ describe("Test GroupGrid Component", () => {
expect(domNode.className).toBe("container-fluid");
let buttons = ReactTestUtils.scryRenderedDOMComponentsWithClass(
comp,
"gridcard-button"
"square-button-md"
);
expect(buttons.length).toBe(2);
ReactTestUtils.Simulate.click(buttons[0]);
Expand Down
Loading

0 comments on commit b5984f1

Please sign in to comment.