Support deploying one certificate to multiple SSH hosts, and support deploying multiple certificates to one SSH host.
This commit is contained in:
49
ui/src/repository/access_group.ts
Normal file
49
ui/src/repository/access_group.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { AccessGroup } from "@/domain/access_groups";
|
||||
import { getPb } from "./api";
|
||||
import { Access } from "@/domain/access";
|
||||
|
||||
export const list = async () => {
|
||||
const resp = await getPb()
|
||||
.collection("access_groups")
|
||||
.getFullList<AccessGroup>({
|
||||
sort: "-created",
|
||||
expand: "access",
|
||||
});
|
||||
|
||||
return resp;
|
||||
};
|
||||
|
||||
export const remove = async (id: string) => {
|
||||
const pb = getPb();
|
||||
|
||||
// 查询有没有关联的access
|
||||
const accessGroup = await pb.collection("access").getList<Access>(1, 1, {
|
||||
filter: `group='${id}' && deleted=null`,
|
||||
});
|
||||
|
||||
if (accessGroup.items.length > 0) {
|
||||
throw new Error("该分组下有授权配置,无法删除");
|
||||
}
|
||||
|
||||
await pb.collection("access_groups").delete(id);
|
||||
};
|
||||
|
||||
export const update = async (accessGroup: AccessGroup) => {
|
||||
const pb = getPb();
|
||||
if (accessGroup.id) {
|
||||
return await pb
|
||||
.collection("access_groups")
|
||||
.update(accessGroup.id, accessGroup);
|
||||
}
|
||||
return await pb.collection("access_groups").create(accessGroup);
|
||||
};
|
||||
|
||||
type UpdateByIdReq = {
|
||||
id: string;
|
||||
[key: string]: string | string[];
|
||||
};
|
||||
|
||||
export const updateById = async (req: UpdateByIdReq) => {
|
||||
const pb = getPb();
|
||||
return await pb.collection("access_groups").update(req.id, req);
|
||||
};
|
||||
Reference in New Issue
Block a user