@sgcloud-sgsistemas/base 1.0.7 → 1.0.9
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 +35 -5
- package/src/modules/topbar/components/user/services/user.service.js +5 -1
- 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.9",
|
|
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
|
+
import Swal from 'sweetalert2'
|
|
3
|
+
|
|
1
4
|
const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
2
5
|
$scope.changeZIndex = false;
|
|
3
6
|
$scope.focus = '';
|
|
@@ -183,21 +186,48 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
|
183
186
|
$scope.organizationSelected = index;
|
|
184
187
|
};
|
|
185
188
|
|
|
186
|
-
$scope.changeOrganization = () => {
|
|
189
|
+
$scope.changeOrganization = async () => {
|
|
187
190
|
if ($scope.organizationSelected !== undefined) {
|
|
188
191
|
if (!$scope.user.changeOrganizationAction) {
|
|
189
192
|
mbUserService.setUser(this.config);
|
|
190
193
|
$scope.user = mbUserService.getUser();
|
|
191
194
|
}
|
|
192
|
-
|
|
195
|
+
let result = (await mbUserService.validTime(
|
|
196
|
+
$scope.user.otherOrganizations[$scope.organizationSelected].organizationHierarchyCode ||
|
|
197
|
+
$scope.user.otherOrganizations[$scope.organizationSelected].hierarchyCode,
|
|
198
|
+
SessionStorage.getItem('user').login,
|
|
199
|
+
SessionStorage.getItem('user').token
|
|
200
|
+
)).data
|
|
201
|
+
if(!result.valid){
|
|
202
|
+
$scope.outOfHourAccess(result.nextAccess || 'Próximo acesso: nunca. Entre em contato com o superior.')
|
|
203
|
+
return
|
|
204
|
+
} else {
|
|
205
|
+
$scope.user.changeOrganizationAction($scope.user.otherOrganizations[$scope.organizationSelected]);
|
|
206
|
+
}
|
|
193
207
|
}
|
|
194
208
|
};
|
|
195
209
|
|
|
210
|
+
$scope.outOfHourAccess = (text) => {
|
|
211
|
+
Swal.fire({
|
|
212
|
+
title: 'Aviso',
|
|
213
|
+
text: text,
|
|
214
|
+
icon: 'warning',
|
|
215
|
+
showCancelButton: false,
|
|
216
|
+
reverseButtons: true,
|
|
217
|
+
confirmButtonColor: '#3085d6',
|
|
218
|
+
cancelButtonColor: '#d33',
|
|
219
|
+
cancelButtonText: 'Cancelar',
|
|
220
|
+
confirmButtonText: 'Ok'
|
|
221
|
+
}).then((result) => {
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
|
|
196
225
|
this.$onInit = () => {
|
|
197
226
|
mbUserService.setComponentCallback((user) => { $scope.user = user; });
|
|
198
227
|
mbUserService.setUser(this.config);
|
|
228
|
+
mbUserService.initAppUrl(SessionStorage.getItem('LoginConfiguration').appUrl);
|
|
199
229
|
$scope.user = mbUserService.getUser();
|
|
200
|
-
if (
|
|
230
|
+
if (SessionStorage.getItem('currentCompany')) {
|
|
201
231
|
$scope.setCompanyInfo()
|
|
202
232
|
} else {
|
|
203
233
|
$scope.setCompanyInfoRecursive()
|
|
@@ -207,7 +237,7 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
|
207
237
|
|
|
208
238
|
$scope.setCompanyInfoRecursive = () => {
|
|
209
239
|
$timeout(() => {
|
|
210
|
-
if (
|
|
240
|
+
if (SessionStorage.getItem('currentCompany')) {
|
|
211
241
|
$scope.setCompanyInfo()
|
|
212
242
|
} else {
|
|
213
243
|
$scope.setCompanyInfoRecursive()
|
|
@@ -216,7 +246,7 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
|
|
|
216
246
|
}
|
|
217
247
|
|
|
218
248
|
$scope.setCompanyInfo = () => {
|
|
219
|
-
$scope.currentCompany =
|
|
249
|
+
$scope.currentCompany = SessionStorage.getItem('currentCompany').data
|
|
220
250
|
$scope.menu = {info:[
|
|
221
251
|
{title: 'Usuário', text: $scope.user.name},
|
|
222
252
|
{title: 'Nome abreviado', text: $scope.currentCompany.shortName},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const service = function UserService() {
|
|
1
|
+
const service = function UserService($http) {
|
|
2
2
|
this.user = {};
|
|
3
|
+
this.initAppUrl = (appUrl) => { this.user.appUrl = appUrl; };
|
|
3
4
|
this.onUpdateUser = () => { };
|
|
4
5
|
this.userComponentCallback = () => { };
|
|
5
6
|
/* Usamos o object assign para que não seja substituido o objeto inteiro ao passar apenas algumas configurações */
|
|
@@ -9,6 +10,9 @@ const service = function UserService() {
|
|
|
9
10
|
};
|
|
10
11
|
this.getUser = () => this.user;
|
|
11
12
|
this.setComponentCallback = (fn) => { this.userComponentCallback = fn; };
|
|
13
|
+
this.validTime = (oi, login, token) => {
|
|
14
|
+
return $http.get(this.user.appUrl.concat(`/api/user-access-time/user-invitation/${oi}?gumgaToken=${token}`), {params:{login}})
|
|
15
|
+
}
|
|
12
16
|
};
|
|
13
17
|
|
|
14
18
|
export default service;
|
|
@@ -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
|
|