add TTL and SyncColumn
This commit is contained in:
parent
2b3c9a6c28
commit
4accb1dfc5
177
.claude/skills/frontend-design/LICENSE.txt
Normal file
177
.claude/skills/frontend-design/LICENSE.txt
Normal file
|
|
@ -0,0 +1,177 @@
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
42
.claude/skills/frontend-design/SKILL.md
Normal file
42
.claude/skills/frontend-design/SKILL.md
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
---
|
||||||
|
name: frontend-design
|
||||||
|
description: Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
|
||||||
|
license: Complete terms in LICENSE.txt
|
||||||
|
---
|
||||||
|
|
||||||
|
This skill guides creation of distinctive, production-grade frontend interfaces that avoid generic "AI slop" aesthetics. Implement real working code with exceptional attention to aesthetic details and creative choices.
|
||||||
|
|
||||||
|
The user provides frontend requirements: a component, page, application, or interface to build. They may include context about the purpose, audience, or technical constraints.
|
||||||
|
|
||||||
|
## Design Thinking
|
||||||
|
|
||||||
|
Before coding, understand the context and commit to a BOLD aesthetic direction:
|
||||||
|
- **Purpose**: What problem does this interface solve? Who uses it?
|
||||||
|
- **Tone**: Pick an extreme: brutally minimal, maximalist chaos, retro-futuristic, organic/natural, luxury/refined, playful/toy-like, editorial/magazine, brutalist/raw, art deco/geometric, soft/pastel, industrial/utilitarian, etc. There are so many flavors to choose from. Use these for inspiration but design one that is true to the aesthetic direction.
|
||||||
|
- **Constraints**: Technical requirements (framework, performance, accessibility).
|
||||||
|
- **Differentiation**: What makes this UNFORGETTABLE? What's the one thing someone will remember?
|
||||||
|
|
||||||
|
**CRITICAL**: Choose a clear conceptual direction and execute it with precision. Bold maximalism and refined minimalism both work - the key is intentionality, not intensity.
|
||||||
|
|
||||||
|
Then implement working code (HTML/CSS/JS, React, Vue, etc.) that is:
|
||||||
|
- Production-grade and functional
|
||||||
|
- Visually striking and memorable
|
||||||
|
- Cohesive with a clear aesthetic point-of-view
|
||||||
|
- Meticulously refined in every detail
|
||||||
|
|
||||||
|
## Frontend Aesthetics Guidelines
|
||||||
|
|
||||||
|
Focus on:
|
||||||
|
- **Typography**: Choose fonts that are beautiful, unique, and interesting. Avoid generic fonts like Arial and Inter; opt instead for distinctive choices that elevate the frontend's aesthetics; unexpected, characterful font choices. Pair a distinctive display font with a refined body font.
|
||||||
|
- **Color & Theme**: Commit to a cohesive aesthetic. Use CSS variables for consistency. Dominant colors with sharp accents outperform timid, evenly-distributed palettes.
|
||||||
|
- **Motion**: Use animations for effects and micro-interactions. Prioritize CSS-only solutions for HTML. Use Motion library for React when available. Focus on high-impact moments: one well-orchestrated page load with staggered reveals (animation-delay) creates more delight than scattered micro-interactions. Use scroll-triggering and hover states that surprise.
|
||||||
|
- **Spatial Composition**: Unexpected layouts. Asymmetry. Overlap. Diagonal flow. Grid-breaking elements. Generous negative space OR controlled density.
|
||||||
|
- **Backgrounds & Visual Details**: Create atmosphere and depth rather than defaulting to solid colors. Add contextual effects and textures that match the overall aesthetic. Apply creative forms like gradient meshes, noise textures, geometric patterns, layered transparencies, dramatic shadows, decorative borders, custom cursors, and grain overlays.
|
||||||
|
|
||||||
|
NEVER use generic AI-generated aesthetics like overused font families (Inter, Roboto, Arial, system fonts), cliched color schemes (particularly purple gradients on white backgrounds), predictable layouts and component patterns, and cookie-cutter design that lacks context-specific character.
|
||||||
|
|
||||||
|
Interpret creatively and make unexpected choices that feel genuinely designed for the context. No design should be the same. Vary between light and dark themes, different fonts, different aesthetics. NEVER converge on common choices (Space Grotesk, for example) across generations.
|
||||||
|
|
||||||
|
**IMPORTANT**: Match implementation complexity to the aesthetic vision. Maximalist designs need elaborate code with extensive animations and effects. Minimalist or refined designs need restraint, precision, and careful attention to spacing, typography, and subtle details. Elegance comes from executing the vision well.
|
||||||
|
|
||||||
|
Remember: Claude is capable of extraordinary creative work. Don't hold back, show what can truly be created when thinking outside the box and committing fully to a distinctive vision.
|
||||||
11
skills-lock.json
Normal file
11
skills-lock.json
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"skills": {
|
||||||
|
"frontend-design": {
|
||||||
|
"source": "anthropics/skills",
|
||||||
|
"sourceType": "github",
|
||||||
|
"skillPath": "skills/frontend-design/SKILL.md",
|
||||||
|
"computedHash": "516bd2154eb843a8240e43d5b285229129853114ad7075a5e141e1c08e408c84"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -209,7 +209,7 @@ export function ComputerCard({
|
||||||
<Badge
|
<Badge
|
||||||
variant={isOffline ? "destructive" : "default"}
|
variant={isOffline ? "destructive" : "default"}
|
||||||
className={`flex items-center gap-1 w-fit ${
|
className={`flex items-center gap-1 w-fit ${
|
||||||
isOffline ? "bg-red-100 text-red-700" : "bg-green-100 text-green-700"
|
isOffline ? "bg-slate-100 text-slate-600" : "bg-teal-50 text-teal-700"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{isOffline ? <WifiOff className="h-3 w-3" /> : <Wifi className="h-3 w-3" />}
|
{isOffline ? <WifiOff className="h-3 w-3" /> : <Wifi className="h-3 w-3" />}
|
||||||
|
|
@ -228,8 +228,8 @@ export function ComputerCard({
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex flex-col items-stretch w-[88px] rounded-lg border-2 overflow-hidden transition-all hover:shadow-md hover:-translate-y-0.5 cursor-pointer select-none",
|
"flex flex-col items-stretch w-[88px] rounded-lg border-2 overflow-hidden transition-all hover:shadow-md hover:-translate-y-0.5 cursor-pointer select-none",
|
||||||
isOffline
|
isOffline
|
||||||
? "border-red-400 bg-white hover:border-red-500"
|
? "border-slate-400 bg-white hover:border-slate-500"
|
||||||
: "border-emerald-400 bg-white hover:border-emerald-500",
|
: "border-teal-400 bg-white hover:border-teal-500",
|
||||||
isSelected && "ring-2 ring-primary ring-offset-1 ring-offset-background"
|
isSelected && "ring-2 ring-primary ring-offset-1 ring-offset-background"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
@ -237,7 +237,7 @@ export function ComputerCard({
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex items-center justify-between px-1.5 py-1",
|
"flex items-center justify-between px-1.5 py-1",
|
||||||
isOffline ? "bg-red-500" : "bg-emerald-500"
|
isOffline ? "bg-slate-500" : "bg-teal-600"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
|
@ -249,7 +249,7 @@ export function ComputerCard({
|
||||||
{!isOffline && (
|
{!isOffline && (
|
||||||
<div
|
<div
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
className="[&_button]:p-0 [&_button]:rounded [&_button]:hover:bg-emerald-400 [&_svg]:h-3.5 [&_svg]:w-3.5 [&_svg]:text-white"
|
className="[&_button]:p-0 [&_button]:rounded [&_button]:hover:bg-teal-500 [&_svg]:h-3.5 [&_svg]:w-3.5 [&_svg]:text-white"
|
||||||
>
|
>
|
||||||
<FolderStatusPopover
|
<FolderStatusPopover
|
||||||
deviceId={device.networkInfos?.[0]?.macAddress || device.id}
|
deviceId={device.networkInfos?.[0]?.macAddress || device.id}
|
||||||
|
|
@ -265,7 +265,7 @@ export function ComputerCard({
|
||||||
<Monitor
|
<Monitor
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-5 w-5",
|
"h-5 w-5",
|
||||||
isOffline ? "text-red-300" : "text-emerald-400"
|
isOffline ? "text-slate-300" : "text-teal-500"
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{firstNetworkInfo?.ipAddress && (
|
{firstNetworkInfo?.ipAddress && (
|
||||||
|
|
@ -281,7 +281,7 @@ export function ComputerCard({
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"text-[10px] font-semibold leading-none mt-0.5",
|
"text-[10px] font-semibold leading-none mt-0.5",
|
||||||
isOffline ? "text-red-500" : "text-emerald-600"
|
isOffline ? "text-slate-500" : "text-teal-600"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{isOffline ? "Off" : "On"}
|
{isOffline ? "Off" : "On"}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,13 @@ export function createAppsColumns(isPending: boolean): ColumnDef<Version>[] {
|
||||||
return [
|
return [
|
||||||
{ accessorKey: "version", header: "Phiên bản" },
|
{ accessorKey: "version", header: "Phiên bản" },
|
||||||
{ accessorKey: "fileName", header: "Tên file" },
|
{ accessorKey: "fileName", header: "Tên file" },
|
||||||
|
{
|
||||||
|
accessorKey: "syncFolder",
|
||||||
|
header: "Thư mục đồng bộ",
|
||||||
|
cell: ({ getValue }) => (
|
||||||
|
<code className="text-xs">{(getValue() as string) || "C:/Setup"}</code>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "updatedAt",
|
accessorKey: "updatedAt",
|
||||||
header: () => (
|
header: () => (
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ export interface CommandRegistryFormData {
|
||||||
commandContent: string;
|
commandContent: string;
|
||||||
qos: 0 | 1 | 2;
|
qos: 0 | 1 | 2;
|
||||||
isRetained: boolean;
|
isRetained: boolean;
|
||||||
|
ttlMinutes: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zod validation schema
|
// Zod validation schema
|
||||||
|
|
@ -53,6 +54,7 @@ const commandRegistrySchema = z.object({
|
||||||
.trim(),
|
.trim(),
|
||||||
qos: z.union([z.literal(0), z.literal(1), z.literal(2)]),
|
qos: z.union([z.literal(0), z.literal(1), z.literal(2)]),
|
||||||
isRetained: z.boolean(),
|
isRetained: z.boolean(),
|
||||||
|
ttlMinutes: z.number().int().min(-1, "TTL tối thiểu là -1 (vô hạn)"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const QoSLevels = [
|
const QoSLevels = [
|
||||||
|
|
@ -98,6 +100,7 @@ export function CommandRegistryForm({
|
||||||
commandContent: initialData?.commandContent || "",
|
commandContent: initialData?.commandContent || "",
|
||||||
qos: (initialData?.qos || 0) as 0 | 1 | 2,
|
qos: (initialData?.qos || 0) as 0 | 1 | 2,
|
||||||
isRetained: initialData?.isRetained || false,
|
isRetained: initialData?.isRetained || false,
|
||||||
|
ttlMinutes: initialData?.ttlMinutes ?? -1,
|
||||||
},
|
},
|
||||||
onSubmit: async ({ value }) => {
|
onSubmit: async ({ value }) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -183,6 +186,7 @@ export function CommandRegistryForm({
|
||||||
<option value={CommandType.SHUTDOWN}>SHUTDOWN - Tắt máy</option>
|
<option value={CommandType.SHUTDOWN}>SHUTDOWN - Tắt máy</option>
|
||||||
<option value={CommandType.TASKKILL}>TASKKILL - Kết thúc tác vụ</option>
|
<option value={CommandType.TASKKILL}>TASKKILL - Kết thúc tác vụ</option>
|
||||||
<option value={CommandType.BLOCK}>BLOCK - Chặn</option>
|
<option value={CommandType.BLOCK}>BLOCK - Chặn</option>
|
||||||
|
<option value={CommandType.RESET}>RESET - Đặt lại</option>
|
||||||
</select>
|
</select>
|
||||||
{field.state.meta.errors?.length > 0 && (
|
{field.state.meta.errors?.length > 0 && (
|
||||||
<p className="text-sm text-red-500">
|
<p className="text-sm text-red-500">
|
||||||
|
|
@ -387,6 +391,31 @@ export function CommandRegistryForm({
|
||||||
)}
|
)}
|
||||||
</form.Field>
|
</form.Field>
|
||||||
|
|
||||||
|
{/* TTL Minutes */}
|
||||||
|
<form.Field name="ttlMinutes">
|
||||||
|
{(field: any) => (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label>TTL (Phút)</Label>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
placeholder="-1"
|
||||||
|
value={field.state.value}
|
||||||
|
onChange={(e) => field.handleChange(Number(e.target.value))}
|
||||||
|
onBlur={field.handleBlur}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
/>
|
||||||
|
{field.state.meta.errors?.length > 0 && (
|
||||||
|
<p className="text-sm text-red-500">
|
||||||
|
{String(field.state.meta.errors[0])}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
Thời gian tồn tại của lệnh retained (phút). -1 = vô hạn.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</form.Field>
|
||||||
|
|
||||||
{/* Submit Button */}
|
{/* Submit Button */}
|
||||||
<div className="flex gap-3 pt-4">
|
<div className="flex gap-3 pt-4">
|
||||||
<Button
|
<Button
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export function UploadVersionForm({ onSubmit, closeDialog }: UploadVersionFormPr
|
||||||
};
|
};
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
defaultValues: { files: new DataTransfer().files, newVersion: "" },
|
defaultValues: { files: new DataTransfer().files, newVersion: "", syncFolder: "" },
|
||||||
onSubmit: async ({ value }) => {
|
onSubmit: async ({ value }) => {
|
||||||
if (!value.newVersion || value.files.length === 0) {
|
if (!value.newVersion || value.files.length === 0) {
|
||||||
toast.error("Vui lòng điền đầy đủ thông tin");
|
toast.error("Vui lòng điền đầy đủ thông tin");
|
||||||
|
|
@ -49,6 +49,7 @@ export function UploadVersionForm({ onSubmit, closeDialog }: UploadVersionFormPr
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
Array.from(value.files).forEach((f) => fd.append("FileInput", f));
|
Array.from(value.files).forEach((f) => fd.append("FileInput", f));
|
||||||
fd.append("Version", value.newVersion);
|
fd.append("Version", value.newVersion);
|
||||||
|
if (value.syncFolder) fd.append("SyncFolder", value.syncFolder);
|
||||||
|
|
||||||
await onSubmit(fd, {
|
await onSubmit(fd, {
|
||||||
onUploadProgress: (e: AxiosProgressEvent) => {
|
onUploadProgress: (e: AxiosProgressEvent) => {
|
||||||
|
|
@ -91,6 +92,23 @@ export function UploadVersionForm({ onSubmit, closeDialog }: UploadVersionFormPr
|
||||||
)}
|
)}
|
||||||
</form.Field>
|
</form.Field>
|
||||||
|
|
||||||
|
<form.Field name="syncFolder">
|
||||||
|
{(field) => (
|
||||||
|
<div>
|
||||||
|
<Label>Thư mục đồng bộ</Label>
|
||||||
|
<Input
|
||||||
|
value={field.state.value}
|
||||||
|
onChange={(e) => field.handleChange(e.target.value)}
|
||||||
|
placeholder="C:/Setup"
|
||||||
|
disabled={isUploading || isDone}
|
||||||
|
/>
|
||||||
|
<p className="text-xs text-muted-foreground mt-1">
|
||||||
|
Để trống = mặc định <code>C:/Setup</code>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</form.Field>
|
||||||
|
|
||||||
<form.Field name="files">
|
<form.Field name="files">
|
||||||
{(field) => (
|
{(field) => (
|
||||||
<div>
|
<div>
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,8 @@ export function DeviceGridCompact({
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex flex-col items-stretch rounded-lg border-2 overflow-hidden transition-all hover:shadow-md hover:-translate-y-0.5 cursor-pointer",
|
"flex flex-col items-stretch rounded-lg border-2 overflow-hidden transition-all hover:shadow-md hover:-translate-y-0.5 cursor-pointer",
|
||||||
isOffline
|
isOffline
|
||||||
? "border-red-400 bg-white hover:border-red-500"
|
? "border-slate-400 bg-white hover:border-slate-500"
|
||||||
: "border-emerald-400 bg-white hover:border-emerald-500",
|
: "border-teal-400 bg-white hover:border-teal-500",
|
||||||
isSelected &&
|
isSelected &&
|
||||||
"ring-2 ring-primary ring-offset-1 ring-offset-background"
|
"ring-2 ring-primary ring-offset-1 ring-offset-background"
|
||||||
)}
|
)}
|
||||||
|
|
@ -76,7 +76,7 @@ export function DeviceGridCompact({
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex items-center justify-between px-1.5 py-1",
|
"flex items-center justify-between px-1.5 py-1",
|
||||||
isOffline ? "bg-red-500" : "bg-emerald-500"
|
isOffline ? "bg-slate-500" : "bg-teal-600"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
|
|
@ -88,7 +88,7 @@ export function DeviceGridCompact({
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-1.5 w-1.5 rounded-full border border-white/40",
|
"h-1.5 w-1.5 rounded-full border border-white/40",
|
||||||
isOffline ? "bg-red-200" : "bg-emerald-200"
|
isOffline ? "bg-slate-200" : "bg-teal-200"
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -108,7 +108,7 @@ export function DeviceGridCompact({
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"text-[10px] font-semibold leading-none",
|
"text-[10px] font-semibold leading-none",
|
||||||
isOffline ? "text-red-500" : "text-emerald-600"
|
isOffline ? "text-slate-500" : "text-teal-600"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{isOffline ? "Off" : "On"}
|
{isOffline ? "Off" : "On"}
|
||||||
|
|
|
||||||
|
|
@ -184,3 +184,13 @@ export function useDeleteFile() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook để gửi manifest [MOCK]
|
||||||
|
*/
|
||||||
|
export function useSendManifest() {
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (data: { targets: string[]; MsiFileIds: number[] }) =>
|
||||||
|
appVersionService.sendManifest(data),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import {
|
||||||
useDeleteRequiredFile,
|
useDeleteRequiredFile,
|
||||||
useInstallMsi,
|
useInstallMsi,
|
||||||
useDownloadFiles,
|
useDownloadFiles,
|
||||||
|
useSendManifest,
|
||||||
} from "@/hooks/queries";
|
} from "@/hooks/queries";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import type { AxiosProgressEvent } from "axios";
|
import type { AxiosProgressEvent } from "axios";
|
||||||
|
|
@ -49,6 +50,8 @@ function AppsComponent() {
|
||||||
|
|
||||||
const deleteRequiredFileMutation = useDeleteRequiredFile();
|
const deleteRequiredFileMutation = useDeleteRequiredFile();
|
||||||
|
|
||||||
|
const sendManifestMutation = useSendManifest();
|
||||||
|
|
||||||
const columns = useMemo(
|
const columns = useMemo(
|
||||||
() => createAppsColumns(installMutation.isPending),
|
() => createAppsColumns(installMutation.isPending),
|
||||||
[installMutation.isPending]
|
[installMutation.isPending]
|
||||||
|
|
@ -188,6 +191,28 @@ function AppsComponent() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSendManifest = async (roomNames: string[]) => {
|
||||||
|
if (!table) {
|
||||||
|
toast.error("Không thể lấy thông tin bảng!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedRows = table.getSelectedRowModel().rows;
|
||||||
|
if (selectedRows.length === 0) {
|
||||||
|
toast.error("Vui lòng chọn ít nhất một file để gửi manifest!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MsiFileIds = selectedRows.map((row: any) => row.original.id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await sendManifestMutation.mutateAsync({ targets: roomNames, MsiFileIds });
|
||||||
|
toast.success("Đã gửi manifest cho các phòng đã chọn!");
|
||||||
|
} catch (e) {
|
||||||
|
toast.error("Gửi manifest thất bại!");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleAddToRequired = async () => {
|
const handleAddToRequired = async () => {
|
||||||
if (!table) {
|
if (!table) {
|
||||||
toast.error("Không thể lấy thông tin bảng!");
|
toast.error("Không thể lấy thông tin bảng!");
|
||||||
|
|
@ -232,6 +257,8 @@ function AppsComponent() {
|
||||||
onDeleteFromServer={handleDeleteFromServer}
|
onDeleteFromServer={handleDeleteFromServer}
|
||||||
onDeleteFromRequired={handleDeleteFromRequiredList}
|
onDeleteFromRequired={handleDeleteFromRequiredList}
|
||||||
onAddToRequired={handleAddToRequired}
|
onAddToRequired={handleAddToRequired}
|
||||||
|
onSendManifest={handleSendManifest}
|
||||||
|
sendManifestLoading={sendManifestMutation.isPending}
|
||||||
updateLoading={installMutation.isPending}
|
updateLoading={installMutation.isPending}
|
||||||
downloadLoading={downloadMutation.isPending}
|
downloadLoading={downloadMutation.isPending}
|
||||||
deleteLoading={deleteMutation.isPending || deleteRequiredFileMutation.isPending}
|
deleteLoading={deleteMutation.isPending || deleteRequiredFileMutation.isPending}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ function CommandPage() {
|
||||||
commandContent: selectedCommand.commandContent,
|
commandContent: selectedCommand.commandContent,
|
||||||
qos: selectedCommand.qoS,
|
qos: selectedCommand.qoS,
|
||||||
isRetained: selectedCommand.isRetained,
|
isRetained: selectedCommand.isRetained,
|
||||||
|
ttlMinutes: selectedCommand.ttlMinutes ?? -1,
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|
@ -106,6 +107,7 @@ function CommandPage() {
|
||||||
2: "SHUTDOWN",
|
2: "SHUTDOWN",
|
||||||
3: "TASKKILL",
|
3: "TASKKILL",
|
||||||
4: "BLOCK",
|
4: "BLOCK",
|
||||||
|
5: "RESET",
|
||||||
};
|
};
|
||||||
return <span>{typeMap[type] || "UNKNOWN"}</span>;
|
return <span>{typeMap[type] || "UNKNOWN"}</span>;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -185,10 +185,10 @@ function RoomDetailPage() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-1.5">
|
||||||
<Badge variant="outline" className="text-[11px] text-emerald-700 border-emerald-200 bg-emerald-50">
|
<Badge variant="outline" className="text-[11px] text-teal-700 border-teal-200 bg-teal-50">
|
||||||
On {onlineCount}
|
On {onlineCount}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Badge variant="outline" className="text-[11px] text-red-600 border-red-200 bg-red-50">
|
<Badge variant="outline" className="text-[11px] text-slate-600 border-slate-200 bg-slate-50">
|
||||||
Off {offlineCount}
|
Off {offlineCount}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Badge variant="secondary" className="text-[11px]">
|
<Badge variant="secondary" className="text-[11px]">
|
||||||
|
|
|
||||||
|
|
@ -129,3 +129,16 @@ export async function deleteFile(data: { MsiFileIds: number[] }): Promise<{ mess
|
||||||
);
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [MOCK] Gửi manifest đến các phòng/thiết bị
|
||||||
|
* @param data - { targets: string[]; MsiFileIds: number[] }
|
||||||
|
*/
|
||||||
|
export async function sendManifest(data: {
|
||||||
|
targets: string[];
|
||||||
|
MsiFileIds: number[];
|
||||||
|
}): Promise<{ message: string }> {
|
||||||
|
// TODO: replace with real endpoint
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 800));
|
||||||
|
return { message: `[MOCK] Manifest sent to ${data.targets.join(", ")}` };
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ interface AppManagerTemplateProps<TData> {
|
||||||
deleteLoading?: boolean;
|
deleteLoading?: boolean;
|
||||||
onAddToRequired?: () => Promise<void> | void;
|
onAddToRequired?: () => Promise<void> | void;
|
||||||
addToRequiredLoading?: boolean;
|
addToRequiredLoading?: boolean;
|
||||||
|
onSendManifest?: (targetNames: string[]) => Promise<void> | void;
|
||||||
|
sendManifestLoading?: boolean;
|
||||||
onTableInit?: (table: any) => void;
|
onTableInit?: (table: any) => void;
|
||||||
rooms?: Room[];
|
rooms?: Room[];
|
||||||
devices?: string[];
|
devices?: string[];
|
||||||
|
|
@ -70,6 +72,8 @@ export function AppManagerTemplate<TData>({
|
||||||
deleteLoading,
|
deleteLoading,
|
||||||
onAddToRequired,
|
onAddToRequired,
|
||||||
addToRequiredLoading,
|
addToRequiredLoading,
|
||||||
|
onSendManifest,
|
||||||
|
sendManifestLoading,
|
||||||
onTableInit,
|
onTableInit,
|
||||||
rooms = [],
|
rooms = [],
|
||||||
devices = [],
|
devices = [],
|
||||||
|
|
@ -78,7 +82,7 @@ export function AppManagerTemplate<TData>({
|
||||||
pageSizeOptions = [5, 10, 15, 20],
|
pageSizeOptions = [5, 10, 15, 20],
|
||||||
}: AppManagerTemplateProps<TData>) {
|
}: AppManagerTemplateProps<TData>) {
|
||||||
const [dialogOpen, setDialogOpen] = useState(false);
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
const [dialogType, setDialogType] = useState<"room" | "device" | "download-room" | "download-device" | null>(null);
|
const [dialogType, setDialogType] = useState<"room" | "device" | "download-room" | "download-device" | "manifest-room" | null>(null);
|
||||||
|
|
||||||
const sortedData = useMemo(() => {
|
const sortedData = useMemo(() => {
|
||||||
const firstItem = data?.[0] as { fileName?: string } | undefined;
|
const firstItem = data?.[0] as { fileName?: string } | undefined;
|
||||||
|
|
@ -124,6 +128,13 @@ export function AppManagerTemplate<TData>({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openManifestRoomDialog = () => {
|
||||||
|
if (rooms.length > 0 && onSendManifest) {
|
||||||
|
setDialogType("manifest-room");
|
||||||
|
setDialogOpen(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleUpdateAll = async () => {
|
const handleUpdateAll = async () => {
|
||||||
if (!onUpdate) return;
|
if (!onUpdate) return;
|
||||||
try {
|
try {
|
||||||
|
|
@ -217,6 +228,16 @@ export function AppManagerTemplate<TData>({
|
||||||
{addToRequiredLoading ? "Đang thêm..." : "Thêm vào danh sách"}
|
{addToRequiredLoading ? "Đang thêm..." : "Thêm vào danh sách"}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{onSendManifest && (
|
||||||
|
<Button
|
||||||
|
onClick={openManifestRoomDialog}
|
||||||
|
disabled={sendManifestLoading}
|
||||||
|
variant="outline"
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
{sendManifestLoading ? "Đang gửi..." : "Gửi Manifest"}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{onDeleteFromServer && onDeleteFromRequired && (
|
{onDeleteFromServer && onDeleteFromRequired && (
|
||||||
<DeleteMenu
|
<DeleteMenu
|
||||||
|
|
@ -315,6 +336,32 @@ export function AppManagerTemplate<TData>({
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Dialog gửi manifest - chọn phòng */}
|
||||||
|
{dialogType === "manifest-room" && (
|
||||||
|
<SelectDialog
|
||||||
|
open={dialogOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setDialogOpen(false);
|
||||||
|
setDialogType(null);
|
||||||
|
}}
|
||||||
|
title="Chọn phòng"
|
||||||
|
description="Chọn các phòng để gửi manifest"
|
||||||
|
icon={<Building2 className="w-6 h-6 text-primary" />}
|
||||||
|
items={mapRoomsToSelectItems(rooms)}
|
||||||
|
onConfirm={async (selectedItems) => {
|
||||||
|
if (!onSendManifest) return;
|
||||||
|
try {
|
||||||
|
await onSendManifest(selectedItems);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Send manifest error:", e);
|
||||||
|
} finally {
|
||||||
|
setDialogOpen(false);
|
||||||
|
setDialogType(null);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Dialog tải file - tìm thiết bị */}
|
{/* Dialog tải file - tìm thiết bị */}
|
||||||
{dialogType === "download-device" && (
|
{dialogType === "download-device" && (
|
||||||
<DeviceSearchDialog
|
<DeviceSearchDialog
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ export interface CommandRegistry {
|
||||||
commandContent: string;
|
commandContent: string;
|
||||||
qoS: 0 | 1 | 2;
|
qoS: 0 | 1 | 2;
|
||||||
isRetained: boolean;
|
isRetained: boolean;
|
||||||
|
ttlMinutes: number;
|
||||||
createdAt?: string;
|
createdAt?: string;
|
||||||
updatedAt?: string;
|
updatedAt?: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ export type Version = {
|
||||||
version: string;
|
version: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
folderPath: string;
|
folderPath: string;
|
||||||
|
syncFolder?: string;
|
||||||
updatedAt?: string;
|
updatedAt?: string;
|
||||||
requestUpdateAt?: string;
|
requestUpdateAt?: string;
|
||||||
isRequired: boolean;
|
isRequired: boolean;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user