@simitgroup/simpleapp-generator 1.0.31 → 1.0.32

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.
@@ -7,14 +7,29 @@
7
7
  */
8
8
 
9
9
  // import MegaMenu from 'primevue/megamenu';
10
- import Menubar from 'primevue/menubar';
11
- const route = useRoute()
12
- const menus = getMenus(route.params.xorg)
10
+ // import Menubar from 'primevue/menubar';
11
+ // const route = useRoute()
12
+ // const menus = getMenus(route.params.xorg)
13
+ const logout = async () => {
14
+ const { signOut } = useAuth();
15
+ const { data } = await <any>useFetch('/api/auth/logout');
16
+ const addPath = encodeURIComponent("/login");
17
+ signOut({ redirect: false });
18
+ window.location.href = data?.value?.path + addPath;
19
+ };
13
20
  </script>
14
21
  <template>
15
- <header>
22
+ <!-- <header> -->
16
23
  <!-- <MegaMenu :model="getMenus()" orientation="horizontal" /> -->
17
- <Menubar :model="menus">
18
- </Menubar>
19
- </header>
24
+ <div class="bg-white border-b-2 border-b-gray-300 h-10 flex">
25
+
26
+ <div class="flex-1">
27
+ <NuxtLink to="/"><i class="pi pi-home m-2"></i>Home</NuxtLink>
28
+ </div>
29
+ <div class="flex-1"></div>
30
+ <button class="text-right" @click="logout()">
31
+ <i class="pi pi-sign-out "></i>logout
32
+ </button>
33
+ </div>
34
+ <!-- </header> -->
20
35
  </template>
@@ -5,15 +5,16 @@
5
5
  * last change 2023-09-09
6
6
  * author: Ks Tan
7
7
  */
8
- </script>
8
+ const menus = getMenus();
9
+ </script>
9
10
  <template>
10
11
  <div>
11
- <h1>index page</h1>
12
- <ul>
13
- <li><NuxtLink :external="true" to="/MS0xLTE" >MS0xLTE (1-1-1)</NuxtLink></li>
14
- <li><NuxtLink :external="true" to="/Mi0yLTI" >Mi0yLTI (2-2-2)</NuxtLink></li>
15
- </ul>
16
-
12
+
13
+
14
+ <div class="desktop-shortcut-link">
15
+ <div v-for="menu in menus[1].items" class="">
16
+ <NuxtLink :external="true" :to="menu.to">{{ menu.label }}</NuxtLink>
17
+ </div>
18
+ </div>
17
19
  </div>
18
-
19
20
  </template>
@@ -5,15 +5,68 @@
5
5
  * last change 2023-09-09
6
6
  * author: Ks Tan
7
7
  */
8
- </script>
8
+ import { ref, Ref } from "vue";
9
+ import { TenantDoc } from "../simpleapp/simpleappdocs/TenantDoc";
10
+ // import OrderList from 'primevue/orderlist';
11
+ import Panel from "primevue/panel";
12
+
13
+ const { $event, $listen } = useNuxtApp();
14
+ const route = useRoute();
15
+ const doc = new TenantDoc("", $event, $listen);
16
+ type tenantDataType = {
17
+ tenantId: number;
18
+ tenantCode: string;
19
+ tenantName: string;
20
+ xorg: string;
21
+ };
22
+ const initialtenant: tenantDataType[] = [];
23
+ const tenantlist = ref(initialtenant);
24
+
25
+ doc
26
+ .getApi()
27
+ .getMyTenant()
28
+ .then((res: any) => {
29
+ for (let i = 0; i < res.data.length; i++) {
30
+ const x = res.data[i];
31
+ const tmp: tenantDataType = {
32
+ xorg: x.xOrg,
33
+ tenantId: x.tenantId,
34
+ tenantCode: x.tenantCode,
35
+ tenantName: x.tenantName,
36
+ };
37
+ tenantlist.value.push(tmp);
38
+ }
39
+ console.log(tenantlist.value);
40
+ });
41
+ // const mytenant = doc.get
42
+ </script>
9
43
  <template>
10
44
  <div>
11
- <h1>index page</h1>
12
- <ul>
13
- <li><NuxtLink :external="true" to="/MS0xLTE" >MS0xLTE (1-1-1)</NuxtLink></li>
14
- <li><NuxtLink :external="true" to="/Mi0yLTI" >Mi0yLTI (2-2-2)</NuxtLink></li>
15
- </ul>
16
-
45
+
46
+ <Panel header="Tenant List">
47
+ <div>
48
+ <NuxtLink
49
+ v-for="item in tenantlist"
50
+ :external="true"
51
+ :to="item.xorg"
52
+ class="tenant-link"
53
+ >
54
+ <div class="flex flex-wrap p-2 align-items-center gap-3">
55
+ <div class="flex-1 flex flex-column gap-2">
56
+ <span class="font-bold">{{ item.tenantName }}</span>
57
+ <div class="flex align-items-center gap-2">
58
+ <span>{{ item.xorg }}</span>
59
+ </div>
60
+ </div>
61
+ <span class="font-bold text-900">{{ item.tenantCode }}</span>
62
+ </div>
63
+ </NuxtLink>
64
+ </div>
65
+ </Panel>
17
66
  </div>
18
-
19
67
  </template>
68
+ <style scoped>
69
+ .p-panel {
70
+ @apply m-2;
71
+ }
72
+ </style>
@@ -127,7 +127,8 @@ export default defineEventHandler(async (event) => {
127
127
  // console.log('#####################################')
128
128
 
129
129
  if (error.response?.status && error.response.status == '401') {
130
- return reject({ statusMessage: 'Unauthorized', statusCode: 401 });
130
+ //return reject({ statusMessage: 'Unauthorized', statusCode: 401 });
131
+ return sendRedirect(event, '/login', 401)
131
132
  // throw createError({ statusMessage: 'Unauthorized', statusCode: 401 })
132
133
  }
133
134
 
@@ -5,7 +5,7 @@
5
5
  button {
6
6
  @apply p-2 border-2
7
7
  }
8
- .simpleapp-input-container{
8
+ .simpleapp-input-container,.simpleapp-input-container,.simpleapp-input-container .simpleapp-inputfield{
9
9
  @apply flex flex-col
10
10
  }
11
11
  .simpleapp-input-container .p-chips ul{
@@ -33,4 +33,17 @@ button {
33
33
  }
34
34
  .bg-warning{
35
35
  @apply bg-orange-600 text-white
36
+ }
37
+
38
+ .desktop-shortcut-link{
39
+ @apply m-2 m-2 p-2 space-x-2 rounded-sm text-center grid grid-cols-4 gap-4
40
+ }
41
+ .desktop-shortcut-link div{
42
+ @apply bg-teal-300 p-2
43
+ }
44
+ .desktop-shortcut-link div:hover{
45
+ @apply bg-teal-600 p-2
46
+ }
47
+ .tenant-link:hover div{
48
+ @apply bg-gray-300
36
49
  }
package/tsconfig.json CHANGED
@@ -13,5 +13,8 @@
13
13
  "noImplicitAny": false,
14
14
  "strictBindCallApply": false,
15
15
  "paths": {"@": ["./"]}
16
- }
16
+ },
17
+ "exclude": [
18
+ "node_modules" , "./dist" , "./tools"
19
+ ]
17
20
  }
@@ -1,115 +0,0 @@
1
- import { Injectable, Scope } from '@nestjs/common';
2
- import Base64URL from '@darkwolf/base64url';
3
- import * as jwt from 'jsonwebtoken'
4
-
5
-
6
-
7
-
8
-
9
- @Injectable({
10
- scope: Scope.REQUEST,
11
- })
12
- export class User {
13
- private static instance: User;
14
- protected uid: string = '';
15
- protected uname: string = '';
16
- protected email: string = '';
17
- protected fullname:string=''
18
- protected xOrg: string = '';
19
- protected tenantId: number = 0;
20
- protected orgId: number = 0;
21
- protected branchId: number = 0;
22
- protected accessrights:any = {}
23
- protected token:string = ''
24
- protected refreshtoken:string = ''
25
- constructor() {}
26
- public static getInstance(): User {
27
- if (!User.instance) {
28
- User.instance = new User();
29
- }
30
- return User.instance;
31
- }
32
- setUserToken = (tokenstr: string) => {
33
- const tokeninfo = jwt.decode(tokenstr)
34
- // realm_access: {
35
- // roles: [
36
- // 'default-roles-simitdeveloper',
37
- // 'offline_access',
38
- // 'uma_authorization'
39
- // ]
40
- // },
41
- // resource_access: { account: { roles: [Array] } },
42
- // scope: 'openid email profile',
43
- // sid: '53192f53-d4af-413b-b8d7-1e186419fe53',
44
- // email_verified: false,
45
- // name: 'kstan kstan',
46
- // preferred_username: 'kstan',
47
- // given_name: 'kstan',
48
- // family_name: 'kstan',
49
- // email: 'kstan@simitgroup.com'
50
-
51
- const u = User.getInstance()
52
- u.token = tokenstr
53
- u.uid = tokeninfo.sub;
54
- u.email = tokeninfo.email
55
- u.uname = tokeninfo.preferred_username
56
- u.fullname = tokeninfo.name
57
- u.accessrights = tokeninfo.resource_access
58
- };
59
- getInfo = () => {
60
- return User.getInstance();
61
- };
62
- getBranchFilter = () => {
63
- return {
64
- tenantId: User.getInstance().tenantId,
65
- orgId: User.getInstance().orgId,
66
- branchId: User.getInstance().branchId,
67
- };
68
- };
69
- getTenantFilter = () => {
70
- return { tenantId: User.getInstance().tenantId };
71
- };
72
- getOrgFilter = () => {
73
- return {
74
- tenantId: User.getInstance().tenantId,
75
- orgId: User.getInstance().orgId,
76
- };
77
- };
78
-
79
- getCreateFilter = () => {
80
- const u = User.getInstance();
81
- return {
82
- tenantId: u.tenantId,
83
- orgId: u.orgId,
84
- branchId: u.branchId,
85
- createdby: u.uid,
86
- updatedby: u.uid,
87
- created: new Date().getTime().toString(),
88
- updated: new Date().getTime().toString(),
89
- };
90
- };
91
- getUpdateFilter = () => {
92
- const u = User.getInstance();
93
- return {
94
- updatedby: u.uid,
95
- updated: new Date().getTime().toString(),
96
- };
97
- };
98
- setXorg = (xorg) => {
99
- try {
100
- const decodedText: string = Base64URL.decodeText(xorg);
101
- const arrXorg = decodedText.split('-');
102
-
103
- if (arrXorg.length == 3) {
104
- const u = User.getInstance();
105
- u.tenantId = Number(arrXorg[0]);
106
- u.orgId = Number(arrXorg[1]);
107
- u.branchId = Number(arrXorg[2]);
108
- } else {
109
- throw 'invalid x-org';
110
- }
111
- } catch (err) {
112
- throw err;
113
- }
114
- };
115
- }