Skip to content

Commit 06a15cd

Browse files
committed
Updated fdc3, improved resizing
1 parent 0f60861 commit 06a15cd

9 files changed

+84
-54
lines changed

package-lock.json

+42-42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"vite": "^5.0.2"
1919
},
2020
"dependencies": {
21-
"@kite9/fdc3": "2.2.0-beta.19",
22-
"@kite9/fdc3-web-impl": "2.2.0-beta.19",
21+
"@kite9/fdc3": "2.2.0-beta.23",
22+
"@kite9/fdc3-web-impl": "2.2.0-beta.23",
2323
"@types/react-dom": "^18.2.25",
2424
"@types/uuid": "^9.0.8",
2525
"@types/ws": "^8.5.10",

src/client/grid/gridstate.ts

+26-4
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,26 @@ export class GridsStateImpl implements GridsState {
8383
})
8484
}
8585

86+
setResizing(resizing: boolean, element: HTMLElement) {
87+
if (resizing) {
88+
element.parentElement?.classList.add(styles.resizing)
89+
} else {
90+
element.parentElement?.classList.remove(styles.resizing)
91+
}
92+
}
93+
8694
createGridstack(e: Element): GridStack {
8795
//const gridId = gridIdforTab(tabId)
8896
const grid = GridStack.init(
8997
{
9098
removable: "#" + TRASH_DROP,
9199
acceptWidgets: true,
92100
margin: '1',
93-
cellHeight: '70px'
101+
cellHeight: '70px',
102+
resizable: {
103+
handles: 'e, se, s, sw, w'
104+
105+
}
94106
},
95107
e as GridStackElement
96108
)
@@ -106,11 +118,11 @@ export class GridsStateImpl implements GridsState {
106118
}
107119
}
108120

109-
element.classList.remove(styles.resizing)
121+
this.setResizing(false, element)
110122
})
111123

112124
grid.on("resizestart", (_event, element) => {
113-
element.classList.add(styles.resizing)
125+
this.setResizing(true, element)
114126
})
115127

116128
grid.on("removed", (event, items) => {
@@ -140,6 +152,12 @@ export class GridsStateImpl implements GridsState {
140152
this.cs.updatePanel(panel)
141153
}
142154
}
155+
156+
this.setResizing(false, element)
157+
})
158+
159+
grid.on("dragstart", (_event, element) => {
160+
this.setResizing(true, element)
143161
})
144162

145163
return grid
@@ -173,6 +191,11 @@ export class GridsStateImpl implements GridsState {
173191
}
174192

175193
createWidget(grid: GridStack, p: AppPanel, content: boolean): GridItemHTMLElement {
194+
// check the panel size
195+
if (p.x == -1 || p.y == -1) {
196+
this.findEmptyArea(p, grid)
197+
}
198+
176199
// add to the grid
177200
const opts: GridStackWidget = {
178201
h: p.h,
@@ -198,7 +221,6 @@ export class GridsStateImpl implements GridsState {
198221
const root = createRoot(div)
199222
const content = this.render(p, contentIdforTab(p.panelId))
200223
root.render(content)
201-
//ReactDOM.render(content, div)
202224
}
203225

204226
findChild(e: DocumentFragment | HTMLElement | Element, id: string): HTMLElement | null {

src/client/state/ServerState.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ServerStateImpl implements ServerState {
6060
this.socket?.emit(DA_HELLO, props)
6161

6262
this.socket?.on(SAIL_APP_OPEN, async (data: SailAppOpenArgs, callback) => {
63-
// (`SAIL_APP_OPEN: ${JSON.stringify(data)}`)
63+
console.log(`SAIL_APP_OPEN: ${JSON.stringify(data)}`)
6464
const instanceId = await getAppState().open(data.appDRecord)
6565
callback(instanceId)
6666
})

src/client/state/clientState.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ abstract class AbstractClientState implements ClientState {
144144
const url = (detail.details as any).url
145145

146146
const ap = {
147-
x: 1,
148-
y: 1,
149-
w: 3,
147+
x: -1,
148+
y: -1,
149+
w: 6,
150150
h: 4,
151151
title: detail.title,
152152
tabId: this.activeTabId,

src/server/da/SailFDC3Server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class SailFDC3Server extends DefaultFDC3Server {
1212
readonly serverContext: SailServerContext
1313

1414
constructor(sc: SailServerContext, helloArgs: DesktopAgentHelloArgs) {
15-
super(sc, sc.directory, helloArgs.channels)
15+
super(sc, sc.directory, helloArgs.channels, true, 60000, 20000)
1616
sc.directory.replace(helloArgs.directories)
1717
this.serverContext = sc
1818
}

src/server/da/SailServerContext.ts

+7
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ export class SailServerContext implements ServerContext<SailData> {
6767
this.instances.find(ca => (ca.instanceId == app.instanceId))!!.state = OPEN
6868
}
6969

70+
async setAppDisconnected(app: AppIdentifier): Promise<void> {
71+
const idx = this.instances.findIndex(ca => (ca.instanceId == app.instanceId))
72+
if (idx != -1) {
73+
this.instances.splice(idx, 1)
74+
}
75+
}
76+
7077
async getConnectedApps(): Promise<AppIdentifier[]> {
7178
return this.instances
7279
.filter(ca => ca.state == OPEN)

src/server/da/initSocketService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function initSocketService(httpServer: any, sessions: Map<string, SailFDC
111111

112112
socket.on(FDC3_APP_EVENT, function (data, from): void {
113113
// message from app to da
114-
console.log(JSON.stringify(data))
114+
console.log(JSON.stringify(data) + " from " + from)
115115

116116
if (fdc3ServerInstance != undefined) {
117117
try {

src/server/da/message-types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ export type SailAppOpenArgs = {
5858
*/
5959
export const FDC3_APP_EVENT = 'fdc3-app-event'
6060
export const FDC3_DA_EVENT = 'fdc3-da-event'
61+

0 commit comments

Comments
 (0)