Skip to content

Commit 861a002

Browse files
committed
Merge branch 'feature-rapid-integration' into feature-epic-3592-workspaces-projects-list
2 parents f5094f2 + 6af5766 commit 861a002

4 files changed

Lines changed: 133 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
44

5-
### ⚠️ Reminder: you must set the tag of the environment you wish to deploy in this repo, then run the deploy workflow in workspaces-stack to deploy to dev, stage or prod.
5+
### ⚠️ Reminder: you must set the tag of the environment you wish to deploy in this repo, then run the deploy workflow in workspaces-stack to deploy to dev, stage or prod.
6+
7+
### Note: The new workflow enabled creates the tags once the PR is merged to develop, stage or production
68

79
## Dev Setup
810

@@ -22,3 +24,5 @@ npm run dev
2224

2325
If you run `npm run dev` and nothing happens, double check your `.env` file.
2426
Undefined environment variables are not handled gracefully right now.
27+
28+

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pages/workspace/[id]/rapid.vue

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<template>
2+
<div class="pageContainer">
3+
<div ref="editorContainer" class="rapidEditorContainer"></div>
4+
<div class="sidebar">
5+
<p class="text-center mt-3">{{ sideBarText }}</p>
6+
<p> Add the action items here based on the selected workspace and editor.</p>
7+
</div>
8+
</div>
9+
10+
</template>
11+
<script setup lang="ts">
12+
import { rapidManager, rapid3Manager } from '~/services/index';
13+
/* We are using this only for osw */
14+
const route = useRoute();
15+
const workspaceId = route.params.id;
16+
const editor = route.query.editor;
17+
const editorContainer = ref(null);
18+
const sideBarText = ref('Loading editor...')
19+
20+
const oswManager = (editor === 'rapid3' && rapid3Manager) ? rapid3Manager : rapidManager
21+
const manager = oswManager
22+
23+
function onEditorLoaded() {
24+
editorContainer.value.appendChild(manager.containerNode);
25+
manager.init(workspaceId);
26+
27+
}
28+
29+
onMounted(() => {
30+
// If a different Rapid version is already loaded, hard-reload to swap.
31+
// Only one version can occupy the global Rapid namespace at a time.
32+
// if (datatype === 'osw') {
33+
const otherManager = manager === rapidManager ? rapid3Manager : rapidManager
34+
if (otherManager?.loaded.value) {
35+
window.location.reload()
36+
return
37+
}
38+
// }
39+
rapidManager.onStateChange((changes) => {
40+
console.log('Rapid state changed:', changes);
41+
sideBarText.value = `Rapid state changed: ${JSON.stringify(changes)}`;
42+
});
43+
44+
if (!manager.loaded.value) {
45+
watch(manager.loaded, (val) => {
46+
if (val) {
47+
onEditorLoaded();
48+
}
49+
});
50+
51+
manager.load();
52+
} else {
53+
editorContainer.value.appendChild(manager.containerNode);
54+
manager.switchWorkspace(workspaceId);
55+
}
56+
});
57+
</script>
58+
59+
<style>
60+
.pageContainer{
61+
align-items: center;
62+
display: flex;
63+
flex-direction: row;
64+
height: 100%;
65+
}
66+
.rapidEditorContainer {
67+
width: 80%;
68+
height: 100%;
69+
}
70+
.sidebar {
71+
width: 20%;
72+
height: 100%;
73+
}
74+
</style>

services/rapid.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export class RapidManager {
55
#baseUrl: string;
66
#osmUrl: string;
77
#tdeiAuth: TdeiAuthStore;
8+
#stateCallback: ((state: any) => void) | null = null;
9+
810

911
constructor(baseUrl: string, osmUrl: string, tdeiAuth: TdeiAuthStore) {
1012
this.#baseUrl = baseUrl;
@@ -16,6 +18,16 @@ export class RapidManager {
1618
this.rapidContext = null;
1719
}
1820

21+
onStateChange(callback: (state: any) => void) {
22+
this.#stateCallback = callback;
23+
}
24+
25+
#notifyStateChange(state: any) {
26+
if (this.#stateCallback) {
27+
this.#stateCallback(state);
28+
}
29+
}
30+
1931
load() {
2032
if (this.loaded.value) {
2133
return
@@ -62,8 +74,10 @@ export class RapidManager {
6274
this.rapidContext.embed(true);
6375
this.rapidContext.containerNode = this.containerNode;
6476
this.rapidContext.assetPath = this.#baseUrl;
77+
6578

66-
console.info('Rapid loaded', this.rapidContext);
79+
console.log('Rapid loaded', this.rapidContext);
80+
6781
}
6882

6983
#patchRapid() {
@@ -75,6 +89,23 @@ export class RapidManager {
7589

7690
// Don't bother to fetch user details when uploading changesets:
7791
rapidOsmService.userDetails = (callback) => { callback('dummy error') };
92+
// const editor = this.rapidContext.editor;
93+
// console.info('Rapid editor', editor);
94+
console.log('Rapid editor ',this.rapidContext);
95+
const editSystem = this.rapidContext.systems.editor;
96+
editSystem.on('stablechange', (state) => {
97+
// this.#notifyStateChange(state);
98+
const changes = editSystem.changes();
99+
console.log('Rapid editor changes', changes);
100+
const changesLength = changes.modified.length || changes.created.length || changes.deleted.length;
101+
102+
this.#notifyStateChange(changesLength);
103+
104+
});
105+
106+
// editSystem.on('reset', () => {
107+
// console.log('Rapid editor reset');
108+
// });
78109
}
79110

80111
#wrapFetch(innerFetch) {

0 commit comments

Comments
 (0)