style: format
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import moment from "moment";
|
||||
|
||||
import { Access } from "@/domain/access";
|
||||
import { getPb } from "./api";
|
||||
import moment from "moment";
|
||||
|
||||
export const list = async () => {
|
||||
return await getPb().collection("access").getFullList<Access>({
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { Access } from "@/domain/access";
|
||||
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",
|
||||
});
|
||||
const resp = await getPb().collection("access_groups").getFullList<AccessGroup>({
|
||||
sort: "-created",
|
||||
expand: "access",
|
||||
});
|
||||
|
||||
return resp;
|
||||
};
|
||||
@@ -31,9 +29,7 @@ export const remove = async (id: string) => {
|
||||
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").update(accessGroup.id, accessGroup);
|
||||
}
|
||||
return await pb.collection("access_groups").create(accessGroup);
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import PocketBase from "pocketbase";
|
||||
|
||||
const apiDomain = import.meta.env.VITE_API_DOMAIN;
|
||||
console.log(apiDomain);
|
||||
|
||||
let pb: PocketBase;
|
||||
export const getPb = () => {
|
||||
if (pb) return pb;
|
||||
|
||||
@@ -11,15 +11,15 @@ export const list = async (req: DeploymentListReq) => {
|
||||
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: "-deployedAt",
|
||||
expand: "domain",
|
||||
});
|
||||
|
||||
return await getPb().collection("deployments").getList<Deployment>(page, perPage, {
|
||||
filter: filter,
|
||||
sort: "-deployedAt",
|
||||
expand: "domain",
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getTimeAfter } from "@/lib/time";
|
||||
import { Domain, Statistic } from "@/domain/domain";
|
||||
import { getPb } from "./api";
|
||||
import { getTimeAfter } from "@/lib/time";
|
||||
|
||||
type DomainListReq = {
|
||||
domain?: string;
|
||||
@@ -10,6 +10,8 @@ type DomainListReq = {
|
||||
};
|
||||
|
||||
export const list = async (req: DomainListReq) => {
|
||||
const pb = getPb();
|
||||
|
||||
let page = 1;
|
||||
if (req.page) {
|
||||
page = req.page;
|
||||
@@ -19,7 +21,7 @@ export const list = async (req: DomainListReq) => {
|
||||
if (req.perPage) {
|
||||
perPage = req.perPage;
|
||||
}
|
||||
const pb = getPb();
|
||||
|
||||
let filter = "";
|
||||
if (req.state === "enabled") {
|
||||
filter = "enabled=true";
|
||||
|
||||
@@ -3,9 +3,7 @@ import { getPb } from "./api";
|
||||
|
||||
export const getEmails = async () => {
|
||||
try {
|
||||
const resp = await getPb()
|
||||
.collection("settings")
|
||||
.getFirstListItem<Setting>("name='emails'");
|
||||
const resp = await getPb().collection("settings").getFirstListItem<Setting>("name='emails'");
|
||||
return resp;
|
||||
} catch (e) {
|
||||
return {
|
||||
@@ -16,9 +14,7 @@ export const getEmails = async () => {
|
||||
|
||||
export const getSetting = async (name: string) => {
|
||||
try {
|
||||
const resp = await getPb()
|
||||
.collection("settings")
|
||||
.getFirstListItem<Setting>(`name='${name}'`);
|
||||
const resp = await getPb().collection("settings").getFirstListItem<Setting>(`name='${name}'`);
|
||||
return resp;
|
||||
} catch (e) {
|
||||
const rs: Setting = {
|
||||
|
||||
Reference in New Issue
Block a user