This commit is contained in:
Keviin Åberg Kultalahti 2021-04-01 08:40:30 +02:00
parent 958cae212d
commit 214243fc22
11 changed files with 941 additions and 951 deletions

View File

@ -67,10 +67,8 @@ export const getFrontendStore = () => {
await hostingStore.actions.fetch() await hostingStore.actions.fetch()
// Initialise backend stores // Initialise backend stores
const [ const [_integrations] = await Promise.all([
_integrations, api.get("/api/integrations").then(r => r.json()),
] = await Promise.all([
api.get("/api/integrations").then(r => r.json())
]) ])
datasources.init() datasources.init()
integrations.set(_integrations) integrations.set(_integrations)

View File

@ -3,11 +3,11 @@ import { queries } from "./"
import api from "../../builderStore/api" import api from "../../builderStore/api"
export const INITIAL_DATASOURCE_VALUES = { export const INITIAL_DATASOURCE_VALUES = {
list: [], list: [],
selected: null, selected: null,
} }
export function createDatasourcesStore(_api = api) { export function createDatasourcesStore() {
const { subscribe, update, set } = writable(INITIAL_DATASOURCE_VALUES) const { subscribe, update, set } = writable(INITIAL_DATASOURCE_VALUES)
return { return {
@ -48,7 +48,9 @@ export function createDatasourcesStore(_api = api) {
return json return json
}, },
delete: async datasource => { delete: async datasource => {
const response = await api.delete(`/api/datasources/${datasource._id}/${datasource._rev}`) const response = await api.delete(
`/api/datasources/${datasource._id}/${datasource._rev}`
)
update(state => { update(state => {
const sources = state.list.filter( const sources = state.list.filter(
existing => existing._id !== datasource._id existing => existing._id !== datasource._id

View File

@ -1,7 +1,6 @@
import { writable } from "svelte/store" import { writable } from "svelte/store"
import api from "builderStore/api" import api from "builderStore/api"
export function createPermissionStore() { export function createPermissionStore() {
const { subscribe } = writable([]) const { subscribe } = writable([])

View File

@ -2,7 +2,6 @@ import { writable, get } from "svelte/store"
import { datasources, integrations } from "./" import { datasources, integrations } from "./"
import api from "builderStore/api" import api from "builderStore/api"
export function createQueriesStore() { export function createQueriesStore() {
const { subscribe, set, update } = writable({ list: [], selected: null }) const { subscribe, set, update } = writable({ list: [], selected: null })
@ -59,7 +58,9 @@ export function createQueriesStore() {
datasources.update(state => ({ ...state, selected: query.datasourceId })) datasources.update(state => ({ ...state, selected: query.datasourceId }))
}, },
delete: async query => { delete: async query => {
const response = await api.delete(`/api/queries/${query._id}/${query._rev}`) const response = await api.delete(
`/api/queries/${query._id}/${query._rev}`
)
update(state => { update(state => {
state.list = state.list.filter(existing => existing._id !== query._id) state.list = state.list.filter(existing => existing._id !== query._id)
if (state.selected === query._id) { if (state.selected === query._id) {
@ -68,7 +69,7 @@ export function createQueriesStore() {
return state return state
}) })
return response; return response
}, },
} }
} }

View File

@ -1,7 +1,6 @@
import { writable } from "svelte/store" import { writable } from "svelte/store"
import api from "builderStore/api" import api from "builderStore/api"
export function createRolesStore() { export function createRolesStore() {
const { subscribe, update, set } = writable([]) const { subscribe, update, set } = writable([])

View File

@ -3,7 +3,6 @@ import { views } from "./"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import api from "builderStore/api" import api from "builderStore/api"
export function createTablesStore() { export function createTablesStore() {
const store = writable({}) const store = writable({})
const { subscribe, update, set } = store const { subscribe, update, set } = store

View File

@ -1,26 +1,25 @@
export const SOME_DATASOURCE = [ export const SOME_DATASOURCE = [
{ {
"type": "datasource", type: "datasource",
"name": "erterter", name: "erterter",
"source": "REST", source: "REST",
"config": { config: {
"url": "localhost", url: "localhost",
"defaultHeaders": {} defaultHeaders: {},
}, },
"_id": "datasource_04b003a7b4a8428eadd3bb2f7eae0255", _id: "datasource_04b003a7b4a8428eadd3bb2f7eae0255",
"_rev": "1-4e72002f1011e9392e655948469b7908" _rev: "1-4e72002f1011e9392e655948469b7908",
} },
] ]
export const SAVE_DATASOURCE = { export const SAVE_DATASOURCE = {
"type": "datasource", type: "datasource",
"name": "CoolDB", name: "CoolDB",
"source": "REST", source: "REST",
"config": { config: {
"url": "localhost", url: "localhost",
"defaultHeaders": {} defaultHeaders: {},
}, },
"_id": "datasource_04b003a7b4a8428eadd3bb2f7eae0255", _id: "datasource_04b003a7b4a8428eadd3bb2f7eae0255",
"_rev": "1-4e72002f1011e9392e655948469b7908" _rev: "1-4e72002f1011e9392e655948469b7908",
} }

View File

@ -1,80 +1,82 @@
export const SOME_QUERY = { export const SOME_QUERY = {
"datasourceId": "datasource_04b003a7b4a8428eadd3bb2f7eae0255", datasourceId: "datasource_04b003a7b4a8428eadd3bb2f7eae0255",
"parameters": [], parameters: [],
"fields": { fields: {
"headers": {}, headers: {},
"queryString": "", queryString: "",
"path": "Speakers" path: "Speakers",
}, },
"queryVerb": "read", queryVerb: "read",
"schema": {}, schema: {},
"name": "Speakers", name: "Speakers",
"_id": "query_datasource_04b003a7b4a8428eadd3bb2f7eae0255_bcb8ffc6fcbc484e8d63121fc0bf986f", _id:
"_rev": "2-941f8699eb0adf995f8bd59c99203b26", "query_datasource_04b003a7b4a8428eadd3bb2f7eae0255_bcb8ffc6fcbc484e8d63121fc0bf986f",
"readable": true _rev: "2-941f8699eb0adf995f8bd59c99203b26",
} readable: true,
}
export const SAVE_QUERY_RESPONSE = { export const SAVE_QUERY_RESPONSE = {
"datasourceId": "datasource_04b003a7b4a8428eadd3bb2f7eae0255", datasourceId: "datasource_04b003a7b4a8428eadd3bb2f7eae0255",
"parameters": [], parameters: [],
"fields": { fields: {
"headers": {}, headers: {},
"queryString": "", queryString: "",
"path": "Speakers" path: "Speakers",
},
queryVerb: "read",
schema: {
id: {
name: "id",
type: "string",
}, },
"queryVerb": "read", firstName: {
"schema": { name: "firstName",
"id": { type: "string",
"name": "id",
"type": "string"
},
"firstName": {
"name": "firstName",
"type": "string"
},
"lastName": {
"name": "lastName",
"type": "string"
},
"fullName": {
"name": "fullName",
"type": "string"
},
"bio": {
"name": "bio",
"type": "string"
},
"tagLine": {
"name": "tagLine",
"type": "string"
},
"profilePicture": {
"name": "profilePicture",
"type": "string"
},
"sessions": {
"name": "sessions",
"type": "string"
},
"isTopSpeaker": {
"name": "isTopSpeaker",
"type": "string"
},
"links": {
"name": "links",
"type": "string"
},
"questionAnswers": {
"name": "questionAnswers",
"type": "string"
},
"categories": {
"name": "categories",
"type": "string"
}
}, },
"name": "Speakers", lastName: {
"_id": "query_datasource_04b003a7b4a8428eadd3bb2f7eae0255_bcb8ffc6fcbc484e8d63121fc0bf986f", name: "lastName",
"_rev": "3-5a64adef494b1e9c793dc91b51ce73c6", type: "string",
"readable": true },
} fullName: {
name: "fullName",
type: "string",
},
bio: {
name: "bio",
type: "string",
},
tagLine: {
name: "tagLine",
type: "string",
},
profilePicture: {
name: "profilePicture",
type: "string",
},
sessions: {
name: "sessions",
type: "string",
},
isTopSpeaker: {
name: "isTopSpeaker",
type: "string",
},
links: {
name: "links",
type: "string",
},
questionAnswers: {
name: "questionAnswers",
type: "string",
},
categories: {
name: "categories",
type: "string",
},
},
name: "Speakers",
_id:
"query_datasource_04b003a7b4a8428eadd3bb2f7eae0255_bcb8ffc6fcbc484e8d63121fc0bf986f",
_rev: "3-5a64adef494b1e9c793dc91b51ce73c6",
readable: true,
}

View File

@ -1,32 +1,32 @@
export const ROLES = [ export const ROLES = [
{ {
"name": "Test", name: "Test",
"permissionId": "admin", permissionId: "admin",
"inherits": "ADMIN", inherits: "ADMIN",
"_id": "role_04681b7e71914a0aa53e09a5bea3584f", _id: "role_04681b7e71914a0aa53e09a5bea3584f",
"_rev": "1-179c71ea61d7fd987306b84b6d64b00e" _rev: "1-179c71ea61d7fd987306b84b6d64b00e",
}, },
{ {
"_id": "ADMIN", _id: "ADMIN",
"name": "Admin", name: "Admin",
"permissionId": "admin", permissionId: "admin",
"inherits": "POWER" inherits: "POWER",
}, },
{ {
"_id": "POWER", _id: "POWER",
"name": "Power", name: "Power",
"permissionId": "power", permissionId: "power",
"inherits": "BASIC" inherits: "BASIC",
}, },
{ {
"_id": "BASIC", _id: "BASIC",
"name": "Basic", name: "Basic",
"permissionId": "write", permissionId: "write",
"inherits": "PUBLIC" inherits: "PUBLIC",
}, },
{ {
"_id": "PUBLIC", _id: "PUBLIC",
"name": "Public", name: "Public",
"permissionId": "public" permissionId: "public",
} },
] ]

File diff suppressed because it is too large Load Diff

View File

@ -1,102 +1,102 @@
export const A_VIEW = { export const A_VIEW = {
"name": "Published", name: "Published",
"tableId": "ta_3c78cffe33664ca9bfb6b2b6cb3ee55a", tableId: "ta_3c78cffe33664ca9bfb6b2b6cb3ee55a",
"filters": [], filters: [],
"schema": { schema: {
"Auto ID": { "Auto ID": {
"name": "Auto ID", name: "Auto ID",
"type": "number", type: "number",
"subtype": "autoID", subtype: "autoID",
"icon": "ri-magic-line", icon: "ri-magic-line",
"autocolumn": true, autocolumn: true,
"constraints": { constraints: {
"type": "number", type: "number",
"presence": false, presence: false,
"numericality": { numericality: {
"greaterThanOrEqualTo": "", greaterThanOrEqualTo: "",
"lessThanOrEqualTo": "" lessThanOrEqualTo: "",
}
},
"lastID": 2
}, },
"Created By": { },
"name": "Created By", lastID: 2,
"type": "link", },
"subtype": "createdBy", "Created By": {
"icon": "ri-magic-line", name: "Created By",
"autocolumn": true, type: "link",
"constraints": { subtype: "createdBy",
"type": "array", icon: "ri-magic-line",
"presence": false autocolumn: true,
}, constraints: {
"tableId": "ta_users", type: "array",
"fieldName": "Guest-Created By", presence: false,
"relationshipType": "many-to-many" },
tableId: "ta_users",
fieldName: "Guest-Created By",
relationshipType: "many-to-many",
},
"Created At": {
name: "Created At",
type: "datetime",
subtype: "createdAt",
icon: "ri-magic-line",
autocolumn: true,
constraints: {
type: "string",
length: {},
presence: false,
datetime: {
latest: "",
earliest: "",
}, },
"Created At": { },
"name": "Created At", },
"type": "datetime", "Updated By": {
"subtype": "createdAt", name: "Updated By",
"icon": "ri-magic-line", type: "link",
"autocolumn": true, subtype: "updatedBy",
"constraints": { icon: "ri-magic-line",
"type": "string", autocolumn: true,
"length": {}, constraints: {
"presence": false, type: "array",
"datetime": { presence: false,
"latest": "", },
"earliest": "" tableId: "ta_users",
} fieldName: "Guest-Updated By",
} relationshipType: "many-to-many",
},
"Updated At": {
name: "Updated At",
type: "datetime",
subtype: "updatedAt",
icon: "ri-magic-line",
autocolumn: true,
constraints: {
type: "string",
length: {},
presence: false,
datetime: {
latest: "",
earliest: "",
}, },
"Updated By": { },
"name": "Updated By", },
"type": "link", Episode: {
"subtype": "updatedBy", name: "Episode",
"icon": "ri-magic-line", type: "link",
"autocolumn": true, tableId: "ta_d4bf541ce0d84b16a1a8e0a060e5f7f7",
"constraints": { fieldName: "Guest",
"type": "array", relationshipType: "one-to-many",
"presence": false },
}, Names: {
"tableId": "ta_users", type: "string",
"fieldName": "Guest-Updated By", constraints: {
"relationshipType": "many-to-many" type: "string",
length: {
maximum: "",
}, },
"Updated At": { presence: false,
"name": "Updated At", },
"type": "datetime", fieldName: "Guest",
"subtype": "updatedAt", name: "Names",
"icon": "ri-magic-line", },
"autocolumn": true, },
"constraints": { }
"type": "string",
"length": {},
"presence": false,
"datetime": {
"latest": "",
"earliest": ""
}
}
},
"Episode": {
"name": "Episode",
"type": "link",
"tableId": "ta_d4bf541ce0d84b16a1a8e0a060e5f7f7",
"fieldName": "Guest",
"relationshipType": "one-to-many"
},
"Names": {
"type": "string",
"constraints": {
"type": "string",
"length": {
"maximum": ""
},
"presence": false
},
"fieldName": "Guest",
"name": "Names"
}
}
}