From 16a6680c2ed13d672f6fced08ba9c166e33eabde Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Mon, 11 May 2020 10:28:06 +0100 Subject: [PATCH] add initialiseClientDB --- .../builder/src/builderStore/store/index.js | 3 +- .../userInterface/temporaryPanelStructure.js | 8 +++++ packages/cli/src/commands/init/initHandler.js | 4 +-- packages/cli/src/commands/new/newHandler.js | 4 +-- packages/cli/src/commands/run/runHandler.js | 3 +- packages/server/package.json | 2 +- .../src/api/routes/tests/application.spec.js | 8 ++--- .../src/api/routes/tests/client.spec.js | 8 ++--- .../src/api/routes/tests/instance.spec.js | 8 ++--- .../server/src/api/routes/tests/model.spec.js | 6 +--- .../src/api/routes/tests/record.spec.js | 8 ++--- .../server/src/api/routes/tests/user.spec.js | 12 +++---- .../server/src/api/routes/tests/view.spec.js | 8 ++--- packages/standard-components/components.json | 7 +++++ packages/standard-components/package.json | 1 + .../standard-components/src/DataMap.svelte | 31 +++++++++++++++++++ packages/standard-components/src/index.js | 1 + 17 files changed, 70 insertions(+), 52 deletions(-) create mode 100644 packages/standard-components/src/DataMap.svelte diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 6a9ff1a863..6994b3f3e8 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -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( diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 5aeb6cf2ec..ce64b37945 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -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: [], + }, ], }, ], diff --git a/packages/cli/src/commands/init/initHandler.js b/packages/cli/src/commands/init/initHandler.js index cdc975c6ab..5bcf0960f2 100644 --- a/packages/cli/src/commands/init/initHandler.js +++ b/packages/cli/src/commands/init/initHandler.js @@ -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) diff --git a/packages/cli/src/commands/new/newHandler.js b/packages/cli/src/commands/new/newHandler.js index c944c168e7..c26d3b72c4 100644 --- a/packages/cli/src/commands/new/newHandler.js +++ b/packages/cli/src/commands/new/newHandler.js @@ -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") diff --git a/packages/cli/src/commands/run/runHandler.js b/packages/cli/src/commands/run/runHandler.js index 30ca1ddb9b..13baebf2b3 100644 --- a/packages/cli/src/commands/run/runHandler.js +++ b/packages/cli/src/commands/run/runHandler.js @@ -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}..`) } diff --git a/packages/server/package.json b/packages/server/package.json index 51b7e030e1..e663b4f391 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -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", diff --git a/packages/server/src/api/routes/tests/application.spec.js b/packages/server/src/api/routes/tests/application.spec.js index 02a9930175..70a4206c20 100644 --- a/packages/server/src/api/routes/tests/application.spec.js +++ b/packages/server/src/api/routes/tests/application.spec.js @@ -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(); }); diff --git a/packages/server/src/api/routes/tests/client.spec.js b/packages/server/src/api/routes/tests/client.spec.js index ebf5660720..a4533a1230 100644 --- a/packages/server/src/api/routes/tests/client.spec.js +++ b/packages/server/src/api/routes/tests/client.spec.js @@ -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); }); diff --git a/packages/server/src/api/routes/tests/instance.spec.js b/packages/server/src/api/routes/tests/instance.spec.js index 80a222c192..5f2399f10d 100644 --- a/packages/server/src/api/routes/tests/instance.spec.js +++ b/packages/server/src/api/routes/tests/instance.spec.js @@ -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); }); diff --git a/packages/server/src/api/routes/tests/model.spec.js b/packages/server/src/api/routes/tests/model.spec.js index d518f8806f..2f18e70173 100644 --- a/packages/server/src/api/routes/tests/model.spec.js +++ b/packages/server/src/api/routes/tests/model.spec.js @@ -10,11 +10,7 @@ describe("/models", () => { let server; beforeAll(async () => { - server = await app({ - config: { - port: 3000 - } - }); + server = app; request = supertest(server); }); diff --git a/packages/server/src/api/routes/tests/record.spec.js b/packages/server/src/api/routes/tests/record.spec.js index ae4e40fc88..eda78efb35 100644 --- a/packages/server/src/api/routes/tests/record.spec.js +++ b/packages/server/src/api/routes/tests/record.spec.js @@ -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); }); diff --git a/packages/server/src/api/routes/tests/user.spec.js b/packages/server/src/api/routes/tests/user.spec.js index f6fb33139b..2590297e88 100644 --- a/packages/server/src/api/routes/tests/user.spec.js +++ b/packages/server/src/api/routes/tests/user.spec.js @@ -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(); }); }) diff --git a/packages/server/src/api/routes/tests/view.spec.js b/packages/server/src/api/routes/tests/view.spec.js index e0dc089c73..5e1811bf72 100644 --- a/packages/server/src/api/routes/tests/view.spec.js +++ b/packages/server/src/api/routes/tests/view.spec.js @@ -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 => { diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index abc72cad72..4705f2b45b 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -291,6 +291,13 @@ } } }, + "datamap": { + "description": "shiny chart", + "data": true, + "props": { + "model": "models" + } + }, "datachart": { "description": "shiny chart", "data": true, diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 5243d546b2..f42f4a73ad 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -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" } diff --git a/packages/standard-components/src/DataMap.svelte b/packages/standard-components/src/DataMap.svelte new file mode 100644 index 0000000000..be173c805e --- /dev/null +++ b/packages/standard-components/src/DataMap.svelte @@ -0,0 +1,31 @@ + + + \ No newline at end of file diff --git a/packages/standard-components/src/index.js b/packages/standard-components/src/index.js index bb6fd739e6..a201c1afae 100644 --- a/packages/standard-components/src/index.js +++ b/packages/standard-components/src/index.js @@ -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"