Closed pautiina closed 6 years ago
same problem here!
The second can be fixed by editing editor-resources/templates/main-oldstyle.php
at line 28 and changing it to:
var host_url = <?php echo $host_url ?>;
However, do note that $host_url
or the $tpl->set("host_url");
isn't actually primed with the correct URL yet (or I've missed how it was set).
I was testing this last night after @pautiina mentioned it in the forum, and didn't see any error, using the editor directly (I use php -S 0.0.0.0:8000
to test). Very odd. Thanks for the correction. The 'return url' is quite likely not passed all the way through. I'll look at that today.
That's strange given it's a 'constant' conversion warning. Maybe the error_reporting() isn't set properly if running that way to include warnings or notices?
Maybe try with debuging with:
php -S 0.0.0.0:8000 -d error_reporting=22527 -d display_errors=1
The number is the number that error_reporting would return after you set the appropriate levels. The above should be E_ALL & ~E_DEPRECATED
This would override any settings in php.ini for the cli or apache. It wouldn't override if a script changes it.
Agreed (re: error reporting).
Also, a bug in your fix ;-) The value for host_url is a string, so the actual change is:
var host_url = '<?php echo $host_url ?>';
(with the quotes)
Just testing a slightly wider patch that actually sets the value though ;-)
ncaught SyntaxError: Unexpected token <
I can't figure out where this is coming from though.
I have update code.
Now when on browser open link cacti/plugins/weathermap/weathermap-cacti10-plugin-editor.php
for choose map for edit on browser console have next warning and error:
jquery.min.js:2 jQuery.Deferred exception: imlist is not defined ReferenceError: imlist is not defined
at HTMLDocument.initJS16 (http://noc/cacti/plugins/weathermap/editor-resources/editor16.js:13:17)
at j (http://noc/cacti/plugins/weathermap/vendor/jquery/dist/jquery.min.js:2:29999)
at k (http://noc/cacti/plugins/weathermap/vendor/jquery/dist/jquery.min.js:2:30313) undefined
r.Deferred.exceptionHook @ jquery.min.js:2
k @ jquery.min.js:2
setTimeout (async)
(anonymous) @ jquery.min.js:2
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
fire @ jquery.min.js:2
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
S @ jquery.min.js:3
jquery.min.js:2 Uncaught ReferenceError: imlist is not defined
at HTMLDocument.initJS16 (editor16.js:13)
at j (jquery.min.js:2)
at k (jquery.min.js:2)
initJS16 @ editor16.js:13
j @ jquery.min.js:2
k @ jquery.min.js:2
setTimeout (async)
r.readyException @ jquery.min.js:2
(anonymous) @ jquery.min.js:2
j @ jquery.min.js:2
k @ jquery.min.js:2
setTimeout (async)
(anonymous) @ jquery.min.js:2
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
fire @ jquery.min.js:2
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
k @ jquery.min.js:2
setTimeout (async)
(anonymous) @ jquery.min.js:2
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
fire @ jquery.min.js:2
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
S @ jquery.min.js:3
favicon.ico:1 GET http://noc/favicon.ico 404 (Not Found)
but editor workly and I can edit map.
The screenshot shows more clearly:
And new error when I try change map properties;
editor.js:136 Uncaught TypeError: Cannot read property 'slice' of undefined
at HTMLInputElement.help_handler (editor.js:136)
at HTMLInputElement.dispatch (jquery.min.js:3)
at HTMLInputElement.q.handle (jquery.min.js:3)
help_handler @ editor.js:136
dispatch @ jquery.min.js:3
q.handle @ jquery.min.js:3
imlist comes from EditorUI.php:
$imagesJSON = "\nvar imlist = " . json_encode($imageList) . ";\n";
$tpl->set("images_json", $imagesJSON);
editor-resources/template/main-oldstyle.php and main.php output $images_json:
<script type="text/javascript">
<?php echo $map_json; ?>
<?php echo $images_json; ?>
<?php echo $fonts_json; ?>
<?php echo $editor_settings; ?>
var $global_settings = <?php echo $global; ?>;
var $global_settings2 = <?php echo $global2; ?>;
var editor_url = '<?php echo $editor_name; ?>';
var fromplug = <?php echo $fromplug ?>;
var host_url = <?php echo host_url ?>;
</script>
The editor-resources/editor16.js
should probably check whether imlist is null before looping through it though:
function initJS16() {
jQuery.each(imlist, function (index, value) {
// slot in the list of images in:
// node icon selectbox
// map background image
var newitem = jQuery("<option />").attr("value", value).text(value);
jQuery(".imlist").append(newitem);
});
jQuery.each(fontlist, function (index, value) {
// slot in the list of fonts in each of the select boxes where they are expected
var newitem = jQuery("<option />").attr("value", value).text(value);
jQuery(".fontlist").append(newitem);
});
Should become:
function initJS16() {
if (imlist != null)
jQuery.each(imlist, function (index, value) {
// slot in the list of images in:
// node icon selectbox
// map background image
var newitem = jQuery("<option />").attr("value", value).text(value);
jQuery(".imlist").append(newitem);
});
if (fontlist != null)
jQuery.each(fontlist, function (index, value) {
// slot in the list of fonts in each of the select boxes where they are expected
var newitem = jQuery("<option />").attr("value", value).text(value);
jQuery(".fontlist").append(newitem);
});
Though @howardjones may find that this is a problem elsewhere since they shouldn't actually be null. You could add a debugger;
statement as the first line of initJS16()
to check that
No, it should check. Or it shouldn't be included on the front-oldstyle.php template. That's where this error shows up (for me anyway), because in the front page, the same variable dump doesn't happen, so they are null. The better way is probably to break out any javascript used on the front picker page into another file. I don't think there is much - just the thing that hides the warning that javascript isn't enabled.
One other thing I noticed from above, it's not just host_url that should be quoted... shouldn't the others too? $global, $global2 and $editor_settings? (unless these are already defined as being arrays or quoted)
No, they are created from json_encode() so they are already valid javascript objects.
I did wonder why they hadn't flagged up yet š
thx so far, its working now for me :+1:
Now these errors are not present.
But the editor is still not working properly.
The editor does not read the map parameters from the configuration file, nor does it change them.
I also can not edit thith parametr for editor:
Not display button for choose data sourse , info_url graph and overlib graph
No-one ever said the editor was working completely - it's been rewritten completely (apart from the javascript) since 0.98. The basic editing for nodes and links works, but quite a few things around the edges don't.
The picker link should show up though. I'll check that again. (although I already know you'll get a HTTP 500 error when the picker opens)
When I open on browser url editor.php I have button for [Pick from Cacti] but when I click for this link I have error, but not HTTP 500:
No-one ever said the editor was working completely - it's been rewritten completely (apart from the javascript) since 0.98. The basic editing for nodes and links works, but quite a few things around the edges don't.
The editor isn't fully functionality š± š¤£
Well, yeah, but even more than before :-) But it's a lot easier to read than it used to be.
Ok, now I have link for choose data source and it's work.
But I have many device name on Cyrillic (russian) my database have utf8mb4 collection and it's dafault charset for cacti:
for me (austria) it works! thanks! perfect work, and thank you very much for your work on that. But, if i want to create links between Nodes, i get following error: weathermap-cacti10-plugin-mgmt.php // editor.js:84 Uncaught ReferenceError: NodeIDs is not defined at HTMLAreaElement.click_handler (editor.js:213) at HTMLAreaElement.dispatch (jquery.min.js:2) at HTMLAreaElement.y.handle (jquery.min.js:2)
@howardjones You're getting things closer so people's expectations are raising ;-)
@dabeani That sounds like you might have an old version of editor-resources/editor.js
... Will confirm though.
Not sure why commit comments aren't appearing in the issue any more... Anyway, you can add links now @dabeani And @pautiina can look at (but not update) map properties. Still some work to do there. Will have to figure out the utf8 stuff - I haven't done anything special there.
I tend to make sure to add # and the issue number somewhere just so it shows up
Forgot to push. D'oh. That wasn't it last time though.
@pautiina I am able to see Cyrillic hostnames in the picker now with 5c3d53b
@howardjones Many thanks. Really. Now normally displayed.
Hello. I have retest the latest code. Visual editor work normally. But when I choose device for data source my browser print some php notice:
Notice: Undefined index: target in /var/www/data/cacti/plugins/weathermap/lib/Weathermap/Integrations/Cacti/EditorDataPicker.php on line 147
I think there is a change that @howardjones is working on. If I recall over the weekend I saw that he had not pushed it out yet because it relied on another change. This may be related (or not š¤·āāļø )
No, this is a bug. I'll take a look later today.
Closing this now. As far as I know, the editor is back to the functionality of 0.98 again.
Hello. Editor not work correctly. When I open editor, browser console have next error:
and on cacti log: