From 42d77cf0979a4c92ab6e423e3281b3e1353b82a4 Mon Sep 17 00:00:00 2001 From: Edoardo Spadoni Date: Mon, 11 Mar 2024 10:54:34 +0100 Subject: [PATCH] wizard. added nethlink configuration button --- .../controllers/configurations/preferences.js | 35 +++++++++++- wizard/app/scripts/services/userservice.js | 30 +++++++++++ .../app/views/configurations/preferences.html | 53 ++++++++++++++++--- 3 files changed, 110 insertions(+), 8 deletions(-) diff --git a/wizard/app/scripts/controllers/configurations/preferences.js b/wizard/app/scripts/controllers/configurations/preferences.js index 7129555e..7d1a919c 100644 --- a/wizard/app/scripts/controllers/configurations/preferences.js +++ b/wizard/app/scripts/controllers/configurations/preferences.js @@ -38,7 +38,7 @@ angular.module('nethvoiceWizardUiApp') $scope.availableUserFilters = ['all', 'configured', 'unconfigured'] $scope.availableUserFiltersNumbers = ['username', 'displayname', 'default_extension', 'lname']; $scope.usersFilterNumbersOrd = false; - + $scope.usersFilter = $scope.availableUserFilters[0] $scope.usersFilterNumbers = $scope.availableUserFiltersNumbers[0] @@ -53,7 +53,7 @@ angular.module('nethvoiceWizardUiApp') return true } }; - + $rootScope.$on('scrollingContainerView', function () { if($scope.allUsers){ if ($scope.allUsers.length > $scope.usersLimit) { @@ -113,6 +113,14 @@ angular.module('nethvoiceWizardUiApp') } $scope.currentUser.webRtcState = false }) + UserService.getNethLinkExtension($scope.currentUser.default_extension).then(function (res) { + $scope.currentUser.nethLinkState = true + }, function (err) { + if (err.status != 404) { + console.log(err) + } + $scope.currentUser.nethLinkState = false + }) UserService.getMobileExtension($scope.currentUser.default_extension).then(function (res) { $scope.currentUser.mobileAppState = true }, function (err) { @@ -572,6 +580,29 @@ angular.module('nethvoiceWizardUiApp') } } + $scope.setNethLink = function (event, state) { + $scope.currentUser.setNethLinkInAction = true + if ($scope.currentUser.nethLinkState) { + UserService.createNethLinkExtension({ + extension: $scope.currentUser.default_extension + }).then(function (res) { + $scope.currentUser.setNethLinkInAction = false + getAllUsers(false) + }, function (err) { + console.log(err) + $scope.currentUser.setNethLinkInAction = false + }) + } else { + UserService.deleteNethLinkExtension($scope.currentUser.default_extension).then(function (res) { + $scope.currentUser.setNethLinkInAction = false + getAllUsers(false) + }, function (err) { + console.log(err) + $scope.currentUser.setNethLinkInAction = false + }) + } + } + $scope.setProfile = function () { ProfileService.setUserProfile($scope.currentUser.id, { profile_id: $scope.currentUser.profile diff --git a/wizard/app/scripts/services/userservice.js b/wizard/app/scripts/services/userservice.js index 0a0eac55..c0f7778d 100644 --- a/wizard/app/scripts/services/userservice.js +++ b/wizard/app/scripts/services/userservice.js @@ -219,6 +219,36 @@ angular.module('nethvoiceWizardUiApp') }); }; + this.getNethLinkExtension = function (mainextension) { + return $q(function (resolve, reject) { + RestService.get('/nethlink/' + mainextension).then(function (res) { + resolve(res); + }, function (err) { + reject(err); + }); + }); + }; + + this.createNethLinkExtension = function (obj) { + return $q(function (resolve, reject) { + RestService.post('/nethlink', obj).then(function (res) { + resolve(res); + }, function (err) { + reject(err); + }); + }); + }; + + this.deleteNethLinkExtension = function (mainextension) { + return $q(function (resolve, reject) { + RestService.delete('/nethlink/' + mainextension).then(function (res) { + resolve(res); + }, function (err) { + reject(err); + }); + }); + }; + this.retrieveFinalInfo = function () { return $q(function (resolve, reject) { RestService.get('/final').then(function (res) { diff --git a/wizard/app/views/configurations/preferences.html b/wizard/app/views/configurations/preferences.html index 14172dd2..8943496a 100644 --- a/wizard/app/views/configurations/preferences.html +++ b/wizard/app/views/configurations/preferences.html @@ -306,7 +306,7 @@

{{'Users Configuration