This repository has been archived by the owner on Feb 14, 2025. It is now read-only.
generated from g3w-suite/g3w-client-plugin-sidebar
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
71 lines (58 loc) · 1.63 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import pluginConfig from './config';
import Service from "./service";
import SidebarComponent from './components/Sidebar.vue';
const { base, inherit } = g3wsdk.core.utils;
const { Plugin: BasePlugin } = g3wsdk.core.plugin;
const { GUI } = g3wsdk.gui;
const Plugin = function() {
const {name, i18n} = pluginConfig;
base(this, {
name,
i18n,
service: Service
});
if (this.registerPlugin(this.config.gid)) {
// Show loading plugin icon
this.setHookLoading({ loading: true });
this.service.once('ready', () => {
//plugin registry
GUI.isReady().then(() => this.setupGui());
// Hide loading plugin icon
this.setHookLoading({loading: false});
this.setReady(true);
});
this.service.init(this.config);
}
/**
* Add a custom button on left sidebar (g3w-client)
*/
this.setupGui = function() {
this.createSideBarComponent(SidebarComponent,
{
id: pluginConfig.name,
title: `plugins.${pluginConfig.name}.title`,
collapsible: true,
open: false,
isolate: false,
iconConfig: {
color: 'green',
icon: 'tools',
},
mobile: true,
/**
* event called
*/
events: {
open: {
when: 'before',
cb:() => { /* TODO: add sample usage */ }
}
},
sidebarOptions: {
position: "spatialbookmarks" // can be a number or a string
}
});
};
};
inherit(Plugin, BasePlugin);
new Plugin();