Initial commit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.directive('changePassword', changePasswordDirective)
|
||||
.controller('changePasswordCtrl', ['$scope', '$', '$http', '$translate', 'utilsService', changePasswordCtrl]);
|
||||
|
||||
function changePasswordDirective() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'profileSettings/html/ChangePasswordTemplate'
|
||||
};
|
||||
}
|
||||
|
||||
function changePasswordCtrl($scope, $, $http, $translate, utilsService) {
|
||||
$scope.changePassword = changePassword;
|
||||
$scope.showHideDialog = showHideDialog;
|
||||
$scope.isDialogVisible = false;
|
||||
|
||||
function changePassword() {
|
||||
const params = $.param({
|
||||
passwords: JSON.stringify($scope.data)
|
||||
});
|
||||
|
||||
$http({
|
||||
method: 'POST',
|
||||
data: params,
|
||||
url: 'utils/api/changePassword'
|
||||
}).then(showConfirmationMessage, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function showConfirmationMessage(response) {
|
||||
if(response.data && response.data.messages) {
|
||||
response.data.messages.forEach(messageData => {
|
||||
const message = $translate.instant('profile.forms.messages.' + messageData.message);
|
||||
utilsService.displayMessage(messageData.code, message);
|
||||
|
||||
if(messageData.code === 'success') {
|
||||
$scope.data = {};
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showHideDialog() {
|
||||
if($scope.data && Object.keys($scope.data).length === 3) {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.isDialogVisible = !$scope.isDialogVisible;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,80 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.directive('editProfile', editProfileDirective)
|
||||
.controller('editProfileCtrl', ['$scope', '$', '$http', '$translate', 'utilsService', editProfileCtrl]);
|
||||
|
||||
function editProfileDirective() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'profileSettings/html/EditProfileTemplate'
|
||||
};
|
||||
}
|
||||
|
||||
function editProfileCtrl($scope, $, $http, $translate, utilsService) {
|
||||
$scope.saveProfile = saveProfile;
|
||||
$scope.getProfile = getProfile;
|
||||
$scope.saveCompany = saveCompany;
|
||||
$scope.isCompanyAdmin = isCompanyAdmin;
|
||||
$scope.idUser = global.getParameterByName('idUser') || 0;
|
||||
|
||||
function isCompanyAdmin(){
|
||||
return $scope.data && (parseInt($scope.data.isCompanyAdmin) === 1 || $scope.data.userType === 'broker');
|
||||
}
|
||||
|
||||
function getProfile(){
|
||||
const params = $.param({
|
||||
idUser: $scope.idUser
|
||||
});
|
||||
|
||||
$http({
|
||||
method: 'POST',
|
||||
data: params,
|
||||
url: 'v2/profileSettings/api/getProfileInfo'
|
||||
}).then(setProfile, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function setProfile(response){
|
||||
if (response.data) {
|
||||
$scope.data = response.data;
|
||||
}
|
||||
}
|
||||
|
||||
function saveProfile() {
|
||||
const params = $.param({
|
||||
idUser: $scope.idUser,
|
||||
profile: JSON.stringify($scope.data)
|
||||
});
|
||||
|
||||
$http({
|
||||
method: 'POST',
|
||||
data: params,
|
||||
url: 'v2/profileSettings/api/saveProfileInfo'
|
||||
}).then(showConfirmationMessage, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function saveCompany() {
|
||||
const params = $.param({
|
||||
companyInfo: JSON.stringify({
|
||||
idCompany: $scope.data.idCompany,
|
||||
companyName: $scope.data.companyName,
|
||||
vatCode: $scope.data.vatCode
|
||||
})
|
||||
});
|
||||
|
||||
$http({
|
||||
method: 'POST',
|
||||
data: params,
|
||||
url: 'v2/profileSettings/api/saveCompanyInfo'
|
||||
}).then(showConfirmationMessage, utilsService.onHttpError);
|
||||
}
|
||||
|
||||
function showConfirmationMessage(response) {
|
||||
if(response.data && response.data.messages) {
|
||||
response.data.messages.forEach(messageData => {
|
||||
const message = $translate.instant('profile.forms.messages.' + messageData.message);
|
||||
utilsService.displayMessage(messageData.code, message);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,38 @@
|
||||
(function () {
|
||||
global.dashModule
|
||||
.directive('profileSettings', profileSettingsDirective)
|
||||
.controller('profileSettingsCtrl', ['$scope', profileSettingsCtrl]);
|
||||
|
||||
function profileSettingsDirective() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'profileSettings/html/ProfileSettingsTemplate'
|
||||
};
|
||||
}
|
||||
|
||||
function profileSettingsCtrl($scope) {
|
||||
$scope.isSubmoduleVisible = isSubmoduleVisible;
|
||||
$scope.setSubModule = setSubModule;
|
||||
$scope.subModule = global.getParameterByName('subModule') || 'editProfile';
|
||||
addUrlListener();
|
||||
|
||||
function addUrlListener() {
|
||||
window.addEventListener('popstate', function (e) {
|
||||
$scope.$evalAsync($scope => {
|
||||
$scope.subModule = e.state ? e.state.subModule : 'editProfile';
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function setSubModule($event) {
|
||||
$scope.subModule = $event.currentTarget.attributes.subModule.value;
|
||||
history.pushState({
|
||||
subModule: $scope.subModule
|
||||
}, null, '?subModule=' + $scope.subModule);
|
||||
}
|
||||
|
||||
function isSubmoduleVisible(subModule) {
|
||||
return subModule === $scope.subModule;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,26 @@
|
||||
@layer-background: rgba(255, 255, 255, 0.7);
|
||||
|
||||
.module-layer {
|
||||
position: relative;
|
||||
margin-top: 1%;
|
||||
background: @layer-background;
|
||||
margin-bottom: 3%;
|
||||
padding-bottom: 2%;
|
||||
}
|
||||
|
||||
#change-password-container {
|
||||
.module-layer;
|
||||
|
||||
.change-passwd-list {
|
||||
display: inline-block;
|
||||
padding: 2%;
|
||||
}
|
||||
|
||||
.passwords-container {
|
||||
padding-bottom: 1%;
|
||||
}
|
||||
}
|
||||
|
||||
#change-profile-container {
|
||||
.module-layer;
|
||||
}
|
||||
Reference in New Issue
Block a user