@sgcloud-sgsistemas/base 1.0.6 → 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 +10 -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 = '';
|
|
@@ -185,6 +188,10 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
|
185
188
|
|
|
186
189
|
$scope.changeOrganization = () => {
|
|
187
190
|
if ($scope.organizationSelected !== undefined) {
|
|
191
|
+
if (!$scope.user.changeOrganizationAction) {
|
|
192
|
+
mbUserService.setUser(this.config);
|
|
193
|
+
$scope.user = mbUserService.getUser();
|
|
194
|
+
}
|
|
188
195
|
$scope.user.changeOrganizationAction($scope.user.otherOrganizations[$scope.organizationSelected]);
|
|
189
196
|
}
|
|
190
197
|
};
|
|
@@ -193,7 +200,7 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
|
193
200
|
mbUserService.setComponentCallback((user) => { $scope.user = user; });
|
|
194
201
|
mbUserService.setUser(this.config);
|
|
195
202
|
$scope.user = mbUserService.getUser();
|
|
196
|
-
if (
|
|
203
|
+
if (SessionStorage.getItem('currentCompany')) {
|
|
197
204
|
$scope.setCompanyInfo()
|
|
198
205
|
} else {
|
|
199
206
|
$scope.setCompanyInfoRecursive()
|
|
@@ -203,7 +210,7 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
|
203
210
|
|
|
204
211
|
$scope.setCompanyInfoRecursive = () => {
|
|
205
212
|
$timeout(() => {
|
|
206
|
-
if (
|
|
213
|
+
if (SessionStorage.getItem('currentCompany')) {
|
|
207
214
|
$scope.setCompanyInfo()
|
|
208
215
|
} else {
|
|
209
216
|
$scope.setCompanyInfoRecursive()
|
|
@@ -212,7 +219,7 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
|
212
219
|
}
|
|
213
220
|
|
|
214
221
|
$scope.setCompanyInfo = () => {
|
|
215
|
-
$scope.currentCompany =
|
|
222
|
+
$scope.currentCompany = SessionStorage.getItem('currentCompany').data
|
|
216
223
|
$scope.menu = {info:[
|
|
217
224
|
{title: 'Usuário', text: $scope.user.name},
|
|
218
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
|
|