Open cross opened 4 years ago
Definitely doable, but as I review what's going in the javascript, I'm reminded why I decided to let the working code remain instead of some better, more centralized system like you're explaining.
Anyway, here are the pertinent points I think you'll want to hit to make this happen:
Here's the code where the profiles information is generated on the server side. https://github.com/hexparrot/mineos-node/blob/fd8396e678f00214e3353d1dff56a2bc0bbf8f1c/server.js#L200
Since both the send_profile_list
and send_spigot_list
don't actually "return" a value (but instead implement the side effect of sending the list via the .emit
, I believe the backend is not the ideal place to implement this. It certainly is possible, but it could also get a bit messy.
Now, in your browser javascript console of the webui, type this:
angular.element('[ng-controller=Webui]').scope()
This should provide you with all the variables live inside the scope of the webui itself. The notable items are profiles
and spigot_list
. spigot_list
is naturally what populates the Spigot page--but more specifically, the spigot builds that actually have a present .jar
.
There's some snags. For example, sending the profile list and the spigot list are two, separate, asynchronous operations. If the socket listeners on the client can consolidate both these lists in to $scope.profiles, that would work, but it also means these items would show up on the Profiles page, which would replace nonsense in the server dropdown, with nonsense in the profile dropdown.
I wonder if it's possible, then, to instead have the Server Status dropdown just list more:
Here, instead of p as p.id group by p.group for p in profiles
, it can iterate profiles and the dummy-generated stuff required to match the information a profile needs:
downloaded: false
filename: "paperclip.jar"
group: "paperspigot"
id: "paperspigot-latest"
releaseTime: 1578088294179
release_version: ""
time: 1578088294179
type: "release"
url: "https://ci.destroystokyo.com/job/PaperSpigot/lastSuccessfulBuild/artifact/paperclip.jar"
version: 0
webui_desc: "Latest paperclip release"
weight: 0
So in other words, create this entry from the information that exists in spigot_list
and modify the dropdown to also include these entries. I think the only important ones would be filename, group, id. Everything else a dummy, filler value. That way, when you choose it from the dropdown, the myprofile
variable that gets populated with this javascript array is available to the button "Copy profile to live server files".
Time is cut short, so I may be missing some details but I hope this helps out. Can definitely provide more insight if you have something specific you're interested in.
Hmm. Okay. Well, thinking about doing it in the client side based on profiles
and spigot_list
isn't something I thought of, but I see now why that's likely the best thing to do. It fixes the issue I had in the U/I, and I suspect we can make everything else fall out of that solution.
The bottom part you wrote above describing details of that I'm a little unclear on, however. All of those dummy-values are already in the profiles objects. Oh, I see, you're thinking about pre-processing the spigot_list
array, and then building these "profiles" object-like things to shove into something that the drop-down iterates in addition to the profiles
array?
Could the existing p as p.id group by p.group for p in profiles
just be changed to iterate over both of those lists, and just do different things with the values in spigot_list
than the ones in profiles
? Or is that substantially harder to code than just pre-building something in the same form as the profiles
members from the items in spigot_list
?
I may experiment, but I get the outline of what you're suggesting and agree it's the best way to reach my goal. And, after this, the value of the "Copy to Server" button on the Spigot page is less needed, could even remove it in theory. :-)
On a related note, the dashboard sometimes shows nothing in the "Profile" column for a server, which I think is reasonable if it's running a spigot from it's server directory. But, there is no way to select no profile from the Server Status page. Shouldn't there be, and then it's just restricted to running jar's from the server directory?
Hey there. I have a concern operating spigot servers in my MineOS. In the server status page, the various spigot versions I have built (using the Spigot interface in the sidebar) do not appear in the "Server Actions" profile drop-down.
I believe this is due to how that list is generated in profiles.js, which is presumably also what's used on the main "Profiles" page in the sidebar.
For Spigot's available downloads, I understand that BuildTools.jar is the only reasonable thing in that main Profiles page. However, after using the Spigot page accessible from the side-bar, there are new directories created in base_directory/profiles. And, after that, it should be possible to see, and choose, these profiles in the drop-down within "Server Actions" chooser. That way, one wouldn't have to copy the jar files into the server root (which isn't so bad, but) and there wouldn't be a non-sensical "Profile" value left set for these servers.
I can supply screen-caps for more detail, and I am happy to code the solution, but I would like your thoughts @hexparrot about what the pros and cons are here, as you've had your head around this before.