formatting

This commit is contained in:
Martin McKeaveney 2020-05-18 11:01:09 +01:00
parent e83816df1c
commit c8dd48b507
24 changed files with 93 additions and 111 deletions

View File

@ -29,4 +29,3 @@
<Modal> <Modal>
<Router {routes} /> <Router {routes} />
</Modal> </Modal>

View File

@ -1,5 +1,5 @@
import { cloneDeep, values } from "lodash/fp" import { cloneDeep, values } from "lodash/fp"
import { backendUiStore } from "builderStore"; import { backendUiStore } from "builderStore"
import * as backendStoreActions from "./backend" import * as backendStoreActions from "./backend"
import { writable, get } from "svelte/store" import { writable, get } from "svelte/store"
import api from "../api" import api from "../api"
@ -194,7 +194,7 @@ const setCurrentScreen = store => screenName => {
const deleteScreen = store => name => { const deleteScreen = store => name => {
store.update(s => { store.update(s => {
const components = s.components.filter(c => c.name !== name) const components = s.components.filter(c => c.name !== name)
const screens = s.screens.filter(c => c.name !== name); const screens = s.screens.filter(c => c.name !== name)
s.components = components s.components = components
s.screens = screens s.screens = screens
@ -351,12 +351,16 @@ const addChildComponent = store => (componentToAdd, presetName) => {
const presetProps = presetName ? component.presets[presetName] : {} const presetProps = presetName ? component.presets[presetName] : {}
const instanceId = get(backendUiStore).selectedDatabase._id; const instanceId = get(backendUiStore).selectedDatabase._id
const newComponent = createProps(component, { const newComponent = createProps(
...presetProps, component,
_instanceId: instanceId {
}, state) ...presetProps,
_instanceId: instanceId,
},
state
)
state.currentComponentInfo._children = state.currentComponentInfo._children.concat( state.currentComponentInfo._children = state.currentComponentInfo._children.concat(
newComponent.props newComponent.props

View File

@ -9,10 +9,7 @@
let databaseName let databaseName
async function createDatabase() { async function createDatabase() {
const response = await api.createDatabase( const response = await api.createDatabase($store.appId, databaseName)
$store.appId,
databaseName
)
store.createDatabaseForApp(response) store.createDatabaseForApp(response)
onClosed() onClosed()
} }

View File

@ -1,5 +1,5 @@
<script> <script>
import { store } from "builderStore"; import { store } from "builderStore"
import Modal from "../../common/Modal.svelte" import Modal from "../../common/Modal.svelte"
import HandlerSelector from "./HandlerSelector.svelte" import HandlerSelector from "./HandlerSelector.svelte"
import IconButton from "../../common/IconButton.svelte" import IconButton from "../../common/IconButton.svelte"

View File

@ -1,5 +1,5 @@
<script> <script>
import { store } from "builderStore"; import { store } from "builderStore"
import Checkbox from "../common/Checkbox.svelte" import Checkbox from "../common/Checkbox.svelte"
import Textbox from "../common/Textbox.svelte" import Textbox from "../common/Textbox.svelte"
import Dropdown from "../common/Dropdown.svelte" import Dropdown from "../common/Dropdown.svelte"

View File

@ -1,5 +1,5 @@
<script> <script>
import { backendUiStore } from "builderStore"; import { backendUiStore } from "builderStore"
import IconButton from "../common/IconButton.svelte" import IconButton from "../common/IconButton.svelte"
import Input from "../common/Input.svelte" import Input from "../common/Input.svelte"
import PropertyCascader from "./PropertyCascader" import PropertyCascader from "./PropertyCascader"
@ -13,7 +13,6 @@
export let styleBindingProperty = "" export let styleBindingProperty = ""
$: bindOptionToStyle = !!styleBindingProperty $: bindOptionToStyle = !!styleBindingProperty
</script> </script>
<div class="unbound-container"> <div class="unbound-container">

View File

@ -25,7 +25,7 @@ export const createProps = (componentDefinition, derivedFromProps) => {
_id: uuid(), _id: uuid(),
_component: componentDefinition._component, _component: componentDefinition._component,
_styles: { position: {}, layout: {} }, _styles: { position: {}, layout: {} },
_code: "" _code: "",
} }
const errors = [] const errors = []

View File

@ -22,5 +22,5 @@ export const TYPE_MAP = {
}, },
models: { models: {
default: [], default: [],
} },
} }

View File

@ -1,6 +1,6 @@
import "./global.css" import "./global.css"
import "./fonts.css" import "./fonts.css"
import "./budibase.css"; import "./budibase.css"
import "/assets/roboto-v20-latin-ext_latin-300" import "/assets/roboto-v20-latin-ext_latin-300"
import "/assets/roboto-v20-latin-ext_latin-400" import "/assets/roboto-v20-latin-ext_latin-400"
import "/assets/roboto-v20-latin-ext_latin-500" import "/assets/roboto-v20-latin-ext_latin-500"

View File

@ -15,7 +15,7 @@ export const loadBudibase = async opts => {
// TODO: update // TODO: update
const user = {} const user = {}
const componentLibraryModules = opts && opts.componentLibraries || {} const componentLibraryModules = (opts && opts.componentLibraries) || {}
const libraries = frontendDefinition.libraries || [] const libraries = frontendDefinition.libraries || []

View File

@ -6,7 +6,7 @@ const env = require("../../environment")
exports.create = async function(ctx) { exports.create = async function(ctx) {
const instanceName = ctx.request.body.name const instanceName = ctx.request.body.name
const uid = uuid.v4().replace(/-/g, "") const uid = uuid.v4().replace(/-/g, "")
const instanceId = `inst_${ctx.params.applicationId.substring(0,7)}_${uid}` const instanceId = `inst_${ctx.params.applicationId.substring(0, 7)}_${uid}`
const { applicationId } = ctx.params const { applicationId } = ctx.params
const clientId = env.CLIENT_ID const clientId = env.CLIENT_ID
const db = new CouchDB(instanceId) const db = new CouchDB(instanceId)

View File

@ -3,7 +3,7 @@ const { create, destroy } = require("../../../db/clientDb")
const supertest = require("supertest") const supertest = require("supertest")
const app = require("../../../app") const app = require("../../../app")
const TEST_CLIENT_ID = "test-client-id"; const TEST_CLIENT_ID = "test-client-id"
exports.supertest = async () => { exports.supertest = async () => {
let request let request
@ -51,7 +51,7 @@ exports.createModel = async (request, instanceId, model) => {
return res.body return res.body
} }
exports.createClientDatabase = async () => await create(TEST_CLIENT_ID); exports.createClientDatabase = async () => await create(TEST_CLIENT_ID)
exports.createApplication = async (request, name = "test_application") => { exports.createApplication = async (request, name = "test_application") => {
const res = await request const res = await request
@ -63,7 +63,7 @@ exports.createApplication = async (request, name = "test_application") => {
return res.body return res.body
} }
exports.destroyClientDatabase = async () => await destroy(TEST_CLIENT_ID); exports.destroyClientDatabase = async () => await destroy(TEST_CLIENT_ID)
exports.createInstance = async (request, appId) => { exports.createInstance = async (request, appId) => {
const res = await request const res = await request

View File

@ -7,15 +7,15 @@ const COUCH_DB_URL = env.COUCH_DB_URL || `leveldb://${budibaseAppsDir()}/.data/`
const isInMemory = env.NODE_ENV === "jest" const isInMemory = env.NODE_ENV === "jest"
let POUCH_DB_DEFAULTS = { let POUCH_DB_DEFAULTS = {
prefix: COUCH_DB_URL prefix: COUCH_DB_URL,
}; }
if (isInMemory) { if (isInMemory) {
PouchDB.plugin(require("pouchdb-adapter-memory")) PouchDB.plugin(require("pouchdb-adapter-memory"))
POUCH_DB_DEFAULTS = { POUCH_DB_DEFAULTS = {
prefix: undefined, prefix: undefined,
adapter: "memory" adapter: "memory",
}; }
} }
const Pouch = PouchDB.defaults(POUCH_DB_DEFAULTS) const Pouch = PouchDB.defaults(POUCH_DB_DEFAULTS)

View File

@ -1,47 +1,46 @@
const { app, BrowserWindow } = require("electron"); const { app, BrowserWindow } = require("electron")
const { join } = require("path"); const { join } = require("path")
const { homedir } = require("os"); const { homedir } = require("os")
const isDev = require("electron-is-dev"); const isDev = require("electron-is-dev")
const { autoUpdater } = require("electron-updater"); const { autoUpdater } = require("electron-updater")
const unhandled = require("electron-unhandled"); const unhandled = require("electron-unhandled")
require("dotenv").config({ path: join(homedir(), ".budibase", ".env") }); require("dotenv").config({ path: join(homedir(), ".budibase", ".env") })
if (isDev) { if (isDev) {
unhandled({ unhandled({
showDialog: true showDialog: true,
}); })
} }
const APP_URL = "http://localhost:4001"; const APP_URL = "http://localhost:4001"
const APP_TITLE = "Budibase Builder"; const APP_TITLE = "Budibase Builder"
let win let win
function createWindow() { function createWindow() {
app.server = require("./app"); app.server = require("./app")
win = new BrowserWindow({ width: 1920, height: 1080 }); win = new BrowserWindow({ width: 1920, height: 1080 })
win.setTitle(APP_TITLE); win.setTitle(APP_TITLE)
win.loadURL(APP_URL); win.loadURL(APP_URL)
if (isDev) { if (isDev) {
win.webContents.openDevTools(); win.webContents.openDevTools()
} else { } else {
autoUpdater.checkForUpdatesAndNotify(); autoUpdater.checkForUpdatesAndNotify()
} }
} }
app.whenReady().then(createWindow) app.whenReady().then(createWindow)
// Quit when all windows are closed. // Quit when all windows are closed.
app.on("window-all-closed", () => { app.on("window-all-closed", () => {
// On macOS it is common for applications and their menu bar // On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q // to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== "darwin") app.quit(); if (process.platform !== "darwin") app.quit()
}); })
app.on("activate", () => { app.on("activate", () => {
// On macOS it's common to re-create a window in the app when the // On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open. // dock icon is clicked and there are no other windows open.
if (win === null) createWindow(); if (win === null) createWindow()
}); })

View File

@ -95,8 +95,8 @@ const buildFrontendAppDefinition = async (config, appId, pageName, pkg) => {
screens: pkg.screens, screens: pkg.screens,
libraries: [ libraries: [
"@budibase/materialdesign-components", "@budibase/materialdesign-components",
"@budibase/standard-components" "@budibase/standard-components",
] ],
}) })
await writeFile( await writeFile(

View File

@ -19,6 +19,6 @@ export default {
resolve({ resolve({
browser: true, browser: true,
}), }),
commonjs() commonjs(),
], ],
} }

View File

@ -1,11 +1,11 @@
<script> <script>
import { onMount } from "svelte"; import { onMount } from "svelte"
import FusionCharts from "fusioncharts"; import FusionCharts from "fusioncharts"
import Charts from "fusioncharts/fusioncharts.charts"; import Charts from "fusioncharts/fusioncharts.charts"
import FusionTheme from "fusioncharts/themes/fusioncharts.theme.fusion"; import FusionTheme from "fusioncharts/themes/fusioncharts.theme.fusion"
import SvelteFC, {fcRoot} from 'svelte-fusioncharts'; import SvelteFC, { fcRoot } from "svelte-fusioncharts"
fcRoot(FusionCharts, Charts, FusionTheme); fcRoot(FusionCharts, Charts, FusionTheme)
export let _bb export let _bb
export let _instanceId export let _instanceId
@ -16,12 +16,12 @@
$: chartConfigs = { $: chartConfigs = {
type, type,
width: '600', width: "600",
height: '400', height: "400",
dataFormat: 'json', dataFormat: "json",
dataSource: { dataSource: {
data: $store[model._id] || [] data: $store[model._id] || [],
} },
} }
async function fetchData() { async function fetchData() {
@ -41,7 +41,6 @@
onMount(async () => { onMount(async () => {
await fetchData() await fetchData()
}) })
</script> </script>
<div id="container"> <div id="container">

View File

@ -8,7 +8,7 @@
let username let username
let password let password
let newModel = { let newModel = {
modelId: model._id modelId: model._id,
} }
let store = _bb.store let store = _bb.store
@ -16,16 +16,13 @@
async function save() { async function save() {
const SAVE_RECORD_URL = `/api/${_instanceId}/records` const SAVE_RECORD_URL = `/api/${_instanceId}/records`
const response = await _bb.api.post(SAVE_RECORD_URL, newModel); const response = await _bb.api.post(SAVE_RECORD_URL, newModel)
const json = await response.json(); const json = await response.json()
store.update(state => { store.update(state => {
state[model._id] = [ state[model._id] = [...state[model._id], json]
...state[model._id],
json
]
return state return state
}); })
} }
const handleInput = field => event => { const handleInput = field => event => {
@ -56,15 +53,12 @@
<label class="form-label" for="form-stacked-text">{field}</label> <label class="form-label" for="form-stacked-text">{field}</label>
<input <input
class="uk-input" class="uk-input"
type={model.schema[field].type === "string" ? "text" : model.schema[field].type} type={model.schema[field].type === 'string' ? 'text' : model.schema[field].type}
on:change={handleInput(field)} on:change={handleInput(field)} />
/>
</div> </div>
{/each} {/each}
</div> </div>
<button on:click={save}> <button on:click={save}>SAVE</button>
SAVE
</button>
</form> </form>
<style> <style>

View File

@ -18,7 +18,7 @@
store.update(state => { store.update(state => {
state[model._id] = json state[model._id] = json
return state return state
}); })
} else { } else {
throw new Error("Failed to fetch records.", response) throw new Error("Failed to fetch records.", response)
} }
@ -31,21 +31,14 @@
}) })
</script> </script>
<section <section class:grid={layout === 'grid'} class:list={layout === 'list'}>
class:grid={layout === "grid"}
class:list={layout === "list"}
>
{#each data as data} {#each data as data}
<div class="data-card"> <div class="data-card">
<ul> <ul>
{#each Object.keys(data) as key} {#each Object.keys(data) as key}
<li> <li>
<span class="data-key"> <span class="data-key">{key}:</span>
{key}: <span class="data-value">{data[key]}</span>
</span>
<span class="data-value">
{data[key]}
</span>
</li> </li>
{/each} {/each}
</ul> </ul>

View File

@ -1,5 +1,5 @@
<script> <script>
import { GoogleMap } from '@beyonk/svelte-googlemaps' import { GoogleMap } from "@beyonk/svelte-googlemaps"
// export let _bb // export let _bb
// export let onLoad // export let onLoad
@ -28,4 +28,4 @@
// } // }
</script> </script>
<GoogleMap apiKey={"AIzaSyCPJ_eiSIbhRMmKBiVYXgh4HFHmbC4ZL5U"} /> <GoogleMap apiKey={'AIzaSyCPJ_eiSIbhRMmKBiVYXgh4HFHmbC4ZL5U'} />

View File

@ -5,13 +5,11 @@
let searchValue = "" let searchValue = ""
function search() { function search() {
const SEARCH_URL = const SEARCH_URL = _bb.api.get(``)
_bb.api.get(``);
} }
</script> </script>
<div> <div>
<input type="text" bind:value={searchValue}> <input type="text" bind:value={searchValue} />
<button on:click={search}>Search</button> <button on:click={search}>Search</button>
</div> </div>

View File

@ -18,7 +18,7 @@
store.update(state => { store.update(state => {
state[model._id] = json state[model._id] = json
return state return state
}); })
headers = Object.keys(json[0]).filter(key => !key.startsWith("_")) headers = Object.keys(json[0]).filter(key => !key.startsWith("_"))
} else { } else {

View File

@ -9,13 +9,13 @@
const fs = require("fs") const fs = require("fs")
const { resolve } = require("path") const { resolve } = require("path")
const rimraf = require("rimraf"); const rimraf = require("rimraf")
const { const {
budibaseTempDir, budibaseTempDir,
} = require("../packages/server/src/utilities/budibaseDir") } = require("../packages/server/src/utilities/budibaseDir")
const devDir = budibaseTempDir() const devDir = budibaseTempDir()
rimraf.sync(devDir); rimraf.sync(devDir)
fs.mkdirSync(`${devDir}/@budibase`, { recursive: true }) fs.mkdirSync(`${devDir}/@budibase`, { recursive: true })
const SYMLINK_PATHS = [ const SYMLINK_PATHS = [