init
This commit is contained in:
22
ui/src/repository/access.ts
Normal file
22
ui/src/repository/access.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Access } from "@/domain/access";
|
||||
import { getPb } from "./api";
|
||||
import moment from "moment";
|
||||
|
||||
export const list = async () => {
|
||||
return await getPb().collection("access").getFullList<Access>({
|
||||
sort: "-created",
|
||||
filter: "deleted = null",
|
||||
});
|
||||
};
|
||||
|
||||
export const save = async (data: Access) => {
|
||||
if (data.id) {
|
||||
return await getPb().collection("access").update(data.id, data);
|
||||
}
|
||||
return await getPb().collection("access").create(data);
|
||||
};
|
||||
|
||||
export const remove = async (data: Access) => {
|
||||
data.deleted = moment.utc().format("YYYY-MM-DD HH:mm:ss");
|
||||
return await getPb().collection("access").update(data.id, data);
|
||||
};
|
||||
7
ui/src/repository/api.ts
Normal file
7
ui/src/repository/api.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import PocketBase from "pocketbase";
|
||||
let pb: PocketBase;
|
||||
export const getPb = () => {
|
||||
if (pb) return pb;
|
||||
pb = new PocketBase("http://127.0.0.1:8090");
|
||||
return pb;
|
||||
};
|
||||
25
ui/src/repository/deployment.ts
Normal file
25
ui/src/repository/deployment.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Deployment, DeploymentListReq } from "@/domain/deployment";
|
||||
import { getPb } from "./api";
|
||||
|
||||
export const list = async (req: DeploymentListReq) => {
|
||||
let page = 1;
|
||||
if (req.page) {
|
||||
page = req.page;
|
||||
}
|
||||
|
||||
let perPage = 10;
|
||||
if (req.perPage) {
|
||||
perPage = req.perPage;
|
||||
}
|
||||
let filter = "domain!=null";
|
||||
if (req.domain) {
|
||||
filter = `domain="${req.domain}"`;
|
||||
}
|
||||
return await getPb()
|
||||
.collection("deployments")
|
||||
.getList<Deployment>(page, perPage, {
|
||||
filter: filter,
|
||||
sort: "-id",
|
||||
expand: "domain",
|
||||
});
|
||||
};
|
||||
27
ui/src/repository/domains.ts
Normal file
27
ui/src/repository/domains.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Domain } from "@/domain/domain";
|
||||
import { getPb } from "./api";
|
||||
|
||||
export const list = async () => {
|
||||
const response = getPb().collection("domains").getFullList<Domain>({
|
||||
sort: "-created",
|
||||
expand: "lastDeployment",
|
||||
});
|
||||
|
||||
return response;
|
||||
};
|
||||
|
||||
export const get = async (id: string) => {
|
||||
const response = await getPb().collection("domains").getOne<Domain>(id);
|
||||
return response;
|
||||
};
|
||||
|
||||
export const save = async (data: Domain) => {
|
||||
if (data.id) {
|
||||
return await getPb().collection("domains").update(data.id, data);
|
||||
}
|
||||
return await getPb().collection("domains").create(data);
|
||||
};
|
||||
|
||||
export const remove = async (id: string) => {
|
||||
return await getPb().collection("domains").delete(id);
|
||||
};
|
||||
Reference in New Issue
Block a user