File size: 8,297 Bytes
7a0c9ff
a8d792f
7a0c9ff
 
 
 
 
 
 
 
 
 
 
 
 
 
a8d792f
 
7a0c9ff
 
 
 
 
 
 
 
a8d792f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a0c9ff
 
 
a8d792f
7a0c9ff
 
 
a8d792f
 
 
 
 
 
 
 
 
 
 
7a0c9ff
 
 
 
 
 
a8d792f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a0c9ff
 
 
 
 
 
a8d792f
 
 
 
 
 
7a0c9ff
 
 
a8d792f
7a0c9ff
 
 
 
 
a8d792f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a0c9ff
 
 
a8d792f
7a0c9ff
 
 
 
 
 
 
 
 
a8d792f
 
 
 
 
 
7a0c9ff
a8d792f
 
 
 
 
 
 
 
 
 
7a0c9ff
 
 
a8d792f
 
 
 
 
7a0c9ff
 
 
 
 
 
a8d792f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7a0c9ff
 
 
 
 
a8d792f
 
 
 
 
 
 
 
 
 
 
 
7a0c9ff
a8d792f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
"use client";

import {
  Settings,
  Gamepad2,
  Trash2,
  Pencil,
  Plus,
  ExternalLink,
} from "lucide-react";
import { Button } from "@/components/ui/button";
import { Card, CardFooter } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { cn } from "@/lib/utils";
import HudCorners from "@/components/hud-corners";
import type { RobotConnection } from "@/types/robot";

interface DeviceDashboardProps {
  robots: RobotConnection[];
  onCalibrate: (robot: RobotConnection) => void;
  onTeleoperate: (robot: RobotConnection) => void;
  onRemove: (robotId: string) => void;
  onEdit: (robot: RobotConnection) => void;
  onFindNew: () => void;
  isConnecting: boolean;
  onScrollToHardware: () => void;
}

export function DeviceDashboard({
  robots,
  onCalibrate,
  onTeleoperate,
  onRemove,
  onEdit,
  onFindNew,
  isConnecting,
  onScrollToHardware,
}: DeviceDashboardProps) {
  return (
    <Card className="border-0 rounded-none">
      <div className="p-4 border-b border-white/10 flex items-center justify-between">
        <div className="flex items-center gap-4">
          <div className="w-1 h-8 bg-primary"></div>
          <div>
            <h3 className="text-xl font-bold text-foreground font-mono tracking-wider uppercase">
              device registry
            </h3>
            <div className="flex items-center gap-2 mt-1">
              <span className="text-xs text-muted-foreground font-mono">
                currently supports SO-100{" "}
              </span>
              <button
                onClick={onScrollToHardware}
                className="text-xs text-primary hover:text-accent transition-colors underline font-mono flex items-center gap-1"
              >
                <ExternalLink className="w-3 h-3" />
                add more devices
              </button>
            </div>
          </div>
        </div>
        {robots.length > 0 && (
          <Button
            onClick={onFindNew}
            disabled={isConnecting}
            size="lg"
            className="font-mono uppercase"
          >
            <Plus className="w-4 h-4 mr-2" />
            add unit
          </Button>
        )}
      </div>

      <div className="pt-6 p-6">
        {robots.length === 0 ? (
          <div className="relative">
            <HudCorners className="p-16">
              <div className="text-center font-mono">
                <div className="mb-6">
                  {isConnecting ? (
                    <>
                      <div className="w-16 h-16 mx-auto mb-4 border-2 border-primary/50 rounded-lg flex items-center justify-center animate-pulse">
                        <Plus className="w-8 h-8 text-primary animate-spin" />
                      </div>
                      <h4 className="text-xl text-primary mb-2 tracking-wider uppercase">
                        scanning for units
                      </h4>
                      <p className="text-sm text-muted-foreground mb-8">
                        searching for available devices...
                      </p>
                    </>
                  ) : (
                    <>
                      <div className="w-16 h-16 mx-auto mb-4 border-2 border-dashed border-primary/50 rounded-lg flex items-center justify-center">
                        <Plus className="w-8 h-8 text-primary/50" />
                      </div>
                      <h4 className="text-xl text-primary mb-2 tracking-wider uppercase">
                        no units detected
                      </h4>

                      <Button
                        onClick={onFindNew}
                        size="lg"
                        className="font-mono uppercase"
                      >
                        <Plus className="w-4 h-4 mr-2" />
                        add unit
                      </Button>
                    </>
                  )}
                </div>
              </div>
            </HudCorners>
          </div>
        ) : (
          <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
            {robots.map((robot) => (
              <HudCorners key={robot.robotId}>
                <Card className="flex flex-col h-full">
                  <div className="p-4 border-b border-white/10">
                    <div className="flex items-start justify-between mb-3">
                      <div className="flex-1">
                        <h4 className="text-xl font-bold text-primary font-mono tracking-wider">
                          {robot.name}
                        </h4>
                        <div className="flex items-center gap-2 mt-1">
                          <span className="text-xs text-muted-foreground font-mono">
                            {robot.serialNumber}
                          </span>
                          <span className="text-xs text-muted-foreground">

                          </span>
                          <span className="text-xs font-mono uppercase text-muted-foreground">
                            {robot.robotType}
                          </span>
                        </div>
                      </div>
                      <Badge
                        variant="outline"
                        className={cn(
                          "border-primary/50 bg-primary/20 text-primary font-mono text-xs",
                          robot.isConnected && "animate-pulse-slow"
                        )}
                      >
                        {robot.isConnected ? "ONLINE" : "OFFLINE"}
                      </Badge>
                    </div>
                  </div>

                  <div className="flex-grow p-4">
                    <div className="grid grid-cols-2 gap-4 text-xs font-mono">
                      <div>
                        <span className="text-muted-foreground uppercase">
                          status:
                        </span>
                        <div className="text-primary uppercase">
                          {robot.isConnected ? "operational" : "disconnected"}
                        </div>
                      </div>
                      <div>
                        <span className="text-muted-foreground uppercase">
                          type:
                        </span>
                        <div className="text-accent uppercase">
                          {robot.robotType}
                        </div>
                      </div>
                    </div>
                  </div>

                  <CardFooter className="p-4 border-t border-white/10 flex flex-wrap gap-2">
                    <Button
                      variant="outline"
                      size="sm"
                      onClick={() => onEdit(robot)}
                      className="font-mono text-xs uppercase"
                    >
                      <Pencil className="w-3 h-3 mr-1" /> edit
                    </Button>
                    <Button
                      variant="outline"
                      size="sm"
                      onClick={() => onCalibrate(robot)}
                      className="font-mono text-xs uppercase"
                    >
                      <Settings className="w-3 h-3 mr-1" /> calibrate
                    </Button>
                    <Button
                      variant="outline"
                      size="sm"
                      onClick={() => onTeleoperate(robot)}
                      className="font-mono text-xs uppercase"
                    >
                      <Gamepad2 className="w-3 h-3 mr-1" /> control
                    </Button>
                    <Button
                      variant="destructive"
                      size="sm"
                      onClick={() =>
                        onRemove(
                          robot.robotId || robot.serialNumber || "unknown"
                        )
                      }
                      className="font-mono text-xs uppercase"
                    >
                      <Trash2 className="w-3 h-3 mr-1" /> remove
                    </Button>
                  </CardFooter>
                </Card>
              </HudCorners>
            ))}
          </div>
        )}
      </div>
    </Card>
  );
}