@zeedhi/teknisa-cli 1.58.0 → 1.60.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/teknisa-cli",
3
- "version": "1.58.0",
3
+ "version": "1.60.0",
4
4
  "description": "Teknisa CLI",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -34,5 +34,5 @@
34
34
  "/src",
35
35
  "/bin"
36
36
  ],
37
- "gitHead": "708b51c2be642855478411bf14293b8049bc1b56"
37
+ "gitHead": "3759059ab3dadb211faea82105972ebc6421c14b"
38
38
  }
@@ -1 +1,3 @@
1
- {}
1
+ {
2
+ "version": 2
3
+ }
@@ -26,6 +26,7 @@
26
26
  "@zeedhi/teknisa-components-common": "*",
27
27
  "@zeedhi/teknisa-components-vuetify": "*",
28
28
  "@zeedhi/tek-lib": "*",
29
+ "babel-loader": "^8.2.5",
29
30
  "eslint": "^7.16.0",
30
31
  "eslint-config-airbnb-typescript": "^12.0.0",
31
32
  "eslint-plugin-import": "2.22.1",
@@ -21,14 +21,16 @@ import Vue from 'vue';
21
21
  import Component from 'vue-class-component';
22
22
  import { ZdPage } from '@zeedhi/vue';
23
23
  import { TekLibAuth } from '@zeedhi/tek-lib';
24
+ import jsonMetadataLocal from './config/jsonMetadataLocal.json';
24
25
 
25
26
  @Component({
26
27
  components: { ZdPage },
27
28
  })
28
29
  export default class App extends Vue {
29
30
  public mainPage = {
31
+ local: false,
32
+ type: 'post',
30
33
  path: 'notfound',
31
- local: true,
32
34
  };
33
35
 
34
36
  private handleMessageEvent(event: any) {
@@ -46,11 +48,34 @@ export default class App extends Vue {
46
48
  if (params) {
47
49
  const page = typeof params === 'string' ? JSON.parse(params).page : params.page;
48
50
  if (page) {
49
- this.mainPage.path = `pages/${page}`;
51
+ const pagePath = `pages/${page}`;
52
+
53
+ const isLocal = jsonMetadataLocal.some((element: any) => element === page);
54
+
55
+ if (isLocal) {
56
+ this.setMainPageLocal(pagePath);
57
+ } else {
58
+ this.setMainPageBackend(pagePath);
59
+ }
50
60
  }
51
61
  }
52
62
  }
53
63
 
64
+ public setMainPageLocal(path: string) {
65
+ this.mainPage.local = true;
66
+ this.mainPage.type = 'get';
67
+ this.mainPage.path = path;
68
+ }
69
+
70
+ public setMainPageBackend(page: any) {
71
+ this.mainPage.local = false;
72
+ this.mainPage.type = 'post';
73
+ this.mainPage.path = '';
74
+ this.mainPage.params = { jsonPath: page };
75
+ this.mainPage.params.jsonPath = page;
76
+ this.mainPage.params.routePath = localStorage.getItem('MODULES_ROUTE_PATH');
77
+ }
78
+
54
79
  public created() {
55
80
  window.addEventListener('message', this.handleMessageEvent);
56
81
  if (process.env.NODE_ENV === 'production') {
@@ -1 +1,3 @@
1
- {}
1
+ {
2
+ "version": 2
3
+ }
@@ -26,6 +26,8 @@
26
26
  "@zeedhi/teknisa-components-common": "*",
27
27
  "@zeedhi/teknisa-components-vuetify": "*",
28
28
  "@zeedhi/tek-lib": "*",
29
+ "@zeedhi/zd-avatar": "*",
30
+ "babel-loader": "^8.2.5",
29
31
  "eslint": "^7.16.0",
30
32
  "eslint-config-airbnb-typescript": "^12.0.0",
31
33
  "eslint-plugin-import": "2.22.1",
@@ -97,19 +97,62 @@ export default class App extends Vue {
97
97
  ],
98
98
  rightSlot: [
99
99
  {
100
- name: 'username',
101
- component: 'ZdText',
102
- text: '{{AppController.userName}}',
103
- },
104
- {
105
- name: 'logout-button',
106
- component: 'ZdButton',
107
- icon: true,
108
- iconName: 'mdi-logout',
109
- events: {
110
- click: () => {
111
- TekLibAuth.logoutConfirm();
100
+ name: 'userInfo',
101
+ component: 'TekUserInfo',
102
+ minWidth: '280px',
103
+ showProfileChange: true,
104
+ user: '{{AppController.userName}}',
105
+ userImage: '',
106
+ aboutImage: '{{AppController.logo}}',
107
+ avatarProps: {
108
+ name: 'tekUserInfoAvatarProps',
109
+ component: 'ZdAvatar',
110
+ color: 'primary',
111
+ avatarSlot: [
112
+ {
113
+ name: 'tekUserInfoAvatarPropsTextSlot',
114
+ component: 'ZdText',
115
+ cssClass: 'white--text',
116
+ tag: 'h2',
117
+ text: '{{AppController.nameInitialLetter}}',
118
+ },
119
+ ],
120
+ },
121
+ topSlot: [
122
+ {
123
+ name: 'userInfoTopSlotList',
124
+ component: 'ZdList',
125
+ items: [
126
+ {
127
+ name: 'item1',
128
+ component: 'ZdListItem',
129
+ title: 'Exemplo 1',
130
+ prependIcon: 'mdi-account-convert',
131
+ cssClass: 'zd-px-2',
132
+ },
133
+ {
134
+ name: 'item2',
135
+ component: 'ZdListItem',
136
+ title: 'Exemplo 2',
137
+ prependIcon: 'mdi-application-cog',
138
+ cssClass: 'zd-px-2',
139
+ },
140
+ ],
112
141
  },
142
+ {
143
+ name: 'userInfoTopSlotDivider',
144
+ component: 'ZdDivider',
145
+ },
146
+ {
147
+ name: 'tekUserInfoList',
148
+ component: 'TekUserInfoList',
149
+ parentName: 'userInfo',
150
+ },
151
+ ],
152
+ bottomSlot: [],
153
+ events: {
154
+ onCreated: '{{AppController.userInfoOnCreated}}',
155
+ onLogoutClick: '{{AppController.userInfoOnLogoutClick}}',
113
156
  },
114
157
  },
115
158
  ],
@@ -1,13 +1,23 @@
1
- import { IEventParam, Metadata, Singleton } from '@zeedhi/core';
2
1
  import {
3
- Menu,
4
- MenuButton,
5
- AlertService,
6
- } from '@zeedhi/common';
2
+ Http,
3
+ IEventParam,
4
+ Metadata,
5
+ Singleton,
6
+ } from '@zeedhi/core';
7
+ import { Menu, MenuButton, AlertService } from '@zeedhi/common';
7
8
  import { TekLibAuth } from '@zeedhi/tek-lib';
9
+ import { TekUserInfo } from '@zeedhi/teknisa-components-common';
8
10
 
9
11
  @Singleton
10
12
  export class AppController {
13
+ public hasImage: boolean = false;
14
+
15
+ get notHasImage(): boolean {
16
+ return !this.hasImage;
17
+ }
18
+
19
+ public imagePath: string = '';
20
+
11
21
  public microservicePage: boolean = false;
12
22
 
13
23
  public toggleMenu({ component }: IEventParam<MenuButton>) {
@@ -27,7 +37,17 @@ export class AppController {
27
37
  }
28
38
 
29
39
  get userName() {
30
- return localStorage.getItem('LOGIN_USER_NAME');
40
+ const username = localStorage.getItem('LOGIN_USER_NAME') || '';
41
+ return this.getFormattedName(username);
42
+ }
43
+
44
+ get nameInitialLetter() {
45
+ const name = this.userName;
46
+ return name.slice(0, 1);
47
+ }
48
+
49
+ get logo() {
50
+ return '/assets/logo.png';
31
51
  }
32
52
 
33
53
  public showMessageExpiredMenu() {
@@ -44,4 +64,54 @@ export class AppController {
44
64
  public escAction() {
45
65
  AlertService.hide();
46
66
  }
67
+
68
+ public async userInfoOnCreated() {
69
+ const userInfoComponent = Metadata.getInstance<TekUserInfo>('userInfo');
70
+ const currentModule = this.getCurrentModule();
71
+
72
+ const { data } = await Http.get('/lib_generalInfo', { params: { currentModule } });
73
+ userInfoComponent.versionInfo = data.versionInfo;
74
+
75
+ if (data.userInfo.IMAGE) {
76
+ this.hasImage = true;
77
+ this.imagePath = data.userInfo.IMAGE;
78
+ } else {
79
+ this.hasImage = false;
80
+ }
81
+ }
82
+
83
+ public userInfoOnLogoutClick() {
84
+ TekLibAuth.logoutConfirm();
85
+ }
86
+
87
+ private getFormattedName(username: string): string {
88
+ const usernameLowerCase = username.toLowerCase();
89
+ const name = usernameLowerCase.replace(/(^\w{1})|(\s+\w{1})/g, (letter: string) => letter.toUpperCase());
90
+ const splitName = name.split(' ');
91
+ if (splitName.length > 1) {
92
+ const firstName = splitName.shift();
93
+ const lastName = splitName.pop();
94
+ let middleName = '';
95
+
96
+ splitName.forEach((item) => {
97
+ middleName += ` ${item.slice(0, 1)}. `;
98
+ });
99
+
100
+ return `${firstName} ${middleName} ${lastName}`;
101
+ }
102
+
103
+ return name;
104
+ }
105
+
106
+ private getCurrentModule(): string {
107
+ const { href } = window.location;
108
+ let currentModule = 'product';
109
+ if (href.includes('/modules/')) {
110
+ let auxHref = href.split('modules/');
111
+ auxHref = auxHref[1].split('/');
112
+ [currentModule] = auxHref;
113
+ }
114
+
115
+ return currentModule;
116
+ }
47
117
  }
@@ -3,6 +3,7 @@ import Zeedhi from '@zeedhi/vue';
3
3
  import ZeedhiComponents from '@zeedhi/vuetify';
4
4
  import TeknisaComponents from '@zeedhi/teknisa-components-vuetify';
5
5
  import TekLibComponents from '@zeedhi/tek-lib';
6
+ import { ZdAvatar } from '@zeedhi/zd-avatar';
6
7
  import { Icons } from '@zeedhi/common';
7
8
  import {
8
9
  Messages,
@@ -29,6 +30,8 @@ Vue.use(ZeedhiComponents);
29
30
  Vue.use(TeknisaComponents);
30
31
  Vue.use(TekLibComponents);
31
32
 
33
+ Vue.component('ZdAvatar', ZdAvatar);
34
+
32
35
  vuetify.framework.icons.values = Icons.getIcons() as any;
33
36
 
34
37
  Messages.add({
@@ -2,7 +2,6 @@ import Vue from 'vue';
2
2
  import Router from 'vue-router';
3
3
  import { Config, Http } from '@zeedhi/core';
4
4
  import { TekLibLocalStorage } from '@zeedhi/tek-lib';
5
- import { LoadingService } from '@zeedhi/common';
6
5
  import routes from './routes';
7
6
  import Store from '../store';
8
7
 
@@ -34,13 +33,7 @@ const callLibStartSessionFromModule = async function callLibStartSessionFromModu
34
33
 
35
34
  router.beforeEach(async (to, from, next) => {
36
35
  if (isOpeningNewModule(to, from) && TekLibLocalStorage.getItem('IS_NEXT')) {
37
- try {
38
- LoadingService.show();
39
- await callLibStartSessionFromModule(to);
40
- LoadingService.hide();
41
- } catch (e) {
42
- LoadingService.hide();
43
- }
36
+ await callLibStartSessionFromModule(to);
44
37
  }
45
38
 
46
39
  TekLibLocalStorage.setItem('IS_NEXT', true);
@@ -34,6 +34,8 @@ export default class Mircroservice extends Vue {
34
34
  PRODUCT_LOGO_URL: Config.env.product.logoUrl,
35
35
  PRODUCT_BACKGROUND_IMG_PATH: Config.env.loginBackgroundImgUrl,
36
36
  MODULES_THEME_COLOR: Config.env.product.modulesThemeColor.replace('#', ''),
37
+ MODULES_ROUTE_PATH: this.$route.path,
38
+ IS_NEXT: TekLibLocalStorage.getItem('IS_NEXT') !== false,
37
39
  });
38
40
 
39
41
  if (!this.page) {
@@ -50,5 +52,6 @@ export default class Mircroservice extends Vue {
50
52
  localStorage.setItem('PRODUCT_LOGO_URL', Config.env.product.logoUrl);
51
53
  localStorage.setItem('PRODUCT_BACKGROUND_IMG_PATH', Config.env.loginBackgroundImgUrl);
52
54
  localStorage.setItem('MODULES_THEME_COLOR', Config.env.product.modulesThemeColor);
55
+ localStorage.setItem('MODULES_ROUTE_PATH', this.$route.path);
53
56
  }
54
57
  }
@@ -1,12 +1,10 @@
1
1
  const editPackageJson = require('./editPackageJson')
2
2
  const renameGitIgnore = require('./renameGitIgnore')
3
- const editCliVersion = require('./editCliVersion')
4
3
 
5
4
  function run(config) {
6
5
  try {
7
6
  editPackageJson(config)
8
7
  renameGitIgnore(config)
9
- editCliVersion(config)
10
8
  } catch (e) {
11
9
  console.error(e)
12
10
  process.exit(1)