Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
epoc-editor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
learninglab
epoc
epoc-editor
Commits
c81bb356
Commit
c81bb356
authored
1 year ago
by
VIAUD Nathan
Browse files
Options
Downloads
Patches
Plain Diff
improvements: saving content.json & project.json before save, preview & export
parent
3a610275
No related branches found
No related tags found
1 merge request
!110
Resolve "Trigger the writing of content.json & project.json before save, exporting & launching preview"
Pipeline
#917090
passed
1 year ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
electron/components/ipc.js
+17
-3
17 additions, 3 deletions
electron/components/ipc.js
src/shared/services/editor.service.ts
+8
-4
8 additions, 4 deletions
src/shared/services/editor.service.ts
src/shared/services/graph.service.ts
+8
-2
8 additions, 2 deletions
src/shared/services/graph.service.ts
with
33 additions
and
9 deletions
electron/components/ipc.js
+
17
−
3
View file @
c81bb356
...
...
@@ -69,17 +69,27 @@ const setupIpcListener = function (targetWindow) {
store
.
updateState
(
'
projects
'
,
{
[
targetWindow
.
id
]:
project
});
});
ipcMain
.
on
(
'
saveEpocProject
'
,
async
(
event
)
=>
{
ipcMain
.
on
(
'
saveEpocProject
'
,
async
(
event
,
data
)
=>
{
if
(
event
.
sender
!==
targetWindow
.
webContents
)
return
;
sendToFrontend
(
event
.
sender
,
'
epocProjectSaving
'
);
const
{
data
:
projectData
,
content
}
=
data
;
await
writeProjectData
(
store
.
state
.
projects
[
targetWindow
.
id
].
workdir
,
projectData
);
await
writeEpocData
(
store
.
state
.
projects
[
targetWindow
.
id
].
workdir
,
content
);
updateSavedProject
(
event
.
sender
,
await
saveEpocProject
(
store
.
state
.
projects
[
targetWindow
.
id
]));
});
ipcMain
.
on
(
'
runPreview
'
,
async
(
event
,
contentPath
)
=>
{
ipcMain
.
on
(
'
runPreview
'
,
async
(
event
,
data
)
=>
{
if
(
event
.
sender
!==
targetWindow
.
webContents
)
return
;
try
{
const
{
contentPath
,
projectJSON
}
=
data
;
const
{
data
:
projectData
,
content
}
=
projectJSON
;
await
writeProjectData
(
store
.
state
.
projects
[
targetWindow
.
id
].
workdir
,
projectData
);
await
writeEpocData
(
store
.
state
.
projects
[
targetWindow
.
id
].
workdir
,
content
);
await
runPreview
(
store
.
state
.
projects
[
targetWindow
.
id
].
workdir
,
contentPath
);
sendToFrontend
(
event
.
sender
,
'
previewReady
'
);
}
catch
(
e
)
{
...
...
@@ -88,10 +98,14 @@ const setupIpcListener = function (targetWindow) {
}
});
ipcMain
.
on
(
'
exportProject
'
,
async
(
event
)
=>
{
ipcMain
.
on
(
'
exportProject
'
,
async
(
event
,
data
)
=>
{
if
(
event
.
sender
!==
targetWindow
.
webContents
)
return
;
try
{
const
{
data
:
projectData
,
content
}
=
data
;
await
writeProjectData
(
store
.
state
.
projects
[
targetWindow
.
id
].
workdir
,
projectData
);
await
writeEpocData
(
store
.
state
.
projects
[
targetWindow
.
id
].
workdir
,
content
);
await
exportProject
(
store
.
state
.
projects
[
targetWindow
.
id
].
workdir
,
store
.
state
.
projects
[
targetWindow
.
id
].
filepath
...
...
This diff is collapsed.
Click to expand it.
src/shared/services/editor.service.ts
+
8
−
4
View file @
c81bb356
...
...
@@ -176,13 +176,15 @@ function openEpocProject(project: ePocProject): void {
function
saveEpocProject
():
void
{
editorStore
.
saving
=
true
;
api
.
send
(
'
saveEpocProject
'
);
const
data
=
graphService
.
getProjectJSON
();
api
.
send
(
'
saveEpocProject
'
,
data
);
}
function
runPreview
():
void
{
waitingToast
(
'
🔭 Démarrage de la prévisualisation...
'
);
editorStore
.
loadingPreview
=
true
;
api
.
send
(
'
runPreview
'
);
const
data
=
graphService
.
getProjectJSON
();
api
.
send
(
'
runPreview
'
,
{
data
});
}
function
runPreviewAtPage
():
void
{
...
...
@@ -214,14 +216,16 @@ function runPreviewAtPage(): void {
if
(
!
error
)
{
editorStore
.
loadingPreview
=
true
;
api
.
send
(
'
runPreview
'
,
contentPath
);
const
projectJSON
=
graphService
.
getProjectJSON
();
api
.
send
(
'
runPreview
'
,
{
contentPath
,
projectJSON
});
}
}
function
exportProject
():
void
{
waitingToast
(
'
⚙️ Export en cours...
'
);
editorStore
.
exporting
=
true
;
api
.
send
(
'
exportProject
'
);
const
data
=
graphService
.
getProjectJSON
();
api
.
send
(
'
exportProject
'
,
data
);
}
export
const
editorService
=
{
...
...
This diff is collapsed.
Click to expand it.
src/shared/services/graph.service.ts
+
8
−
2
View file @
c81bb356
...
...
@@ -31,13 +31,18 @@ const { nodes, edges, findNode, toObject } = useVueFlow({ id: 'main' });
function
writeProjectData
():
void
{
debounceFunction
(
500
,
()
=>
{
const
data
=
JSON
.
stringify
(
toObject
());
const
content
=
JSON
.
stringify
(
createContentJSON
());
const
{
data
,
content
}
=
getProjectJSON
();
api
.
send
(
'
writeProjectData
'
,
data
);
api
.
send
(
'
writeEpocData
'
,
content
);
});
}
function
getProjectJSON
():
{
data
:
string
;
content
:
string
}
{
const
data
=
JSON
.
stringify
(
toObject
());
const
content
=
JSON
.
stringify
(
createContentJSON
());
return
{
data
,
content
};
}
function
importFile
(
filepath
:
string
,
targetDirectory
?:
string
):
Promise
<
string
>
{
api
.
send
(
'
importFile
'
,
{
filepath
,
targetDirectory
});
...
...
@@ -279,6 +284,7 @@ export const graphService = {
getPreviousNode
,
getNextNode
,
openContextMenu
,
getProjectJSON
};
let
openedConditionIndex
:
number
|
null
=
null
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment