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

@ -5,9 +5,9 @@ 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", queryVerb: "read",
"schema": { schema: {
"id": { id: {
"name": "id", name: "id",
"type": "string" type: "string",
}, },
"firstName": { firstName: {
"name": "firstName", name: "firstName",
"type": "string" type: "string",
}, },
"lastName": { lastName: {
"name": "lastName", name: "lastName",
"type": "string" type: "string",
}, },
"fullName": { fullName: {
"name": "fullName", name: "fullName",
"type": "string" type: "string",
}, },
"bio": { bio: {
"name": "bio", name: "bio",
"type": "string" type: "string",
}, },
"tagLine": { tagLine: {
"name": "tagLine", name: "tagLine",
"type": "string" type: "string",
}, },
"profilePicture": { profilePicture: {
"name": "profilePicture", name: "profilePicture",
"type": "string" type: "string",
}, },
"sessions": { sessions: {
"name": "sessions", name: "sessions",
"type": "string" type: "string",
}, },
"isTopSpeaker": { isTopSpeaker: {
"name": "isTopSpeaker", name: "isTopSpeaker",
"type": "string" type: "string",
}, },
"links": { links: {
"name": "links", name: "links",
"type": "string" type: "string",
}, },
"questionAnswers": { questionAnswers: {
"name": "questionAnswers", name: "questionAnswers",
"type": "string" type: "string",
}, },
"categories": { categories: {
"name": "categories", name: "categories",
"type": "string" type: "string",
}
}, },
"name": "Speakers", },
"_id": "query_datasource_04b003a7b4a8428eadd3bb2f7eae0255_bcb8ffc6fcbc484e8d63121fc0bf986f", name: "Speakers",
"_rev": "3-5a64adef494b1e9c793dc91b51ce73c6", _id:
"readable": true "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 },
lastID: 2,
}, },
"Created By": { "Created By": {
"name": "Created By", name: "Created By",
"type": "link", type: "link",
"subtype": "createdBy", subtype: "createdBy",
"icon": "ri-magic-line", icon: "ri-magic-line",
"autocolumn": true, autocolumn: true,
"constraints": { constraints: {
"type": "array", type: "array",
"presence": false presence: false,
}, },
"tableId": "ta_users", tableId: "ta_users",
"fieldName": "Guest-Created By", fieldName: "Guest-Created By",
"relationshipType": "many-to-many" relationshipType: "many-to-many",
}, },
"Created At": { "Created At": {
"name": "Created At", name: "Created At",
"type": "datetime", type: "datetime",
"subtype": "createdAt", subtype: "createdAt",
"icon": "ri-magic-line", icon: "ri-magic-line",
"autocolumn": true, autocolumn: true,
"constraints": { constraints: {
"type": "string", type: "string",
"length": {}, length: {},
"presence": false, presence: false,
"datetime": { datetime: {
"latest": "", latest: "",
"earliest": "" earliest: "",
} },
} },
}, },
"Updated By": { "Updated By": {
"name": "Updated By", name: "Updated By",
"type": "link", type: "link",
"subtype": "updatedBy", subtype: "updatedBy",
"icon": "ri-magic-line", icon: "ri-magic-line",
"autocolumn": true, autocolumn: true,
"constraints": { constraints: {
"type": "array", type: "array",
"presence": false presence: false,
}, },
"tableId": "ta_users", tableId: "ta_users",
"fieldName": "Guest-Updated By", fieldName: "Guest-Updated By",
"relationshipType": "many-to-many" relationshipType: "many-to-many",
}, },
"Updated At": { "Updated At": {
"name": "Updated At", name: "Updated At",
"type": "datetime", type: "datetime",
"subtype": "updatedAt", subtype: "updatedAt",
"icon": "ri-magic-line", icon: "ri-magic-line",
"autocolumn": true, autocolumn: true,
"constraints": { constraints: {
"type": "string", type: "string",
"length": {}, length: {},
"presence": false, presence: false,
"datetime": { datetime: {
"latest": "", latest: "",
"earliest": "" 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 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",
},
}, },
"fieldName": "Guest",
"name": "Names"
}
}
} }