@silexlabs/silex-dashboard 1.0.2 → 1.0.4

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.
@@ -0,0 +1,188 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html lang="">
4
+ <head>
5
+ <link rel="stylesheet" href="/css/connectors.css" />
6
+
7
+ <link
8
+ rel="alternate"
9
+ hreflang="fr"
10
+ href="/fr/connectors" />
11
+
12
+ <style>
13
+ .button { cursor: pointer; }
14
+ a { text-decoration: none; }
15
+ a:hover { text-decoration: underline; }
16
+
17
+ .skeleton-anim:after {
18
+ width: 100%;
19
+ height: 100%;
20
+ position: absolute;
21
+ top: 0;
22
+ left: 0;
23
+ content: "";
24
+ background:
25
+ linear-gradient(0.25turn, transparent, rgba(255,255,255,.75), transparent),
26
+ linear-gradient(transparent, transparent),
27
+ radial-gradient(38px circle at 19px 19px, transparent 50%, transparent 51%),
28
+ linear-gradient(transparent, transparent);
29
+ background-repeat: no-repeat;
30
+ background-size: 315px 250px, 315px 180px, 100px 100px, 225px 30px;
31
+ background-position: -315px 0, 0 0, 0px 190px, 50px 195px;
32
+ animation: loading 1.5s infinite;
33
+ }
34
+
35
+ @keyframes loading {
36
+ to {
37
+ background-position: 200% 0, 0 0, 0 190px, 50px 195px;
38
+ }
39
+ }
40
+
41
+ </style>
42
+ <script src="/node_modules/vue/dist/vue.global.js"></script>
43
+ <script src="/js/main.js"></script>
44
+ <script type="module">
45
+ window.addEventListener('load', function() {
46
+ const { createApp } = Vue;
47
+ const { api, constants, types } = silex;
48
+ const {
49
+ ConnectorType,
50
+ } = types
51
+ const {
52
+ connectorList,
53
+ logout,
54
+ } = api
55
+
56
+ const App = {
57
+ data() {
58
+ return {
59
+ connectors: [],
60
+ error: null,
61
+ message: null,
62
+ loading: true,
63
+ lastConnector: null,
64
+ }
65
+ },
66
+ mounted() {
67
+ this.init()
68
+ window.addEventListener('message', (event) => {
69
+ if(event.data && event.data.type === 'login') {
70
+ this.loginResult(event.data)
71
+ }
72
+ })
73
+ },
74
+
75
+ methods: {
76
+ async init() {
77
+ try {
78
+ this.loading = true
79
+ console.log('init')
80
+ this.connectors = await connectorList({type: ConnectorType.STORAGE})
81
+ console.log('connectors', this.connectors)
82
+ this.loading = false
83
+ } catch (error) {
84
+ console.error(error)
85
+ this.error = error
86
+ this.loading = false
87
+ }
88
+ },
89
+ openLogin(connector) {
90
+ this.lastConnector = connector
91
+ const nonOAuthUrl = `${constants.API_PATH}${constants.API_CONNECTOR_PATH}${constants.API_CONNECTOR_LOGIN}?connectorId=${connector.connectorId}&type=${connector.type}`
92
+ console.log('openLogin', connector.oauthUrl, nonOAuthUrl)
93
+ window.open(connector.oauthUrl || nonOAuthUrl, '_blank')
94
+ },
95
+ loginResult(data) {
96
+ console.log('loginResult', data)
97
+ if(data.error) {
98
+ this.error = data.error
99
+ this.message = `Error, login failed. ${data.message}`
100
+ } else {
101
+ window.location.href = '/'
102
+ }
103
+ },
104
+ async logout() {
105
+ try {
106
+ this.message = 'Logging out'
107
+ await logout({type: ConnectorType.STORAGE, connectorId: this.lastConnector.connectorId})
108
+ this.loggedIn = false
109
+ this.user = null
110
+ this.websites = []
111
+ this.loading = false
112
+ this.message = ''
113
+ this.error = false
114
+ } catch (error) {
115
+ console.error(error)
116
+ this.error = error
117
+ this.message = error.message
118
+ this.loading = false
119
+ }
120
+ },
121
+ },
122
+ };
123
+
124
+ // Start vue app
125
+ createApp(App).mount('.app');
126
+ })
127
+ </script>
128
+
129
+ <title></title>
130
+ <link rel="icon" href="" />
131
+ <meta property="description" content=""/>
132
+ <meta property="og:title" content=""/>
133
+ <meta property="og:description" content=""/>
134
+ <meta property="og:image" content=""/>
135
+ </head>
136
+ <body
137
+ id="i2hcfw"
138
+ class=" app"
139
+
140
+
141
+ ><A
142
+ id="ixzhcr" href="/"
143
+ class="button button-bar__item--secondary "
144
+
145
+
146
+ >< Back</A><div
147
+ id="imgx81"
148
+
149
+
150
+
151
+ ><H1
152
+
153
+
154
+
155
+
156
+ >Welcome to Silex</H1><div
157
+
158
+ class="subtitle "
159
+
160
+
161
+ >Please login to continue</div><div
162
+ id="in62y2"
163
+ class="button-bar "
164
+
165
+
166
+ ><A
167
+ id="isqe61" href="https://"
168
+ class="h-space button-bar__item--main button-bar_item button big-button "
169
+ v-if="!loading" v-for="(connector, index) in connectors" :key="index" :style="{ backgroundColor: connector.background, color: connector.color }" @click="openLogin(connector)"
170
+
171
+ ><div
172
+ id="i87asw"
173
+
174
+ v-text="connector.displayName"
175
+
176
+ >Insert your text here</div></A></div><div
177
+ id="i9msnk"
178
+
179
+ v-if="error" v-html="message"
180
+
181
+ >Insert your text here</div><div
182
+ id="i6akll"
183
+ class="button button--tertiary "
184
+ v-if="error" @click="logout()"
185
+
186
+ >Logout</div></div></body>
187
+ </html>
188
+