@sgcloud-sgsistemas/base 1.0.8 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sgcloud-sgsistemas/base",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Base para os sistemas da mobiage",
5
5
  "repository": {
6
6
  "type": "private",
@@ -1,5 +1,5 @@
1
1
  import { SessionStorage } from "../../../../../helper/namespaces/sessionstorage";
2
-
2
+ import Swal from 'sweetalert2'
3
3
 
4
4
  const controller = function ($scope, $timeout, mbUserService, $state) {
5
5
  $scope.changeZIndex = false;
@@ -186,19 +186,46 @@ const controller = function ($scope, $timeout, mbUserService, $state) {
186
186
  $scope.organizationSelected = index;
187
187
  };
188
188
 
189
- $scope.changeOrganization = () => {
189
+ $scope.changeOrganization = async () => {
190
190
  if ($scope.organizationSelected !== undefined) {
191
191
  if (!$scope.user.changeOrganizationAction) {
192
192
  mbUserService.setUser(this.config);
193
193
  $scope.user = mbUserService.getUser();
194
194
  }
195
- $scope.user.changeOrganizationAction($scope.user.otherOrganizations[$scope.organizationSelected]);
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
+ }
196
207
  }
197
208
  };
198
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
+
199
225
  this.$onInit = () => {
200
226
  mbUserService.setComponentCallback((user) => { $scope.user = user; });
201
227
  mbUserService.setUser(this.config);
228
+ mbUserService.initAppUrl(SessionStorage.getItem('LoginConfiguration').appUrl);
202
229
  $scope.user = mbUserService.getUser();
203
230
  if (SessionStorage.getItem('currentCompany')) {
204
231
  $scope.setCompanyInfo()
@@ -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;