hexparrot / mineos-node

node.js implementation of mineos minecraft management
GNU General Public License v3.0
333 stars 169 forks source link

Feature Request: Optional columns on dashboard server list #314

Open cross opened 4 years ago

cross commented 4 years ago

I have multiple IP addresses on my server, so the "port" alone is not very useful. Additionally, I added a column to display the ping version. These "Version" and "IP" columns are useful for me, but assumedly would be un-interesting to the general population, as they weren't there already.

I don't know Node or Angular well enough to know how to make "optional" columns, but would like that feature. Fully configurable columns would be ideal.

hexparrot commented 4 years ago

Pretty simple, luckily! Check out index.html:

diff --git a/html/index.html b/html/index.html
index 37568a1..13739dc 100644
--- a/html/index.html
+++ b/html/index.html
@@ -409,6 +409,7 @@
                                             <tr>
                                                 <th translate="SERVER"></th>
                                                 <th translate="PROFILE"></th>
+                                                <th class="hidden-phone">IP</th>
                                                 <th class="hidden-phone" translate="PORT"></th>
                                                 <th translate="STATUS"></th>
                                                 <th translate="MEMORY"></th>
@@ -421,6 +422,7 @@
                                                     <a ng-click="$parent.change_page('server_status', server_name)">{{ server_name }}</a>
                                                 </td>
                                                 <td><a ng-attr-title="{{ 'MC Protocol: ' + instance.heartbeat.ping.protocol }}">{{ instance.sc.minecraft.profile }}</a></td>
+                                                <td class="hidden-phone">{{ (instance.sc.minecraft.unconventional ? '-----' : instance.sp['server-ip']) }}</td>
                                                 <td class="hidden-phone">{{ (instance.sc.minecraft.unconventional ? '-----' : instance.sp['server-port']) }}</td>
                                                 <td><span class="label" ng-show="instance.heartbeat" ng-class="{'label-success': instance.heartbeat.up, 'label-important': !instance.heartbeat.up}">{{ instance.heartbeat.up ? 'up' : 'down' }}</span></td>
                                                 <td>{{ instance.heartbeat.memory.VmRSS | kb_string_to_mb }}</td>

Long story short, add a column header to the table header, add the column's contents to a table row.

Of course, if you're asking how to make them "optional" in that they can be freely added and removed without sourcecode changes, then yes, it'll be a bit more involving. It'll require a system that can hold state--and likely that state is held server side (for persistence), which means adding new entries to mineos.conf or the like.

From there, you would have to send that information (via .emit) and then you'd create a loop in both the top <tr>s, one which adds n <th> elements and the same amount of <td> in the body.

cross commented 4 years ago

Yeah. I'd already figured out how to add the columns I wanted. I'll hook that into a PR for review, though it's not working so not for merge. State would be ideal, but not 100% required. I had figured it would be kinda like the MASK_PASSWORD variable in login.html, and per-server. Though, thinking about it again, yeah, it should likely even be user specific. Does MineOS have user-preferences of any sort even?

hexparrot commented 4 years ago

Functionality implemented in master branch as https://github.com/hexparrot/mineos-node/commit/857c25d0cdb89a43c0e15ada938c474a462c214e.

Add optional_columns = ''server-ip,motd" to your mineos.conf and restart the webui.