Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
moqui
/
moqui-mjml
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
57039d4b
authored
2024-04-10 17:17:37 -0600
by
acetousk
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Create api and services (WIP), fix auth and urls for screen, add data
1 parent
ed4848ef
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
4 deletions
data/MjmlSecurityData.xml
data/MjmlSetupData.xml
screen/MjmlApp.xml
service/moqui/mjml/MjmlServices.xml
data/MjmlSecurityData.xml
View file @
57039d4
...
...
@@ -29,7 +29,7 @@ along with this software (see the LICENSE.md file). If not, see
<!-- Artifact group for all of the Moqui Mjml REST API via the mjml resource (the root resource) -->
<moqui.security.ArtifactGroup
artifactGroupId=
"MOQUI_MJML_API"
description=
"Example REST API (via root resource)"
/>
<moqui.security.ArtifactGroupMember
artifactGroupId=
"MOQUI_MJML_API"
artifactTypeEnumId=
"AT_REST_PATH"
inheritAuthz=
"Y"
artifactName=
"/
example
"
/>
inheritAuthz=
"Y"
artifactName=
"/
moqui-mjml/mjml
"
/>
<!-- Full permissions for the ADMIN user group -->
<moqui.security.ArtifactAuthz
artifactAuthzId=
"MOQUI_MJML_API_AUTHZ_ALL"
userGroupId=
"ADMIN"
artifactGroupId=
"MOQUI_MJML_API"
authzTypeEnumId=
"AUTHZT_ALWAYS"
authzActionEnumId=
"AUTHZA_ALL"
/>
...
...
data/MjmlSetupData.xml
View file @
57039d4
...
...
@@ -20,6 +20,7 @@ along with this software (see the LICENSE.md file). If not, see
<moqui.screen.ScreenThemeResource
screenThemeId=
"MJML_DEFAULT"
sequenceNum=
"50"
resourceTypeEnumId=
"STRT_STYLESHEET"
resourceValue=
"/mjmlstatic/css/grapes.min.css"
/>
<moqui.screen.ScreenThemeResource
screenThemeId=
"MJML_DEFAULT"
sequenceNum=
"52"
resourceTypeEnumId=
"STRT_STYLESHEET"
resourceValue=
"/mjmlstatic/css/grapesjs-mjml.css"
/>
<delete-moqui.screen.ScreenThemeResource
screenThemeId=
"MJML_DEFAULT"
sequenceNum=
"10"
resourceTypeEnumId=
"STRT_SCRIPT"
resourceValue=
"/js/MoquiLib.js"
/>
<moqui.screen.ScreenThemeResource
screenThemeId=
"MJML_DEFAULT"
sequenceNum=
"51"
resourceTypeEnumId=
"STRT_SCRIPT"
resourceValue=
"/mjmlstatic/js/grapesjs.min.js"
/>
<moqui.screen.ScreenThemeResource
screenThemeId=
"MJML_DEFAULT"
sequenceNum=
"52"
resourceTypeEnumId=
"STRT_SCRIPT"
resourceValue=
"/mjmlstatic/js/grapesjs-mjml.min.js"
/>
...
...
@@ -33,5 +34,7 @@ along with this software (see the LICENSE.md file). If not, see
<moqui.screen.ScreenThemeResource
screenThemeId=
"MJML_DEFAULT"
sequenceNum=
"110"
resourceTypeEnumId=
"STRT_HEADER_TITLE"
resourceValue=
"Email Editor"
/>
<moqui.resource.DbResource
resourceId=
"GRAPESJS"
filename=
"grapesjs"
isFile=
"N"
/>
<moqui.resource.DbResource
resourceId=
"GRAPESJS_PROJECT"
filename=
"project"
isFile=
"N"
parentResourceId=
"GRAPESJS"
/>
</entity-facade-xml>
...
...
screen/MjmlApp.xml
View file @
57039d4
...
...
@@ -16,11 +16,30 @@ along with this software (see the LICENSE.md file). If not, see
xsi:noNamespaceSchemaLocation=
"http://moqui.org/xsd/xml-screen-3.xsd"
menu-image=
"fa fa-flash"
menu-image-type=
"icon"
standalone=
"true"
screen-theme-type-enum-id=
"STT_MJML"
>
<parameter
name=
"resourceId"
/>
<transition
name=
"handleGrapeJs"
read-only=
"true"
method=
"get"
>
<actions>
<log
level=
"warn"
message=
"context.toString() ${context.toString()}"
/>
<service-call
name=
"moqui.MjmlServices.get#GrapeJs"
in-map=
"[resourceId:resourceId]"
out-map=
"context"
/>
</actions>
<default-response
url=
"."
/></transition>
<transition
name=
"handleGrapeJs"
read-only=
"true"
method=
"post"
>
<actions>
<log
level=
"warn"
message=
"context.toString() ${context.toString()}"
/>
<service-call
name=
"moqui.MjmlServices.store#GrapeJs"
in-map=
"context"
out-map=
"context"
/>
</actions>
<default-response
url=
"."
/></transition>
<actions>
<set
field=
"baseLinkUrl"
from=
"!'production'.equals(System.getProperty('instance_purpose')) ? 'http://localhost:8080' : ec.web.getWebappRootUrl(true,true)"
/>
</actions>
<widgets>
<render-mode><text
type=
"html"
location=
"component://webroot/screen/includes/Header.html.ftl"
/></render-mode>
<render-mode><text
type=
"html,vuet,qvt"
>
<![CDATA[
<render-mode><text
type=
"html"
>
<![CDATA[
<input type="hidden" id="confMoquiSessionToken" value="${ec.web.sessionToken}">
<style>
body,
html {
...
...
@@ -159,10 +178,37 @@ along with this software (see the LICENSE.md file). If not, see
<script
type=
"text/javascript"
>
// Wait for the plugin to be injected by the dev server
window.onload = () => {
const resourceId = new URLSearchParams(window.location.search).get('resourceId');
window.editor = grapesjs.init({
height: '100%',
noticeOnUnload: false,
storageManager: false,
// Default configurations
storageManager: {
type: 'remote', // Storage type. Available: local | remote
autosave: true, // Store data automatically
autoload: true, // Autoload stored data on init
stepsBeforeSave: 1, // If autosave is enabled, indicates how many changes are necessary before the store method is triggered
// ...
// Default storage options
options: {
remote: {
urlLoad: "${baseLinkUrl}/rest/s1/moqui-mjml/mjml?resourceId=" + resourceId,
urlStore: "${baseLinkUrl}/rest/s1/moqui-mjml/mjml?resourceId=" + resourceId,
headers: {
"X-CSRF-Token": document.getElementById('confMoquiSessionToken').value
},
// The `remote` storage uses the POST method when stores data but
// the json-server API requires PATCH.
// fetchOptions: opts => (opts.method === 'POST' ? { method: 'PATCH' } : {}),
// As the API stores projects in this format `{id: 1, data: projectData }`,
// we have to properly update the body before the store and extract the
// project data from the response result.
onStore: data => ({ resourceId: resourceId, data }),
onLoad: result => result.data,
},
}
},
fromElement: true,
container: '#gjs',
...
...
service/moqui/mjml/MjmlServices.xml
View file @
57039d4
...
...
@@ -14,5 +14,47 @@ along with this software (see the LICENSE.md file). If not, see
-->
<services
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"http://moqui.org/xsd/service-definition-3.xsd"
>
<service
verb=
"get"
noun=
"GrapeJs"
>
<description>
Create MJML
</description>
<in-parameters>
<parameter
name=
"resourceId"
/>
</in-parameters>
<out-parameters>
<parameter
name=
"data"
/>
</out-parameters>
<actions>
<set
field=
"file"
from=
"ec.resource.getLocationReference('dbresource://grapesjs/project/'+resourceId)"
/>
<set
field=
"data"
from=
"file.getText()"
/>
</actions>
</service>
<service
verb=
"store"
noun=
"GrapeJs"
>
<description>
Create MJML
</description>
<in-parameters>
<parameter
name=
"resourceId"
/>
<parameter
name=
"data"
type=
"String"
/>
</in-parameters>
<out-parameters>
<parameter
name=
"resourceId"
/>
</out-parameters>
<actions>
<!-- <log level="warn" message="context.toString() ${context.toString()}"/>-->
<!-- <log level="warn" message="store#GrapeJs ec.web.secureRequestParameters.data ${ec.web.secureRequestParameters.data}"/>-->
<log
level=
"warn"
message=
"store#GrapeJs ec.web.secureRequestParameters._requestBodyText ${ec.web.secureRequestParameters._requestBodyText}"
/>
<log
level=
"warn"
message=
"store#GrapeJs data ${data} typeof data ${data.getClass().getName()}"
/>
<!-- <set field="data" from="groovy.json.JsonOutput.toJson(data)"/>-->
<set
field=
"project"
from=
"ec.resource.getLocationReference('dbresource://grapesjs/project')"
/>
<set
field=
"file"
from=
"project.makeFile(java.util.UUID.randomUUID().toString())"
/>
<script>
<![CDATA[
file.putText(data)
file.move(project.location + "/" + file.dbResourceId)
]]>
</script>
<set
field=
"resourceId"
from=
"context.resourceId"
/>
</actions>
</service>
</services>
...
...
Please
register
or
sign in
to post a comment