Cacti / plugin_gexport

Cacti Graph Export Plugin
GNU General Public License v2.0
12 stars 9 forks source link

.js & .css files? #29

Closed cfishwick closed 5 years ago

cfishwick commented 6 years ago

So whilst I love idea behind this plugin and have it installed and performing exports, the resulting index file is unusable as it includes calls to a whole lot of CSS and JS files that are not referenced anywhere else in the plugin. Now, I know that most (all?) is included with various parts of Cacti etc, but that doesn't help with exporting to a different host etc. Is there something I'm missing here?

netniV commented 6 years ago

No, you've hit the nail on the head. The plugin is designed to generate a page where the CSS and JS are used to replicate the look and feel of your cacti installation. If you have these copied over to another server, you can either parse the index.php output and create your own or copy over the static JS/CSS files and then the site will display the index page properly.

cfishwick commented 6 years ago

(edited because I'm a numpty on Monday mornings and didn't error check something)

With regards to the JS & CSS file structure, if "Clear DIrectory" is clicked in export definition, it appears to check if the directories exist, ready for an export, then deletes them all, then completes the export (minus most pretty much all the supporting files, because the directories were deleted). Surely the correct order would be to, before anything else, clear the destination directory, then create the directory structure and then finally export/copy the files into that structure?

netniV commented 6 years ago

That should be what is happening, yes. What makes you believe it's occurring the other way? I haven't actually checked the source at this point to confirm and deny your findings.

cfishwick commented 6 years ago

I believe that's what is happening because everytime I do an export, those directories/files are not present in the end result, despite entering the procdure to create and populate the directories. Further troubleshooting seems to confirm. I think this is also the crux of the issue that @PAOK1926 might also be having in the other issue thread, as without the JS and CSS, the result is the same as the screenshot they posted (i.e. I think the graphs are being created for them, just not displaying properly).

cfishwick commented 6 years ago

Moving this chunk of code: clearstatcache(); if (!is_dir($export_path)) { if (!mkdir($export_path)) { export_fatal($export, "Unable to create path '" . $export_path . "'! Export can not continue."); } } else { if ($export['export_clear'] == 'on') { delTree($export_path, true); } }

from the "export_graphs" function to the "exporter" function in the functions.php file resolves this issue, but probably creates problems elsewhere, I haven't looked hard enough yet.

netniV commented 6 years ago

Feel free to create a PR if you can with your changes. I'll review and commit if it looks right 👍 Alternatively, post your diff files here and I'll apply / commit them.

cfishwick commented 6 years ago

Here's a diff file to apply against functions.php

function.diff.txt

netniV commented 6 years ago

OK, I can see what you did there. I think that should work OK. Probably going to tweak it slightly more but thanks for the pointers 👍

netniV commented 6 years ago

So I went to have a quick look and apparently this isn't the latest version that is in the repository here. Can you verify the version and source location you got your copy from?

cfishwick commented 6 years ago

Well that's weird, I did a git clone. From the INFO file:

[info] name = gexport version = 1.4.1 longname = Graph Export Package for Cacti author = The Cacti Group email = homepage = http://www.cacti.net compat = 1.1.10 capabilities = online_view:1, online_mgmt:1, offline_view:0, offline_mgmt:0, remote_collect:0

netniV commented 6 years ago

Does your functions.php mirror https://github.com/Cacti/plugin_gexport/blob/develop/functions.php

cfishwick commented 6 years ago

According to diff the git clone version and the one above are identical.

netniV commented 6 years ago

I’m confused by that then because line 416 in your diff was the one that was changed. If that is the functions file that is part of the git clone, the online source doesn’t show code that matches before or after.

dsclassen commented 5 years ago

I'm not sure if this is related, but in the functions.php file there is a reference to a query-migrate.js file that does not exist in the cacti develop branch.

copy("$root_path/include/js/jquery-migrate.js", "$export_path/js/jquery-migrate.js");
netniV commented 5 years ago

As of Cacti Core 1.2, we do not utilise the the jquery-migrate any more. But we haven't reviewed the plugins yet for 1.2 compatibility. That will be coming shortly.

netniV commented 5 years ago

I've made an update to try and make more compatible with 1.2. See if that helps you.