text: "use strict";var ApplicationConfiguration=function(){var applicationModuleName="hdnotify",applicationModuleVendorDependencies=["ngResource","ngCookies","ngAnimate","ngTouch","ngSanitize","ui.router","ui.bootstrap","ui.utils","ui.bootstrap.datetimepicker","simplePagination","angular-confirm"],registerModule=function(moduleName,dependencies){angular.module(moduleName,dependencies||[]),angular.module(applicationModuleName).requires.push(moduleName)};return{applicationModuleName:applicationModuleName,applicationModuleVendorDependencies:applicationModuleVendorDependencies,registerModule:registerModule}}();angular.module(ApplicationConfiguration.applicationModuleName,ApplicationConfiguration.applicationModuleVendorDependencies),angular.module(ApplicationConfiguration.applicationModuleName).config(["$locationProvider",function($locationProvider){$locationProvider.hashPrefix("!")}]),angular.element(document).ready(function(){"#_=_"===window.location.hash&&(window.location.hash="#!"),angular.bootstrap(document,[ApplicationConfiguration.applicationModuleName])}),ApplicationConfiguration.registerModule("core"),ApplicationConfiguration.registerModule("notices"),ApplicationConfiguration.registerModule("templates"),ApplicationConfiguration.registerModule("users"),angular.module("core").config(["$stateProvider","$urlRouterProvider",function($stateProvider,$urlRouterProvider){$urlRouterProvider.otherwise("/"),$stateProvider.state("home",{url:"/",templateUrl:"modules/core/views/dashboard.client.view.html"})}]),angular.module("core").controller("DashboardController",["$scope","$stateParams","$location","Authentication","Notices","Pagination",function($scope,$stateParams,$location,Authentication,Notices,Pagination){$scope.authentication=Authentication,$scope.find=function(){$scope.notices=Notices.query(function(result){$scope.pagination=Pagination.getNew(10);var totalNotices=result.length;$scope.pagination.numPages=Math.ceil(totalNotices/$scope.pagination.perPage)})}}]),angular.module("core").controller("HeaderController",["$scope","Authentication","Menus","Notices",function($scope,Authentication,Menus,Notices){$scope.authentication=Authentication,$scope.isCollapsed=!1,$scope.menu=Menus.getMenu("topbar"),$scope.toggleCollapsibleMenu=function(){$scope.isCollapsed=!$scope.isCollapsed},$scope.$on("$stateChangeSuccess",function(){$scope.isCollapsed=!1}),$scope.server=Notices.getEnv()}]),angular.module("core").directive("sideNavigation",["$timeout",function($timeout){return{restrict:"A",link:function(scope,element){scope.$watch("authentication.user",function(){$timeout(function(){element.metisMenu()})})}}}]).directive("minimalizaSidebar",["$timeout",function($timeout){return{restrict:"A",template:'<a class="navbar-minimalize minimalize-styl-2 btn btn-danger" href="" ng-click="minimalize()"><i class="fa fa-bars"></i></a>',controller:["$scope","$element",function($scope,$element){$scope.minimalize=function(){angular.element("body").toggleClass("mini-navbar"),!angular.element("body").hasClass("mini-navbar")||angular.element("body").hasClass("body-small")?(angular.element("#side-menu").hide(),$timeout(function(){angular.element("#side-menu").fadeIn(500)},100)):angular.element("#side-menu").removeAttr("style")}}]}}]),angular.module("core").service("Menus",[function(){this.defaultRoles=["*"],this.menus={};var shouldRender=function(user){if(!user)return this.isPublic;if(~this.roles.indexOf("*"))return!0;for(var userRoleIndex in user.roles)for(var roleIndex in this.roles)if(this.roles[roleIndex]===user.roles[userRoleIndex])return!0;return!1};this.validateMenuExistance=function(menuId){if(menuId&&menuId.length){if(this.menus[menuId])return!0;throw new Error("Menu does not exists")}throw new Error("MenuId was not provided")},this.getMenu=function(menuId){return this.validateMenuExistance(menuId),this.menus[menuId]},this.addMenu=function(menuId,isPublic,roles){return this.menus[menuId]={isPublic:isPublic||!1,roles:roles||this.defaultRoles,items:[],shouldRender:shouldRender},this.menus[menuId]},this.removeMenu=function(menuId){this.validateMenuExistance(menuId),delete this.menus[menuId]},this.addMenuItem=function(menuId,menuItemTitle,menuItemURL,iconClass,menuItemType,menuItemUIRoute,isPublic,roles,position){return this.validateMenuExistance(menuId),this.menus[menuId].items.push({title:menuItemTitle,link:menuItemURL,iconClass:iconClass,menuItemType:menuItemType||"item",menuItemClass:menuItemType,uiRoute:menuItemUIRoute||"/"+menuItemURL,isPublic:null===isPublic||"undefined"==typeof isPublic?this.menus[menuId].isPublic:isPublic,roles:null===roles||"undefined"==typeof roles?this.menus[menuId].roles:roles,position:position||0,items:[],shouldRender:shouldRender}),this.menus[menuId]},this.addSubMenuItem=function(menuId,rootMenuItemURL,menuItemTitle,menuItemURL,menuItemUIRoute,isPublic,roles,position){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)this.menus[menuId].items[itemIndex].link===rootMenuItemURL&&this.menus[menuId].items[itemIndex].items.push({title:menuItemTitle,link:menuItemURL,uiRoute:menuItemUIRoute||"/"+menuItemURL,isPublic:null===isPublic||"undefined"==typeof isPublic?this.menus[menuId].items[itemIndex].isPublic:isPublic,roles:null===roles||"undefined"==typeof roles?this.menus[menuId].items[itemIndex].roles:roles,position:position||0,shouldRender:shouldRender});return this.menus[menuId]},this.removeMenuItem=function(menuId,menuItemURL){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)this.menus[menuId].items[itemIndex].link===menuItemURL&&this.menus[menuId].items.splice(itemIndex,1);return this.menus[menuId]},this.removeSubMenuItem=function(menuId,submenuItemURL){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)for(var subitemIndex in this.menus[menuId].items[itemIndex].items)this.menus[menuId].items[itemIndex].items[subitemIndex].link===submenuItemURL&&this.menus[menuId].items[itemIndex].items.splice(subitemIndex,1);return this.menus[menuId]},this.addMenu("topbar")}]),angular.module("notices").run(["Menus",function(Menus){Menus.addMenuItem("topbar","New Notice","notices/create","fa-pencil")}]),angular.module("notices").config(["$stateProvider",function($stateProvider){$stateProvider.state("listNotices",{url:"/notices",templateUrl:"modules/core/views/dashboard.client.view.html"}).state("createNotice",{url:"/notices/create",templateUrl:"modules/notices/views/create-notice.client.view.html"}).state("viewNotice",{url:"/notices/:noticeId",templateUrl:"modules/notices/views/view-notice.client.view.html"}).state("updateNotice",{url:"/notices/:noticeId/update",templateUrl:"modules/notices/views/update-notice.client.view.html"})}]),angular.module("notices").controller("NoticesController",["$scope","$confirm","$stateParams","$location","Authentication","Notices",function($scope,$confirm,$stateParams,$location,Authentication,Notices,Templates){$scope.authentication=Authentication,$scope.create=function(){var notice=new Notices({notice_type:this.type,subject:this.noticeForm.subject,status:"active",auto_update:this.update_time,ticket_number:this.ticket,priority:this.priority,impacted_services:this.noticeForm.impacted_services,description:this.noticeForm.description,status_update:this.noticeForm.status_update,outage_start_time:this.outage_start_time,affected_regions:this.noticeForm.affected_regions,email_dlist:this.noticeForm.email_dlist});$confirm({text:"Are you sure you want to send this notice?"}).then(function(){notice.$save(function(response){$location.path("/")},function(errorResponse){$scope.error=errorResponse.data.message})})},$scope.remove=function(notice){if(notice){notice.$remove();for(var i in $scope.notices)$scope.notices[i]===notice&&$scope.notices.splice(i,1)}else $scope.notice.$remove(function(){$location.path("notices")})},this.check=!1,$scope.updateCheck=function(){var update_type=this.notice.status;this.check="closed"===update_type?!0:!1},$scope.update=function(){var notice=$scope.notice;notice.$update(function(){$location.path("/")},function(errorResponse){$scope.error=errorResponse.data.message})},$scope.find=function(){$scope.notices=Notices.query()},$scope.findOne=function(){$scope.notice=Notices.get({noticeId:$stateParams.noticeId})},$scope.findLatest=function(){$scope.notice=Notices.getLatest()},$scope.templates=Notices.getTemplates()}]),angular.module("notices").factory("Notices",["$resource",function($resource){return $resource("notices/:noticeId",{noticeId:"@_id"},{update:{method:"PUT"},getLatest:{method:"GET",url:"notices/status/latest",isArray:!1},getTemplates:{method:"GET",url:"notices/templates/:templateId",isArray:!0},getEnv:{method:"GET",url:"server/environment",isArray:!1}})}]),angular.module("templates").run(["Menus",function(Menus){Menus.addMenuItem("topbar","New Template","templates/create","fa-plus"),Menus.addMenuItem("topbar","Edit Template","templates","fa-pencil-square-o")}]),angular.module("templates").config(["$stateProvider",function($stateProvider){$stateProvider.state("listTemplates",{url:"/templates",templateUrl:"modules/templates/views/list-templates.client.view.html"}).state("createTemplate",{url:"/templates/create",templateUrl:"modules/templates/views/create-template.client.view.html"}).state("viewTemplate",{url:"/templates/:templateId",templateUrl:"modules/templates/views/view-template.client.view.html"}).state("editTemplate",{url:"/templates/:templateId/edit",templateUrl:"modules/templates/views/edit-template.client.view.html"})}]),angular.module("templates").controller("TemplatesController",["$scope","$stateParams","$location","Authentication","Templates",function($scope,$stateParams,$location,Authentication,Templates){$scope.authentication=Authentication,$scope.create=function(){var template=new Templates({subject:this.subject,affected_regions:this.affected_regions,impacted_services:this.impacted_services,description:this.description,email_dlist:this.email_dlist});template.$save(function(response){$location.path("templates/"+response._id)},function(errorResponse){$scope.error=errorResponse.data.message})},$scope.remove=function(template){if(template){template.$remove();for(var i in $scope.templates)$scope.templates[i]===template&&$scope.templates.splice(i,1)}else $scope.template.$remove(function(){$location.path("templates")})},$scope.update=function(){var template=$scope.template;template.$update(function(){$location.path("templates/"+template._id)},function(errorResponse){$scope.error=errorResponse.data.message})},$scope.find=function(){$scope.templates=Templates.query()},$scope.findOne=function(){$scope.template=Templates.get({templateId:$stateParams.templateId})}}]),angular.module("templates").factory("Templates",["$resource",function($resource){return $resource("templates/:templateId",{templateId:"@_id"},{update:{method:"PUT"}})}]),angular.module("users").config(["$httpProvider",function($httpProvider){$httpProvider.interceptors.push(["$q","$location","Authentication",function($q,$location,Authentication){return{responseError:function(rejection){switch(rejection.status){case 401:Authentication.user=null,$location.path("signin");break;case 403:}return $q.reject(rejection)}}}])}]),angular.module("users").config(["$stateProvider",function($stateProvider){$stateProvider.state("profile",{url:"/settings/profile",templateUrl:"modules/users/views/settings/edit-profile.client.view.html"}).state("password",{url:"/settings/password",templateUrl:"modules/users/views/settings/change-password.client.view.html"}).state("accounts",{url:"/settings/accounts",templateUrl:"modules/users/views/settings/social-accounts.client.view.html"}).state("signup",{url:"/signup",templateUrl:"modules/users/views/authentication/signup.client.view.html"}).state("signin",{url:"/signin",templateUrl:"modules/users/views/authentication/signin.client.view.html"}).state("forgot",{url:"/password/forgot",templateUrl:"modules/users/views/password/forgot-password.client.view.html"}).state("reset-invalid",{url:"/password/reset/invalid",templateUrl:"modules/users/views/password/reset-password-invalid.client.view.html"}).state("reset-success",{url:"/password/reset/success",templateUrl:"modules/users/views/password/reset-password-success.client.view.html"}).state("reset",{url:"/password/reset/:token",templateUrl:"modules/users/views/password/reset-password.client.view.html"})}]),angular.module("users").controller("AuthenticationController",["$scope","$http","$location","Authentication",function($scope,$http,$location,Authentication){$scope.authentication=Authentication,$scope.authentication.user&&$location.path("/"),$scope.signup=function(){$http.post("/auth/signup",$scope.credentials).success(function(response){$scope.authentication.user=response,$location.path("/")}).error(function(response){$scope.error=response.message})},$scope.signin=function(){$http.post("/auth/signin",$scope.credentials).success(function(response){$scope.authentication.user=response,$location.path("/")}).error(function(response){$scope.error="InvalidCredentialsError"===response.name?"Invalid Username or Password":response.message})}}]),angular.module("users").controller("PasswordController",["$scope","$stateParams","$http","$location","Authentication",function($scope,$stateParams,$http,$location,Authentication){$scope.authentication=Authentication,$scope.authentication.user&&$location.path("/"),$scope.askForPasswordReset=function(){$scope.success=$scope.error=null,$http.post("/auth/forgot",$scope.credentials).success(function(response){$scope.credentials=null,$scope.success=response.message}).error(function(response){$scope.credentials=null,$scope.error=response.message})},$scope.resetUserPassword=function(){$scope.success=$scope.error=null,$http.post("/auth/reset/"+$stateParams.token,$scope.passwordDetails).success(function(response){$scope.passwordDetails=null,Authentication.user=response,$location.path("/password/reset/success")}).error(function(response){$scope.error=response.message})}}]),angular.module("users").controller("SettingsController",["$scope","$http","$location","Users","Authentication",function($scope,$http,$location,Users,Authentication){$scope.user=Authentication.user,$scope.user||$location.path("/"),$scope.hasConnectedAdditionalSocialAccounts=function(provider){for(var i in $scope.user.additionalProvidersData)return!0;return!1},$scope.isConnectedSocialAccount=function(provider){return $scope.user.provider===provider||$scope.user.additionalProvidersData&&$scope.user.additionalProvidersData[provider]},$scope.removeUserSocialAccount=function(provider){$scope.success=$scope.error=null,$http["delete"]("/users/accounts",{params:{provider:provider}}).success(function(response){$scope.success=!0,$scope.user=Authentication.user=response}).error(function(response){$scope.error=response.message})},$scope.updateUserProfile=function(isValid){if(isValid){$scope.success=$scope.error=null;var user=new Users($scope.user);user.$update(function(response){$scope.success=!0,Authentication.user=response},function(response){$scope.error=response.data.message})}else $scope.submitted=!0},$scope.changeUserPassword=function(){$scope.success=$scope.error=null,$http.post("/users/password",$scope.passwordDetails).success(function(response){$scope.success=!0,$scope.passwordDetails=null}).error(function(response){$scope.error=response.message})}}]),angular.module("users").factory("Authentication",[function(){var _this=this;return _this._data={user:window.user},_this._data}]),angular.module("users").factory("Users",["$resource",function($resource){return $resource("users",{},{update:{method:"PUT"}})}]);