@hostlink/nuxt-light 0.0.74 → 0.0.76

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/dist/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "0.0.74"
4
+ "version": "0.0.76"
5
5
  }
@@ -5,12 +5,10 @@ import { useLight, q, getCurrentUser, m, f } from '../';
5
5
  import { ref, computed, reactive, provide, watch } from 'vue';
6
6
  import { useRuntimeConfig } from 'nuxt/app';
7
7
 
8
-
9
8
  const config = useRuntimeConfig();
10
9
 
11
10
  const appVersion = config.public.appVersion ?? '0.0.1';
12
11
 
13
-
14
12
  const quasar = useQuasar();
15
13
  quasar.dark.set(false);
16
14
  const light = useLight();
@@ -62,15 +60,11 @@ const toggleRightDrawer = () => {
62
60
  rightDrawerOpen.value = !rightDrawerOpen.value
63
61
  }
64
62
 
65
-
66
- let isAdmin = false;
67
63
  let showViewAs = false;
68
64
  if (user.value && user.value.roles.indexOf('Administrators') != -1) {
69
- isAdmin = true;
70
65
  showViewAs = true;
71
66
  }
72
67
 
73
-
74
68
  const menuOverlayHeader = ref(false)
75
69
  const layoutView = computed(() => {
76
70
  let s = ''
@@ -86,10 +80,8 @@ const style = reactive({
86
80
  dense: my.styles?.dense || false
87
81
  });
88
82
 
89
-
90
83
  const isMouseOnDrawer = ref(false)
91
84
 
92
-
93
85
  const isMini = computed(() => {
94
86
  if (isMouseOnDrawer.value) {
95
87
  return false
@@ -165,7 +157,6 @@ const exitViewAs = async () => {
165
157
  window.location.reload();
166
158
  }
167
159
 
168
-
169
160
  const storageColor = computed(() => {
170
161
  if (system) {
171
162
  if (system.diskFreeSpacePercent < 0.05) {
@@ -196,7 +187,6 @@ const storageUsagePercent = computed(() => {
196
187
  return 0;
197
188
  })
198
189
 
199
-
200
190
  </script>
201
191
 
202
192
  <template>
@@ -247,13 +237,10 @@ const storageUsagePercent = computed(() => {
247
237
  </div>
248
238
 
249
239
  <div class="text-right">
250
- {{ user.roles.join(",") }}
240
+ {{ user.roles[0] }}
251
241
  </div>
252
242
  </div>
253
243
 
254
-
255
-
256
-
257
244
  <q-btn flat round dense icon="sym_o_person" class="q-mr-sm">
258
245
  <q-menu max-width="250px">
259
246
  <q-list>
@@ -10,7 +10,7 @@ setApiUrl(config?.public?.apiBase ?? '/api/');
10
10
  let app = null
11
11
 
12
12
  try {
13
- app = (await q({ app: ['company', 'companyLogo', 'logged', 'twoFactorAuthentication'] })).app;
13
+ app = (await q({ app: ['company', 'companyLogo', 'logged', 'twoFactorAuthentication', 'googleClientId'] })).app;
14
14
  } catch (e) {
15
15
  Dialog.create({
16
16
  title: 'Error',
@@ -28,7 +28,7 @@ try {
28
28
  <q-page-container class="bg-grey-2" style="color:#1f1f1f">
29
29
  <q-page padding>
30
30
  <l-login :company="app.company" :company-logo="app.companyLogo"
31
- :twoFactorAuthentication="app.twoFactorAuthentication"></l-login>
31
+ :twoFactorAuthentication="app.twoFactorAuthentication" :google-client-id="app.googleClientId"></l-login>
32
32
  </q-page>
33
33
  </q-page-container>
34
34
  </q-layout>
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { ref, reactive, onMounted } from 'vue'
3
- import { useQuasar } from 'quasar';
3
+ import { useQuasar, Notify } from 'quasar';
4
4
  import { useI18n } from 'vue-i18n';
5
5
  import { m, notify } from '../';
6
6
 
@@ -11,10 +11,11 @@ import { login, webauthnLogin } from '@hostlink/light';
11
11
  const config = useRuntimeConfig();
12
12
 
13
13
 
14
- defineProps({
14
+ const props = defineProps({
15
15
  company: String,
16
16
  companyLogo: String,
17
- twoFactorAuthentication: Boolean
17
+ twoFactorAuthentication: Boolean,
18
+ googleClientId: String
18
19
  })
19
20
 
20
21
  const i18n = useI18n();
@@ -123,16 +124,35 @@ const bioLogin = async () => {
123
124
  }
124
125
 
125
126
  }
126
- const googleResponse = () => {
127
-
127
+ const handleGoogleCredentialResponse = async (response) => {
128
+ try {
129
+ await m("googleLogin", { credential: response.credential });
130
+ window.self.location.reload();
131
+ } catch (e) {
132
+ notify(e.message, "negative");
133
+ }
128
134
  }
129
135
 
130
136
  onMounted(() => {
131
- if (config.public.GOOGLE_CLIENT_ID) {
137
+ if (props.googleClientId) {
138
+
139
+
140
+ if (!window.google) {
141
+ Notify.create({
142
+ message: "Google login is not available", //set script https://accounts.google.com/gsi/client in nuuxt.config.js
143
+ color: "negative",
144
+ icon: "sym_o_error",
145
+ position: "top",
146
+ timeout: 2000
147
+ });
148
+ return;
149
+
150
+ }
151
+
132
152
  //google
133
153
  google.accounts.id.initialize({
134
- client_id: "829616239009-23sf7s3blsnab9a288sb4j15orqqamlp.apps.googleusercontent.com",
135
- callback: googleResponse,
154
+ client_id: props.googleClientId,
155
+ callback: handleGoogleCredentialResponse,
136
156
  });
137
157
 
138
158
  google.accounts.id.renderButton(
@@ -144,7 +164,6 @@ onMounted(() => {
144
164
  text: 'signin_with',
145
165
  size: 'large',
146
166
  logo_alignment: 'left'
147
-
148
167
  }
149
168
  );
150
169
 
@@ -179,13 +198,10 @@ onMounted(() => {
179
198
  <l-btn v-if="hasBioLogin" outline rounded color="primary" icon="sym_o_fingerprint" @click="bioLogin" />
180
199
  <l-btn label="Forget password" outline rounded color="primary" icon="sym_o_lock_reset" @click="forgetPassword" />
181
200
  </q-card-actions>
182
- <q-card-actions v-if="config.public.GOOGLE_CLIENT_ID">
183
-
201
+ <q-card-actions v-if="props.googleClientId">
184
202
  <div>
185
-
186
203
  <div id="g_id_signin"></div>
187
204
  </div>
188
-
189
205
  </q-card-actions>
190
206
  </q-card>
191
207
  </template>
@@ -71,11 +71,7 @@ if (props.addBtn) {
71
71
  showAddBtn = true
72
72
  }
73
73
 
74
- //const title = props.title || route.path.split("/")[1];
75
-
76
- //title split by Capital letter, but if Captial letter is followed by another Capital letter, it is not split
77
- const title = props.title || route.path.split("/")[1].replace(/([A-Z])(?=[A-Z])/g, '$1 ').replace(/([a-z])(?=[A-Z])/g, '$1 ');
78
-
74
+ const title = props.title || route.path.split("/")[1].replace(/([a-z])(?=[A-Z])/g, '$1 ').replace(/([A-Z]*)(?=[A-Z][a-z])/g, '$1 ')
79
75
  const module = route.path.split("/")[1];
80
76
  const onDelete = async () => {
81
77
 
@@ -0,0 +1,93 @@
1
+ <script setup>
2
+ import { reactive, onMounted } from "vue"
3
+ import { Notify } from "quasar";
4
+ import { q, m } from '../../../'
5
+ let { app, my } = await q({ app: ['googleClientId'], my: ["gmail"] })
6
+
7
+ my = reactive(my);
8
+
9
+ const handleGoogleCredentialResponse = async (response) => {
10
+ try {
11
+ await m("googleRegister", { credential: response.credential })
12
+
13
+ const resp = await q("my", ["gmail"]);
14
+ my.gmail = resp.gmail;
15
+
16
+ Notify.create({
17
+ message: "Google account linked",
18
+ color: "positive",
19
+ position: "top",
20
+ timeout: 2000
21
+ });
22
+ } catch (e) {
23
+ console.log(e)
24
+ }
25
+ }
26
+
27
+ onMounted(() => {
28
+ if (app.googleClientId) {
29
+ if (!window.google) {
30
+ Notify.create({
31
+ message: "Google login is not available", //set script https://accounts.google.com/gsi/client in nuuxt.config.js
32
+ color: "negative",
33
+ icon: "sym_o_error",
34
+ position: "top",
35
+ timeout: 2000
36
+ });
37
+ return;
38
+ }
39
+ }
40
+
41
+ //google
42
+ google.accounts.id.initialize({
43
+ client_id: app.googleClientId,
44
+ callback: handleGoogleCredentialResponse,
45
+ });
46
+
47
+ google.accounts.id.renderButton(
48
+ document.getElementById('g_id_signin'),
49
+ {
50
+ type: 'profile',
51
+ shape: 'pill',
52
+ theme: 'outline',
53
+ text: 'signin_with',
54
+ size: 'large',
55
+ logo_alignment: 'left'
56
+ }
57
+ );
58
+
59
+ });
60
+
61
+ const unlink = async () => {
62
+ await m("unlinkGoogle");
63
+ my.gmail = null;
64
+ window.location.reload();
65
+ }
66
+
67
+ </script>
68
+ <template>
69
+ <l-card :bordered="false">
70
+
71
+ <template v-if="app.googleClientId">
72
+ <q-card-section v-if="my.gmail">
73
+ You have already linked your Google account.<br />
74
+
75
+ Your gmail is {{ my.gmail }}
76
+
77
+
78
+
79
+ <l-btn label="Unlink" @click="unlink" icon="sym_o_delete"></l-btn>
80
+ </q-card-section>
81
+
82
+ <q-card-section v-else>
83
+ Click the button below to link your Google account.
84
+ <div id="g_id_signin"></div>
85
+ </q-card-section>
86
+ </template>
87
+
88
+ <q-card-section v-else>
89
+ Google login is not available. Please set GOOGLE_CLIENT_ID in server settings.
90
+ </q-card-section>
91
+
92
+ </l-card>
93
+ </template>
@@ -23,6 +23,8 @@ const route = useRoute()
23
23
  replace />
24
24
  <q-route-tab name="bio" icon="sym_o_fingerprint" :label="$t('Bio')" to="/User/setting/bio-auth"
25
25
  exact replace />
26
+ <q-route-tab name="openid" icon="sym_o_key" :label="$t('Open ID')" to="/User/setting/open_id" exact replace />
27
+
26
28
  </q-tabs>
27
29
  </template>
28
30
 
@@ -121,6 +121,11 @@ function User_setting_information() {
121
121
  /* webpackChunkName: "User-setting-information" */ './pages/User/setting/information.vue'
122
122
  )
123
123
  }
124
+ function User_setting_open_id() {
125
+ return import(
126
+ /* webpackChunkName: "User-setting-open_id" */ './pages/User/setting/open_id.vue'
127
+ )
128
+ }
124
129
  function User_setting_password() {
125
130
  return import(
126
131
  /* webpackChunkName: "User-setting-password" */ './pages/User/setting/password.vue'
@@ -317,6 +322,11 @@ export default [
317
322
  path: 'information',
318
323
  component: User_setting_information,
319
324
  },
325
+ {
326
+ name: 'User-setting-open_id',
327
+ path: 'open_id',
328
+ component: User_setting_open_id,
329
+ },
320
330
  {
321
331
  name: 'User-setting-password',
322
332
  path: 'password',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.74",
3
+ "version": "0.0.76",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",