RCON Improvement

This commit is contained in:
Casey
2022-06-13 21:08:41 -04:00
committed by CHOMPStation2
parent 30d721f502
commit 42b6f8847c
8 changed files with 83 additions and 33 deletions

View File

@@ -1,3 +1,5 @@
#define SMES_PER_PAGE 4
/datum/tgui_module/rcon /datum/tgui_module/rcon
name = "Power RCON" name = "Power RCON"
tgui_id = "RCON" tgui_id = "RCON"
@@ -5,17 +7,41 @@
var/list/known_SMESs = null var/list/known_SMESs = null
var/list/known_breakers = null var/list/known_breakers = null
var/filtered_smeslist = list()
var/current_page = 1
var/number_pages = 0
/datum/tgui_module/rcon/proc/filter_smeslist(var/page)
number_pages = known_SMESs.len / SMES_PER_PAGE
if(number_pages != round(number_pages))
number_pages = round(number_pages) + 1
var/page_index = page - 1
var/lower_bound = page_index * SMES_PER_PAGE + 1
var/upper_bound = (page_index + 1) * SMES_PER_PAGE
upper_bound = min(upper_bound, known_SMESs.len)
filtered_smeslist = list()
for(var/index = lower_bound, index <= upper_bound, index++)
filtered_smeslist += known_SMESs[index]
/datum/tgui_module/rcon/tgui_data(mob/user) /datum/tgui_module/rcon/tgui_data(mob/user)
FindDevices() // Update our devices list FindDevices() // Update our devices list
var/list/data = ..() var/list/data = ..()
filter_smeslist(current_page)
// SMES DATA (simplified view) // SMES DATA (simplified view)
var/list/smeslist[0] var/list/smeslist[0]
for(var/obj/machinery/power/smes/buildable/SMES in known_SMESs) for(var/obj/machinery/power/smes/buildable/SMES in filtered_smeslist)
var/list/smes_data = SMES.tgui_data() var/list/smes_data = SMES.tgui_data()
smes_data["RCON_tag"] = SMES.RCon_tag smes_data["RCON_tag"] = SMES.RCon_tag
smeslist.Add(list(smes_data)) smeslist.Add(list(smes_data))
data["pages"] = number_pages
data["current_page"] = current_page
data["smes_info"] = sortByKey(smeslist, "RCON_tag") data["smes_info"] = sortByKey(smeslist, "RCON_tag")
// BREAKER DATA (simplified view) // BREAKER DATA (simplified view)
@@ -34,6 +60,10 @@
return TRUE return TRUE
switch(action) switch(action)
if("set_smes_page")
var/page = params["index"]
current_page = page
. = TRUE
if("smes_in_toggle") if("smes_in_toggle")
var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(params["smes"]) var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(params["smes"])
if(SMES) if(SMES)

View File

@@ -53,6 +53,10 @@ export class Tooltip extends Component<TooltipProps, TooltipState> {
<Popper <Popper
options={{ options={{
placement: this.props.position || "auto", placement: this.props.position || "auto",
modifiers: [{
name: "eventListeners",
enabled: false,
}],
}} }}
popperContent={ popperContent={
<div <div

View File

@@ -4,7 +4,7 @@
* @license MIT * @license MIT
*/ */
import { clamp01 } from 'common/math'; import { Loader } from "./common/Loader";
import { useBackend } from '../backend'; import { useBackend } from '../backend';
import { Component, createRef } from 'inferno'; import { Component, createRef } from 'inferno';
import { Box, Flex, Section } from '../components'; import { Box, Flex, Section } from '../components';
@@ -135,15 +135,3 @@ export class AlertModal extends Component {
} }
} }
export const Loader = props => {
const { value } = props;
return (
<div className="AlertModal__Loader">
<Box
className="AlertModal__LoaderProgress"
style={{ width: clamp01(value) * 100 + '%' }} />
</div>
);
};

View File

@@ -4,9 +4,9 @@
* @license MIT * @license MIT
*/ */
import { clamp01 } from 'common/math'; import { Loader } from "./common/Loader";
import { useBackend, useLocalState } from '../backend'; import { useBackend, useLocalState } from '../backend';
import { Box, Button, Section, Input, Stack } from '../components'; import { Button, Section, Input, Stack } from '../components';
import { KEY_DOWN, KEY_UP, KEY_ENTER, KEY_SPACE, KEY_ESCAPE, KEY_HOME, KEY_END } from 'common/keycodes'; import { KEY_DOWN, KEY_UP, KEY_ENTER, KEY_SPACE, KEY_ESCAPE, KEY_HOME, KEY_END } from 'common/keycodes';
import { Window } from '../layouts'; import { Window } from '../layouts';
@@ -210,16 +210,3 @@ export const ListInput = (props, context) => {
</Window> </Window>
); );
}; };
export const Loader = props => {
const { value } = props;
return (
<div className="ListInput__Loader">
<Box
className="ListInput__LoaderProgress"
style={{
width: clamp01(value) * 100 + '%',
}} />
</div>
);
};

View File

@@ -14,7 +14,7 @@ export const RCON = (props, context) => {
return ( return (
<Window <Window
width={630} width={630}
height={440} height={540}
resizable> resizable>
<Window.Content scrollable> <Window.Content scrollable>
<RCONContent /> <RCONContent />
@@ -61,10 +61,16 @@ const RCONSmesList = (props, context) => {
const { const {
smes_info, smes_info,
pages,
current_page,
} = data; } = data;
const runCallback = (cb) => {
return cb();
};
return ( return (
<Section title="SMESs"> <Section title={"SMESs (Page " + current_page + ")"}>
<Stack vertical> <Stack vertical>
{smes_info.map(smes => ( {smes_info.map(smes => (
<Stack.Item key={smes.RCON_tag}> <Stack.Item key={smes.RCON_tag}>
@@ -72,6 +78,23 @@ const RCONSmesList = (props, context) => {
</Stack.Item> </Stack.Item>
))} ))}
</Stack> </Stack>
Page Selection:<br />
{runCallback(() => {
const row = [];
for (let i = 1; i < pages; i++) {
row.push(
<Button
selected={current_page === i}
key={i}
onClick={() => act("set_smes_page", {
index: i,
})}>
{i}
</Button>
);
}
return row;
})}
</Section> </Section>
); );
}; };

View File

@@ -0,0 +1,14 @@
import { Box } from '../../components';
import { clamp01 } from 'common/math';
export const Loader = props => {
const { value } = props;
return (
<div className="AlertModal__Loader">
<Box
className="AlertModal__LoaderProgress"
style={{ width: clamp01(value) * 100 + '%' }} />
</div>
);
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long