feat(admin/machines): company search input with suggestions; rename machine dialog using Convex mutation; improve CPU name rendering and Defender booleans; add pulsating online indicator on cards and detail
This commit is contained in:
parent
124bb2a26f
commit
129407dbce
2 changed files with 151 additions and 34 deletions
|
|
@ -650,3 +650,37 @@ export const linkAuthAccount = mutation({
|
|||
return { ok: true }
|
||||
},
|
||||
})
|
||||
|
||||
export const rename = mutation({
|
||||
args: {
|
||||
machineId: v.id("machines"),
|
||||
actorId: v.id("users"),
|
||||
tenantId: v.optional(v.string()),
|
||||
hostname: v.string(),
|
||||
},
|
||||
handler: async (ctx, { machineId, actorId, tenantId, hostname }) => {
|
||||
// Reutiliza requireStaff através de tickets.ts helpers
|
||||
const machine = await ctx.db.get(machineId)
|
||||
if (!machine) {
|
||||
throw new ConvexError("Máquina não encontrada")
|
||||
}
|
||||
// Verifica permissão no tenant da máquina
|
||||
const viewer = await ctx.db.get(actorId)
|
||||
if (!viewer || viewer.tenantId !== machine.tenantId) {
|
||||
throw new ConvexError("Acesso negado ao tenant da máquina")
|
||||
}
|
||||
const normalizedRole = (viewer.role ?? "AGENT").toUpperCase()
|
||||
const STAFF = new Set(["ADMIN", "MANAGER", "AGENT", "COLLABORATOR"])
|
||||
if (!STAFF.has(normalizedRole)) {
|
||||
throw new ConvexError("Apenas equipe interna pode renomear máquinas")
|
||||
}
|
||||
|
||||
const nextName = hostname.trim()
|
||||
if (nextName.length < 2) {
|
||||
throw new ConvexError("Informe um nome válido para a máquina")
|
||||
}
|
||||
|
||||
await ctx.db.patch(machineId, { hostname: nextName, updatedAt: Date.now() })
|
||||
return { ok: true }
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue