forked from tsai/budibase
5 changed files with 35 additions and 51 deletions
@ -1,47 +1,11 @@ |
|||||
import { writable } from "svelte/store" |
import { writable } from "svelte/store" |
||||
import api, { get } from "../api" |
|
||||
|
|
||||
const INITIAL_ADMIN_STATE = { |
const INITIAL_ADMIN_STATE = { |
||||
oauth: [] |
oauth: [], |
||||
} |
} |
||||
|
|
||||
export const getAdminStore = () => { |
export const getAdminStore = () => { |
||||
const store = writable({ ...INITIAL_ADMIN_STATE }) |
const store = writable({ ...INITIAL_ADMIN_STATE }) |
||||
store.actions = { |
store.actions = {} |
||||
fetch: async () => { |
|
||||
const responses = await Promise.all([ |
|
||||
api.get("/api/hosting/"), |
|
||||
api.get("/api/hosting/urls"), |
|
||||
]) |
|
||||
const [info, urls] = await Promise.all(responses.map(resp => resp.json())) |
|
||||
store.update(state => { |
|
||||
state.hostingInfo = info |
|
||||
state.appUrl = urls.app |
|
||||
return state |
|
||||
}) |
|
||||
return info |
|
||||
}, |
|
||||
save: async hostingInfo => { |
|
||||
const response = await api.post("/api/hosting", hostingInfo) |
|
||||
const revision = (await response.json()).rev |
|
||||
store.update(state => { |
|
||||
state.hostingInfo = { |
|
||||
...hostingInfo, |
|
||||
_rev: revision, |
|
||||
} |
|
||||
return state |
|
||||
}) |
|
||||
}, |
|
||||
fetchDeployedApps: async () => { |
|
||||
let deployments = await (await get("/api/hosting/apps")).json() |
|
||||
store.update(state => { |
|
||||
state.deployedApps = deployments |
|
||||
state.deployedAppNames = Object.values(deployments).map(app => app.name) |
|
||||
state.deployedAppUrls = Object.values(deployments).map(app => app.url) |
|
||||
return state |
|
||||
}) |
|
||||
return deployments |
|
||||
}, |
|
||||
} |
|
||||
return store |
return store |
||||
} |
} |
||||
|
|||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in new issue