@genesislcap/foundation-workspace 14.406.0-workspaces.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-extractor.json +5 -0
- package/dist/dts/index.d.ts +4 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/tsdoc-metadata.json +11 -0
- package/dist/dts/workspace/filter-registry.d.ts +34 -0
- package/dist/dts/workspace/filter-registry.d.ts.map +1 -0
- package/dist/dts/workspace/grid-register/grid-register.d.ts +23 -0
- package/dist/dts/workspace/grid-register/grid-register.d.ts.map +1 -0
- package/dist/dts/workspace/grid-register/grid-register.template.d.ts +4 -0
- package/dist/dts/workspace/grid-register/grid-register.template.d.ts.map +1 -0
- package/dist/dts/workspace/grid-register/index.d.ts +2 -0
- package/dist/dts/workspace/grid-register/index.d.ts.map +1 -0
- package/dist/dts/workspace/grid-registry.d.ts +47 -0
- package/dist/dts/workspace/grid-registry.d.ts.map +1 -0
- package/dist/dts/workspace/index.d.ts +9 -0
- package/dist/dts/workspace/index.d.ts.map +1 -0
- package/dist/dts/workspace/layout-registry.d.ts +27 -0
- package/dist/dts/workspace/layout-registry.d.ts.map +1 -0
- package/dist/dts/workspace/layout-wrapper/index.d.ts +2 -0
- package/dist/dts/workspace/layout-wrapper/index.d.ts.map +1 -0
- package/dist/dts/workspace/layout-wrapper/layout-wrapper.d.ts +14 -0
- package/dist/dts/workspace/layout-wrapper/layout-wrapper.d.ts.map +1 -0
- package/dist/dts/workspace/layout-wrapper/layout-wrapper.template.d.ts +4 -0
- package/dist/dts/workspace/layout-wrapper/layout-wrapper.template.d.ts.map +1 -0
- package/dist/dts/workspace/workspace-state.d.ts +45 -0
- package/dist/dts/workspace/workspace-state.d.ts.map +1 -0
- package/dist/dts/workspace/workspace-state.types.d.ts +26 -0
- package/dist/dts/workspace/workspace-state.types.d.ts.map +1 -0
- package/dist/dts/workspace/workspace.types.d.ts +25 -0
- package/dist/dts/workspace/workspace.types.d.ts.map +1 -0
- package/dist/dts/workspace-components.d.ts +22 -0
- package/dist/dts/workspace-components.d.ts.map +1 -0
- package/dist/dts/workspace-manager/index.d.ts +2 -0
- package/dist/dts/workspace-manager/index.d.ts.map +1 -0
- package/dist/dts/workspace-manager/workspace-manager.d.ts +70 -0
- package/dist/dts/workspace-manager/workspace-manager.d.ts.map +1 -0
- package/dist/dts/workspace-manager/workspace-manager.styles.d.ts +2 -0
- package/dist/dts/workspace-manager/workspace-manager.styles.d.ts.map +1 -0
- package/dist/dts/workspace-manager/workspace-manager.template.d.ts +4 -0
- package/dist/dts/workspace-manager/workspace-manager.template.d.ts.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/workspace/filter-registry.js +47 -0
- package/dist/esm/workspace/grid-register/grid-register.js +136 -0
- package/dist/esm/workspace/grid-register/grid-register.template.js +4 -0
- package/dist/esm/workspace/grid-register/index.js +1 -0
- package/dist/esm/workspace/grid-registry.js +109 -0
- package/dist/esm/workspace/index.js +8 -0
- package/dist/esm/workspace/layout-registry.js +45 -0
- package/dist/esm/workspace/layout-wrapper/index.js +1 -0
- package/dist/esm/workspace/layout-wrapper/layout-wrapper.js +64 -0
- package/dist/esm/workspace/layout-wrapper/layout-wrapper.template.js +4 -0
- package/dist/esm/workspace/workspace-state.js +193 -0
- package/dist/esm/workspace/workspace-state.types.js +1 -0
- package/dist/esm/workspace/workspace.types.js +1 -0
- package/dist/esm/workspace-components.js +43 -0
- package/dist/esm/workspace-manager/index.js +1 -0
- package/dist/esm/workspace-manager/workspace-manager.js +436 -0
- package/dist/esm/workspace-manager/workspace-manager.styles.js +138 -0
- package/dist/esm/workspace-manager/workspace-manager.template.js +259 -0
- package/dist/foundation-workspace.api.json +3614 -0
- package/dist/foundation-workspace.d.ts +343 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/docs/.gitkeep +1 -0
- package/docs/api/foundation-workspace.defaultfilterregistry.md +17 -0
- package/docs/api/foundation-workspace.defaultgridregistry.md +17 -0
- package/docs/api/foundation-workspace.defaultlayoutregistry.md +18 -0
- package/docs/api/foundation-workspace.defaultworkspacestate._constructor_.md +65 -0
- package/docs/api/foundation-workspace.defaultworkspacestate.auth.md +14 -0
- package/docs/api/foundation-workspace.defaultworkspacestate.kvstorage.md +14 -0
- package/docs/api/foundation-workspace.defaultworkspacestate.md +115 -0
- package/docs/api/foundation-workspace.filterregistration.filterkey.md +14 -0
- package/docs/api/foundation-workspace.filterregistration.getfiltervalue.md +14 -0
- package/docs/api/foundation-workspace.filterregistration.md +98 -0
- package/docs/api/foundation-workspace.filterregistration.setfiltervalue.md +14 -0
- package/docs/api/foundation-workspace.filterregistry.applyfiltersvalues.md +53 -0
- package/docs/api/foundation-workspace.filterregistry.getallfiltersvalues.md +18 -0
- package/docs/api/foundation-workspace.filterregistry.md +16 -0
- package/docs/api/foundation-workspace.filterregistry.registerfilter.md +81 -0
- package/docs/api/foundation-workspace.filterregistry.unregisterfilter.md +53 -0
- package/docs/api/foundation-workspace.gridregister.gridkey.md +14 -0
- package/docs/api/foundation-workspace.gridregister.gridregistry.md +14 -0
- package/docs/api/foundation-workspace.gridregister.md +100 -0
- package/docs/api/foundation-workspace.gridregister.workspacestate.md +14 -0
- package/docs/api/foundation-workspace.gridregistration.columnapi.md +14 -0
- package/docs/api/foundation-workspace.gridregistration.gridapi.md +14 -0
- package/docs/api/foundation-workspace.gridregistration.gridkey.md +14 -0
- package/docs/api/foundation-workspace.gridregistration.md +98 -0
- package/docs/api/foundation-workspace.gridregistry.applyallgridssettings.md +53 -0
- package/docs/api/foundation-workspace.gridregistry.applygridsettings.md +72 -0
- package/docs/api/foundation-workspace.gridregistry.getallgridssettings.md +18 -0
- package/docs/api/foundation-workspace.gridregistry.getgrid.md +53 -0
- package/docs/api/foundation-workspace.gridregistry.md +16 -0
- package/docs/api/foundation-workspace.gridregistry.registergrid.md +81 -0
- package/docs/api/foundation-workspace.gridregistry.unregistergrid.md +53 -0
- package/docs/api/foundation-workspace.layoutregistry.applysavedlayouts.md +53 -0
- package/docs/api/foundation-workspace.layoutregistry.getlayoutsconfigs.md +18 -0
- package/docs/api/foundation-workspace.layoutregistry.md +16 -0
- package/docs/api/foundation-workspace.layoutregistry.registerlayout.md +67 -0
- package/docs/api/foundation-workspace.layoutregistry.unregisterlayout.md +53 -0
- package/docs/api/foundation-workspace.layoutwrapper.layoutkey.md +14 -0
- package/docs/api/foundation-workspace.layoutwrapper.layoutregistry.md +14 -0
- package/docs/api/foundation-workspace.layoutwrapper.md +81 -0
- package/docs/api/foundation-workspace.loadmode.md +16 -0
- package/docs/api/foundation-workspace.md +332 -0
- package/docs/api/foundation-workspace.savedfiltervalue.filterkey.md +14 -0
- package/docs/api/foundation-workspace.savedfiltervalue.md +79 -0
- package/docs/api/foundation-workspace.savedfiltervalue.value.md +14 -0
- package/docs/api/foundation-workspace.savedgridsettings.columnstate.md +14 -0
- package/docs/api/foundation-workspace.savedgridsettings.gridkey.md +14 -0
- package/docs/api/foundation-workspace.savedgridsettings.md +99 -0
- package/docs/api/foundation-workspace.savedgridsettings.savedat.md +14 -0
- package/docs/api/foundation-workspace.savedlayout.layout.md +14 -0
- package/docs/api/foundation-workspace.savedlayout.layoutkey.md +14 -0
- package/docs/api/foundation-workspace.savedlayout.md +79 -0
- package/docs/api/foundation-workspace.savedworkspace.description.md +14 -0
- package/docs/api/foundation-workspace.savedworkspace.filters.md +14 -0
- package/docs/api/foundation-workspace.savedworkspace.grids.md +14 -0
- package/docs/api/foundation-workspace.savedworkspace.layouts.md +14 -0
- package/docs/api/foundation-workspace.savedworkspace.md +174 -0
- package/docs/api/foundation-workspace.savedworkspace.name.md +14 -0
- package/docs/api/foundation-workspace.savedworkspace.savedat.md +14 -0
- package/docs/api/foundation-workspace.savedworkspace.username.md +14 -0
- package/docs/api/foundation-workspace.sharedworkspace.createdon.md +14 -0
- package/docs/api/foundation-workspace.sharedworkspace.data.md +14 -0
- package/docs/api/foundation-workspace.sharedworkspace.description.md +14 -0
- package/docs/api/foundation-workspace.sharedworkspace.id.md +14 -0
- package/docs/api/foundation-workspace.sharedworkspace.md +174 -0
- package/docs/api/foundation-workspace.sharedworkspace.modifiedon.md +14 -0
- package/docs/api/foundation-workspace.sharedworkspace.name.md +14 -0
- package/docs/api/foundation-workspace.sharedworkspace.username.md +14 -0
- package/docs/api/foundation-workspace.workspacecomponents.md +29 -0
- package/docs/api/foundation-workspace.workspacemanager.applyingworkspace.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.auth.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.canshareworkspace.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.connect.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.dialogboundary.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.filterregistry.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.gridregistry.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.isloading.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.layoutregistry.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.loadmodal.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.loadmode.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.md +442 -0
- package/docs/api/foundation-workspace.workspacemanager.savedworkspaces.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.savemodal.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.savemode.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.selectedworkspacetooverwrite.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.sharedworkspacedialogboundary.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.sharedworkspaces.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.workspacedescription.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.workspacename.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.workspacestate.md +14 -0
- package/docs/api/foundation-workspace.workspacemanager.workspacetoshare.md +14 -0
- package/docs/api/foundation-workspace.workspacestate.deleteworkspace.md +53 -0
- package/docs/api/foundation-workspace.workspacestate.getcurrentworkspace.md +18 -0
- package/docs/api/foundation-workspace.workspacestate.getsavedworkspaces.md +18 -0
- package/docs/api/foundation-workspace.workspacestate.loadworkspace.md +53 -0
- package/docs/api/foundation-workspace.workspacestate.md +16 -0
- package/docs/api/foundation-workspace.workspacestate.saveworkspace.md +111 -0
- package/docs/api/foundation-workspace.workspacestate.setcurrentworkspace.md +53 -0
- package/docs/api/index.md +30 -0
- package/docs/api-report.md.api.md +372 -0
- package/license.txt +46 -0
- package/package.json +69 -0
- package/src/index.ts +3 -0
- package/src/workspace/filter-registry.ts +80 -0
- package/src/workspace/grid-register/grid-register.template.ts +7 -0
- package/src/workspace/grid-register/grid-register.ts +142 -0
- package/src/workspace/grid-register/index.ts +1 -0
- package/src/workspace/grid-registry.ts +157 -0
- package/src/workspace/index.ts +8 -0
- package/src/workspace/layout-registry.ts +58 -0
- package/src/workspace/layout-wrapper/index.ts +1 -0
- package/src/workspace/layout-wrapper/layout-wrapper.template.ts +7 -0
- package/src/workspace/layout-wrapper/layout-wrapper.ts +66 -0
- package/src/workspace/workspace-state.ts +234 -0
- package/src/workspace/workspace-state.types.ts +27 -0
- package/src/workspace/workspace.types.ts +26 -0
- package/src/workspace-components.ts +51 -0
- package/src/workspace-manager/index.ts +1 -0
- package/src/workspace-manager/workspace-manager.styles.ts +139 -0
- package/src/workspace-manager/workspace-manager.template.ts +352 -0
- package/src/workspace-manager/workspace-manager.ts +420 -0
- package/temp/api-report.md.api.md +372 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { __awaiter, __decorate } from "tslib";
|
|
2
|
+
import { Auth, Connect } from '@genesislcap/foundation-comms';
|
|
3
|
+
import { showNotificationDialog, showNotificationToast, } from '@genesislcap/foundation-notifications';
|
|
4
|
+
import { customElement, observable } from '@microsoft/fast-element';
|
|
5
|
+
import { FoundationElement } from '@microsoft/fast-foundation';
|
|
6
|
+
import { LayoutRegistry, GridRegistry, FilterRegistry, WorkspaceState, } from '../workspace';
|
|
7
|
+
import { WorkspaceManagerStyles as styles } from './workspace-manager.styles';
|
|
8
|
+
import { WORKSPACE_DESCRIPTION_MAX, WorkspaceManagerTemplate as template, } from './workspace-manager.template';
|
|
9
|
+
/**
|
|
10
|
+
* Workspace persistence UI (save/load + share/delete shared workspaces).
|
|
11
|
+
* @alpha
|
|
12
|
+
*/
|
|
13
|
+
let WorkspaceManager = class WorkspaceManager extends FoundationElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.workspaceName = '';
|
|
17
|
+
this.workspaceDescription = '';
|
|
18
|
+
this.savedWorkspaces = [];
|
|
19
|
+
this.sharedWorkspaces = [];
|
|
20
|
+
this.isLoading = false;
|
|
21
|
+
this.applyingWorkspace = false;
|
|
22
|
+
this.loadMode = 'MY';
|
|
23
|
+
this.saveMode = 'create';
|
|
24
|
+
this.selectedWorkspaceToOverwrite = '';
|
|
25
|
+
this.workspaceToShare = '';
|
|
26
|
+
}
|
|
27
|
+
sanitizeDescription(input) {
|
|
28
|
+
const cleaned = (input !== null && input !== void 0 ? input : '')
|
|
29
|
+
// allow only letters, numbers and whitespace
|
|
30
|
+
.replace(/[^a-zA-Z0-9\s]/g, '')
|
|
31
|
+
// normalise whitespace
|
|
32
|
+
.replace(/\s+/g, ' ')
|
|
33
|
+
.trim();
|
|
34
|
+
return cleaned.slice(0, WORKSPACE_DESCRIPTION_MAX);
|
|
35
|
+
}
|
|
36
|
+
updateWorkspaceDescription(raw) {
|
|
37
|
+
this.workspaceDescription = this.sanitizeDescription(raw);
|
|
38
|
+
}
|
|
39
|
+
setDescriptionFromSelectedWorkspace() {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const name = (_a = this.selectedWorkspaceToOverwrite) === null || _a === void 0 ? void 0 : _a.trim();
|
|
42
|
+
if (!name) {
|
|
43
|
+
this.workspaceDescription = '';
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const existing = this.savedWorkspaces.find((w) => w.name === name);
|
|
47
|
+
this.workspaceDescription = this.sanitizeDescription((_b = existing === null || existing === void 0 ? void 0 : existing.description) !== null && _b !== void 0 ? _b : '');
|
|
48
|
+
}
|
|
49
|
+
connectedCallback() {
|
|
50
|
+
const _super = Object.create(null, {
|
|
51
|
+
connectedCallback: { get: () => super.connectedCallback }
|
|
52
|
+
});
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
_super.connectedCallback.call(this);
|
|
55
|
+
yield this.refreshSavedWorkspaces();
|
|
56
|
+
yield this.refreshSharedWorkspaces();
|
|
57
|
+
this.canShareWorkspace = this.auth.currentUser.hasPermission('SHARE_WORKSPACE');
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
refreshSavedWorkspaces() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
this.isLoading = true;
|
|
63
|
+
try {
|
|
64
|
+
this.savedWorkspaces = yield this.workspaceState.getSavedWorkspaces();
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error('Failed to load saved workspaces', error);
|
|
68
|
+
this.savedWorkspaces = [];
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
this.isLoading = false;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
refreshSharedWorkspaces() {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
try {
|
|
78
|
+
const response = yield this.connect.request('REQ_SHARED_WORKSPACES');
|
|
79
|
+
const rows = (response === null || response === void 0 ? void 0 : response.REPLY) || [];
|
|
80
|
+
this.sharedWorkspaces = rows.map((row) => {
|
|
81
|
+
var _a;
|
|
82
|
+
return ({
|
|
83
|
+
id: row.SHARED_WORKSPACE_ID,
|
|
84
|
+
name: row.WORKSPACE_NAME,
|
|
85
|
+
userName: row.USER_NAME,
|
|
86
|
+
description: (_a = row.DESCRIPTION) !== null && _a !== void 0 ? _a : undefined,
|
|
87
|
+
createdOn: row.CREATED_ON,
|
|
88
|
+
modifiedOn: row.MODIFIED_ON,
|
|
89
|
+
data: row.WORKSPACE_DATA,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
this.notifyError(`REQ_SHARED_WORKSPACES ${JSON.stringify(error)}`);
|
|
95
|
+
console.error('Failed to load shared workspaces', error);
|
|
96
|
+
this.sharedWorkspaces = [];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
notifyError(body = 'Error') {
|
|
101
|
+
showNotificationToast({ title: 'Error', body, iconName: 'bell', toast: { type: 'error', autoClose: false } }, 'rapid');
|
|
102
|
+
}
|
|
103
|
+
saveWorkspace() {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const workspaceName = this.saveMode === 'overwrite'
|
|
106
|
+
? this.selectedWorkspaceToOverwrite.trim()
|
|
107
|
+
: this.workspaceName.trim();
|
|
108
|
+
if (!workspaceName) {
|
|
109
|
+
console.error('workspace-manager: workspace name is required');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const layoutConfigs = this.layoutRegistry.getLayoutsConfigs();
|
|
114
|
+
const gridSettings = this.gridRegistry.getAllGridsSettings();
|
|
115
|
+
const filterValues = this.filterRegistry.getAllFiltersValues();
|
|
116
|
+
yield this.workspaceState.saveWorkspace(workspaceName, layoutConfigs, gridSettings, filterValues, this.workspaceDescription.trim() || undefined);
|
|
117
|
+
this.workspaceName = '';
|
|
118
|
+
this.workspaceDescription = '';
|
|
119
|
+
this.closeSaveDialog();
|
|
120
|
+
yield this.refreshSavedWorkspaces();
|
|
121
|
+
console.log('Workspace saved successfully');
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error('Failed to save workspace', error);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
applyWorkspace(workspace) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
if (workspace.filters && workspace.filters.length > 0) {
|
|
131
|
+
this.filterRegistry.applyFiltersValues(workspace.filters);
|
|
132
|
+
}
|
|
133
|
+
if (workspace.layouts && workspace.layouts.length > 0) {
|
|
134
|
+
yield this.layoutRegistry.applySavedLayouts(workspace.layouts);
|
|
135
|
+
}
|
|
136
|
+
if (workspace.grids && workspace.grids.length > 0) {
|
|
137
|
+
yield this.gridRegistry.applyAllGridsSettings(workspace.grids);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
loadWorkspace(workspaceName) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
try {
|
|
144
|
+
this.applyingWorkspace = true;
|
|
145
|
+
const workspace = yield this.workspaceState.loadWorkspace(workspaceName);
|
|
146
|
+
if (workspace) {
|
|
147
|
+
yield this.applyWorkspace(workspace);
|
|
148
|
+
this.closeLoadDialog();
|
|
149
|
+
console.log('Workspace loaded successfully');
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
console.warn('Workspace not found:', workspaceName);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
this.applyingWorkspace = false;
|
|
157
|
+
console.error('Failed to load workspace', error);
|
|
158
|
+
}
|
|
159
|
+
this.applyingWorkspace = false;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
requestSharedWorkspace(SHARED_WORKSPACE_ID) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
try {
|
|
165
|
+
const response = yield this.connect.request('REQ_LOAD_SHARED_WORKSPACE', {
|
|
166
|
+
REQUEST: { SHARED_WORKSPACE_ID },
|
|
167
|
+
});
|
|
168
|
+
return response.REPLY || [];
|
|
169
|
+
}
|
|
170
|
+
catch (e) {
|
|
171
|
+
console.error(e);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
loadSharedWorkspace(shared) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
+
try {
|
|
178
|
+
this.applyingWorkspace = true;
|
|
179
|
+
const sharedData = yield this.requestSharedWorkspace(shared.id);
|
|
180
|
+
if (!(sharedData === null || sharedData === void 0 ? void 0 : sharedData.length)) {
|
|
181
|
+
console.warn('workspace has no data');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const dataJoined = sharedData.map((d) => d.WORKSPACE_DATA).join('');
|
|
185
|
+
const workspace = JSON.parse(dataJoined);
|
|
186
|
+
yield this.applyWorkspace(workspace);
|
|
187
|
+
this.closeLoadDialog();
|
|
188
|
+
console.log('Shared workspace loaded successfully');
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
console.error('Failed to load shared workspace', error);
|
|
192
|
+
}
|
|
193
|
+
this.applyingWorkspace = false;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
deleteWorkspace(workspaceName) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
try {
|
|
199
|
+
yield this.workspaceState.deleteWorkspace(workspaceName);
|
|
200
|
+
yield this.refreshSavedWorkspaces();
|
|
201
|
+
console.log('Workspace deleted successfully');
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
console.error('Failed to delete workspace', error);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
showDeleteConfirmation(title, body, actionFunction, dialogBoundary) {
|
|
209
|
+
showNotificationDialog({
|
|
210
|
+
title,
|
|
211
|
+
body,
|
|
212
|
+
dialog: {
|
|
213
|
+
confirmingActions: [{ label: 'Delete', action: actionFunction }],
|
|
214
|
+
dismissingAction: { label: 'Cancel' },
|
|
215
|
+
},
|
|
216
|
+
}, 'rapid', dialogBoundary);
|
|
217
|
+
}
|
|
218
|
+
confirmDeleteWorkspace(workspaceName) {
|
|
219
|
+
const trimmedName = workspaceName === null || workspaceName === void 0 ? void 0 : workspaceName.trim();
|
|
220
|
+
if (!trimmedName)
|
|
221
|
+
return;
|
|
222
|
+
this.showDeleteConfirmation('Delete workspace', `Are you sure you want to delete the workspace "${trimmedName}"? This action cannot be undone.`, () => this.deleteWorkspace(trimmedName), this.dialogBoundary);
|
|
223
|
+
}
|
|
224
|
+
modifySharedWorkspace(sharedWorkspace) {
|
|
225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
var _a, _b;
|
|
227
|
+
try {
|
|
228
|
+
const layouts = this.layoutRegistry.getLayoutsConfigs();
|
|
229
|
+
const grids = this.gridRegistry.getAllGridsSettings();
|
|
230
|
+
const filters = this.filterRegistry.getAllFiltersValues();
|
|
231
|
+
const baseWorkspace = yield this.workspaceState.loadWorkspace(sharedWorkspace.name);
|
|
232
|
+
const description = this.sanitizeDescription((_b = (_a = baseWorkspace === null || baseWorkspace === void 0 ? void 0 : baseWorkspace.description) !== null && _a !== void 0 ? _a : sharedWorkspace.description) !== null && _b !== void 0 ? _b : '') ||
|
|
233
|
+
undefined;
|
|
234
|
+
const workspace = {
|
|
235
|
+
name: sharedWorkspace.name,
|
|
236
|
+
username: sharedWorkspace.userName,
|
|
237
|
+
description,
|
|
238
|
+
layouts,
|
|
239
|
+
grids,
|
|
240
|
+
filters,
|
|
241
|
+
savedAt: new Date().toISOString(),
|
|
242
|
+
};
|
|
243
|
+
const response = yield this.connect.commitEvent('EVENT_SHARED_WORKSPACE_MODIFY', {
|
|
244
|
+
VALIDATE: false,
|
|
245
|
+
DETAILS: {
|
|
246
|
+
WORKSPACE_NAME: sharedWorkspace.name,
|
|
247
|
+
WORKSPACE_DATA: JSON.stringify(workspace),
|
|
248
|
+
WORKSPACE_DESCRIPTION: description !== null && description !== void 0 ? description : null,
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
if (response.MESSAGE_TYPE == 'EVENT_ACK') {
|
|
252
|
+
this.closeSaveDialog();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
catch (e) {
|
|
256
|
+
this.notifyError(`EVENT_SHARED_WORKSPACE_MODIFY ${JSON.stringify(e)}`);
|
|
257
|
+
console.error(e);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
deleteSharedWorkspace(sharedWorkspace) {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
+
try {
|
|
264
|
+
const response = yield this.connect.commitEvent('EVENT_SHARED_WORKSPACE_DELETE', {
|
|
265
|
+
VALIDATE: false,
|
|
266
|
+
DETAILS: { WORKSPACE_NAME: sharedWorkspace.name },
|
|
267
|
+
});
|
|
268
|
+
if (response.MESSAGE_TYPE == 'EVENT_ACK') {
|
|
269
|
+
this.closeSaveDialog();
|
|
270
|
+
yield this.refreshSharedWorkspaces();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
catch (e) {
|
|
274
|
+
this.notifyError(`EVENT_SHARED_WORKSPACE_DELETE ${JSON.stringify(e)}`);
|
|
275
|
+
console.error(e);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
confirmDeleteSharedWorkspace(sharedWorkspace) {
|
|
280
|
+
if (!(sharedWorkspace === null || sharedWorkspace === void 0 ? void 0 : sharedWorkspace.name))
|
|
281
|
+
return;
|
|
282
|
+
this.showDeleteConfirmation('Delete shared workspace', `Are you sure you want to delete the shared workspace "${sharedWorkspace.name}"? This action cannot be undone.`, () => this.deleteSharedWorkspace(sharedWorkspace), this.sharedWorkspaceDialogBoundary);
|
|
283
|
+
}
|
|
284
|
+
shareExistingWorkspace(workspaceName) {
|
|
285
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
286
|
+
var _a;
|
|
287
|
+
const name = workspaceName === null || workspaceName === void 0 ? void 0 : workspaceName.trim();
|
|
288
|
+
if (!name)
|
|
289
|
+
return;
|
|
290
|
+
try {
|
|
291
|
+
const workspace = yield this.workspaceState.loadWorkspace(name);
|
|
292
|
+
if (!workspace) {
|
|
293
|
+
console.warn('Workspace not found for sharing:', name);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const response = yield this.connect.commitEvent('EVENT_SHARED_WORKSPACE_INSERT', {
|
|
297
|
+
VALIDATE: false,
|
|
298
|
+
DETAILS: {
|
|
299
|
+
WORKSPACE_NAME: workspace.name,
|
|
300
|
+
WORKSPACE_DATA: JSON.stringify(workspace),
|
|
301
|
+
WORKSPACE_DESCRIPTION: (_a = workspace.description) !== null && _a !== void 0 ? _a : null,
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
if (response.MESSAGE_TYPE == 'EVENT_ACK') {
|
|
305
|
+
console.log('Workspace shared successfully');
|
|
306
|
+
this.closeSaveDialog();
|
|
307
|
+
yield this.refreshSharedWorkspaces();
|
|
308
|
+
}
|
|
309
|
+
else if (response.MESSAGE_TYPE == 'EVENT_NACK') {
|
|
310
|
+
console.warn('Failed to share workspace', response);
|
|
311
|
+
this.closeSaveDialog();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
console.error('Failed to share workspace', error);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
openSaveDialog() {
|
|
320
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
321
|
+
yield this.refreshSavedWorkspaces();
|
|
322
|
+
this.saveModal.show();
|
|
323
|
+
this.workspaceName = '';
|
|
324
|
+
this.workspaceDescription = '';
|
|
325
|
+
this.saveMode = 'create';
|
|
326
|
+
this.selectedWorkspaceToOverwrite = '';
|
|
327
|
+
this.workspaceToShare = '';
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
isWorkspaceExisting(workspaceName) {
|
|
331
|
+
return this.savedWorkspaces.some((p) => p.name.toLowerCase() === workspaceName.toLowerCase());
|
|
332
|
+
}
|
|
333
|
+
saveModeChanged(oldValue, newValue) {
|
|
334
|
+
if (newValue === 'create') {
|
|
335
|
+
this.selectedWorkspaceToOverwrite = '';
|
|
336
|
+
this.workspaceDescription = '';
|
|
337
|
+
}
|
|
338
|
+
else if (newValue === 'overwrite') {
|
|
339
|
+
this.workspaceName = '';
|
|
340
|
+
this.setDescriptionFromSelectedWorkspace();
|
|
341
|
+
}
|
|
342
|
+
else if (newValue === 'shared') {
|
|
343
|
+
this.workspaceName = '';
|
|
344
|
+
this.selectedWorkspaceToOverwrite = '';
|
|
345
|
+
this.workspaceDescription = '';
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
selectedWorkspaceToOverwriteChanged(oldValue, newValue) {
|
|
349
|
+
if (this.saveMode === 'overwrite') {
|
|
350
|
+
this.setDescriptionFromSelectedWorkspace();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
openLoadDialog() {
|
|
354
|
+
this.refreshSharedWorkspaces();
|
|
355
|
+
this.loadModal.show();
|
|
356
|
+
}
|
|
357
|
+
closeSaveDialog() {
|
|
358
|
+
this.saveModal.close();
|
|
359
|
+
this.workspaceName = '';
|
|
360
|
+
this.workspaceDescription = '';
|
|
361
|
+
}
|
|
362
|
+
closeLoadDialog() {
|
|
363
|
+
this.loadModal.close();
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
__decorate([
|
|
367
|
+
observable
|
|
368
|
+
], WorkspaceManager.prototype, "workspaceName", void 0);
|
|
369
|
+
__decorate([
|
|
370
|
+
observable
|
|
371
|
+
], WorkspaceManager.prototype, "workspaceDescription", void 0);
|
|
372
|
+
__decorate([
|
|
373
|
+
observable
|
|
374
|
+
], WorkspaceManager.prototype, "savedWorkspaces", void 0);
|
|
375
|
+
__decorate([
|
|
376
|
+
observable
|
|
377
|
+
], WorkspaceManager.prototype, "sharedWorkspaces", void 0);
|
|
378
|
+
__decorate([
|
|
379
|
+
observable
|
|
380
|
+
], WorkspaceManager.prototype, "isLoading", void 0);
|
|
381
|
+
__decorate([
|
|
382
|
+
observable
|
|
383
|
+
], WorkspaceManager.prototype, "applyingWorkspace", void 0);
|
|
384
|
+
__decorate([
|
|
385
|
+
observable
|
|
386
|
+
], WorkspaceManager.prototype, "loadMode", void 0);
|
|
387
|
+
__decorate([
|
|
388
|
+
observable
|
|
389
|
+
], WorkspaceManager.prototype, "saveModal", void 0);
|
|
390
|
+
__decorate([
|
|
391
|
+
observable
|
|
392
|
+
], WorkspaceManager.prototype, "loadModal", void 0);
|
|
393
|
+
__decorate([
|
|
394
|
+
observable
|
|
395
|
+
], WorkspaceManager.prototype, "saveMode", void 0);
|
|
396
|
+
__decorate([
|
|
397
|
+
observable
|
|
398
|
+
], WorkspaceManager.prototype, "selectedWorkspaceToOverwrite", void 0);
|
|
399
|
+
__decorate([
|
|
400
|
+
observable
|
|
401
|
+
], WorkspaceManager.prototype, "workspaceToShare", void 0);
|
|
402
|
+
__decorate([
|
|
403
|
+
observable
|
|
404
|
+
], WorkspaceManager.prototype, "dialogBoundary", void 0);
|
|
405
|
+
__decorate([
|
|
406
|
+
observable
|
|
407
|
+
], WorkspaceManager.prototype, "sharedWorkspaceDialogBoundary", void 0);
|
|
408
|
+
__decorate([
|
|
409
|
+
LayoutRegistry
|
|
410
|
+
], WorkspaceManager.prototype, "layoutRegistry", void 0);
|
|
411
|
+
__decorate([
|
|
412
|
+
GridRegistry
|
|
413
|
+
], WorkspaceManager.prototype, "gridRegistry", void 0);
|
|
414
|
+
__decorate([
|
|
415
|
+
FilterRegistry
|
|
416
|
+
], WorkspaceManager.prototype, "filterRegistry", void 0);
|
|
417
|
+
__decorate([
|
|
418
|
+
WorkspaceState
|
|
419
|
+
], WorkspaceManager.prototype, "workspaceState", void 0);
|
|
420
|
+
__decorate([
|
|
421
|
+
Connect
|
|
422
|
+
], WorkspaceManager.prototype, "connect", void 0);
|
|
423
|
+
__decorate([
|
|
424
|
+
Auth
|
|
425
|
+
], WorkspaceManager.prototype, "auth", void 0);
|
|
426
|
+
__decorate([
|
|
427
|
+
observable
|
|
428
|
+
], WorkspaceManager.prototype, "canShareWorkspace", void 0);
|
|
429
|
+
WorkspaceManager = __decorate([
|
|
430
|
+
customElement({
|
|
431
|
+
name: 'workspace-manager',
|
|
432
|
+
template,
|
|
433
|
+
styles,
|
|
434
|
+
})
|
|
435
|
+
], WorkspaceManager);
|
|
436
|
+
export { WorkspaceManager };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { css } from '@microsoft/fast-element';
|
|
2
|
+
export const WorkspaceManagerStyles = css `
|
|
3
|
+
.workspace-manager {
|
|
4
|
+
display: flex;
|
|
5
|
+
gap: 10px;
|
|
6
|
+
align-items: center;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.dialog-content {
|
|
10
|
+
padding: 16px;
|
|
11
|
+
min-width: 400px;
|
|
12
|
+
max-width: 400px;
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
max-height: 90vh;
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.button-group {
|
|
20
|
+
display: flex;
|
|
21
|
+
gap: 8px;
|
|
22
|
+
justify-content: flex-end;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.workspace-list {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
gap: 12px;
|
|
29
|
+
max-height: 400px;
|
|
30
|
+
overflow-y: auto;
|
|
31
|
+
margin: 10px 0;
|
|
32
|
+
align-items: unset;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
rapid-label {
|
|
36
|
+
margin-bottom: 10px;
|
|
37
|
+
display: block;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.empty-state {
|
|
41
|
+
padding: 24px;
|
|
42
|
+
text-align: center;
|
|
43
|
+
color: var(--neutral-foreground-hint);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.save-mode-selector {
|
|
47
|
+
margin-bottom: 16px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.warning-message {
|
|
51
|
+
margin: 12px 0;
|
|
52
|
+
padding: 12px;
|
|
53
|
+
border: 1px solid var(--warning-color);
|
|
54
|
+
border-radius: 4px;
|
|
55
|
+
font-size: 14px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.workspace-item {
|
|
59
|
+
padding: 12px;
|
|
60
|
+
border: 1px solid var(--neutral-stroke-rest);
|
|
61
|
+
border-radius: 4px;
|
|
62
|
+
background: var(--neutral-fill-rest);
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.workspace-item:hover {
|
|
69
|
+
background: var(--neutral-fill-hover);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.workspace-item::part(control) {
|
|
73
|
+
margin-top: 2px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.workspace-info {
|
|
77
|
+
flex: 1;
|
|
78
|
+
margin-left: 8px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.workspace-name {
|
|
82
|
+
font-weight: 600;
|
|
83
|
+
margin-bottom: 4px;
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
gap: 8px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.workspace-date {
|
|
90
|
+
font-size: 12px;
|
|
91
|
+
color: var(--neutral-foreground-hint);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.workspace-description {
|
|
95
|
+
font-size: 12px;
|
|
96
|
+
color: var(--neutral-foreground-hint);
|
|
97
|
+
margin-top: 4px;
|
|
98
|
+
white-space: pre-wrap;
|
|
99
|
+
word-break: break-word;
|
|
100
|
+
line-height: 1.4;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.workspace-description-input {
|
|
104
|
+
width: 100%;
|
|
105
|
+
min-height: 60px;
|
|
106
|
+
padding: 8px 12px;
|
|
107
|
+
margin-bottom: 16px;
|
|
108
|
+
font-family: inherit;
|
|
109
|
+
font-size: 14px;
|
|
110
|
+
border: 1px solid var(--neutral-stroke-rest);
|
|
111
|
+
border-radius: 4px;
|
|
112
|
+
background: var(--neutral-fill-rest);
|
|
113
|
+
color: var(--neutral-foreground-rest);
|
|
114
|
+
resize: vertical;
|
|
115
|
+
box-sizing: border-box;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.workspace-description-input::placeholder {
|
|
119
|
+
color: var(--neutral-foreground-hint);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.workspace-description-input:focus {
|
|
123
|
+
outline: none;
|
|
124
|
+
border-color: var(--accent-fill-rest);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.loading-container {
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
align-items: center;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
padding: 24px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.save-field {
|
|
136
|
+
margin-bottom: 20px;
|
|
137
|
+
}
|
|
138
|
+
`;
|