1+ < head >
2+ <!-- Meta -->
3+ < meta charset ="utf-8 ">
4+ < meta name ="viewport " content ="width=device-width, initial-scale=1, shrink-to-fit=no ">
5+ < title > Kubek - Minecraft Servers</ title >
6+
7+ <!-- MDB -->
8+ < script src ="js/mdb.min.js "> </ script >
9+ < link rel ="stylesheet " href ="css/mdb.min.css ">
10+
11+ <!-- Others -->
12+ < script src ="js/jquery-3.6.0.min.js "> </ script >
13+ < link rel ="stylesheet " href ="css/animate.min.css " />
14+ < link rel ="stylesheet " href ="css/toastify.min.css " />
15+ < script src ="js/socket.io.min.js "> </ script >
16+ < script src ="js/toastify-js.js "> </ script >
17+ < script src ="js/sweetalert2.all.min.js "> </ script >
18+
19+ <!-- Own -->
20+ < link rel ="stylesheet " href ="css/globals.css " />
21+ < link rel ="stylesheet " href ="css/template.nav.css " />
22+ < script src ="js/funcs.js "> </ script >
23+
24+ <!-- Fonts and icons -->
25+ < link rel ="preconnect " href ="https://fonts.googleapis.com ">
26+ < link rel ="preconnect " href ="https://fonts.gstatic.com " crossorigin >
27+ < link
28+ href ="https://fonts.googleapis.com/css2?family=Open Sans:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap "
29+ rel ="stylesheet ">
30+ < link href ="https://fonts.googleapis.com/icon?family=Material+Icons " rel ="stylesheet ">
31+
32+ <!-- Page unique -->
33+ < link rel ="stylesheet " href ="css/pages/hardware-info.css ">
34+ </ head >
35+
36+ < body >
37+ < div id ="oldc ">
38+ < p class ="fs-1 fw-bold "> Software summary</ p >
39+ < table class ="table ">
40+ < tbody >
41+ < tr >
42+ < th style ="text-align:left; ">
43+ < div class ="d-flex align-items-center ">
44+ < span class ="material-icons "> wysiwyg</ span >
45+ < span style ="margin-left: 16px; "> OS Name</ span >
46+ </ div >
47+ </ th >
48+ < td style ="text-align:right; " id ="os-name "> Unknown</ td >
49+ </ tr >
50+ < tr >
51+ < th style ="text-align:left; ">
52+ < div class ="d-flex align-items-center ">
53+ < span class ="material-icons "> wysiwyg</ span >
54+ < span style ="margin-left: 16px; "> OS Build</ span >
55+ </ div >
56+ </ th >
57+ < td style ="text-align:right; " id ="os-build "> Unknown</ td >
58+ </ tr >
59+ </ tbody >
60+ </ table >
61+ < p class ="fs-1 fw-bold "> CPU and memory</ p >
62+ < table class ="table ">
63+ < tbody >
64+ < tr >
65+ < th style ="text-align:left; ">
66+ < div class ="d-flex align-items-center ">
67+ < span class ="material-icons "> memory</ span >
68+ < span style ="margin-left: 16px; "> Total RAM</ span >
69+ </ div >
70+ </ th >
71+ < td style ="text-align:right; " id ="totalmem "> Unknown</ td >
72+ </ tr >
73+ < tr >
74+ < th style ="text-align:left; ">
75+ < div class ="d-flex align-items-center ">
76+ < span class ="material-icons "> memory</ span >
77+ < span style ="margin-left: 16px; "> CPU Model</ span >
78+ </ div >
79+ </ th >
80+ < td style ="text-align:right; " id ="cpu-model "> Unknown</ td >
81+ </ tr >
82+ < tr >
83+ < th style ="text-align:left; ">
84+ < div class ="d-flex align-items-center ">
85+ < span class ="material-icons "> memory</ span >
86+ < span style ="margin-left: 16px; "> CPU Speed</ span >
87+ </ div >
88+ </ th >
89+ < td style ="text-align:right; " id ="cpu-speed "> Unknown</ td >
90+ </ tr >
91+ </ tbody >
92+ </ table >
93+ < p class ="fs-1 fw-bold "> Local disks</ p >
94+ < table class ="table " id ="disks-table ">
95+ < thead >
96+ < tr >
97+ < th > Letter</ th >
98+ < th > Type</ th >
99+ < th > Used</ th >
100+ < th > Free</ th >
101+ < th > Total </ th >
102+ < th > Used %</ th >
103+ </ tr >
104+ </ thead >
105+ < tbody > </ tbody >
106+ </ table >
107+ < p class ="fs-1 fw-bold "> Enviroment values</ p >
108+ < table class ="table " id ="env-table ">
109+ < tbody > </ tbody >
110+ </ table >
111+ </ div >
112+ </ body >
113+
114+ < script >
115+ var socket ;
116+ $ ( document ) . ready ( function ( ) {
117+ loadTemplate ( function ( ) {
118+ hideLoading ( ) ;
119+ } ) ;
120+ socket = openSocket ( ) ;
121+ socket . on ( "handshake" , function ( ) {
122+ console . log ( "Socket handshake success" ) ;
123+ socket . emit ( "update" , {
124+ type : "servers"
125+ } ) ;
126+ $ . get ( "/kubek/hardware" , function ( hw ) {
127+ for ( var key in hw . enviroment ) {
128+ value = hw . enviroment [ key ] ;
129+ $ ( "#env-table tbody" ) . append ( '<tr><th style="text-align:left;">' + key +
130+ '</th><td style="text-align:right;">' + value + '</td></tr>' ) ;
131+ }
132+ hw . disks . forEach ( function ( disk ) {
133+ console . log ( disk ) ;
134+ type = disk [ '_filesystem' ] ;
135+ letter = disk [ '_mounted' ] ;
136+ total = Math . round ( disk [ '_blocks' ] / 1024 / 1024 / 1024 ) + " GB" ;
137+ used = Math . round ( disk [ '_used' ] / 1024 / 1024 / 1024 ) + " GB" ;
138+ free = Math . round ( disk [ '_available' ] / 1024 / 1024 / 1024 ) + " GB" ;
139+ percent = disk [ '_capacity' ] ;
140+ $ ( "#disks-table tbody" ) . append ( '<tr><td>' + letter + '</td><td>' + type + '</td><td>' + used + '</td><td>' + free + '</td><td>' + total + '</td><td>' + percent + '</td></tr>' ) ;
141+ } ) ;
142+ $ ( "#os-name" ) . text ( hw . platform . version + " (" + hw . platform . arch + ")" ) ;
143+ $ ( "#os-build" ) . text ( hw . platform . release ) ;
144+ $ ( "#totalmem" ) . text ( hw . totalmem + " Mb" ) ;
145+ $ ( "#cpu-model" ) . text ( hw . cpu . model + " (" + hw . cpu . cores + " cores)" ) ;
146+ $ ( "#cpu-speed" ) . text ( hw . cpu . speed + " MHz" ) ;
147+ } ) ;
148+ } ) ;
149+ socket . on ( "handleUpdate" , function ( arg ) {
150+ type = arg . type ;
151+ data = arg . data ;
152+ switch ( type ) {
153+ case "servers" :
154+ if ( data [ currentServer ] . status == "stopped" ) {
155+ $ ( "#server-status" ) . removeClass ( "badge-success badge-warning" ) ;
156+ $ ( "#server-status" ) . addClass ( "badge-danger" ) ;
157+ $ ( "#server-status" ) . html ( "Offline" ) ;
158+ $ ( "#server-start-button" ) . show ( ) ;
159+ $ ( "#server-stop-button" ) . hide ( ) ;
160+ } else if ( data [ currentServer ] . status == "started" ) {
161+ $ ( "#server-status" ) . removeClass ( "badge-danger badge-warning" ) ;
162+ $ ( "#server-status" ) . addClass ( "badge-success" ) ;
163+ $ ( "#server-status" ) . html ( "Online" ) ;
164+ $ ( "#server-start-button" ) . hide ( ) ;
165+ $ ( "#server-stop-button" ) . show ( ) ;
166+ } else if ( data [ currentServer ] . status == "starting" ) {
167+ $ ( "#server-status" ) . removeClass ( "badge-success badge-danger" ) ;
168+ $ ( "#server-status" ) . addClass ( "badge-warning" ) ;
169+ $ ( "#server-status" ) . html ( "Starting" ) ;
170+ $ ( "#server-start-button" ) . hide ( ) ;
171+ $ ( "#server-stop-button" ) . hide ( ) ;
172+ } else if ( data [ currentServer ] . status == "stopping" ) {
173+ $ ( "#server-status" ) . removeClass ( "badge-success badge-danger" ) ;
174+ $ ( "#server-status" ) . addClass ( "badge-warning" ) ;
175+ $ ( "#server-status" ) . html ( "Stopping" ) ;
176+ $ ( "#server-start-button" ) . hide ( ) ;
177+ $ ( "#server-stop-button" ) . hide ( ) ;
178+ }
179+ break ;
180+ case "downloadTasks" :
181+ $ ( ".ntc-pool" ) . html ( "" ) ;
182+ Object . keys ( data ) . forEach ( function ( k ) {
183+ $ ( ".ntc-pool" ) . append (
184+ '<div class="ntc ntc-poolbox" style="background: rgb(43,53,63); color: white;"><div class="ntb">Downloading ' +
185+ k + ' (' + data [ k ] + '%)</div><div class="ntb"><progress max="100" value="' + data [ k ] +
186+ '" class="pnf"></progress></div></div>' ) ;
187+ } ) ;
188+ break ;
189+ }
190+ } ) ;
191+ } ) ;
192+ </ script >
0 commit comments