@silexlabs/silex-dashboard 1.0.2 → 1.0.3
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/.silex-client.js +27 -0
- package/{index.js → .silex.js} +17 -9
- package/_data/api-translations.json +6 -2
- package/_includes/api-connectors.js.html +47 -0
- package/_includes/api-websites.js.html +148 -0
- package/_includes/connectors.html +74 -0
- package/_includes/websites.html +385 -0
- package/_silex/default/meta.json +1 -0
- package/_silex/default/website.json +1 -0
- package/_site/css/connectors.css +1 -0
- package/_site/css/websites.css +1 -0
- package/_site/en/connectors/index.html +124 -0
- package/_site/en/index.html +549 -169
- package/_site/fr/connectors/index.html +124 -0
- package/_site/fr/index.html +550 -170
- package/package.json +7 -5
- package/pages/connectors.css.liquid +4 -0
- package/pages/en/connectors.md +4 -0
- package/pages/en/index.md +2 -1
- package/pages/fr/connectors.md +5 -0
- package/pages/fr/index.md +2 -1
- package/pages/websites.css.liquid +4 -0
- package/.silex/default/.silex.data.json +0 -1
- package/_includes/main.html +0 -1
- package/_includes/website-list.js.html +0 -172
- package/_site/README/index.html +0 -12
- package/_site/css/main.css +0 -1
- package/css/main.css.liquid +0 -4
- package/pages/main.css.liquid +0 -4
- /package/{.silex → _silex}/default/assets/alex-small.jpg +0 -0
- /package/{.silex → _silex}/default/assets/silex-icon-2018@200px.png +0 -0
package/.silex-client.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import templatePlugin from '/node_modules/@silexlabs/silex/dist/plugins/client/plugins/client/template.js'
|
|
2
|
+
import publishTo from '/node_modules/@silexlabs/silex/dist/plugins/client/plugins/client/publicationRenderer.js'
|
|
3
|
+
|
|
4
|
+
export default async function(config, options) {
|
|
5
|
+
console.log('silex-client.js', templatePlugin)
|
|
6
|
+
// Defaults
|
|
7
|
+
const opts = {
|
|
8
|
+
...options,
|
|
9
|
+
}
|
|
10
|
+
await config.addPlugin(templatePlugin)
|
|
11
|
+
await config.addPlugin(publishTo, {
|
|
12
|
+
publishTo: 'https://silex.me/publish',
|
|
13
|
+
css: {
|
|
14
|
+
frontMatter: true,
|
|
15
|
+
ext: '.css.liquid',
|
|
16
|
+
path: '../../pages'
|
|
17
|
+
},
|
|
18
|
+
html: {
|
|
19
|
+
frontMatter: false,
|
|
20
|
+
path: '../../_includes'
|
|
21
|
+
},
|
|
22
|
+
assets: {
|
|
23
|
+
path: '../../',
|
|
24
|
+
url: '/',
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
}
|
package/{index.js → .silex.js}
RENAMED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
const fs = require('node:fs/promises')
|
|
2
2
|
const { join } = require('node:path')
|
|
3
3
|
const express = require('express')
|
|
4
|
+
const node_modules = require('node_modules-path')
|
|
4
5
|
const serveStatic = require('serve-static')
|
|
5
6
|
const locale = require('locale')
|
|
6
|
-
|
|
7
|
-
function withCache(req, res, next) {
|
|
8
|
-
res.header('Cache-Control', 'public,max-age=86400,immutable') // 24h
|
|
9
|
-
next()
|
|
10
|
-
}
|
|
7
|
+
const { withCache } = require('@silexlabs/silex/dist/plugins/server/plugins/server/Cache')
|
|
11
8
|
|
|
12
9
|
module.exports = async function(config, options) {
|
|
13
10
|
// Defaults
|
|
@@ -22,11 +19,22 @@ module.exports = async function(config, options) {
|
|
|
22
19
|
|
|
23
20
|
// Serve the dashboard and the editor
|
|
24
21
|
config.on('silex:startup:start', ({app}) => {
|
|
22
|
+
const router = express.Router()
|
|
23
|
+
app.use(router)
|
|
24
|
+
|
|
25
|
+
// Use cache
|
|
26
|
+
router.use(withCache)
|
|
27
|
+
|
|
28
|
+
// Localization populate req.locale
|
|
29
|
+
router.use(locale(languages.map(l => l.code), opts.defaultLanguage))
|
|
30
|
+
|
|
25
31
|
// Serve the dashboard
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
router.use('/', serveStatic(opts.rootPath))
|
|
33
|
+
|
|
34
|
+
// Serve scripts
|
|
35
|
+
//router.use('/js/vue/', express.static(node_modules('vue') + '/vue'))
|
|
36
|
+
//router.use('/js/@silexlabs/silex/', express.static(node_modules('@silexlabs/silex') + '/@silexlabs/silex'))
|
|
37
|
+
router.use('/', express.static(join(__dirname, 'public')))
|
|
30
38
|
|
|
31
39
|
// Serve the editor when the ?id param is present in the URL
|
|
32
40
|
const editorRouter = express.Router()
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
"Failed to create website": "Failed to create website",
|
|
8
8
|
"Deleting a website? Are your sure? Really?": "Deleting a website? Are your sure? Really?",
|
|
9
9
|
"Website deleted successfully": "Website deleted successfully",
|
|
10
|
-
"Failed to delete website": "Failed to delete website"
|
|
10
|
+
"Failed to delete website": "Failed to delete website",
|
|
11
|
+
"New name for this website": "New name for this website",
|
|
12
|
+
"Website renamed successfully": "Website renamed successfully"
|
|
11
13
|
},
|
|
12
14
|
"fr": {
|
|
13
15
|
"Failed to fetch websites": "Erreur, impossible de récupérer la liste des sites",
|
|
@@ -17,6 +19,8 @@
|
|
|
17
19
|
"Failed to create website": "Erreur, le site n\\'a pas été créé",
|
|
18
20
|
"Deleting a website? Are your sure? Really?": "Etes vous sûr.e de vouloir supprimer définitivement ce site ?",
|
|
19
21
|
"Website deleted successfully": "Le site a bien été effacé",
|
|
20
|
-
"Failed to delete website": "Erreur, le site n\\'a pas été effacé"
|
|
22
|
+
"Failed to delete website": "Erreur, le site n\\'a pas été effacé",
|
|
23
|
+
"New name for this website": "Nouveau nom",
|
|
24
|
+
"Website renamed successfully": "Changement de nom effectué"
|
|
21
25
|
}
|
|
22
26
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script src="/node_modules/vue/dist/vue.global.js"></script>
|
|
2
|
+
<script src="/js/main.js"></script>
|
|
3
|
+
<script type="module">
|
|
4
|
+
window.addEventListener('load', function() {
|
|
5
|
+
const { createApp } = Vue;
|
|
6
|
+
const { api, constants, types } = silex;
|
|
7
|
+
const {
|
|
8
|
+
ConnectorType,
|
|
9
|
+
} = types
|
|
10
|
+
const {
|
|
11
|
+
connectorList,
|
|
12
|
+
} = api
|
|
13
|
+
|
|
14
|
+
const App = {
|
|
15
|
+
data() {
|
|
16
|
+
return {
|
|
17
|
+
connectors: [],
|
|
18
|
+
error: null,
|
|
19
|
+
message: null,
|
|
20
|
+
loading: true,
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
mounted() {
|
|
24
|
+
this.init()
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
methods: {
|
|
28
|
+
async init() {
|
|
29
|
+
try {
|
|
30
|
+
this.loading = true
|
|
31
|
+
console.log('init')
|
|
32
|
+
this.connectors = await connectorList()
|
|
33
|
+
console.log('connectors', this.connectors)
|
|
34
|
+
this.loading = false
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error(error)
|
|
37
|
+
this.error = error
|
|
38
|
+
this.loading = false
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Start vue app
|
|
45
|
+
createApp(App).mount('.app');
|
|
46
|
+
})
|
|
47
|
+
</script>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<script src="/node_modules/vue/dist/vue.global.js"></script>
|
|
2
|
+
<script src="/js/main.js"></script>
|
|
3
|
+
<script type="module">
|
|
4
|
+
const CONNECTORS_PATH = '/connectors/'
|
|
5
|
+
window.addEventListener('load', function() {
|
|
6
|
+
const { createApp } = Vue;
|
|
7
|
+
const { api, constants, types } = silex;
|
|
8
|
+
const {
|
|
9
|
+
ConnectorType,
|
|
10
|
+
} = types
|
|
11
|
+
const {
|
|
12
|
+
getUser,
|
|
13
|
+
logout,
|
|
14
|
+
websiteDelete,
|
|
15
|
+
websiteList,
|
|
16
|
+
websiteCreate,
|
|
17
|
+
websiteMetaWrite,
|
|
18
|
+
} = api
|
|
19
|
+
|
|
20
|
+
const App = {
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
websites: [],
|
|
24
|
+
newWebsiteName: '',
|
|
25
|
+
showCreationForm: false,
|
|
26
|
+
error: null,
|
|
27
|
+
message: null,
|
|
28
|
+
loggedIn: false,
|
|
29
|
+
loading: true,
|
|
30
|
+
storage: null,
|
|
31
|
+
user: null,
|
|
32
|
+
showMenu: false,
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
mounted() {
|
|
36
|
+
this.init()
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
methods: {
|
|
40
|
+
async init() {
|
|
41
|
+
try {
|
|
42
|
+
// Debug
|
|
43
|
+
window.app = this
|
|
44
|
+
const user = await getUser({type: ConnectorType.STORAGE})
|
|
45
|
+
if(user) {
|
|
46
|
+
this.user = user
|
|
47
|
+
this.loggedIn = true
|
|
48
|
+
this.websites = await websiteList({connectorId: this.user.storage.connectorId})
|
|
49
|
+
this.loading = false
|
|
50
|
+
} else {
|
|
51
|
+
this.openLogin()
|
|
52
|
+
}
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(error)
|
|
55
|
+
this.loading = false
|
|
56
|
+
if(error.code === 401) {
|
|
57
|
+
this.loggedIn = false
|
|
58
|
+
this.openLogin()
|
|
59
|
+
} else {
|
|
60
|
+
this.error = error
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
openLogin(id, lang) {
|
|
66
|
+
//throw new Error('debug')
|
|
67
|
+
const path = `/{{lang}}${CONNECTORS_PATH}`
|
|
68
|
+
console.log(window.location.pathname, window.location.path, path)
|
|
69
|
+
if(window.location.pathname === path) return
|
|
70
|
+
window.open(path, '_self')
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
openEditor(id, lang) {
|
|
74
|
+
window.open(`/?id=${id}&lang=${lang}&connectorId=${this.user.storage.connectorId}`, '_blank')
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
async logout() {
|
|
78
|
+
await logout({
|
|
79
|
+
type: ConnectorType.STORAGE,
|
|
80
|
+
connectorId: this.user.storage.connectorId,
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
async createWebsite() {
|
|
85
|
+
if (!this.newWebsiteName) throw new Error('{{ api-translations[lang]["You need to provide a website name"] }}')
|
|
86
|
+
this.loading = true
|
|
87
|
+
try {
|
|
88
|
+
const websiteId = this.newWebsiteName.replace(/[/\\?%*:|"<>]/g, '_')
|
|
89
|
+
const result = await websiteCreate({
|
|
90
|
+
websiteId,
|
|
91
|
+
data: {
|
|
92
|
+
name: this.newWebsiteName,
|
|
93
|
+
imageUrl: null,
|
|
94
|
+
},
|
|
95
|
+
connectorId: this.user.storage.connectorId
|
|
96
|
+
})
|
|
97
|
+
this.message = '{{ api-translations[lang]["Website created successfully"] }}'
|
|
98
|
+
this.newWebsiteName = ''
|
|
99
|
+
this.showCreationForm = false;
|
|
100
|
+
this.websites = await websiteList({connectorId: this.user.storage.connectorId})
|
|
101
|
+
this.loading = false
|
|
102
|
+
return result
|
|
103
|
+
} catch (error) {
|
|
104
|
+
this.loading = false
|
|
105
|
+
console.error(error)
|
|
106
|
+
this.error = '{{ api-translations[lang]["Failed to create website"] }}'
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
async deleteWebsite(websiteId) {
|
|
111
|
+
const ok = confirm('{{ api-translations[lang]["Deleting a website? Are your sure? Really?"] }}')
|
|
112
|
+
if (!ok) return
|
|
113
|
+
this.loading = true
|
|
114
|
+
try {
|
|
115
|
+
const result = await websiteDelete({websiteId, connectorId: this.user.storage.connectorId})
|
|
116
|
+
this.message = '{{ api-translations[lang]["Website deleted successfully"] }}'
|
|
117
|
+
this.websites = await websiteList({connectorId: this.user.storage.connectorId})
|
|
118
|
+
this.loading = false
|
|
119
|
+
return result
|
|
120
|
+
} catch (error) {
|
|
121
|
+
this.loading = false
|
|
122
|
+
this.error = '{{ api-translations[lang]["Failed to delete website"] }}'
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
async renameWebsite(websiteId) {
|
|
127
|
+
const website = this.websites.find(w => w.websiteId === websiteId)
|
|
128
|
+
const name = prompt('{{ api-translations[lang]["New name for this website"] }}', website.name)
|
|
129
|
+
if (!name) return
|
|
130
|
+
this.loading = true
|
|
131
|
+
try {
|
|
132
|
+
const result = await websiteMetaWrite({websiteId, connectorId: this.user.storage.connectorId, data: { name }})
|
|
133
|
+
this.message = '{{ api-translations[lang]["Website renamed successfully"] }}'
|
|
134
|
+
this.websites = await websiteList({connectorId: this.user.storage.connectorId})
|
|
135
|
+
this.loading = false
|
|
136
|
+
return result
|
|
137
|
+
} catch (error) {
|
|
138
|
+
this.loading = false
|
|
139
|
+
this.error = '{{ api-translations[lang]["Failed to delete website"] }}'
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Start vue app
|
|
146
|
+
createApp(App).mount('.app');
|
|
147
|
+
})
|
|
148
|
+
</script>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
<!DOCTYPE html>
|
|
3
|
+
<html lang="">
|
|
4
|
+
<head>
|
|
5
|
+
<link rel="stylesheet" href="/css/connectors.css" />
|
|
6
|
+
{% render "alternate.liquid" languages: languages lang: lang page: page %}
|
|
7
|
+
|
|
8
|
+
<style>
|
|
9
|
+
.button { cursor: pointer; }
|
|
10
|
+
a { text-decoration: none; }
|
|
11
|
+
a:hover { text-decoration: underline; }
|
|
12
|
+
|
|
13
|
+
.skeleton-anim:after {
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 100%;
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: 0;
|
|
18
|
+
left: 0;
|
|
19
|
+
content: "";
|
|
20
|
+
background:
|
|
21
|
+
linear-gradient(0.25turn, transparent, rgba(255,255,255,.75), transparent),
|
|
22
|
+
linear-gradient(transparent, transparent),
|
|
23
|
+
radial-gradient(38px circle at 19px 19px, transparent 50%, transparent 51%),
|
|
24
|
+
linear-gradient(transparent, transparent);
|
|
25
|
+
background-repeat: no-repeat;
|
|
26
|
+
background-size: 315px 250px, 315px 180px, 100px 100px, 225px 30px;
|
|
27
|
+
background-position: -315px 0, 0 0, 0px 190px, 50px 195px;
|
|
28
|
+
animation: loading 1.5s infinite;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@keyframes loading {
|
|
32
|
+
to {
|
|
33
|
+
background-position: 200% 0, 0 0, 0 190px, 50px 195px;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
</style>
|
|
38
|
+
{% render "api-connectors.js.html" frontmatter: frontmatter page: page site: site api-translations: api-translations lang: lang %}
|
|
39
|
+
|
|
40
|
+
<title>{{ title }}</title>
|
|
41
|
+
<link rel="icon" href="" />
|
|
42
|
+
<meta property="description" content=""/>
|
|
43
|
+
<meta property="og:title" content=""/>
|
|
44
|
+
<meta property="og:description" content=""/>
|
|
45
|
+
<meta property="og:image" content=""/>
|
|
46
|
+
</head>
|
|
47
|
+
<body
|
|
48
|
+
id="i2hcfw"
|
|
49
|
+
class=" app"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
><div
|
|
53
|
+
id="imgx81"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
><div
|
|
58
|
+
id="in62y2"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
><div
|
|
63
|
+
id="isqe61"
|
|
64
|
+
|
|
65
|
+
v-if="!loading" v-for="(connector, index) in connectors" :key="index"
|
|
66
|
+
|
|
67
|
+
><div
|
|
68
|
+
id="i87asw"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
>Insert your text here</div></div></div></div></body>
|
|
73
|
+
</html>
|
|
74
|
+
|