add apis and svelte store
This commit is contained in:
parent
06e2b041d2
commit
34754f47ce
|
@ -0,0 +1,40 @@
|
||||||
|
import { writable } from "svelte/store"
|
||||||
|
import { API } from "api"
|
||||||
|
|
||||||
|
export function createBackupsStore() {
|
||||||
|
const { subscribe, set } = writable([])
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
set([
|
||||||
|
{
|
||||||
|
trigger: "PUBLISH",
|
||||||
|
name: "A Backup",
|
||||||
|
date: "1665407451",
|
||||||
|
userId: "Peter Clement",
|
||||||
|
contents: [
|
||||||
|
{ datasources: ["datasource1", "datasource2"] },
|
||||||
|
{ screens: ["screen1", "screen2"] },
|
||||||
|
{ automations: ["automation1", "automation2"] },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
async function searchBackups(appId) {
|
||||||
|
return API.searchBackups(appId)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createManualBackup(appId, name) {
|
||||||
|
let resp = API.createManualBackup(appId, name)
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
subscribe,
|
||||||
|
load,
|
||||||
|
createManualBackup,
|
||||||
|
searchBackups,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const backups = createBackupsStore()
|
|
@ -9,3 +9,4 @@ export { templates } from "./templates"
|
||||||
export { licensing } from "./licensing"
|
export { licensing } from "./licensing"
|
||||||
export { groups } from "./groups"
|
export { groups } from "./groups"
|
||||||
export { plugins } from "./plugins"
|
export { plugins } from "./plugins"
|
||||||
|
export { backups } from "./backups"
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
export const buildBackupsEndpoints = API => ({
|
||||||
|
/**
|
||||||
|
* Gets a list of users in the current tenant.
|
||||||
|
*/
|
||||||
|
searchBackups: async appId => {
|
||||||
|
return await API.post({
|
||||||
|
url: `/api/apps/${appId}/backups/search`,
|
||||||
|
body: {
|
||||||
|
trigger: "MANUAL",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
createManualBackup: async ({ appId, name }) => {
|
||||||
|
return await API.post({
|
||||||
|
url: `/api/apps/${appId}/backups`,
|
||||||
|
body: { name },
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
|
@ -25,6 +25,7 @@ import { buildViewEndpoints } from "./views"
|
||||||
import { buildLicensingEndpoints } from "./licensing"
|
import { buildLicensingEndpoints } from "./licensing"
|
||||||
import { buildGroupsEndpoints } from "./groups"
|
import { buildGroupsEndpoints } from "./groups"
|
||||||
import { buildPluginEndpoints } from "./plugins"
|
import { buildPluginEndpoints } from "./plugins"
|
||||||
|
import { buildBackupsEndpoints } from "./backups"
|
||||||
|
|
||||||
const defaultAPIClientConfig = {
|
const defaultAPIClientConfig = {
|
||||||
/**
|
/**
|
||||||
|
@ -245,5 +246,6 @@ export const createAPIClient = config => {
|
||||||
...buildLicensingEndpoints(API),
|
...buildLicensingEndpoints(API),
|
||||||
...buildGroupsEndpoints(API),
|
...buildGroupsEndpoints(API),
|
||||||
...buildPluginEndpoints(API),
|
...buildPluginEndpoints(API),
|
||||||
|
...buildBackupsEndpoints(API),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue