Remove any naming of dataspaces
This commit is contained in:
parent
f9ab2a239f
commit
083836a87b
|
@ -10,7 +10,7 @@ export const createWebsocket = context => {
|
||||||
const host = location.hostname
|
const host = location.hostname
|
||||||
const port = location.port || (tls ? 443 : 80)
|
const port = location.port || (tls ? 443 : 80)
|
||||||
const socket = io(`${proto}//${host}:${port}`, {
|
const socket = io(`${proto}//${host}:${port}`, {
|
||||||
path: "/socket/dataspace",
|
path: "/socket/spreadsheet",
|
||||||
// Cap reconnection attempts to 3 (total of 15 seconds before giving up)
|
// Cap reconnection attempts to 3 (total of 15 seconds before giving up)
|
||||||
reconnectionAttempts: 3,
|
reconnectionAttempts: 3,
|
||||||
// Delay reconnection attempt by 5 seconds
|
// Delay reconnection attempt by 5 seconds
|
||||||
|
@ -20,12 +20,12 @@ export const createWebsocket = context => {
|
||||||
timeout: 4000,
|
timeout: 4000,
|
||||||
})
|
})
|
||||||
|
|
||||||
const connectToDataspace = tableId => {
|
const connectToTable = tableId => {
|
||||||
if (!socket.connected) {
|
if (!socket.connected) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Identify which dataspace we are editing
|
// Identify which table we are editing
|
||||||
socket.emit("select-dataspace", tableId, response => {
|
socket.emit("select-table", tableId, response => {
|
||||||
// handle initial connection info
|
// handle initial connection info
|
||||||
users.set(response.users)
|
users.set(response.users)
|
||||||
userId.set(response.id)
|
userId.set(response.id)
|
||||||
|
@ -34,7 +34,7 @@ export const createWebsocket = context => {
|
||||||
|
|
||||||
// Event handlers
|
// Event handlers
|
||||||
socket.on("connect", () => {
|
socket.on("connect", () => {
|
||||||
connectToDataspace(get(tableId))
|
connectToTable(get(tableId))
|
||||||
})
|
})
|
||||||
socket.on("row-update", data => {
|
socket.on("row-update", data => {
|
||||||
if (data.id) {
|
if (data.id) {
|
||||||
|
@ -52,7 +52,7 @@ export const createWebsocket = context => {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Change websocket connection when dataspace changes
|
// Change websocket connection when dataspace changes
|
||||||
tableId.subscribe(connectToDataspace)
|
tableId.subscribe(connectToTable)
|
||||||
|
|
||||||
// Notify selected cell changes
|
// Notify selected cell changes
|
||||||
focusedCellId.subscribe($focusedCellId => {
|
focusedCellId.subscribe($focusedCellId => {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { quotas } from "@budibase/pro"
|
||||||
import * as internal from "./internal"
|
import * as internal from "./internal"
|
||||||
import * as external from "./external"
|
import * as external from "./external"
|
||||||
import { isExternalTable } from "../../../integrations/utils"
|
import { isExternalTable } from "../../../integrations/utils"
|
||||||
import { dataspaceSocket } from "../../../websockets"
|
import { spreadsheetSocket } from "../../../websockets"
|
||||||
import { Ctx } from "@budibase/types"
|
import { Ctx } from "@budibase/types"
|
||||||
import * as utils from "./utils"
|
import * as utils from "./utils"
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ export async function patch(ctx: any): Promise<any> {
|
||||||
ctx.body = row
|
ctx.body = row
|
||||||
|
|
||||||
// Notify websocket change
|
// Notify websocket change
|
||||||
dataspaceSocket.emit("row-update", { id: row._id })
|
spreadsheetSocket.emit("row-update", { id: row._id })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
ctx.throw(400, err)
|
ctx.throw(400, err)
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ export const save = async (ctx: any) => {
|
||||||
ctx.body = row
|
ctx.body = row
|
||||||
|
|
||||||
// Notify websocket change
|
// Notify websocket change
|
||||||
dataspaceSocket.emit("row-update", { id: row._id })
|
spreadsheetSocket.emit("row-update", { id: row._id })
|
||||||
}
|
}
|
||||||
export async function fetchView(ctx: any) {
|
export async function fetchView(ctx: any) {
|
||||||
const tableId = getTableId(ctx)
|
const tableId = getTableId(ctx)
|
||||||
|
@ -115,7 +115,7 @@ export async function destroy(ctx: any) {
|
||||||
for (let row of rows) {
|
for (let row of rows) {
|
||||||
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, appId, row)
|
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, appId, row)
|
||||||
// Notify websocket change
|
// Notify websocket change
|
||||||
dataspaceSocket.emit("row-update", { id: row._id })
|
spreadsheetSocket.emit("row-update", { id: row._id })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let resp = await quotas.addQuery(() => pickApi(tableId).destroy(ctx), {
|
let resp = await quotas.addQuery(() => pickApi(tableId).destroy(ctx), {
|
||||||
|
@ -126,7 +126,7 @@ export async function destroy(ctx: any) {
|
||||||
row = resp.row
|
row = resp.row
|
||||||
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, appId, row)
|
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, appId, row)
|
||||||
// Notify websocket change
|
// Notify websocket change
|
||||||
dataspaceSocket.emit("row-update", { id: row._id })
|
spreadsheetSocket.emit("row-update", { id: row._id })
|
||||||
}
|
}
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
// for automations include the row that was deleted
|
// for automations include the row that was deleted
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import http from "http"
|
import http from "http"
|
||||||
import Koa from "koa"
|
import Koa from "koa"
|
||||||
import DataspaceSocket from "./dataspace"
|
import SpreadsheetSocket from "./spreadsheet"
|
||||||
import ClientAppSocket from "./client"
|
import ClientAppSocket from "./client"
|
||||||
|
|
||||||
let clientAppSocket: ClientAppSocket
|
let clientAppSocket: ClientAppSocket
|
||||||
let dataspaceSocket: DataspaceSocket
|
let spreadsheetSocket: SpreadsheetSocket
|
||||||
|
|
||||||
export const initialise = (app: Koa, server: http.Server) => {
|
export const initialise = (app: Koa, server: http.Server) => {
|
||||||
clientAppSocket = new ClientAppSocket(app, server)
|
clientAppSocket = new ClientAppSocket(app, server)
|
||||||
dataspaceSocket = new DataspaceSocket(app, server)
|
spreadsheetSocket = new SpreadsheetSocket(app, server)
|
||||||
}
|
}
|
||||||
|
|
||||||
export { clientAppSocket, dataspaceSocket }
|
export { clientAppSocket, spreadsheetSocket }
|
||||||
|
|
|
@ -4,19 +4,19 @@ import { permissions } from "@budibase/backend-core"
|
||||||
import http from "http"
|
import http from "http"
|
||||||
import Koa from "koa"
|
import Koa from "koa"
|
||||||
|
|
||||||
export default class DataspaceSocket extends Socket {
|
export default class SpreadsheetSocket extends Socket {
|
||||||
constructor(app: Koa, server: http.Server) {
|
constructor(app: Koa, server: http.Server) {
|
||||||
super(app, server, "/socket/dataspace", [authorized(permissions.BUILDER)])
|
super(app, server, "/socket/spreadsheet", [authorized(permissions.BUILDER)])
|
||||||
|
|
||||||
this.io.on("connection", socket => {
|
this.io.on("connection", socket => {
|
||||||
const user = socket.data.user
|
const user = socket.data.user
|
||||||
console.log(`Dataspace user connected: ${user?.id}`)
|
console.log(`Spreadsheet user connected: ${user?.id}`)
|
||||||
|
|
||||||
// Socket state
|
// Socket state
|
||||||
let currentRoom: string
|
let currentRoom: string
|
||||||
|
|
||||||
// Initial identification of connected dataspace
|
// Initial identification of connected spreadsheet
|
||||||
socket.on("select-dataspace", async (tableId, callback) => {
|
socket.on("select-table", async (tableId, callback) => {
|
||||||
// Leave current room
|
// Leave current room
|
||||||
if (currentRoom) {
|
if (currentRoom) {
|
||||||
socket.to(currentRoom).emit("user-disconnect", socket.data.user)
|
socket.to(currentRoom).emit("user-disconnect", socket.data.user)
|
Loading…
Reference in New Issue