diff --git a/apiserver/apiserver/api/throttles.py b/apiserver/apiserver/api/throttles.py index cdaabe1..a5d1348 100644 --- a/apiserver/apiserver/api/throttles.py +++ b/apiserver/apiserver/api/throttles.py @@ -24,7 +24,7 @@ class LoggingThrottle(throttling.BaseThrottle): return True elif path == '/sessions/' and user == None: return True - elif path in ['/pinball/high_scores/', '/protocoin/printer_balance/', '/hosting/high_scores/']: + elif path in ['/pinball/high_scores/', '/protocoin/printer_balance/', '/hosting/high_scores/', '/stats/ord2/printer3d/', '/stats/ord3/printer3d/']: return True if request.data: diff --git a/apiserver/apiserver/api/utils_stats.py b/apiserver/apiserver/api/utils_stats.py index f81c811..832c162 100644 --- a/apiserver/apiserver/api/utils_stats.py +++ b/apiserver/apiserver/api/utils_stats.py @@ -30,6 +30,7 @@ DEFAULTS = { 'autoscan': '', 'last_scan': {}, 'closing': {}, + 'printer3d': {}, } if secrets.MUMBLE: diff --git a/apiserver/apiserver/api/views.py b/apiserver/apiserver/api/views.py index 405dbd4..cdb5fe2 100644 --- a/apiserver/apiserver/api/views.py +++ b/apiserver/apiserver/api/views.py @@ -953,6 +953,23 @@ class StatsViewSet(viewsets.ViewSet, List): return Response(200) + @action(detail=True, methods=['post']) + def printer3d(self, request, pk=None): + printer3d = cache.get('printer3d', {}) + + devicename = pk + status = request.data['result']['status'] + + printer3d[devicename] = dict( + progress=int(status['display_status']['progress'] * 100), + #filename=status['print_stats']['filename'], + state=status['idle_timeout']['state'], + ) + cache.set('printer3d', printer3d) + + return Response(200) + + class MemberCountViewSet(Base, List): pagination_class = None diff --git a/webclient/src/Home.js b/webclient/src/Home.js index fbd9be4..b865298 100644 --- a/webclient/src/Home.js +++ b/webclient/src/Home.js @@ -244,6 +244,8 @@ export function Home(props) { const closedStat = (x) => stats && stats.closing ? moment().unix() > stats.closing['time'] ? 'Closed' : 'Open until ' + stats.closing['time_str'] : 'Unknown'; + const printer3dStat = (x) => stats && stats.printer3d[x] ? stats.printer3d[x].state === 'Printing' ? 'Printing (' + stats.printer3d[x].progress + '%)' : stats.printer3d[x].state : 'Unknown'; + const show_signup = stats?.at_protospace; return ( @@ -357,6 +359,10 @@ export function Home(props) { } trigger={[more]} />

+

ORD2 printer: {printer3dStat('ord2')}

+ +

ORD3 printer: {printer3dStat('ord3')}

+ {user &&

Alarm status: {alarmStat()}{doorOpenStat()}

} {user &&

Hosting status: {closedStat()}

}