Commit 33105fba authored by Pierre Marchand's avatar Pierre Marchand

[clients/streaming] ported compose and fixed various issues

parent 130ad963
......@@ -32,6 +32,7 @@ const getData =
const getSource =
subscribe('data/alias', state => ({
kind: 'local',
data: getData(state),
keys: getKeys(),
types: getTypes(),
......
import * as debug from 'debug';
import { DIV, NodeOrOptional } from 'sdi/components/elements';
import { headerWithString } from 'sdi/components/header';
import header from 'sdi/components/header';
import footer from 'sdi/components/footer';
import { loop, getUserId, getApiUrl } from 'sdi/app';
......@@ -30,13 +30,13 @@ const wrappedMain = (name: string, ...elements: NodeOrOptional[]) =>
DIV(
{ className: 'query-inner' },
modal(),
headerWithString(getAppName())(() =>
header('angled-query', () =>
DIV({
className: 'navigate app-listview',
onClick: navigateIndex
},
tr.angled('toQueryList')
))(),
)),
DIV({ className: `main ${name}` }, ...elements),
footer()
);
......
......@@ -29,7 +29,7 @@ import * as mapEvents from '../events/map';
import tr from 'sdi/locale';
const logger = debug('sdi:comp:map');
export const mapId = 'main-view';
export const mapName = 'main-view';
const options: IMapOptions = {
element: null,
......@@ -46,7 +46,7 @@ let mapUpdate: () => void;
const attachMap = (element: Element | null) => {
if (!mapUpdate) {
const { update, setTarget } = create(mapId, {
const { update, setTarget } = create(mapName, {
...options,
element,
});
......@@ -64,7 +64,7 @@ const renderZoomLevel =
() => DIV({ className: 'map__zoom-level' },
`${tr.compose('mapZoomLevel')} : ${Math.round(getZoom())}`
);
const render = () => {
if (mapUpdate) {
mapUpdate();
......@@ -72,15 +72,15 @@ const render = () => {
const overlays: ReactNode[] = [];
overlays.push(DIV({ className: 'scale-and-zoom' },
renderScaleline(mapQueries.getScaleLine()),
renderZoomLevel()),
overlays.push(DIV({ className: 'scale-and-zoom' },
renderScaleline(mapQueries.getScaleLine()),
renderZoomLevel()),
);
return (
DIV({ className: 'map-wrapper', key: 'the-map-wrapper' },
DIV({
id: mapId,
id: mapName,
className: 'map',
ref: attachMap,
}),
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
import { query } from 'sdi/shape';
import { uniqIdGen } from 'sdi/util';
import { setCurrentMapId, setLayout } from './app';
import { setCurrentMapId, setLayout, clearMap } from './app';
import { AppLayout } from '../shape/types';
......@@ -55,7 +55,7 @@ const pushHome =
const goHome =
() => {
setCurrentMapId(null);
clearMap();
setLayout(AppLayout.Dashboard);
};
......
......@@ -38,6 +38,8 @@ const queries = {
export default queries;
export const getView = queries.getView;
export const getZoom = () => queries.getView().zoom;
......
......@@ -75,6 +75,7 @@ const getLayerListData =
export const getTableSource =
subscribe('data/datasetMetadata', state => ({
kind: 'local',
data: getLayerListData(state),
keys: loadLayerListKeys(),
types: loadLayerListTypes(),
......
......@@ -22,6 +22,8 @@ import {
TableDataType,
tableQueries,
emptySource,
TableSourceGetter,
TableSource,
} from 'sdi/components/table';
import {
FeatureCollection,
......@@ -139,13 +141,16 @@ const getLayerTypes =
return getLayerKeys(layer).map(typer);
};
export const getSource =
() => getLayerOption().fold(emptySource(),
layer => ({
data: getLayerData(layer),
keys: getLayerKeys(layer),
types: getLayerTypes(layer),
}));
export const getSource: TableSourceGetter =
() => getLayerOption()
.fold<TableSource>(
emptySource(),
layer => ({
kind: 'local',
data: getLayerData(layer),
keys: getLayerKeys(layer),
types: getLayerTypes(layer),
}));
......
......@@ -36,7 +36,7 @@ const wrappedMain = (
) =>
DIV(
{ className: 'dashboard-inner' },
header('dashboard')(() => DIV({}))(),
header('dashboard'),
DIV({ className: `main ${name}` }, ...elements),
footer()
);
......
......@@ -108,13 +108,10 @@ const loadLayer =
),
() => {
if (bbox) {
return addFeaturesToLayer(mapName,
() => some({
name: getMessageRecord(metadata.resourceTitle),
info,
metadata,
}),
() => right(some(layer)),
return addFeaturesToLayer(
mapName,
info,
layer.features,
);
}
return null;
......@@ -178,7 +175,7 @@ const loadLayerDataAccordingToZoom = (layer: ILayerInfo, metadata: Inspire) => {
if (isZoomVisible(zoom, minZoom, maxZoom)) {
let extent = null;
if (metadata.dataStreamUrl) {
extent = getView().extent;
extent = getView().extent;
}
loadLayer(layer, metadata, extent);
......
......@@ -74,6 +74,7 @@ const getLayerListData =
export const getTableSource =
subscribe('data/datasetMetadata', state => ({
kind: 'local',
data: getLayerListData(state),
keys: loadLayerListKeys(),
types: loadLayerListTypes(),
......@@ -107,6 +108,7 @@ const getKeywordsData =
export const getKeywordsSource =
subscribe('data/keywords', state => ({
kind: 'local',
data: getKeywordsData(state),
keys: keywordsKeys(),
types: keywordsTypes(),
......
......@@ -20,6 +20,7 @@ const getTypes =
export const getSource: TableSourceGetter =
() => ({
kind: 'local',
data: getData(),
keys: getKeys(),
types: getTypes(),
......
......@@ -47,11 +47,6 @@ import { isNotNullNorUndefined } from 'sdi/util';
const logger = debug('sdi:events/app');
export const activityLogger = activity('view');
// observe('component/table', (ts) => {
// console.group('table');
// console.info(JSON.stringify(ts, null, 2));
// console.groupEnd();
// });
observe('data/maps',
() => fromNullable(getMapInfo())
......@@ -66,7 +61,7 @@ observe('port/map/view',
fromNullable(view.extent)
.map(e =>
mapStream(e, ({ uri, lid }, extent) =>
loadLayerDataExtent(lid, uri)(extent))));
loadLayerDataExtent(lid, uri, extent))));
......@@ -98,7 +93,7 @@ const loadLayer =
if (l.visible && layerInRange(l)) {
fromNullable(getView().extent)
.map((e) => {
loadLayerDataExtent(l.id, md.uniqueResourceIdentifier)(e);
loadLayerDataExtent(l.id, md.uniqueResourceIdentifier, e);
});
}
}
......@@ -111,34 +106,37 @@ const loadLayer =
const loadLayerDataExtent =
(layerId: string, url: string) => (bbox: Extent) =>
getSyntheticLayerInfo(layerId)
.map(({ info }) =>
whenInRange(info)
.map((info) => {
pushStreamExtent(bbox, { lid: layerId, uri: url });
fetchLayer(`${url}?bbox=${bbox[0]},${bbox[1]},${bbox[2]},${bbox[3]}`)
.then((layer) => {
if (layer.features !== null) {
addFeaturesToLayer(mapName, info, layer.features);
dispatch('data/layers', (state) => {
if (url in state) {
state[url].features = state[url].features.concat(layer.features);
}
else {
state[url] = layer;
}
return state;
});
}
})
.catch((err) => {
logger(`Failed to load features at ${url} due to ${err}`);
dispatch('remote/errors', state => ({ ...state, [url]: `${err}` }));
});
})
);
const loadLayerDataExtent = (
layerId: string,
url: string,
bbox: Extent,
) =>
getSyntheticLayerInfo(layerId)
.map(({ info }) =>
whenInRange(info)
.map((info) => {
pushStreamExtent(bbox, { lid: layerId, uri: url });
fetchLayer(`${url}?bbox=${bbox[0]},${bbox[1]},${bbox[2]},${bbox[3]}`)
.then((layer) => {
if (layer.features !== null) {
addFeaturesToLayer(mapName, info, layer.features);
dispatch('data/layers', (state) => {
if (url in state) {
state[url].features = state[url].features.concat(layer.features);
}
else {
state[url] = layer;
}
return state;
});
}
})
.catch((err) => {
logger(`Failed to load features at ${url} due to ${err}`);
dispatch('remote/errors', state => ({ ...state, [url]: `${err}` }));
});
})
);
const loadLayerData = (url: string) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment