-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dash: adapt to richer child computer status #442
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ const ListComputers: React.FC<Props> = ({ devices }) => ( | |
)} | ||
<div className="mt-8 grid grid-cols-1 lg+:grid-cols-2 2xl:grid-cols-3 gap-8"> | ||
{devices.map((device) => { | ||
const onlineUser = device.users.find((user) => user.isOnline); | ||
const onlineUser = device.users.find((user) => user.status.case !== `offline`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another case where i simplify the new state back into the old boolean for now |
||
return ( | ||
<ComputerCard | ||
key={device.id} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,10 +46,10 @@ const UsersOverview: React.FC<Props> = ({ className, users }) => { | |
|
||
export default UsersOverview; | ||
|
||
const UserOverview: React.FC<User> = ({ isOnline, name }) => ( | ||
const UserOverview: React.FC<User> = ({ status, name }) => ( | ||
<div className="flex justify-between items-center rounded-xl py-4 px-4 even:bg-slate-50/50"> | ||
<h3 className="font-medium text-slate-900">{name}</h3> | ||
{isOnline ? ( | ||
{status.case !== `offline` ? ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another spot |
||
<Badge size="large" className="!px-4" type="green"> | ||
<i className="mr-2 fa-solid fa-circle text-green-400 text-sm scale-50" /> | ||
online | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
import { Link } from 'react-router-dom'; | ||
import type { ChildComputerStatus } from '@dash/types'; | ||
|
||
type Props = { | ||
id: UUID; | ||
deviceId: UUID; | ||
modelTitle: string; | ||
modelIdentifier: string; | ||
name?: string; | ||
status: 'online' | 'offline'; | ||
status: ChildComputerStatus; | ||
className?: string; | ||
}; | ||
|
||
|
@@ -42,7 +43,7 @@ const UserDevice: React.FC<Props> = ({ | |
{name && <h4 className="text-sm text-slate-500 line-clamp-1">{modelTitle}</h4>} | ||
</div> | ||
</div> | ||
{status === `online` && ( | ||
{status.case !== `offline` && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the final spot |
||
<> | ||
<div className="flex items-center gap-2 mr-2"> | ||
<span className={`text-sm text-slate-500 hidden xs:block`}>online</span> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,13 +34,21 @@ export interface BlockedApp { | |
schedule?: RuleSchedule; | ||
} | ||
|
||
export type ChildComputerStatus = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the new enum that the API sends back. in a few months, when we push everyone past 2.7.0, the dates will no longer be optional. but for now we'll have to support both types of data, since < 2.7.0 macapps don't send the richer detaill. |
||
| { case: 'filterSuspended'; resuming?: ISODateString } | ||
| { case: 'downtime'; ending?: ISODateString } | ||
| { case: 'downtimePaused'; resuming?: ISODateString } | ||
| { case: 'offline' } | ||
| { case: 'filterOff' } | ||
| { case: 'filterOn' }; | ||
|
||
export type ClientAuth = 'none' | 'user' | 'admin' | 'superAdmin'; | ||
|
||
export interface Device { | ||
id: UUID; | ||
name?: string; | ||
releaseChannel: ReleaseChannel; | ||
users: Array<{ id: UUID; name: string; isOnline: boolean }>; | ||
users: Array<{ id: UUID; name: string; status: ChildComputerStatus }>; | ||
appVersion: string; | ||
serialNumber: string; | ||
modelIdentifier: string; | ||
|
@@ -207,7 +215,7 @@ export type UserActivityItem = | |
export interface UserDevice { | ||
id: UUID; | ||
deviceId: UUID; | ||
isOnline: boolean; | ||
status: ChildComputerStatus; | ||
modelFamily: DeviceModelFamily; | ||
modelTitle: string; | ||
modelIdentifier: string; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're getting much richer detail from the API now, but to leverage it well will take some UI design work, to show stuff like "Suspended, resuming in 30 minutes" in the various places where this data is surfaced. So, for now, what I've done is basically downcast the data back to a boolean of "offline/online" like we used to get. This preserves the current behavior, and allows us to release the Macapp Version 2.7.0 which will start sending the richer data, and then we can as soon as we're ready start surfacing it to the parents in the dashboard. Basically, whenever you're ready to do a little design/component work on it.