Skip to content

Commit eb0d874

Browse files
author
Gérard Collin
committed
feat: support for app preview
1 parent ef9d8cb commit eb0d874

4 files changed

Lines changed: 89 additions & 1 deletion

File tree

apps/xt-host/projects/host/src/app/project-load/project-load.component.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,40 @@ describe('ProjectLoadComponent', () => {
2828
it('should create', () => {
2929
expect(component).toBeTruthy();
3030
});
31+
3132
});
33+
34+
const PRJ_DEFINITION={
35+
"name": "Simple",
36+
"template": false,
37+
"description": "Simple project with no need for plugins",
38+
"content": {
39+
"creation": {
40+
"type": "Application",
41+
"name": "Simple",
42+
"entities": [
43+
{
44+
"from": "",
45+
"name": "SimpleNote",
46+
"fields": [
47+
{
48+
"name": "Text",
49+
"type": "string"
50+
},
51+
{
52+
"name": "Amount",
53+
"type": "number"
54+
},
55+
{
56+
"name": "Check",
57+
"type": "boolean"
58+
}
59+
]
60+
}
61+
],
62+
"sharing": {
63+
"with": "Dont-code users"
64+
}
65+
}
66+
}
67+
}

apps/xt-host/projects/host/src/app/project-load/project-load.component.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,17 @@ export class ProjectLoadComponent implements OnInit {
119119
}
120120

121121
}
122+
123+
function bufferToString(buffer: ArrayBuffer): string {
124+
return String.fromCharCode.apply(null, Array.from(new Uint16Array(buffer)));
125+
}
126+
127+
function stringToBuffer(value: string): ArrayBuffer {
128+
let buffer = new ArrayBuffer(value.length * 2); // 2 bytes per char
129+
let view = new Uint16Array(buffer);
130+
for (let i = 0, length = value.length; i < length; i++) {
131+
view[i] = value.charCodeAt(i);
132+
}
133+
return buffer;
134+
}
135+

apps/xt-host/projects/host/src/app/shared/app-config/app-config.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export class AppConfigService {
105105
loader: (options) => {
106106
if (options.params.pluginsLoaded) {
107107
if (options.params.projectDefinition!=null) {
108-
return Promise.resolve(options.params.projectDefinition);
108+
const jsonDef=JSON.parse(options.params.projectDefinition);
109+
return Promise.resolve(jsonDef);
109110
} else if (options.params.projectName!=null) {
110111
let projectUrl = options.params.projectUrl;
111112
if (projectUrl==null) {

docs/test-project-definition.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Base 64:
2+
ewogICJuYW1lIjogIlNpbXBsZSIsCiAgInRlbXBsYXRlIjogZmFsc2UsCiAgImRlc2NyaXB0aW9uIjogIlNpbXBsZSBwcm9qZWN0IHdpdGggbm8gbmVlZCBmb3IgcGx1Z2lucyIsCiAgImNvbnRlbnQiOiB7CiAgICAiY3JlYXRpb24iOiB7CiAgICAgICJ0eXBlIjogIkFwcGxpY2F0aW9uIiwKICAgICAgIm5hbWUiOiAiU2ltcGxlIiwKICAgICAgImVudGl0aWVzIjogWwogICAgICAgIHsKICAgICAgICAgICJmcm9tIjogIiIsCiAgICAgICAgICAibmFtZSI6ICJTaW1wbGVOb3RlIiwKICAgICAgICAgICJmaWVsZHMiOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAibmFtZSI6ICJUZXh0IiwKICAgICAgICAgICAgICAidHlwZSI6ICJzdHJpbmciCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAibmFtZSI6ICJBbW91bnQiLAogICAgICAgICAgICAgICJ0eXBlIjogIm51bWJlciIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgICJuYW1lIjogIkNoZWNrIiwKICAgICAgICAgICAgICAidHlwZSI6ICJib29sZWFuIgogICAgICAgICAgICB9CiAgICAgICAgICBdCiAgICAgICAgfQogICAgICBdLAogICAgICAic2hhcmluZyI6IHsKICAgICAgICAid2l0aCI6ICJEb250LWNvZGUgdXNlcnMiCiAgICAgIH0KICAgIH0KICB9Cn0K
3+
4+
{
5+
"name": "Simple",
6+
"template": false,
7+
"description": "Simple project with no need for plugins",
8+
"content": {
9+
"creation": {
10+
"type": "Application",
11+
"name": "Simple",
12+
"entities": [
13+
{
14+
"from": "",
15+
"name": "SimpleNote",
16+
"fields": [
17+
{
18+
"name": "Text",
19+
"type": "string"
20+
},
21+
{
22+
"name": "Amount",
23+
"type": "number"
24+
},
25+
{
26+
"name": "Check",
27+
"type": "boolean"
28+
}
29+
]
30+
}
31+
],
32+
"sharing": {
33+
"with": "Dont-code users"
34+
}
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)