import { Fragment } from 'inferno';
import { useBackend } from '../backend';
import { Box, Button, Dimmer, Icon, LabeledList, ProgressBar, Section } from '../components';
import { Window } from '../layouts';
import { InterfaceLockNoticeBox } from './common/InterfaceLockNoticeBox';
import { FullscreenNotice } from './common/FullscreenNotice';
export const APC = (props, context) => {
const { act, data } = useBackend(context);
let body = ;
if (data.gridCheck) {
body = ;
} else if (data.failTime) {
body = ;
}
return (
{body}
);
};
const powerStatusMap = {
2: {
color: 'good',
externalPowerText: 'External Power',
chargingText: 'Fully Charged',
},
1: {
color: 'average',
externalPowerText: 'Low External Power',
chargingText: 'Charging',
},
0: {
color: 'bad',
externalPowerText: 'No External Power',
chargingText: 'Not Charging',
},
};
const malfMap = {
1: {
icon: 'terminal',
content: 'Override Programming',
action: 'hack',
},
// 2: {
// icon: 'caret-square-down',
// content: 'Shunt Core Process',
// action: 'occupy',
// },
// 3: {
// icon: 'caret-square-left',
// content: 'Return to Main Core',
// action: 'deoccupy',
// },
// 4: {
// icon: 'caret-square-down',
// content: 'Shunt Core Process',
// action: 'occupy',
// },
};
const ApcContent = (props, context) => {
const { act, data } = useBackend(context);
const locked = data.locked && !data.siliconUser;
const normallyLocked = data.normallyLocked;
const externalPowerStatus = powerStatusMap[data.externalPower] || powerStatusMap[0];
const chargingStatus = powerStatusMap[data.chargingStatus] || powerStatusMap[0];
const channelArray = data.powerChannels || [];
// const malfStatus = malfMap[data.malfStatus] || null;
const adjustedCellChange = data.powerCellStatus / 100;
return (
Fault in ID authenticator.
Please contact maintenance for service.
}
/>
act('breaker')}
/>
}>
[ {externalPowerStatus.externalPowerText} ]
act('charge')}
/>
}>
[ {chargingStatus.chargingText} ]
{channelArray.map((channel) => {
const { topicParams } = channel;
return (
= 2 ? 'good' : 'bad'}>
{channel.status >= 2 ? 'On' : 'Off'}
);
})}
{data.totalCharging ? (
{data.totalLoad} W (+ {data.totalCharging} W charging)
) : (
{data.totalLoad} W
)}
act('overload')} />
}>
act('cover')}
/>
}
/>
act('nightshift', {
nightshift: 2,
})
}
/>
act('nightshift', {
nightshift: 1,
})
}
/>
act('nightshift', {
nightshift: 3,
})
}
/>
}
/>
act('emergency_lighting')}
/>
}
/>
);
};
const GridCheck = (props, context) => {
return (
Power surge detected, grid check in effect...
);
};
const ApcFailure = (props, context) => {
const { data, act } = useBackend(context);
let rebootOptions = act('reboot')} />;
if (data.locked && !data.siliconUser) {
rebootOptions = Swipe an ID card for manual reboot.;
}
return (
SYSTEM FAILURE
I/O regulators malfunction detected! Waiting for system reboot...
Automatic reboot in {data.failTime} seconds...
{rebootOptions}
);
};