Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iframe refactor #529

Merged
merged 5 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ const G3W_KEYS = {
// bing: '<INSERT HERE YOUR BING API KEY>'
};

const G3W_IFRAME = { // testing MESSAGE sent to "Open in iframe" map control
id: null,
action: 'app:getcenter', // or 'app:getextent'
data: { epsg: 4326 }
};

let conf = {
assetsFolder: './src/assets', // path to G3W-CLIENT assets folder
pluginsFolder: './src/plugins', // path to G3W-CLIENT plugins folder
Expand All @@ -39,6 +45,7 @@ let conf = {
initConfig.group.vendorkeys = Object.assign(initConfig.group.vendorkeys || {}, G3W_KEYS);
initConfig.group.plugins = Object.assign(initConfig.group.plugins || {}, G3W_PLUGINS.reduce((a, v) => ({ ...a, [v]: { ...initConfig.group.plugins[v], gid: initConfig.group.initproject, baseUrl: initConfig.staticurl }}), {}));
});
g3wsdk.gui.GUI.once('iframe:message', (w, e) => { w.postMessage(G3W_IFRAME, '*') });
g3wsdk.gui.GUI.once('ready', () => { console.log('ready'); });
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import CatalogLayersStoresRegistry from 'store/catalog-layers';
import DataRouterService from 'services/data';
import ChangesManager from 'services/editing';
import SessionsRegistry from 'store/sessions';
import IFrameRouterService from 'services/iframe-plugin';
import IFrameRouterService from 'services/iframe';
import MapLayersStoresRegistry from 'store/map-layers';
import PluginsRegistry from 'store/plugins';
import ProjectsRegistry from 'store/projects';
Expand Down
11 changes: 0 additions & 11 deletions src/app/core/iframe/routerservice.js

This file was deleted.

169 changes: 0 additions & 169 deletions src/app/core/iframe/services/baseservice.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/app/core/iframe/services/index.js

This file was deleted.

52 changes: 0 additions & 52 deletions src/app/core/iframe/services/plugins/service.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/app/core/iframe/test/data/template.js

This file was deleted.

26 changes: 0 additions & 26 deletions src/app/core/iframe/test/templates/template.html

This file was deleted.

31 changes: 30 additions & 1 deletion src/index.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,33 @@ import './globals';
window.g3wsdk.info();

// run app (index.prod.js)
require('./index.prod');
require('./index.prod');

// custom map control: "Open in iframe"
g3wsdk.gui.GUI.once('ready', () => {
g3wsdk.gui.GUI.getService('map').once('ready', function() {
this.createMapControl('onclick',
{
id: "OPENIFRAME",
options: {
add: true,
clickmap: false,
name: 'OPENIFRAME',
tipLabel: 'Open in iframe',
customClass: g3wsdk.gui.GUI.getFontClass('plugin'),
onclick() {
const w = window.open('about:blank', '_blank', `fullscreen=yes`);
w.document.write(`<!doctype HTML><html><head><title>Test Iframe</title><style>html,body,iframe{width:100%;height:100%;margin:0;border:0;display:block;}</style></head><body><iframe src="${location.href}"></iframe></body></html>`);
// send message to iframe when app is ready
w.addEventListener('message', e => {
if (e.data.action === 'app:ready') {
setTimeout(() => g3wsdk.gui.GUI.emit('iframe:message', w.document.querySelector('iframe').contentWindow, e), 2000)
}
}, false);
// prevent page refresh (eg. CTRL+R)
w.onbeforeunload = () => w.close();
}
},
});
});
});
2 changes: 1 addition & 1 deletion src/services/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ const ApplicationService = function() {
* iframeservice
*/
this.startIFrameService = function({project}={}) {
const iframeService = require('core/iframe/routerservice');
const iframeService = require('services/iframe').default;
iframeService.init({project});
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import OWSService from 'services/data-ows';
import ProxyService from 'services/data-proxy';
import QueryService from 'services/data-query';
import SearchService from 'services/data-search';
import IFrameRouterService from 'services/iframe-plugin';
import IFrameRouterService from 'services/iframe';
import GUI from 'services/gui';

const { splitContextAndMethod } = require('utils');
Expand Down
Loading