add initialiseClientDB

This commit is contained in:
Martin McKeaveney 2020-05-11 10:28:06 +01:00
parent 6c51c872e9
commit 16a6680c2e
17 changed files with 70 additions and 52 deletions

View File

@ -108,7 +108,6 @@ const setPackage = (store, initial) => async pkg => {
initial.appId = pkg.application._id
store.set(initial)
console.log(initial)
return initial
}
@ -359,7 +358,7 @@ const addChildComponent = store => (componentToAdd, presetName) => {
const newComponent = createProps(component, {
...presetProps,
instanceId
_instanceId: instanceId
}, state)
state.currentComponentInfo._children = state.currentComponentInfo._children.concat(

View File

@ -205,6 +205,14 @@ export default {
commonProps: {},
children: [],
},
{
name: "Map",
_component: "@budibase/standard-components/datamap",
description: "Shiny map",
icon: "ri-map-pin-line",
commonProps: {},
children: [],
},
],
},
],

View File

@ -3,10 +3,10 @@ const { exists, readFile, writeFile, ensureDir } = require("fs-extra")
const chalk = require("chalk")
const { serverFileName, xPlatHomeDir } = require("../../common")
const { join } = require("path")
const initialiseClientDb = require("@budibase/server/db/initialiseClientDb")
const initialiseClientDb = require("@budibase/server/src/db/initialiseClientDb")
const Sqrl = require("squirrelly")
const uuid = require("uuid")
const CouchDB = require("@budibase/server/db/client")
const CouchDB = require("@budibase/server/src/db/client")
module.exports = opts => {
run(opts)

View File

@ -1,8 +1,8 @@
const { xPlatHomeDir } = require("../../common")
const dotenv = require("dotenv")
const createInstance = require("@budibase/server/api/controllers/instance")
const createInstance = require("@budibase/server/src/api/controllers/instance")
.create
const createApplication = require("@budibase/server/api/controllers/application")
const createApplication = require("@budibase/server/src/api/controllers/application")
.create
const { copy, readJSON, writeJSON, remove, exists } = require("fs-extra")
const { resolve, join } = require("path")

View File

@ -1,9 +1,8 @@
const app = require("@budibase/server/app")
const { xPlatHomeDir } = require("../../common")
module.exports = ({ dir }) => {
dir = xPlatHomeDir(dir)
process.chdir(dir)
app()
app = require("@budibase/server/src/app")
console.log(`Budibase Builder running on port ${process.env.PORT}..`)
}

View File

@ -5,7 +5,7 @@
"main": "src/index.js",
"scripts": {
"test": "jest",
"test:integration": "jest neo --runInBand",
"test:integration": "jest routes --runInBand",
"test:watch": "jest -w",
"initialise": "node ../cli/bin/budi init ./myapps -b local -q",
"budi": "node ../cli/bin/budi",

View File

@ -1,5 +1,5 @@
const supertest = require("supertest");
const app = require("../../../../app");
const app = require("../../../app");
const { createClientDatabase, destroyDatabase } = require("./couchTestUtils");
@ -10,11 +10,7 @@ describe("/applications", () => {
let server;
beforeAll(async () => {
server = await app({
config: {
port: 3000
}
});
server = app;
request = supertest(server);
await createClientDatabase();
});

View File

@ -1,5 +1,5 @@
const supertest = require("supertest");
const app = require("../../../../app");
const app = require("../../../app");
const { createClientDatabase, destroyClientDatabase } = require("./couchTestUtils")
@ -11,11 +11,7 @@ describe("/clients", () => {
let db;
beforeAll(async () => {
server = await app({
config: {
port: 3000
}
});
server = app
request = supertest(server);
});

View File

@ -1,5 +1,5 @@
const supertest = require("supertest");
const app = require("../../../../app");
const app = require("../../../app");
const {
createInstanceDatabase,
createClientDatabase,
@ -15,11 +15,7 @@ describe("/instances", () => {
let server;
beforeAll(async () => {
server = await app({
config: {
port: 3000
}
});
server = app
request = supertest(server);
});

View File

@ -10,11 +10,7 @@ describe("/models", () => {
let server;
beforeAll(async () => {
server = await app({
config: {
port: 3000
}
});
server = app;
request = supertest(server);
});

View File

@ -1,5 +1,5 @@
const supertest = require("supertest");
const app = require("../../../../app");
const app = require("../../../app");
const { createInstanceDatabase, createModel } = require("./couchTestUtils");
const TEST_INSTANCE_ID = "testing-123";
@ -20,11 +20,7 @@ describe("/records", () => {
let db;
beforeAll(async () => {
server = await app({
config: {
port: 3000
}
});
server = app;
request = supertest(server);
});

View File

@ -1,5 +1,5 @@
const supertest = require("supertest");
const app = require("../../../../app");
const app = require("../../../app");
const {
createInstanceDatabase
} = require("./couchTestUtils");
@ -15,11 +15,7 @@ describe("/users", () => {
let server;
beforeAll(async () => {
server = await app({
config: {
port: 3000
}
});
server = app
request = supertest(server);
});
@ -45,8 +41,8 @@ describe("/users", () => {
.expect('Content-Type', /json/)
.expect(200)
.end(async (err, res) => {
const createdUser = res.body[0];
expect(createdUser.name).toEqual(TEST_USER.name);
const user = res.body[0];
expect(user.name).toEqual(TEST_USER.name);
done();
});
})

View File

@ -11,11 +11,7 @@ describe("/views", () => {
let db;
beforeAll(async () => {
server = await app({
config: {
port: 3000
}
});
server = app;
request = supertest(server);
});
@ -29,7 +25,7 @@ describe("/views", () => {
});
afterEach(async () => {
await db.destroy();
db && await db.destroy();
});
it("returns a success message when the view is successfully created", done => {

View File

@ -291,6 +291,13 @@
}
}
},
"datamap": {
"description": "shiny chart",
"data": true,
"props": {
"model": "models"
}
},
"datachart": {
"description": "shiny chart",
"data": true,

View File

@ -37,6 +37,7 @@
"license": "MIT",
"gitHead": "b1f4f90927d9e494e513220ef060af28d2d42455",
"dependencies": {
"@beyonk/svelte-googlemaps": "^2.2.0",
"fusioncharts": "^3.15.1-sr.1",
"svelte-fusioncharts": "^1.0.0"
}

View File

@ -0,0 +1,31 @@
<script>
import { GoogleMap } from '@beyonk/svelte-googlemaps'
// export let _bb
// export let onLoad
// export let _instanceId
// export let model
// let mapComponent
// let headers = []
// let store = _bb.store
// $: data = $store[model._id] || []
// async function fetchData() {
// const FETCH_RECORDS_URL = `/api/${_instanceId}/all_${model._id}/records`
// const response = await _bb.api.get(FETCH_RECORDS_URL)
// if (response.status === 200) {
// const json = await response.json()
// store.update(state => {
// state[model._id] = json
// return state
// });
// } else {
// throw new Error("Failed to fetch records.", response)
// }
// }
</script>
<GoogleMap apiKey={"AIzaSyCPJ_eiSIbhRMmKBiVYXgh4HFHmbC4ZL5U"} />

View File

@ -19,3 +19,4 @@ export { default as dataform } from "./DataForm.svelte"
export { default as datachart } from "./DataChart.svelte"
export { default as datalist } from "./DataList.svelte"
export { default as datasearch } from "./DataSearch.svelte"
export { default as datamap } from "./DataMap.svelte"