Rebuild ReactJS files for current master branch ?

Support questions about the Network Weather Map plugin

Moderators: Developers, Moderators

Post Reply
gmontassis
Posts: 7
Joined: Tue Jun 11, 2019 8:42 am

Rebuild ReactJS files for current master branch ?

Post by gmontassis »

Hi,

Do you have any idea how to rebuild the ReactJS files for the "master" branch ?

1/ I installed the necessary dependencies :

* From Weathermap plugin's root :

Code: Select all

$ npm install
$ npm audit fix
$ composer update
* Then from "websrc/cacti-mgmt/" :

Code: Select all

$ npm install
$ npm audit fix --force
2/ "postbuild.js" edition to apply the following fixes:

Code: Select all

--- postbuild-orig.js   2019-06-11 15:49:58.102675877 +0200
+++ postbuild.js        2019-06-11 15:50:09.090316355 +0200
@@ -8,14 +8,14 @@
 const src = './build/';
 const dest = '../../cacti-resources/mgmt/';

-const targets = ["main.js", "main.css", "main.css.map", "main.js.map"];
+const targets = ["main.js", "main.css"];


 //const target = "main.js";

 for (let target of targets) {

-    let file = require('./build/asset-manifest.json')[target];
+    let file = require('./build/asset-manifest.json')["files"][target];
     console.log(`${src}${file} => ${dest}${target}`);

     if (!fs.existsSync(dest)) {
3/ But when I run "npm run build" :

Code: Select all

$ npm run build

> cacti-mgmt@1.0.0 build /var/www/cacti/cacti-1.2.3/plugins/weathermap/websrc/cacti-mgmt
> react-scripts build

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  78.56 KB  build/static/js/2.5cdd15b6.chunk.js
  6.95 KB   build/static/js/main.bb1cce28.chunk.js
  1.22 KB   build/static/css/main.2f1ad4ce.chunk.css
  762 B     build/static/js/runtime~main.a8a9905a.js
  353 B     build/static/css/2.126055ff.chunk.css

The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:

  "homepage" : "http://myname.github.io/myapp",

The build folder is ready to be deployed.
You may serve it with a static server:

  npm install -g serve
  serve -s build

Find out more about deployment here:

  https://bit.ly/CRA-deploy


> cacti-mgmt@1.0.0 postbuild /var/www/cacti/cacti-1.2.3/plugins/weathermap/websrc/cacti-mgmt
> node postbuild.js

./build//static/js/main.bb1cce28.chunk.js => ../../cacti-resources/mgmt/main.js
./build//static/css/main.2f1ad4ce.chunk.css => ../../cacti-resources/mgmt/main.css
Although there is no error message and the target files have been rebuilt and replaced, I only have the following reduced display in Cacti :

----------
This is the React UI below here
INCOMPLETE
Testing API
Map List - Settings - Map Files
----------

-> Does anyone know how to rebuild the "main.js" and "main.css" files with all the features currently available on "master" ? I intend to apply the same for "cacti-user/" once this one will be solved :-)

Let me know !

Gilles
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Rebuild ReactJS files for current master branch ?

Post by Howie »

That all looked right to me. What does the javascript console in your browser say?

(what features do you think you are missing? I don't think the compiled javascript files are out of date...)
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
gmontassis
Posts: 7
Joined: Tue Jun 11, 2019 8:42 am

Re: Rebuild ReactJS files for current master branch ?

Post by gmontassis »

Hi Howard,

Thanks for your reply.
Howie wrote:That all looked right to me. What does the javascript console in your browser say?
No error in console or network.
Howie wrote:(what features do you think you are missing? I don't think the compiled javascript files are out of date...)
Here is the IHM before :
Plugin IHM before rebuilding it
Plugin IHM before rebuilding it
before.png (30.74 KiB) Viewed 4396 times
And after :
Plugin IHM after rebuilding it
Plugin IHM after rebuilding it
after.png (6.7 KiB) Viewed 4396 times
As you can see, a lot of things are missing...

Gilles
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Rebuild ReactJS files for current master branch ?

Post by Howie »

No, I meant why did you want to rebuild?

The parts that are missing NOW in your system are all the React parts :-)
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
gmontassis
Posts: 7
Joined: Tue Jun 11, 2019 8:42 am

Re: Rebuild ReactJS files for current master branch ?

Post by gmontassis »

Howie wrote:No, I meant why did you want to rebuild?

The parts that are missing NOW in your system are all the React parts :-)
My goal is to see how it all works in order to adapt the plugin to the v1.x of Cacti.
I thought that the "main.js" and "main.css" files currently available on master had been generated this way ... but apparently not.

Is the use of ReactJS mandatory ? Could not the plugin be ported to the new version of Cacti otherwise ?

I will give it a try but it seems to require a lot of work redesign as well as a huge knowledge of the existing plugin code...

Thank you for your answers.

Gilles
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Rebuild ReactJS files for current master branch ?

Post by Howie »

No, that's how they were generated. It should work. It's just not necessary if all you were going to do is use it.

And yes, as part of breaking the project up between Cacti and Weathermap, we will be looking to make something more like the older plugin.

Not sure why wouldn't you expect to need knowledge of the existing plugin?? That how rewriting software usually works...
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
gmontassis
Posts: 7
Joined: Tue Jun 11, 2019 8:42 am

Re: Rebuild ReactJS files for current master branch ?

Post by gmontassis »

Hello Howard,
Howie wrote:No, that's how they were generated. It should work. It's just not necessary if all you were going to do is use it.
OK. So, if these files were really rebuilt following the procedure described in my first message, why by restarting the reconstruction I see a different display in Cacti ?
How do you do on your side to generate the "main.js" and "main.css" files that are on the "master" branch ?
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Rebuild ReactJS files for current master branch ?

Post by Howie »

gmontassis wrote:Hello Howard,
Howie wrote:No, that's how they were generated. It should work. It's just not necessary if all you were going to do is use it.
OK. So, if these files were really rebuilt following the procedure described in my first message, why by restarting the reconstruction I see a different display in Cacti ?
How do you do on your side to generate the "main.js" and "main.css" files that are on the "master" branch ?
"npm run build"

I'll give it a try later today. I haven't built them in a while.

EDIT: I just noticed "$ npm audit fix --force" in your output. So I guess that the breaking changes you ignored really were breaking changes. :-)

Just trying this myself now.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
gmontassis
Posts: 7
Joined: Tue Jun 11, 2019 8:42 am

Re: Rebuild ReactJS files for current master branch ?

Post by gmontassis »

Howie wrote:
gmontassis wrote:How do you do on your side to generate the "main.js" and "main.css" files that are on the "master" branch ?
"npm run build"
That's what I did (as explained in my first post).
Howie wrote:I'll give it a try later today. I haven't built them in a while.
OK, let me know !
Thanks
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Rebuild ReactJS files for current master branch ?

Post by Howie »

So, it worked fine for me. I've updated the various dependencies to address some security issues. I needed to add a browsers section to each package.json, but that was so that the dev server would run, as far as I can tell.

Please don't work on the React stuff though - it's going to go away.
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
gmontassis
Posts: 7
Joined: Tue Jun 11, 2019 8:42 am

Re: Rebuild ReactJS files for current master branch ?

Post by gmontassis »

Howie wrote:So, it worked fine for me. I've updated the various dependencies to address some security issues. I needed to add a browsers section to each package.json, but that was so that the dev server would run, as far as I can tell.
Thanks. I guess it should be more system specific...
Howie wrote:Please don't work on the React stuff though - it's going to go away.
Good news. I thought everything would be rewritten this way !
gmontassis
Posts: 7
Joined: Tue Jun 11, 2019 8:42 am

Re: Rebuild ReactJS files for current master branch ?

Post by gmontassis »

Howard,
Howie wrote:Please don't work on the React stuff though - it's going to go away.
However, I read in "lib/Weathermap/Integrations/Cacti/README.md" than you were intending to do a big rewrite with ReactJS :
lib/Weathermap/Integrations/Cacti/README.md wrote:I am intending to do all the page-rendering for Weathermap on the client-side, using two React-based applications
Why did you give up the idea ?
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Re: Rebuild ReactJS files for current master branch ?

Post by Howie »

Because it's already hard to get collaboration on the project, and that just makes it harder :-)
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests