/** * @api {delete} /api/v1/area/:area_selector delete * @apiName delete * @apiGroup Area */ async function destroy(req, res) { await gladys.area.destroy(req.params.area_selector); res.json({ success: true, }); }
this.context.plugins.reduce((acc, plugin) => { if (!isEmpty(plugin.toJS().injectedComponents)) { const injectedComponents = plugin .toJS() .injectedComponents.filter( compo => compo.plugin === this.props.plugin && compo.container === this.props.container && compo.area === this.props.area ); return injectedComponents[0]; } return acc; }, {})
svg .selectAll("mylayers") .data(data) .enter() .append("path") .style("fill", d => color(d.key)) .attr( "d", d3 .area() .x(d => x(d3.isoParse(d.data.x))) .y0(d => y(d[0])) .y1(d => y(d[1])) );
/** * Retrieve external links from injected components * @type {Array} List of external links to display */ const getInjectedComponents = (container, area, plugins, rest) => { const componentsToInject = Object.keys(plugins).reduce((acc, current) => { // Retrieve injected compos from plugin const currentPlugin = plugins[current]; const injectedComponents = get(currentPlugin, 'injectedComponents', []); const compos = injectedComponents .filter(compo => { return compo.plugin === `${pluginId}.${container}` && compo.area === area; }) .map(compo => { const Component = compo.component; return <Component {...compo} {...rest} key={compo.key} />; }); return [...acc, ...compos]; }, []); return componentsToInject; }
/** * @api {get} /api/v1/area get * @apiName get * @apiGroup Area * @apiSuccessExample {json} Success-Response * [{ * "id": "daff2ca0-5ab8-4e72-8561-c4ed9c7c6901", * "name": "Home", * "selector": "home", * "latitude": 48, * "longitude": 12, * "radius": 100, * "color": "#5042f4", * "updated_at": "2019-05-09T03:11:03.819Z", * "created_at": "2019-05-09T03:11:03.819Z" * }] */ async function get(req, res) { const areas = await gladys.area.get(); res.json(areas); }
/** * @api {post} /api/v1/area create * @apiName create * @apiGroup Area * @apiUse AreaParam * @apiSuccessExample {json} Success-Response * { * "id": "daff2ca0-5ab8-4e72-8561-c4ed9c7c6901", * "name": "Home", * "selector": "home", * "latitude": 48, * "longitude": 12, * "radius": 100, * "color": "#5042f4", * "updated_at": "2019-05-09T03:11:03.819Z", * "created_at": "2019-05-09T03:11:03.819Z" * } */ async function create(req, res) { const area = await gladys.area.create(req.body); res.status(201).json(area); }
/** * @api {patch} /api/v1/area/:area_selector update * @apiName update * @apiGroup Area * @apiUse AreaParam * @apiSuccessExample {json} Success-Response * { * "id": "daff2ca0-5ab8-4e72-8561-c4ed9c7c6901", * "name": "Home", * "selector": "home", * "latitude": 48, * "longitude": 12, * "radius": 100, * "color": "#5042f4", * "updated_at": "2019-05-09T03:11:03.819Z", * "created_at": "2019-05-09T03:11:03.819Z" * } */ async function update(req, res) { const area = await gladys.area.update(req.params.area_selector, req.body); res.json(area); }
.filter(compo => { return ( compo.plugin === `${pluginId}.${container}` && compo.area === area ); })
/** * @api {delete} /api/v1/area/:area_selector delete * @apiName delete * @apiGroup Area */ async function destroy(req, res) { await gladys.area.destroy(req.params.area_selector); res.json({ success: true, }); }
this.context.plugins.reduce((acc, plugin) => { if (!isEmpty(plugin.toJS().injectedComponents)) { const injectedComponents = plugin .toJS() .injectedComponents.filter( compo => compo.plugin === this.props.plugin && compo.container === this.props.container && compo.area === this.props.area ); return injectedComponents[0]; } return acc; }, {})
/** * Retrieve external links from injected components * @type {Array} List of external links to display */ const getInjectedComponents = (container, area, plugins, rest) => { const componentsToInject = Object.keys(plugins).reduce((acc, current) => { // Retrieve injected compos from plugin const currentPlugin = plugins[current]; const injectedComponents = get(currentPlugin, 'injectedComponents', []); const compos = injectedComponents .filter(compo => { return compo.plugin === `${pluginId}.${container}` && compo.area === area; }) .map(compo => { const Component = compo.component; return <Component {...compo} {...rest} key={compo.key} />; }); return [...acc, ...compos]; }, []); return componentsToInject; }
/** * @api {get} /api/v1/area get * @apiName get * @apiGroup Area * @apiSuccessExample {json} Success-Response * [{ * "id": "daff2ca0-5ab8-4e72-8561-c4ed9c7c6901", * "name": "Home", * "selector": "home", * "latitude": 48, * "longitude": 12, * "radius": 100, * "color": "#5042f4", * "updated_at": "2019-05-09T03:11:03.819Z", * "created_at": "2019-05-09T03:11:03.819Z" * }] */ async function get(req, res) { const areas = await gladys.area.get(); res.json(areas); }
/** * @api {patch} /api/v1/area/:area_selector update * @apiName update * @apiGroup Area * @apiUse AreaParam * @apiSuccessExample {json} Success-Response * { * "id": "daff2ca0-5ab8-4e72-8561-c4ed9c7c6901", * "name": "Home", * "selector": "home", * "latitude": 48, * "longitude": 12, * "radius": 100, * "color": "#5042f4", * "updated_at": "2019-05-09T03:11:03.819Z", * "created_at": "2019-05-09T03:11:03.819Z" * } */ async function update(req, res) { const area = await gladys.area.update(req.params.area_selector, req.body); res.json(area); }
/** * @api {post} /api/v1/area create * @apiName create * @apiGroup Area * @apiUse AreaParam * @apiSuccessExample {json} Success-Response * { * "id": "daff2ca0-5ab8-4e72-8561-c4ed9c7c6901", * "name": "Home", * "selector": "home", * "latitude": 48, * "longitude": 12, * "radius": 100, * "color": "#5042f4", * "updated_at": "2019-05-09T03:11:03.819Z", * "created_at": "2019-05-09T03:11:03.819Z" * } */ async function create(req, res) { const area = await gladys.area.create(req.body); res.status(201).json(area); }
.filter(compo => { return ( compo.plugin === `${pluginId}.${container}` && compo.area === area ); })