From 9aea9226345f5cbbb4c4b867739392b584f3ba4b Mon Sep 17 00:00:00 2001 From: "kuldeep.arora" Date: Thu, 6 Sep 2018 10:35:47 +0530 Subject: [PATCH] Added local and UTC Timezone clock --- app/index.html | 5 + app/js/app.js | 4 +- .../accountSetting/accountSetting.Controller.js | 101 ++++++++++++++++++--- app/partials/accountSetting/accountSetting.html | 24 +++-- app/partials/login/login.controller.js | 4 +- app/partials/main/main.controller.js | 25 ++++- app/partials/main/main.html | 20 +++- bower.json | 3 +- 8 files changed, 159 insertions(+), 27 deletions(-) diff --git a/app/index.html b/app/index.html index 9f3bf62..5192d1b 100644 --- a/app/index.html +++ b/app/index.html @@ -249,5 +249,10 @@ + + + + + \ No newline at end of file diff --git a/app/js/app.js b/app/js/app.js index 7cc48ea..85b4842 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -1,7 +1,7 @@ 'use strict'; - angular.module('acufuel', ['nvd3', 'ngCookies', 'ngResource', 'ngSanitize', 'ui.router', 'ngAnimate', 'ui.bootstrap', 'xeditable', 'ui.toggle', 'ngTable', 'ui.select2', 'ckeditor', 'ui.calendar', 'ngDragDrop', 'ui.select']) + angular.module('acufuel', ['nvd3', 'ngCookies', 'ngResource', 'ngSanitize', 'ui.router', 'ngAnimate', 'ui.bootstrap', 'xeditable', 'ui.toggle', 'ngTable', 'ui.select2', 'ckeditor', 'ui.calendar', 'ngDragDrop', 'ui.select','ds.clock']) .config(['$httpProvider', function($httpProvider) { $httpProvider.defaults.withCredentials = true; @@ -9,7 +9,7 @@ $httpProvider.interceptors.push('httpRequestInterceptor'); }]) - + .factory('httpRequestInterceptor', ['$q', '$rootScope', '$location', function($q, $rootScope, $location) { return { request: function($config) { diff --git a/app/partials/accountSetting/accountSetting.Controller.js b/app/partials/accountSetting/accountSetting.Controller.js index caf9968..48a677e 100644 --- a/app/partials/accountSetting/accountSetting.Controller.js +++ b/app/partials/accountSetting/accountSetting.Controller.js @@ -16,15 +16,31 @@ } $scope.userid = JSON.parse(localStorage.getItem('userProfileId')); - if($scope.userid && $scope.userid != null && $scope.userid != undefined){ - var id = $scope.userid; - AccountSettingService.loginUserData(id).then(function(result) { - $scope.userData = result; - $scope.userData.status = $scope.userData.account.user.status.toLowerCase(); - $scope.userData.userType = $scope.userData.userType.type.toLowerCase(); - }) + + //call this function after upload data + function getLoginUserData(){ + + if($scope.userid && $scope.userid != null && $scope.userid != undefined){ + var id = $scope.userid; + AccountSettingService.loginUserData(id).then(function(result) { + if(result.userTimeZone.slice(0,1)==="P"){ + + result.userTimeZone = result.userTimeZone.replace("P","+"); + + }else if(result.userTimeZone.slice(0,1)==="M"){ + + result.userTimeZone = result.userTimeZone.replace("M","-"); + } + $scope.userData = result; + $scope.userData.status = $scope.userData.account.user.status.toLowerCase(); + $scope.userData.userType = $scope.userData.userType.type.toLowerCase(); + }) + } } + getLoginUserData(); + + AccountSettingService.getProducts().then(function(result) { $scope.productList = result; for(var i=0;i<$scope.productList.length;i++){ @@ -45,17 +61,29 @@ $scope.addArray[index].name = productlist[index].name; $scope.addArray[index].status = productlist[index].status; $scope.productData.productList = $scope.addArray; - console.log($scope.productData) + // console.log($scope.productData) } $scope.updateUser = function(){ + window.localStorage.setItem('userTimeZone',JSON.stringify($scope.userData.userTimeZone)); + //Database not save the = and - sign of timezone offset + if($scope.userData.userTimeZone.slice(0,1)==="+"){ + + $scope.userData.userTimeZone = $scope.userData.userTimeZone.replace("+","P"); + + }else if($scope.userData.userTimeZone.slice(0,1)==="-"){ + + $scope.userData.userTimeZone = $scope.userData.userTimeZone.replace("-","M"); + } + var updateData = "companyName=" + $scope.userData.companyName + "&username=" + $scope.userData.username + "&firstName=" + $scope.userData.firstName + "&lastName=" + $scope.userData.lastName + "&phone=" + $scope.userData.phone + "&mobile=" + $scope.userData.mobile - + "&status=" + $scope.userData.status + "&userType=" + $scope.userData.userType + "&userTypeId=" + $scope.userData.userType.id + "&userProfileId=" + $scope.userid; + + "&status=" + $scope.userData.status + "&userType=" + $scope.userData.userType + "&userTypeId=" + $scope.userData.userType.id + "&userProfileId=" + $scope.userid + "&userTimeZone=" + $scope.userData.userTimeZone; + // console.log("======updateData===",updateData) AccountSettingService.updateUserProfile(updateData).then(function(result) { - + AccountSettingService.updateProducts($scope.productData).then(function(result) { toastr.success(''+result.success+'', { closeButton: true @@ -63,8 +91,12 @@ window.localStorage.setItem('currentUserName', JSON.stringify($scope.userData.firstName +' '+ $scope.userData.lastName)); window.localStorage.setItem('companyName', JSON.stringify($scope.userData.companyName)); $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); - $scope.companyName= JSON.parse(localStorage.getItem('companyName')) + $scope.companyName= JSON.parse(localStorage.getItem('companyName')); + $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone')); + //console.log("====value after update===",$scope.userTimeZone ) + window.localStorage.removeItem('userTime'); $scope.testFunction(); + getLoginUserData(); }) }) @@ -84,7 +116,7 @@ } $scope.checkEmail = function(email, type) { - console.log(type) + //console.log(type) AccountSettingService.checkEmail(email).then(function(result) { if(result.status == 'ACTIVE'){ toastr.error('Email already exists.', { @@ -106,8 +138,7 @@ }) }else{ if (validateEmail($scope.accountdata.userName)) { - console.log("checkbox",$scope.accountdata.allowEpd ,$scope.accountdata.allowFma -) + //console.log("checkbox",$scope.accountdata.allowEpd ,$scope.accountdata.allowFma) AccountSettingService.addAdditionalAccount($scope.accountdata).then(function(result) { getAdditionalAccounts(); $scope.accountdata = {}; @@ -163,13 +194,14 @@ } }) } + $scope.cancelDelete = function(){ $('#delete1').css('display', 'none'); } $scope.resetPassword = function(email) { - console.log("emailid",email) + //console.log("emailid",email) AccountSettingService.resetPassword(email).then(function(result){ if(typeof result == 'object') { toastr.info("Password generated successfully. Please check your email for new password"); @@ -181,7 +213,46 @@ }) } + + $scope.timeZoneList = [{name:'(GMT-12:00) International Date Line West',value:'-12.00'}, + {name:'(GMT-11:00) Midway Island, Samoa',value:'-11.00'}, + {name:'(GMT-10:00) Hawaii',value :'-10.00'}, + {name:'(GMT-09:30) Pacific/Marquesas (French Polynesia)',value :'-09.30'}, + {name:'(GMT-09:00) Pacific/Gambier(French Polynesia)(US)',value :'-09.00'}, + {name:'(GMT-08:00) Alaska',value :'-08.00'}, + {name:'(GMT-07:00) Arizona,(US and Canada)',value :'-07.00'}, + {name:'(GMT-06:00) (Central America),Chihuahua,Saskatchewan,Ecuador',value :'-06.00'}, + {name:'(GMT-05:00) Central Time (US and Canada) Bogota, Mexico City,Lima,Brazil, Quito',value :'-05.00'}, + {name:'(GMT-04:00) Eastern Time (US and Canada),Caracas, La Paz,Indiana (East)',value :'-04.00'}, + {name:'(GMT-03:00) Atlantic Time (Canada),Santiago,Brasilia,Buenos Aires',value :'-03.00'}, + {name:'(GMT-02:30) Newfoundland and Labrador,(Canada)',value :'-02.30'}, + {name:'(GMT-02:00) Mid-Atlantic,Greenland',value :'-02.00'}, + {name:'(GMT-01:00) Cape Verde Islands',value :'-01.00'}, + {name:'(GMT) Azores,Dublin, Edinburgh, Lisbon, London',value :'00.00'}, + {name:'(GMT+01:00) West Central Africa,Canary Islands,Casablanca, Monrovia',value :'+01.00'}, + {name:'(GMT+02:00) Brussels,Amsterdam,Harare,Madrid,Paris,Cairo,Belgrade',value :'+02.00'}, + {name:'(GMT+03:00) Moscow,Jerusalem,St.Petersburg, Athens,Baghdad,Kuwait,Helsinki,Nairobi',value :'+03.00'}, + {name:'(GMT+04:00) Armenia,Azerbaijan,UAE,(Russia)',value :'+04.00'}, + {name:'(GMT+04:30) Kabul,(Afghanistan)',value :'+04.30'}, + {name:'(GMT+05:00) Islamabad, Karachi, Tashkent (Pakistan)',value :'+05.00'}, + {name:'(GMT+05:30) Chennai,New Delhi(India),(Sri Lanka)',value :'+05.30'}, + {name:'(GMT+05:45) Kathmandu (Nepal)',value :'+05.45'}, + {name:'(GMT+06:00) Astana,Kazakhstan,Dhaka(Bangladesh),(Bhutan),(Russia)',value :'+06.00'}, + {name:'(GMT+06:30) Yangon Rangoon (Myanmar)',value :'+06.30'}, + {name:'(GMT+07:00) Laos,Krasnoyarsk,Hanoi,Bangkok(Thailand),Jakarta(Indonesia)',value :'+07.00'}, + {name:'(GMT+08:00) Perth(Western Australia),Beijing(China),Kuala Lumpur(Singapore),(Malaysia)',value :'+08.00'}, + {name:'(GMT+08:45) Australia/Eucla',value :'+08.45'}, + {name:'(GMT+09:00) Japan/North Korea/South Korea/East Timor',value :'+09.00'}, + {name:'(GMT+09:30) Adelaide/Darwin(Australia)',value :'+09.30' }, + {name:'(GMT+10:00) Guam, Port Moresby,Hobart,Vladivostok,Brisbane,Melbourne(Australia),Papua New Guinea',value :'+10.00'}, + {name:'(GMT+10:30) Australia/Lord_Howe',value :'+10.30'}, + {name:'(GMT+11:00) Magadan, Solomon Islands, New Caledonia',value :'+11.00'}, + {name:'(GMT+12:00) Auckland, Wellington,Fiji Islands, Kamchatka, Marshall Islands',value :'+12.00'}, + {name:'(GMT+12:45) Pacific/Chatham, New Zealand',value :'+12.45'}, + {name:'(GMT+13:00) Nuku alofa,Samoa,Tonga',value :'+13.00'}, + {name:'(GMT+14:00) Pacific/Kiritimati',value :'+14.00'}] + } })(); diff --git a/app/partials/accountSetting/accountSetting.html b/app/partials/accountSetting/accountSetting.html index ef6701f..5a5d793 100644 --- a/app/partials/accountSetting/accountSetting.html +++ b/app/partials/accountSetting/accountSetting.html @@ -27,16 +27,27 @@
-
- +
+ + + +
-
-
+
@@ -261,4 +272,5 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/app/partials/login/login.controller.js b/app/partials/login/login.controller.js index b5e0e9d..d294471 100644 --- a/app/partials/login/login.controller.js +++ b/app/partials/login/login.controller.js @@ -34,12 +34,14 @@ $state.go('resetPassword'); } else { LoginService.authenticate().then(function(result){ + window.localStorage.setItem("userTime", JSON.stringify(result.userProfile.userTimeZone)); + var currentUserDetail = JSON.parse(window.localStorage.getItem("currentUser")); if(currentUserDetail.type === 'ADDITIONAL'){ var email = $scope.data.username; //console.log("hi",email) LoginService.getAdditionalAccess(email).then(function(result){ - console.log("getaccess",result) + // console.log("getaccess",result) window.localStorage.setItem("EPDAccess", JSON.stringify(result.allowEpd)); window.localStorage.setItem("FMAAccess", JSON.stringify(result.allowFma)); }) diff --git a/app/partials/main/main.controller.js b/app/partials/main/main.controller.js index 863d149..8221552 100644 --- a/app/partials/main/main.controller.js +++ b/app/partials/main/main.controller.js @@ -5,18 +5,41 @@ .controller('MainController', [ '$scope', '$filter','$rootScope','$state', '$window', '$interval', MainController]); function MainController($scope, $filter, $rootScope,$state, $window, $interval) { - + $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); $scope.companyName = JSON.parse(localStorage.getItem('companyName')); var User = JSON.parse(localStorage.getItem('currentUser')); + + //for login userTime from GetAPI timezone + var tempuserTime = JSON.parse(localStorage.getItem('userTime')); + + if (tempuserTime != null) { + if (tempuserTime.slice(0, 1) === "P") { + $scope.userTimeZone = tempuserTime.replace("P", "+"); + console.log("==p===",$scope.userTimeZone) + } else if (tempuserTime.slice(0, 1) === "M") { + $scope.userTimeZone = tempuserTime.replace("M", "-"); + console.log("==M===",$scope.userTimeZone) + } + + } else { + + $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone')); + console.log("===$scope.userTimeZone==",$scope.userTimeZone) + } + if(User.type === 'ADDITIONAL'){ $scope.companyName = $scope.currentUserName; } + $scope.testFunction = function(){ $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName')); $scope.companyName = JSON.parse(localStorage.getItem('companyName')); + $scope.userTimeZone = JSON.parse(localStorage.getItem('userTimeZone')); + console.log("===$scope.userTimeZone test==",$scope.userTimeZone) + } $scope.logout = function(){ diff --git a/app/partials/main/main.html b/app/partials/main/main.html index f868448..39f2a00 100644 --- a/app/partials/main/main.html +++ b/app/partials/main/main.html @@ -1,4 +1,11 @@ +