1
+ /**
2
+ * LizDict
3
+ * @typedef {object } lizDict
4
+ */
5
+
6
+ /**
7
+ * Execute JS from server
8
+ */
1
9
export default function executeJSFromServer ( ) {
2
10
lizMap . events . on ( {
3
11
uicreated : ( ) => {
4
-
5
- // skipWarningsDisplay is used in tests, to skip a possible warnings about old QGIS plugin used
6
- if ( ! document . body . dataset . skipWarningsDisplay ) {
7
- displayWarningsAdministrator ( ) ;
8
- }
12
+ const withDisplay = ! document . body . dataset . skipWarningsDisplay ;
13
+ displayWarningsAdministrator ( withDisplay ) ;
14
+ checkInvalidLayersCfgFile ( withDisplay ) ;
9
15
10
16
if ( document . body . dataset . lizmapHideLegend ) {
11
17
document . querySelector ( 'li.switcher.active #button-switcher' ) ?. click ( ) ;
@@ -26,7 +32,9 @@ export default function executeJSFromServer() {
26
32
var search = $ ( '#nominatim-search' ) ;
27
33
if ( search . length != 0 ) {
28
34
$ ( '#mapmenu' ) . append ( search ) ;
29
- $ ( '#nominatim-search div.dropdown-menu' ) . removeClass ( 'pull-right' ) . addClass ( 'pull-left' ) ;
35
+ $ (
36
+ '#nominatim-search div.dropdown-menu'
37
+ ) . removeClass ( 'pull-right' ) . addClass ( 'pull-left' ) ;
30
38
}
31
39
32
40
//calculate dock position and size
@@ -46,7 +54,8 @@ export default function executeJSFromServer() {
46
54
if ( $ ( '#mapmenu li.switcher' ) . hasClass ( 'active' ) )
47
55
$ ( '#button-switcher' ) . click ( ) ;
48
56
49
- $ ( '#mapmenu .nav-list > li.permaLink a' ) . attr ( 'data-original-title' , lizDict [ 'embed.open.map' ] ) ;
57
+ $ ( '#mapmenu .nav-list > li.permaLink a' ) . attr (
58
+ 'data-original-title' , lizDict [ 'embed.open.map' ] ) ;
50
59
} ,
51
60
dockopened : ( ) => {
52
61
// one tool at a time
@@ -65,7 +74,8 @@ export default function executeJSFromServer() {
65
74
// autocompletion items for locatebylayer feature
66
75
$ ( 'div.locate-layer select' ) . hide ( ) ;
67
76
$ ( 'span.custom-combobox' ) . show ( ) ;
68
- $ ( '#locate div.locate-layer input.custom-combobox-input' ) . autocomplete ( 'option' , 'position' , { my : 'left top' , at : 'left bottom' } ) ;
77
+ $ ( '#locate div.locate-layer input.custom-combobox-input'
78
+ ) . autocomplete ( 'option' , 'position' , { my : 'left top' , at : 'left bottom' } ) ;
69
79
}
70
80
71
81
if ( evt . id == 'permaLink' ) {
@@ -79,30 +89,101 @@ export default function executeJSFromServer() {
79
89
}
80
90
81
91
/**
82
- * Display messages to the user about deprecated features or outdated versions.
92
+ * Display a message about invalid layers, detected on the client side.
93
+ *
94
+ * A message is logged in the console in English.
95
+ * Another message is translated and displayed for GIS administrators.
96
+ *
97
+ * @param {boolean } withDisplay If the message must be displayed in the web interface, only in the console otherwise.
98
+ */
99
+ function checkInvalidLayersCfgFile ( withDisplay ) {
100
+ const invalidLayers = lizMap . mainLizmap . initialConfig . invalidLayersNotFoundInCfg ;
101
+ if ( invalidLayers . length === 0 ) {
102
+ return ;
103
+ }
104
+
105
+ let message = `WMS layers "${ invalidLayers . join ( ', ' ) } " are not found in the Lizmap configuration. ` ;
106
+ message += `Is the Lizmap configuration file "${ lizUrls . params . project } .qgs.cfg" up to date ?` ;
107
+ console . warn ( message ) ;
108
+
109
+ if ( ! withDisplay ) {
110
+ return ;
111
+ }
112
+
113
+ if ( ! document . body . dataset . lizmapAdminUser ) {
114
+ return ;
115
+ }
116
+
117
+ const layersNotFound = `
118
+ ${ lizDict [ 'project.has.not.found.layers' ] } <br>
119
+ <code>${ invalidLayers . join ( ', ' ) } </code>` ;
120
+
121
+ lizMap . addMessage (
122
+ layersNotFound ,
123
+ 'warning' ,
124
+ true
125
+ ) . attr ( 'id' , 'lizmap-warning-message' ) ;
126
+ }
127
+
128
+ /**
129
+ * Display messages to the administrator about deprecated features or outdated versions.
130
+ *
131
+ * The message is translated and displayed for GIS administrators.
132
+ * A message is logged in the console in English.
133
+ *
134
+ * @param {boolean } withDisplay If the message must be displayed in the web interface, only in the console otherwise.
83
135
*/
84
- function displayWarningsAdministrator ( ) {
85
- if ( document . body . dataset . lizmapPluginUpdateWarningUrl ) {
86
- var message = lizDict [ 'project.plugin.outdated.warning' ] ;
87
- message += `<br><a href="${ document . body . dataset . lizmapPluginUpdateWarningUrl } ">` ;
88
- message += lizDict [ 'visit.admin.panel.project.page' ] ;
89
- message += '</a>' ;
90
- message += '<br>' ;
91
- message += lizDict [ 'project.admin.panel.info' ] ;
92
- // The plugin can be easily updated, the popup can not be closed
93
- lizMap . addMessage ( message , 'warning' , false ) . attr ( 'id' , 'lizmap-warning-message' ) ;
94
- } else if ( document . body . dataset . lizmapPluginHasWarningsUrl ) {
95
- var message = lizDict [ 'project.has.warnings' ] ;
96
- message += `<br><a href="${ document . body . dataset . lizmapPluginHasWarningsUrl } ">` ;
97
- message += lizDict [ 'visit.admin.panel.project.page' ] ;
98
- message += '</a>' ;
99
- message += '<br>' ;
100
- message += lizDict [ 'project.admin.panel.info' ] ;
101
- // It can take times to fix these issues, the popup can be closed
102
- lizMap . addMessage ( message , 'warning' , true ) . attr ( 'id' , 'lizmap-warning-message' ) ;
136
+ function displayWarningsAdministrator ( withDisplay ) {
137
+ if ( document . body . dataset . lizmapPluginUpdateWarning ) {
138
+ console . warn ( 'The plugin in QGIS is not up to date.' ) ;
139
+
140
+ if ( document . body . dataset . lizmapPluginUpdateWarningUrl && withDisplay ) {
141
+ let messageOutdatedWarning = lizDict [ 'project.plugin.outdated.warning' ] ;
142
+ messageOutdatedWarning += `<br><a href="${ document . body . dataset . lizmapPluginUpdateWarningUrl } ">` ;
143
+ messageOutdatedWarning += lizDict [ 'visit.admin.panel.project.page' ] ;
144
+ messageOutdatedWarning += '</a>' ;
145
+ messageOutdatedWarning += '<br>' ;
146
+ messageOutdatedWarning += lizDict [ 'project.admin.panel.info' ] ;
147
+
148
+ // The plugin can be easily updated, the popup can not be closed
149
+ lizMap . addMessage (
150
+ messageOutdatedWarning ,
151
+ 'warning' ,
152
+ false
153
+ ) . attr ( 'id' , 'lizmap-warning-message' ) ;
154
+ }
155
+
156
+ } else if ( document . body . dataset . lizmapPluginHasWarnings ) {
157
+ console . warn ( 'The project has some warnings in the Lizmap plugin.' ) ;
158
+
159
+ if ( document . body . dataset . lizmapPluginHasWarningsUrl && withDisplay ) {
160
+ let messageHasWarnings = lizDict [ 'project.has.warnings' ] ;
161
+ messageHasWarnings += `<br><a href="${ document . body . dataset . lizmapPluginHasWarningsUrl } ">` ;
162
+ messageHasWarnings += lizDict [ 'visit.admin.panel.project.page' ] ;
163
+ messageHasWarnings += '</a>' ;
164
+ messageHasWarnings += '<br>' ;
165
+ messageHasWarnings += lizDict [ 'project.admin.panel.info' ] ;
166
+
167
+ // It can take times to fix these issues, the popup can be closed
168
+ lizMap . addMessage (
169
+ messageHasWarnings ,
170
+ 'warning' ,
171
+ true
172
+ ) . attr ( 'id' , 'lizmap-outdated-plugin' ) ;
173
+ }
103
174
}
104
175
105
176
if ( document . body . dataset . lizmapActionWarningOld ) {
106
- lizMap . addMessage ( document . body . dataset . lizmapActionWarningOld , 'info' , true ) . attr ( 'id' , 'lizmap-action-message' ) ;
177
+ let message = 'The project uses deprecated Action JSON format. ' ;
178
+ message += 'Read https://docs.lizmap.com/current/en/publish/lizmap_plugin/actions.html for more information' ;
179
+ console . warn ( message ) ;
180
+
181
+ if ( document . body . dataset . lizmapAdminUser && withDisplay ) {
182
+ lizMap . addMessage (
183
+ document . body . dataset . lizmapActionWarningOld ,
184
+ 'info' ,
185
+ true
186
+ ) . attr ( 'id' , 'lizmap-action-message' ) ;
187
+ }
107
188
}
108
189
}
0 commit comments