@sgcloud-sgsistemas/base 1.0.7 → 1.0.8
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 +4 -1
- package/src/helper/namespaces/sessionstorage.ts +33 -0
- package/src/modules/topbar/components/search/controllers/search.controller.js +3 -1
- package/src/modules/topbar/components/user/controllers/user.controller.js +6 -3
- package/src/modules/topbar/controllers/topbar.controller.js +5 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sgcloud-sgsistemas/base",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Base para os sistemas da mobiage",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "private",
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@mobiage/eslint-config": "^1.0.0",
|
|
25
|
+
"@types/crypto-js": "^4.0.2",
|
|
26
|
+
"@types/node": "^20.6.5",
|
|
25
27
|
"babel-core": "^6.26.0",
|
|
26
28
|
"babel-loader": "^7.1.2",
|
|
27
29
|
"babel-plugin-transform-runtime": "^6.23.0",
|
|
@@ -54,6 +56,7 @@
|
|
|
54
56
|
"angular-animate": "1.6.10",
|
|
55
57
|
"angular-hotkeys": "^1.7.0",
|
|
56
58
|
"angular-sanitize": "1.6.10",
|
|
59
|
+
"crypto-js": "^4.1.1",
|
|
57
60
|
"jquery": "^3.2.1",
|
|
58
61
|
"jquery-maskmoney": "^3.0.2",
|
|
59
62
|
"sanitize.css": "^5.0.0"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import CryptoJS from 'crypto-js'
|
|
2
|
+
|
|
3
|
+
export namespace SessionStorage {
|
|
4
|
+
const CIPHER_SECRET = process.env.CIPHER_SECRET
|
|
5
|
+
|
|
6
|
+
export function setItem(key, value) {
|
|
7
|
+
try {
|
|
8
|
+
if (CIPHER_SECRET){
|
|
9
|
+
const cipherText = CryptoJS.AES.encrypt(JSON.stringify(value), CIPHER_SECRET).toString();
|
|
10
|
+
localStorage.setItem(key, cipherText)
|
|
11
|
+
} else {
|
|
12
|
+
localStorage.setItem(key, JSON.stringify(value))
|
|
13
|
+
}
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.error(`Erro ao armazenar '${key}' no localStorage`)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getItem(key): any {
|
|
20
|
+
try {
|
|
21
|
+
if (CIPHER_SECRET){
|
|
22
|
+
const cipherText = localStorage.getItem(key)
|
|
23
|
+
const cipher = CryptoJS.AES.decrypt(cipherText, CIPHER_SECRET)
|
|
24
|
+
return JSON.parse(cipher.toString(CryptoJS.enc.Utf8))
|
|
25
|
+
} else {
|
|
26
|
+
return JSON.parse(localStorage.getItem(key))
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
const localData: any = localStorage.getItem(key)
|
|
30
|
+
return localData !== 'undefined' ? localData : null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SessionStorage } from "../../../../../helper/namespaces/sessionstorage";
|
|
2
|
+
|
|
1
3
|
const controller = function ($scope, $timeout, mbSidemenuService, hotkeys) {
|
|
2
4
|
$scope.searchValue = '';
|
|
3
5
|
$scope.data = [];
|
|
@@ -276,7 +278,7 @@ const controller = function ($scope, $timeout, mbSidemenuService, hotkeys) {
|
|
|
276
278
|
$scope.onFocusInput = () => { };
|
|
277
279
|
|
|
278
280
|
$scope.isCompanyInvalid = () => {
|
|
279
|
-
return
|
|
281
|
+
return SessionStorage.getItem("isCompanyInvalid")
|
|
280
282
|
};
|
|
281
283
|
|
|
282
284
|
this.$onInit = () => {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { SessionStorage } from "../../../../../helper/namespaces/sessionstorage";
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
2
5
|
$scope.changeZIndex = false;
|
|
3
6
|
$scope.focus = '';
|
|
@@ -197,7 +200,7 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
|
197
200
|
mbUserService.setComponentCallback((user) => { $scope.user = user; });
|
|
198
201
|
mbUserService.setUser(this.config);
|
|
199
202
|
$scope.user = mbUserService.getUser();
|
|
200
|
-
if (
|
|
203
|
+
if (SessionStorage.getItem('currentCompany')) {
|
|
201
204
|
$scope.setCompanyInfo()
|
|
202
205
|
} else {
|
|
203
206
|
$scope.setCompanyInfoRecursive()
|
|
@@ -207,7 +210,7 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
|
207
210
|
|
|
208
211
|
$scope.setCompanyInfoRecursive = () => {
|
|
209
212
|
$timeout(() => {
|
|
210
|
-
if (
|
|
213
|
+
if (SessionStorage.getItem('currentCompany')) {
|
|
211
214
|
$scope.setCompanyInfo()
|
|
212
215
|
} else {
|
|
213
216
|
$scope.setCompanyInfoRecursive()
|
|
@@ -216,7 +219,7 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
|
216
219
|
}
|
|
217
220
|
|
|
218
221
|
$scope.setCompanyInfo = () => {
|
|
219
|
-
$scope.currentCompany =
|
|
222
|
+
$scope.currentCompany = SessionStorage.getItem('currentCompany').data
|
|
220
223
|
$scope.menu = {info:[
|
|
221
224
|
{title: 'Usuário', text: $scope.user.name},
|
|
222
225
|
{title: 'Nome abreviado', text: $scope.currentCompany.shortName},
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SessionStorage } from "../../../helper/namespaces/sessionstorage";
|
|
2
|
+
|
|
1
3
|
const controller = function (mbSidemenuService) {
|
|
2
4
|
const vm = this;
|
|
3
5
|
|
|
@@ -14,13 +16,13 @@ const controller = function (mbSidemenuService) {
|
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
vm.isOnline = () => {
|
|
17
|
-
const onlineStatus = JSON.parse(
|
|
19
|
+
const onlineStatus = JSON.parse(SessionStorage.getItem('online-status'))
|
|
18
20
|
return onlineStatus && onlineStatus.online
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
vm.changeStatusOnline = () => {
|
|
22
|
-
const onlineStatus = JSON.parse(
|
|
23
|
-
|
|
24
|
+
const onlineStatus = JSON.parse(SessionStorage.getItem('online-status'))
|
|
25
|
+
SessionStorage.setItem('online-status', JSON.stringify({change: true, online: !(onlineStatus && onlineStatus.online)}))
|
|
24
26
|
}
|
|
25
27
|
};
|
|
26
28
|
|