adminforth 1.2.50 → 1.2.51

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.
@@ -121,6 +121,8 @@ export default class AdminForthRestAPI {
121
121
  usernameFieldName: usernameColumn.label,
122
122
  loginBackgroundImage: this.adminforth.config.auth.loginBackgroundImage,
123
123
  title: (_j = this.adminforth.config.customization) === null || _j === void 0 ? void 0 : _j.title,
124
+ demoCredentials: this.adminforth.config.auth.demoCredentials,
125
+ loginPromptHTML: this.adminforth.config.auth.loginPromptHTML,
124
126
  };
125
127
  }),
126
128
  });
@@ -375,6 +375,7 @@ async function deleteRecord(row) {
375
375
  primaryKey: row._primaryKeyValue,
376
376
  }
377
377
  });
378
+ console.log('safsa', res)
378
379
  if (!res.error){
379
380
  emits('update:records', true)
380
381
  showSuccesTost('Record deleted successfully')
@@ -1,7 +1,13 @@
1
1
  <template>
2
2
 
3
3
 
4
- <div id="toast-default" class="flex items-center w-full p-4 text-gray-500 bg-white rounded-lg shadow dark:text-gray-400 dark:bg-gray-800" role="alert">
4
+ <div id="toast-default" class="flex items-center w-full p-4 text-gray-500 rounded-lg shadow dark:text-gray-400 dark:bg-gray-800" role="alert"
5
+ :class="
6
+ {
7
+ 'danger': 'bg-red-100',
8
+ }[toast.variant]
9
+ "
10
+ >
5
11
  <div v-if="toast.variant == 'info'" class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-blue-500 bg-blue-100 rounded-lg dark:bg-blue-800 dark:text-blue-200">
6
12
  <svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 20">
7
13
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.147 15.085a7.159 7.159 0 0 1-6.189 3.307A6.713 6.713 0 0 1 3.1 15.444c-2.679-4.513.287-8.737.888-9.548A4.373 4.373 0 0 0 5 1.608c1.287.953 6.445 3.218 5.537 10.5 1.5-1.122 2.706-3.01 2.853-6.14 1.433 1.049 3.993 5.395 1.757 9.117Z"/>
@@ -27,8 +33,8 @@
27
33
  <span class="sr-only">Check icon</span>
28
34
  </div>
29
35
 
30
- <div class="ms-3 text-sm font-normal max-w-xs" v-if="toast.messageHtml" v-html="toast.messageHtml"></div>
31
- <div class="ms-3 text-sm font-normal max-w-xs" v-else>{{toast.message}}</div>
36
+ <div class="ms-3 text-sm font-normal max-w-xs pr-2" v-if="toast.messageHtml" v-html="toast.messageHtml"></div>
37
+ <div class="ms-3 text-sm font-normal max-w-xs pr-2" v-else>{{toast.message}}</div>
32
38
  <button @click="closeToast" type="button" class="ms-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex items-center justify-center h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700" >
33
39
  <svg class="w-3 h-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
34
40
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
@@ -61,6 +61,17 @@
61
61
  </div>
62
62
  </div>
63
63
 
64
+
65
+ <div v-if="coreStore.config?.loginPromptHTML"
66
+ class="flex items-center p-4 mb-4 text-sm text-gray-800 rounded-lg bg-gray-50 dark:bg-gray-800 dark:text-gray-400" role="alert"
67
+ >
68
+ <svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
69
+ <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
70
+ </svg>
71
+ <span class="sr-only">Info</span>
72
+ <div v-html="coreStore.config?.loginPromptHTML"></div>
73
+ </div>
74
+
64
75
  <button
65
76
  @click="login"
66
77
  type="submit" class="flex items-center justify-center gap-1 w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
@@ -106,8 +117,14 @@ const showPw = ref(false);
106
117
 
107
118
  const error = ref(null);
108
119
 
109
- onMounted(() => {
110
- coreStore.getPublicConfig();
120
+ onMounted(async () => {
121
+ await coreStore.getPublicConfig();
122
+ if (coreStore.config?.demoCredentials) {
123
+ console.log('Setting demo credentials');
124
+ const [username, password] = coreStore.config.demoCredentials.split(':');
125
+ usernameInput.value.value = username;
126
+ passwordInput.value.value = password;
127
+ }
111
128
  usernameInput.value.focus();
112
129
  });
113
130
 
@@ -124,7 +124,7 @@ import { IconPenSolid, IconTrashBinSolid } from '@iconify-prerendered/vue-flowbi
124
124
  import { onMounted, ref } from 'vue';
125
125
  import { useRoute,useRouter } from 'vue-router';
126
126
  import {callAdminForthApi} from '@/utils';
127
- import {showSuccesTost} from '@/composables/useFrontendApi';
127
+ import { showSuccesTost, showErrorTost } from '@/composables/useFrontendApi';
128
128
 
129
129
 
130
130
  const item = ref(null);
@@ -170,7 +170,7 @@ async function deleteRecord(row) {
170
170
  router.push({ name: 'resource-list', params: { resourceId: route.params.resourceId } });
171
171
  showSuccesTost('Record deleted successfully')
172
172
  } else {
173
- console.error(res.error)
173
+ showErrorTost(res.error)
174
174
  }
175
175
 
176
176
  } catch (e) {
@@ -147,6 +147,8 @@ export default class AdminForthRestAPI {
147
147
  usernameFieldName: usernameColumn.label,
148
148
  loginBackgroundImage: this.adminforth.config.auth.loginBackgroundImage,
149
149
  title: this.adminforth.config.customization?.title,
150
+ demoCredentials: this.adminforth.config.auth.demoCredentials,
151
+ loginPromptHTML: this.adminforth.config.auth.loginPromptHTML,
150
152
  };
151
153
  },
152
154
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.2.50",
3
+ "version": "1.2.51",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -375,6 +375,7 @@ async function deleteRecord(row) {
375
375
  primaryKey: row._primaryKeyValue,
376
376
  }
377
377
  });
378
+ console.log('safsa', res)
378
379
  if (!res.error){
379
380
  emits('update:records', true)
380
381
  showSuccesTost('Record deleted successfully')
@@ -1,7 +1,13 @@
1
1
  <template>
2
2
 
3
3
 
4
- <div id="toast-default" class="flex items-center w-full p-4 text-gray-500 bg-white rounded-lg shadow dark:text-gray-400 dark:bg-gray-800" role="alert">
4
+ <div id="toast-default" class="flex items-center w-full p-4 text-gray-500 rounded-lg shadow dark:text-gray-400 dark:bg-gray-800" role="alert"
5
+ :class="
6
+ {
7
+ 'danger': 'bg-red-100',
8
+ }[toast.variant]
9
+ "
10
+ >
5
11
  <div v-if="toast.variant == 'info'" class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-blue-500 bg-blue-100 rounded-lg dark:bg-blue-800 dark:text-blue-200">
6
12
  <svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 20">
7
13
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.147 15.085a7.159 7.159 0 0 1-6.189 3.307A6.713 6.713 0 0 1 3.1 15.444c-2.679-4.513.287-8.737.888-9.548A4.373 4.373 0 0 0 5 1.608c1.287.953 6.445 3.218 5.537 10.5 1.5-1.122 2.706-3.01 2.853-6.14 1.433 1.049 3.993 5.395 1.757 9.117Z"/>
@@ -27,8 +33,8 @@
27
33
  <span class="sr-only">Check icon</span>
28
34
  </div>
29
35
 
30
- <div class="ms-3 text-sm font-normal max-w-xs" v-if="toast.messageHtml" v-html="toast.messageHtml"></div>
31
- <div class="ms-3 text-sm font-normal max-w-xs" v-else>{{toast.message}}</div>
36
+ <div class="ms-3 text-sm font-normal max-w-xs pr-2" v-if="toast.messageHtml" v-html="toast.messageHtml"></div>
37
+ <div class="ms-3 text-sm font-normal max-w-xs pr-2" v-else>{{toast.message}}</div>
32
38
  <button @click="closeToast" type="button" class="ms-auto -mx-1.5 -my-1.5 bg-white text-gray-400 hover:text-gray-900 rounded-lg focus:ring-2 focus:ring-gray-300 p-1.5 hover:bg-gray-100 inline-flex items-center justify-center h-8 w-8 dark:text-gray-500 dark:hover:text-white dark:bg-gray-800 dark:hover:bg-gray-700" >
33
39
  <svg class="w-3 h-3" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
34
40
  <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
@@ -61,6 +61,17 @@
61
61
  </div>
62
62
  </div>
63
63
 
64
+
65
+ <div v-if="coreStore.config?.loginPromptHTML"
66
+ class="flex items-center p-4 mb-4 text-sm text-gray-800 rounded-lg bg-gray-50 dark:bg-gray-800 dark:text-gray-400" role="alert"
67
+ >
68
+ <svg class="flex-shrink-0 inline w-4 h-4 me-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
69
+ <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
70
+ </svg>
71
+ <span class="sr-only">Info</span>
72
+ <div v-html="coreStore.config?.loginPromptHTML"></div>
73
+ </div>
74
+
64
75
  <button
65
76
  @click="login"
66
77
  type="submit" class="flex items-center justify-center gap-1 w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
@@ -106,8 +117,14 @@ const showPw = ref(false);
106
117
 
107
118
  const error = ref(null);
108
119
 
109
- onMounted(() => {
110
- coreStore.getPublicConfig();
120
+ onMounted(async () => {
121
+ await coreStore.getPublicConfig();
122
+ if (coreStore.config?.demoCredentials) {
123
+ console.log('Setting demo credentials');
124
+ const [username, password] = coreStore.config.demoCredentials.split(':');
125
+ usernameInput.value.value = username;
126
+ passwordInput.value.value = password;
127
+ }
111
128
  usernameInput.value.focus();
112
129
  });
113
130
 
@@ -124,7 +124,7 @@ import { IconPenSolid, IconTrashBinSolid } from '@iconify-prerendered/vue-flowbi
124
124
  import { onMounted, ref } from 'vue';
125
125
  import { useRoute,useRouter } from 'vue-router';
126
126
  import {callAdminForthApi} from '@/utils';
127
- import {showSuccesTost} from '@/composables/useFrontendApi';
127
+ import { showSuccesTost, showErrorTost } from '@/composables/useFrontendApi';
128
128
 
129
129
 
130
130
  const item = ref(null);
@@ -170,7 +170,7 @@ async function deleteRecord(row) {
170
170
  router.push({ name: 'resource-list', params: { resourceId: route.params.resourceId } });
171
171
  showSuccesTost('Record deleted successfully')
172
172
  } else {
173
- console.error(res.error)
173
+ showErrorTost(res.error)
174
174
  }
175
175
 
176
176
  } catch (e) {
@@ -1058,6 +1058,17 @@ export type AdminForthConfig = {
1058
1058
  * This field will be used to display user name in the top right corner of the admin panel.
1059
1059
  */
1060
1060
  userFullNameField?: string,
1061
+
1062
+ /**
1063
+ * Pair of login and pass substitution for demo mode. Split by ':'
1064
+ * ! This option is for demo purposes only, never use it for your projects
1065
+ */
1066
+ demoCredentials?: string,
1067
+
1068
+ /**
1069
+ * Any prompt to show users on login. Supports HTML.
1070
+ */
1071
+ loginPromptHTML?: string,
1061
1072
  },
1062
1073
  /**
1063
1074
  * Array of resources which will be displayed in the admin panel.