working through auth - adding user instance map
This commit is contained in:
parent
c3f68e9895
commit
2afd1cd4dd
|
@ -1,7 +1,7 @@
|
||||||
import { filter, cloneDeep, values } from "lodash/fp"
|
import { filter, cloneDeep, values } from "lodash/fp"
|
||||||
import { pipe } from "components/common/core"
|
import { pipe } from "components/common/core"
|
||||||
import * as backendStoreActions from "./backend"
|
import * as backendStoreActions from "./backend"
|
||||||
import { writable } from "svelte/store"
|
import { writable, get } from "svelte/store"
|
||||||
import api from "../api"
|
import api from "../api"
|
||||||
import {
|
import {
|
||||||
DEFAULT_PAGES_OBJECT
|
DEFAULT_PAGES_OBJECT
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
// It's a screen, set it to that screen
|
// It's a screen, set it to that screen
|
||||||
if ($params.screen !== "page-layout") {
|
if ($params.screen !== "page-layout") {
|
||||||
store.setCurrentScreen($params.screen)
|
store.setCurrentScreen(decodeURI($params.screen))
|
||||||
|
|
||||||
// There are leftover stuff, like IDs, so navigate the components and find the ID and select it.
|
// There are leftover stuff, like IDs, so navigate the components and find the ID and select it.
|
||||||
if ($leftover) {
|
if ($leftover) {
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
// Find Component with ID and continue
|
// Find Component with ID and continue
|
||||||
function findComponent(ids, children) {
|
function findComponent(ids, children) {
|
||||||
|
console.log(ids, children);
|
||||||
// Setup stuff
|
// Setup stuff
|
||||||
let componentToSelect
|
let componentToSelect
|
||||||
let currentChildren = children
|
let currentChildren = children
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
import PagesList from "components/userInterface/PagesList.svelte"
|
import PagesList from "components/userInterface/PagesList.svelte"
|
||||||
import IconButton from "components/common/IconButton.svelte"
|
import IconButton from "components/common/IconButton.svelte"
|
||||||
import NewScreen from "components/userInterface/NewScreen.svelte"
|
import NewScreen from "components/userInterface/NewScreen.svelte"
|
||||||
import CurrentItemPreview from "components/userInterface/CurrentItemPreview.svelte"
|
import CurrentItemPreview from "components/userInterface/AppPreview"
|
||||||
import SettingsView from "components/userInterface/SettingsView.svelte"
|
|
||||||
import PageView from "components/userInterface/PageView.svelte"
|
import PageView from "components/userInterface/PageView.svelte"
|
||||||
import ComponentsPaneSwitcher from "components/userInterface/ComponentsPaneSwitcher.svelte"
|
import ComponentsPaneSwitcher from "components/userInterface/ComponentsPaneSwitcher.svelte"
|
||||||
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
||||||
|
@ -104,7 +103,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<NewScreen bind:this={newScreenPicker} />
|
<NewScreen bind:this={newScreenPicker} />
|
||||||
<SettingsView bind:this={settingsView} />
|
|
||||||
|
|
||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
bind:this={confirmDeleteDialog}
|
bind:this={confirmDeleteDialog}
|
||||||
|
|
|
@ -24,6 +24,7 @@ exports.create = async function(ctx) {
|
||||||
const { id, rev } = await clientDb.post({
|
const { id, rev } = await clientDb.post({
|
||||||
type: "app",
|
type: "app",
|
||||||
instances: [],
|
instances: [],
|
||||||
|
userInstanceMap: {},
|
||||||
componentLibraries: [
|
componentLibraries: [
|
||||||
"@budibase/standard-components",
|
"@budibase/standard-components",
|
||||||
"@budibase/materialdesign-components"
|
"@budibase/materialdesign-components"
|
||||||
|
|
|
@ -24,6 +24,16 @@ exports.create = async function(ctx) {
|
||||||
type: "user"
|
type: "user"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// the clientDB needs to store a map of users against the app
|
||||||
|
const clientDB = new CouchDB(process.env.CLIENT_ID);
|
||||||
|
const app = await clientDB.get(ctx.params.appId);
|
||||||
|
|
||||||
|
app.userInstanceMap = {
|
||||||
|
...app.userInstanceMap,
|
||||||
|
[response._id]: ctx.params.instanceId
|
||||||
|
}
|
||||||
|
await clientDb.put(app);
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
user: {
|
user: {
|
||||||
id: response.id,
|
id: response.id,
|
||||||
|
|
|
@ -5,7 +5,7 @@ const router = Router();
|
||||||
|
|
||||||
router
|
router
|
||||||
.get("/api/:instanceId/users", controller.fetch)
|
.get("/api/:instanceId/users", controller.fetch)
|
||||||
.post("/api/:instanceId/users", controller.create)
|
.post("/api/:appId/:instanceId/users", controller.create)
|
||||||
.delete("/api/:instanceId/users/:userId", controller.destroy);
|
.delete("/api/:instanceId/users/:userId", controller.destroy);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
Loading…
Reference in New Issue