1+ /**
2+ * LizDict
3+ * @typedef {object } lizDict
4+ */
5+
6+ /**
7+ * Execute JS from server
8+ */
19export default function executeJSFromServer ( ) {
210 lizMap . events . on ( {
311 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 ) ;
915
1016 if ( document . body . dataset . lizmapHideLegend ) {
1117 document . querySelector ( 'li.switcher.active #button-switcher' ) ?. click ( ) ;
@@ -26,7 +32,9 @@ export default function executeJSFromServer() {
2632 var search = $ ( '#nominatim-search' ) ;
2733 if ( search . length != 0 ) {
2834 $ ( '#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' ) ;
3038 }
3139
3240 //calculate dock position and size
@@ -46,7 +54,8 @@ export default function executeJSFromServer() {
4654 if ( $ ( '#mapmenu li.switcher' ) . hasClass ( 'active' ) )
4755 $ ( '#button-switcher' ) . click ( ) ;
4856
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' ] ) ;
5059 } ,
5160 dockopened : ( ) => {
5261 // one tool at a time
@@ -65,7 +74,8 @@ export default function executeJSFromServer() {
6574 // autocompletion items for locatebylayer feature
6675 $ ( 'div.locate-layer select' ) . hide ( ) ;
6776 $ ( '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' } ) ;
6979 }
7080
7181 if ( evt . id == 'permaLink' ) {
@@ -79,30 +89,101 @@ export default function executeJSFromServer() {
7989}
8090
8191/**
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.
83135 */
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+ }
103174 }
104175
105176 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+ }
107188 }
108189}
0 commit comments