Viewing File: /usr/local/cpanel/base/frontend/jupiter/site-monitor/index.cmb.min.js
define("app/views/ROUTES",["cjt/util/locale"],function(e){"use strict";var t=[{id:"listSiteMonitors",path:"/",hideTitle:!1,controller:"listSiteMonitors",templateUrl:"views/listSiteMonitors.phtml",title:e.maketext("Site Monitors"),breadcrumb:{id:"listSiteMonitors",name:e.maketext("Site Monitors"),path:"/"},resolve:{initialSites:["sites",function(e){return e.get().then(function(e){return e},function(e){return new Error(e.error)})}]}}];return t}),define("app/models/enum-helper",[],function(){"use strict";return{fromString:function(e,t){if(!e||"object"!=typeof e)throw new Error("You must pass an object as the enum.");if(!t||"string"!=typeof t&&"number"!=typeof t)throw new Error("The value must be either a string or number");var i=Object.keys(e).find(function(i){return e[i]===t});if("undefined"==typeof i)throw new Error("The enum does not contain a property with the value "+t);return i}}}),define("app/models/domain-type.enum",["app/models/enum-helper"],function(e){"use strict";var t={SUBDOMAIN:"subdomain",ADDON:"addon",ALIAS:"alias",MAIN:"main_domain",EXTERNAL:"external"};return t.fromString=function(i){return e.fromString(t,i)},t}),define("app/models/monitor-status.enum",["app/models/enum-helper"],function(e){"use strict";var t={Down:"down",Up:"up"};return t.fromString=function(i){return e.fromString(t,i)},t}),define("app/models/monitor-type.enum",["app/models/enum-helper"],function(e){"use strict";var t={HTTP:"http",HTTPS:"https",ICMP:"icmp",TCP:"telnet"};return t.fromString=function(i){return e.fromString(t,i)},t}),define("app/models/uptime-window.enum",["app/models/enum-helper"],function(e){"use strict";var t={Last24Hours:"last 24 hours",Last7Days:"last 7 days",Last30Days:"last 30 days",SinceStart:"since start"};return t.fromString=function(i){return e.fromString(t,i)},t}),define("app/models/monitor-state.enum",["app/models/enum-helper"],function(e){"use strict";var t={Creating:"creating",Removing:"removing",Ready:"ready",Error:"error",None:"none"};return t.fromString=function(i){return e.fromString(t,i)},t}),define("app/models/monitor",["app/models/monitor-status.enum","app/models/monitor-type.enum","app/models/uptime-window.enum","app/models/monitor-state.enum"],function(e,t,i,s){"use strict";function r(e){e&&(this.id=e.id,this.name=e.name,this.protocol=e.protocol||t.HTTPS,this.domain=e.domain,this.port=e.port||n(this.protocol),this.path=e.path||"",this.search=e.search||"",this.enabled=e.enabled||!0,this.data=e.data||[],this.contact=e.contact,this.firstUpdate=e.firstUpdate,this.lastUpdate=e.lastUpdate,this.fromLocation=e.fromLocation,this.interval=e.interval||o,this.sslExpiration=e.sslExpiration,this.state=e.state||s.Ready)}function n(e){switch(e){case t.ICMP:return;case t.TCP:return 23;case t.HTTP:return 80;case t.HTTPS:default:return 443}}var o=1800;return r.prototype.url=function(){return(/^http/.test(this.protocol)?this.protocol+"://":"")+this.domain+(this.port!==n(this.protocol)?":"+this.port:"")+"/"+this.path+(""!==this.search?"?"+this.search:"")},r.prototype.clone=function(){return new r(_.cloneDeep(this))},r.parseListItem=function(e){var t="https://"+e.url,i=new URL(t);return new r({id:e.id,name:e.name,protocol:e.type,domain:i.hostname,port:Number(i.port),path:i.pathname.replace(/^\//,""),search:i.search.replace(/^\?/,""),type:e.type,firstUpdate:new Date(1e3*e.first_update),lastUpdate:new Date(1e3*e.last_update),sslExpiration:new Date(1e3*e.ssl_expiration_timestamp),fromLocation:e.monitor.name})},r.parseItem=function(e){var t=new URL(e.url);return new r({id:angular.isDefined(e.id)?e.id:null,name:angular.isDefined(e.name)?e.name:null,protocol:e.type,domain:t.hostname,port:t.port,path:t.pathname.replace(/^\//,""),search:t.search.replace(/^\?/,""),firstUpdate:angular.isDefined(e.first_update)?new Date(1e3*e.first_update):null,lastUpdate:angular.isDefined(e.last_update)?new Date(1e3*e.last_update):null,fromLocation:angular.isDefined(e.monitor)?e.monitor.name:null,interval:angular.isDefined(e.interval)?e.interval:null,state:angular.isDefined(e.state)?e.state:null})},r.DEFAULT_CHECK_INTERVAL=o,r}),define("app/models/site",["lodash","app/models/monitor","app/models/domain-type.enum"],function(e,t,i){"use strict";function s(e){var t=this;t.monitors=e.monitors||[],t.fetchFailed=e.fetchFailed||!1,Object.keys(e).forEach(function(i){t[i]=e[i]}),t.type=i[i.fromString(e.type)],t.protocol=t.isHttpsRedirecting?"https":"http"}return s.prototype._makeMatcher=function(e,t){return t=t&&"function"==typeof t?t(e):function(t){return t.name===e.name}},s.prototype.findMonitor=function(e,t){return t=this._makeMatcher(e,t),this.monitors.filter(t)},s.prototype.findFirstMonitor=function(e,t){return t=this._makeMatcher(e,t),this.monitors.find(t)},s.prototype.addMonitor=function(t,i){i=this._makeMatcher(t,i);var s=e.findIndex(this.monitors,i);-1!==s?this.monitors[s]=t:this.monitors.push(t)},s.prototype.removeMonitor=function(t,i){i=this._makeMatcher(t,i),e.remove(this.monitors,i)},s.prototype.anyEnabled=function(){return this.monitors.length>0},s}),define("app/services/monitoring",["angular","lodash","cjt/util/locale","cjt/io/uapi-request","cjt/io/uapi","cjt/modules","cjt/services/APICatcher"],function(e,t,i,s){"use strict";var r=e.module("cpanel.siteMonitor.monitoringService",["cjt2.services.apicatcher"]);r.factory("monitoring",["$q","APICatcher","PAGE",function(e,t){var r=function(){};return r.prototype=Object.create(t),r.prototype.list=function(){var e=this,t=new s.Class;return t.initialize("Monitoring","get_all_site_monitors"),e.promise(t).then(function(e){return e.data.response.monitors})},r.prototype.get=function(e){var t=this;if("string"!=typeof e||""===e)throw new Error("The `id` argument is required.");var i=new s.Class;return i.initialize("Monitoring","get_site_monitor"),i.addArgument("id",e),t.promise(i).then(function(e){return e.data.response})},r.prototype.enable=function(e,t,r){var n=this;if("string"!=typeof e||""===e)throw new Error("The `domain` argument is required.");if(r&&!Array.isArray(r))throw new Error("The `emails` argument must be an array of email addresses.");var o=new s.Class;return o.initialize("Monitoring","create_site_monitor"),o.addArgument("site",e),o.addArgument("name",t||e),o.addArgument("email",r),n.promise(o).then(function(t){if("200"===t.data.http_code)return t.data.response.id;throw new Error(i.maketext("The system could not create the monitor for [_1] with the error: [_2]",e,t.data.response.error))})},r.prototype.disable=function(e,t){var r=this;if("string"!=typeof e||""===e)throw new Error("The `id` argument is required.");var n=new s.Class;return n.initialize("Monitoring","remove_site_monitor"),n.addArgument("id",e),r.promise(n).then(function(e){if("204"===e.data.http_code)return!0;throw new Error(i.maketext("The system could not remove the monitor for [_1] with the error: [_2]",t,e.data.response.error))})},new r}])}),define("app/services/sitesCache",["angular","lodash","cjt/util/locale","cjt/io/uapi-request","app/models/site","app/models/monitor","cjt/util/parse","cjt/io/uapi","cjt/io/api2","cjt/modules","cjt/services/APICatcher"],function(e,t,i,s,r){"use strict";var n=e.module("cpanel.siteMonitor.sitesCacheService",[]);n.factory("sitesCache",[function(){var e=[],t={},i=function(){};return i.prototype.add=function(i){e||(e=[]);var i=new r(i);return t[i.domain]&&this.remove(i.domain),t[i.domain]=i,e.push(i),i},i.prototype.clear=function(){e=[],t={}},i.prototype.remove=function(i){var s=this,r=s.findByDomainName(i);if(!r)return!1;for(var n=e.length-1;n>=0;n--)if(e[n].domain===r.domain)return e.splice(n,1),delete t[i],!0;return!1},i.prototype.get=function(){return e},i.prototype.findByDomainName=function(e){return t[e]},i.prototype.findMonitor=function(e,t){var i=this.findByDomainName(e);if(i)return i.monitors.find(function(e){return e.url()===t})},new i}])}),define("app/services/sites",["angular","lodash","cjt/util/locale","cjt/io/uapi-request","app/models/domain-type.enum","app/models/site","app/models/monitor","cjt/util/parse","app/services/monitoring","cjt/io/uapi","cjt/io/api2","cjt/modules","cjt/services/APICatcher","app/services/sitesCache"],function(e,t,i,s,r,n,o,a){"use strict";var c=e.module("cpanel.siteMonitor.sitesService",["cjt2.services.apicatcher","cpanel.siteMonitor.sitesCacheService","cpanel.siteMonitor.monitoringService"]);c.value("PAGE",PAGE),c.factory("sites",["$q","APICatcher","PAGE","sitesCache","monitoring",function(t,i,c,l,u){function h(e){return function(t,i){return e[i]||t.push(i),t}}var d,p,_,f,m=function(){};m.prototype=i,m.prototype._getSubDomainObject=function(e){var t=this;return"string"==typeof e?l.findByDomainName(e+"."+t.getMainDomain().domain):void 0},m.prototype._associateAddonDomains=function(){var t=this;e.forEach(_,function(e){var i=t._getSubDomainObject(e.subdomain);i&&(i.associatedAddonDomain=e.domain)})},m.prototype.getMainDomain=function(){return d},m.prototype.findByDomainName=function(e){return l.findByDomainName(e)},m.prototype.fetchSites=function(){var e=this,t=new s.Class;return t.initialize("DomainInfo","domains_data"),t.addArgument("return_https_redirect_status",1),e.promise(t).then(function(t){var i=e.parseDomain(t.data.main_domain);i.type=r.MAIN,d=i,l.add(i),f=[];var s=t.data.sub_domains||[];return s.forEach(function(t){var i=e.parseDomain(t,r.SUBDOMAIN);f.push(i),l.add(i)}),_=[],s=t.data.addon_domains||[],s.forEach(function(t){var i=e.parseDomain(t,r.ADDON);_.push(i),l.add(i);var s=e.parseDomain(t,r.ADDON);s.domain=s.rootDomain,s.type=r.SUBDOMAIN,f.push(s),l.add(s)}),p=[],t.data.parked_domains.forEach(function(i){var s=e.parseDomain(t.data.main_domain,r.ALIAS);s.domain=i,p.push(s),l.add(s)}),i})},m.prototype.parseDomain=function(e,t){if(!e)throw new Error("Invalid domain information object");var i=Object.keys(e);if(!i||!i.length)throw new Error("Invalid domain information object");var s=["domain","homedir"].reduce(h(e),[]);if(s.length)throw new Error("The domain information object is missing the keys: "+s.join(","));if(!e.documentroot&&!e.dir)throw new Error("The domain information object must have one of the keys: "+["documentroot","dir"].join(","));var o=this,l={domain:e.domain,homedir:e.homedir,documentRoot:e.documentroot||e.dir,rootDomain:e.servername,isHttpsRedirecting:a.parseBoolean(e.is_https_redirecting),hasValidHTTPSAliases:a.parseBoolean(e.all_aliases_valid),nonHTTPS:!a.parseBoolean(e.can_https_redirect),redirectsTo:"not redirected"===e.status?null:e.status,type:e.type,realRootDomain:c.mainDomain};if(t){l.type=t,l.homedir=o.getMainDomain().homedir;var u=o.getMainDomain().domain,d=l.rootDomain?l.rootDomain.substr(0,l.rootDomain.lastIndexOf("."+u)):null;t!==r.ALIAS&&(l.subdomain=d),t===r.SUBDOMAIN?l.rootDomain=u:t===r.ALIAS&&(l.rootDomain=c.mainDomain)}return new n(l)};var g=null;return m.prototype._monitorFetchFailed=function(){var e=l.get();e&&e.length>0&&e.forEach(function(e){e.fetchFailed=!0})},m.prototype.get=function(e){var i=this;e||(e={});var s=e.refresh||!1;if(g)return g;if(!s){var a=l.get();if(a.length>0)return t.resolve(a)}return l.clear(),i.error=null,g=t.all([i.fetchSites().then(function(e){return i.error&&i._monitorFetchFailed(),e}),u.list()]).then(function(e){i._associateAddonDomains();var t="undefined"!=typeof e[1]?e[1]:void 0;return t&&t.forEach(function(e){var t=o.parseListItem(e),i=t.domain.replace(/^www./,""),s=l.findByDomainName(i);if(s)s.addMonitor(t);else{var a=new n({domain:i,type:r.EXTERNAL});a.addMonitor(t),l.add(a)}}),g=null,l.get()}).catch(function(e){throw i.error=e,i._monitorFetchFailed(),e})},new m}])}),function(e){define("jquery-chosen",["jquery"],function(){return function(){(function(){var e,t,i,s,r,n={}.hasOwnProperty,o=function(e,t){function i(){this.constructor=e}for(var s in t)n.call(t,s)&&(e[s]=t[s]);return i.prototype=t.prototype,e.prototype=new i,e.__super__=t.prototype,e};s=function(){function e(){this.options_index=0,this.parsed=[]}return e.prototype.add_node=function(e){return"OPTGROUP"===e.nodeName.toUpperCase()?this.add_group(e):this.add_option(e)},e.prototype.add_group=function(e){var t,i,s,r,n,o;for(t=this.parsed.length,this.parsed.push({array_index:t,group:!0,label:this.escapeExpression(e.label),title:e.title?e.title:void 0,children:0,disabled:e.disabled,classes:e.className}),n=e.childNodes,o=[],s=0,r=n.length;r>s;s++)i=n[s],o.push(this.add_option(i,t,e.disabled));return o},e.prototype.add_option=function(e,t,i){return"OPTION"===e.nodeName.toUpperCase()?(""!==e.text?(null!=t&&(this.parsed[t].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:e.value,text:e.text,html:e.innerHTML,title:e.title?e.title:void 0,selected:e.selected,disabled:i===!0?i:e.disabled,group_array_index:t,group_label:null!=t?this.parsed[t].label:null,classes:e.className,style:e.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},e.prototype.escapeExpression=function(e){var t,i;return null==e||e===!1?"":/[\&\<\>\"\'\`]/.test(e)?(t={"<":"<",">":">",'"':""","'":"'","`":"`"},i=/&(?!\w+;)|[\<\>\"\'\`]/g,e.replace(i,function(e){return t[e]||"&"})):e},e}(),s.select_to_array=function(e){var t,i,r,n,o;for(i=new s,o=e.childNodes,r=0,n=o.length;n>r;r++)t=o[r],i.add_node(t);return i.parsed},t=function(){function e(t,i){this.form_field=t,this.options=null!=i?i:{},e.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}return e.prototype.set_default_values=function(){var e=this;return this.click_test_action=function(t){return e.test_active_click(t)},this.activate_action=function(t){return e.activate_field(t)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0,this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1,this.max_shown_results=this.options.max_shown_results||Number.POSITIVE_INFINITY},e.prototype.set_default_text=function(){return this.default_text=this.form_field.getAttribute("data-placeholder")?this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.options.placeholder_text_multiple||this.options.placeholder_text||e.default_multiple_text:this.options.placeholder_text_single||this.options.placeholder_text||e.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||e.default_no_result_text},e.prototype.choice_label=function(e){return this.include_group_label_in_selected&&null!=e.group_label?"<b class='group-name'>"+e.group_label+"</b>"+e.html:e.html},e.prototype.mouse_enter=function(){return this.mouse_on_container=!0},e.prototype.mouse_leave=function(){return this.mouse_on_container=!1},e.prototype.input_focus=function(){var e=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return e.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},e.prototype.input_blur=function(){var e=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return e.blur_test()},100))},e.prototype.results_option_build=function(e){var t,i,s,r,n,o,a;for(t="",r=0,a=this.results_data,n=0,o=a.length;o>n&&(i=a[n],s="",s=i.group?this.result_add_group(i):this.result_add_option(i),""!==s&&(r++,t+=s),(null!=e?e.first:void 0)&&(i.selected&&this.is_multiple?this.choice_build(i):i.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(i))),!(r>=this.max_shown_results));n++);return t},e.prototype.result_add_option=function(e){var t,i;return e.search_match&&this.include_option_in_results(e)?(t=[],e.disabled||e.selected&&this.is_multiple||t.push("active-result"),!e.disabled||e.selected&&this.is_multiple||t.push("disabled-result"),e.selected&&t.push("result-selected"),null!=e.group_array_index&&t.push("group-option"),""!==e.classes&&t.push(e.classes),i=document.createElement("li"),i.className=t.join(" "),i.style.cssText=e.style,i.setAttribute("data-option-array-index",e.array_index),i.innerHTML=e.search_text,e.title&&(i.title=e.title),this.outerHTML(i)):""},e.prototype.result_add_group=function(e){var t,i;return(e.search_match||e.group_match)&&e.active_options>0?(t=[],t.push("group-result"),e.classes&&t.push(e.classes),i=document.createElement("li"),i.className=t.join(" "),i.innerHTML=e.search_text,e.title&&(i.title=e.title),this.outerHTML(i)):""},e.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing?this.winnow_results():void 0},e.prototype.reset_single_select_options=function(){var e,t,i,s,r;for(s=this.results_data,r=[],t=0,i=s.length;i>t;t++)e=s[t],r.push(e.selected?e.selected=!1:void 0);return r},e.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},e.prototype.results_search=function(){return this.results_showing?this.winnow_results():this.results_show()},e.prototype.winnow_results=function(){var e,t,i,s,r,n,o,a,c,l,u,h;for(this.no_results_clear(),s=0,n=this.get_search_text(),e=n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),c=new RegExp(e,"i"),i=this.get_search_regex(e),h=this.results_data,l=0,u=h.length;u>l;l++)t=h[l],t.search_match=!1,r=null,this.include_option_in_results(t)&&(t.group&&(t.group_match=!1,t.active_options=0),null!=t.group_array_index&&this.results_data[t.group_array_index]&&(r=this.results_data[t.group_array_index],0===r.active_options&&r.search_match&&(s+=1),r.active_options+=1),t.search_text=t.group?t.label:t.html,(!t.group||this.group_search)&&(t.search_match=this.search_string_match(t.search_text,i),t.search_match&&!t.group&&(s+=1),t.search_match?(n.length&&(o=t.search_text.search(c),a=t.search_text.substr(0,o+n.length)+"</em>"+t.search_text.substr(o+n.length),t.search_text=a.substr(0,o)+"<em>"+a.substr(o)),null!=r&&(r.group_match=!0)):null!=t.group_array_index&&this.results_data[t.group_array_index].search_match&&(t.search_match=!0)));return this.result_clear_highlight(),1>s&&n.length?(this.update_results_content(""),this.no_results(n)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},e.prototype.get_search_regex=function(e){var t;return t=this.search_contains?"":"^",new RegExp(t+e,"i")},e.prototype.search_string_match=function(e,t){var i,s,r,n;if(t.test(e))return!0;if(this.enable_split_word_search&&(e.indexOf(" ")>=0||0===e.indexOf("["))&&(s=e.replace(/\[|\]/g,"").split(" "),s.length))for(r=0,n=s.length;n>r;r++)if(i=s[r],t.test(i))return!0},e.prototype.choices_count=function(){var e,t,i,s;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,s=this.form_field.options,t=0,i=s.length;i>t;t++)e=s[t],e.selected&&(this.selected_option_count+=1);return this.selected_option_count},e.prototype.choices_click=function(e){return e.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},e.prototype.keyup_checker=function(e){var t,i;switch(t=null!=(i=e.which)?i:e.keyCode,this.search_field_scale(),t){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(e.preventDefault(),this.results_showing)return this.result_select(e);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:case 18:break;default:return this.results_search()}},e.prototype.clipboard_event_checker=function(){var e=this;return setTimeout(function(){return e.results_search()},50)},e.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},e.prototype.include_option_in_results=function(e){return this.is_multiple&&!this.display_selected_options&&e.selected?!1:!this.display_disabled_options&&e.disabled?!1:e.empty?!1:!0},e.prototype.search_results_touchstart=function(e){return this.touch_started=!0,this.search_results_mouseover(e)},e.prototype.search_results_touchmove=function(e){return this.touch_started=!1,this.search_results_mouseout(e)},e.prototype.search_results_touchend=function(e){return this.touch_started?this.search_results_mouseup(e):void 0},e.prototype.outerHTML=function(e){var t;return e.outerHTML?e.outerHTML:(t=document.createElement("div"),t.appendChild(e),t.innerHTML)},e.browser_is_supported=function(){return/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:/IEMobile/i.test(window.navigator.userAgent)?!1:/Windows Phone/i.test(window.navigator.userAgent)?!1:/BlackBerry/i.test(window.navigator.userAgent)?!1:/BB10/i.test(window.navigator.userAgent)?!1:"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:!0},e.default_multiple_text="Select Some Options",e.default_single_text="Select an Option",e.default_no_result_text="No results match",e}(),e=jQuery,e.fn.extend({chosen:function(s){return t.browser_is_supported()?this.each(function(){var t,r;return t=e(this),r=t.data("chosen"),"destroy"===s?void(r instanceof i&&r.destroy()):void(r instanceof i||t.data("chosen",new i(this,s)))}):this}}),i=function(t){function i(){return r=i.__super__.constructor.apply(this,arguments)}return o(i,t),i.prototype.setup=function(){return this.form_field_jq=e(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},i.prototype.set_up_html=function(){var t,i;return t=["chosen-container"],t.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&t.push(this.form_field.className),this.is_rtl&&t.push("chosen-rtl"),i={"class":t.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(i.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=e("<div />",i),this.container.html(this.is_multiple?'<ul class="chosen-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>':'<a class="chosen-single chosen-default"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior()},i.prototype.on_ready=function(){return this.form_field_jq.trigger("chosen:ready",{chosen:this})},i.prototype.register_observers=function(){var e=this;return this.container.bind("touchstart.chosen",function(t){return e.container_mousedown(t),t.preventDefault()}),this.container.bind("touchend.chosen",function(t){return e.container_mouseup(t),t.preventDefault()}),this.container.bind("mousedown.chosen",function(t){e.container_mousedown(t)}),this.container.bind("mouseup.chosen",function(t){e.container_mouseup(t)}),this.container.bind("mouseenter.chosen",function(t){e.mouse_enter(t)}),this.container.bind("mouseleave.chosen",function(t){e.mouse_leave(t)}),this.search_results.bind("mouseup.chosen",function(t){e.search_results_mouseup(t)}),this.search_results.bind("mouseover.chosen",function(t){e.search_results_mouseover(t)}),this.search_results.bind("mouseout.chosen",function(t){e.search_results_mouseout(t)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(t){e.search_results_mousewheel(t)}),this.search_results.bind("touchstart.chosen",function(t){e.search_results_touchstart(t)}),this.search_results.bind("touchmove.chosen",function(t){e.search_results_touchmove(t)}),this.search_results.bind("touchend.chosen",function(t){e.search_results_touchend(t)}),this.form_field_jq.bind("chosen:updated.chosen",function(t){e.results_update_field(t)}),this.form_field_jq.bind("chosen:activate.chosen",function(t){e.activate_field(t)}),this.form_field_jq.bind("chosen:open.chosen",function(t){e.container_mousedown(t)}),this.form_field_jq.bind("chosen:close.chosen",function(t){e.input_blur(t)}),this.search_field.bind("blur.chosen",function(t){e.input_blur(t)}),this.search_field.bind("keyup.chosen",function(t){e.keyup_checker(t)}),this.search_field.bind("keydown.chosen",function(t){e.keydown_checker(t)}),this.search_field.bind("focus.chosen",function(t){e.input_focus(t)}),this.search_field.bind("cut.chosen",function(t){e.clipboard_event_checker(t)}),this.search_field.bind("paste.chosen",function(t){e.clipboard_event_checker(t)}),this.is_multiple?this.search_choices.bind("click.chosen",function(t){e.choices_click(t)}):this.container.bind("click.chosen",function(e){e.preventDefault()})},i.prototype.destroy=function(){return e(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},i.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},i.prototype.container_mousedown=function(t){return this.is_disabled||(t&&"mousedown"===t.type&&!this.results_showing&&t.preventDefault(),null!=t&&e(t.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!t||e(t.target)[0]!==this.selected_item[0]&&!e(t.target).parents("a.chosen-single").length||(t.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),e(this.container[0].ownerDocument).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},i.prototype.container_mouseup=function(e){return"ABBR"!==e.target.nodeName||this.is_disabled?void 0:this.results_reset(e)},i.prototype.search_results_mousewheel=function(e){var t;return e.originalEvent&&(t=e.originalEvent.deltaY||-e.originalEvent.wheelDelta||e.originalEvent.detail),null!=t?(e.preventDefault(),"DOMMouseScroll"===e.type&&(t=40*t),this.search_results.scrollTop(t+this.search_results.scrollTop())):void 0},i.prototype.blur_test=function(){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},i.prototype.close_field=function(){return e(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},i.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},i.prototype.test_active_click=function(t){var i;return i=e(t.target).closest(".chosen-container"),i.length&&this.container[0]===i[0]?this.active_field=!0:this.close_field()},i.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=s.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},i.prototype.result_do_highlight=function(e){var t,i,s,r,n;if(e.length){if(this.result_clear_highlight(),this.result_highlight=e,this.result_highlight.addClass("highlighted"),s=parseInt(this.search_results.css("maxHeight"),10),n=this.search_results.scrollTop(),r=s+n,i=this.result_highlight.position().top+this.search_results.scrollTop(),t=i+this.result_highlight.outerHeight(),t>=r)return this.search_results.scrollTop(t-s>0?t-s:0);if(n>i)return this.search_results.scrollTop(i)}},i.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},i.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},i.prototype.update_results_content=function(e){return this.search_results.html(e)},i.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},i.prototype.set_tab_index=function(){var e;return this.form_field.tabIndex?(e=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=e):void 0},i.prototype.set_label_behavior=function(){var t=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=e("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(e){return t.is_multiple?t.container_mousedown(e):t.activate_field()}):void 0},i.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))
},i.prototype.search_results_mouseup=function(t){var i;return i=e(t.target).hasClass("active-result")?e(t.target):e(t.target).parents(".active-result").first(),i.length?(this.result_highlight=i,this.result_select(t),this.search_field.focus()):void 0},i.prototype.search_results_mouseover=function(t){var i;return i=e(t.target).hasClass("active-result")?e(t.target):e(t.target).parents(".active-result").first(),i?this.result_do_highlight(i):void 0},i.prototype.search_results_mouseout=function(t){return e(t.target).hasClass("active-result")?this.result_clear_highlight():void 0},i.prototype.choice_build=function(t){var i,s,r=this;return i=e("<li />",{"class":"search-choice"}).html("<span>"+this.choice_label(t)+"</span>"),t.disabled?i.addClass("search-choice-disabled"):(s=e("<a />",{"class":"search-choice-close","data-option-array-index":t.array_index}),s.bind("click.chosen",function(e){return r.choice_destroy_link_click(e)}),i.append(s)),this.search_container.before(i)},i.prototype.choice_destroy_link_click=function(t){return t.preventDefault(),t.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(e(t.target))},i.prototype.choice_destroy=function(e){return this.result_deselect(e[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),e.parents("li").first().remove(),this.search_field_scale()):void 0},i.prototype.results_reset=function(){return this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},i.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},i.prototype.result_select=function(e){var t,i;return this.result_highlight?(t=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?t.removeClass("active-result"):this.reset_single_select_options(),t.addClass("result-selected"),i=this.results_data[t[0].getAttribute("data-option-array-index")],i.selected=!0,this.form_field.options[i.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(i):this.single_set_selected_text(this.choice_label(i)),(e.metaKey||e.ctrlKey)&&this.is_multiple||this.results_hide(),this.show_search_field_default(),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[i.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,e.preventDefault(),this.search_field_scale())):void 0},i.prototype.single_set_selected_text=function(e){return null==e&&(e=this.default_text),e===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").html(e)},i.prototype.result_deselect=function(e){var t;return t=this.results_data[e],this.form_field.options[t.options_index].disabled?!1:(t.selected=!1,this.form_field.options[t.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[t.options_index].value}),this.search_field_scale(),!0)},i.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")):void 0},i.prototype.get_search_text=function(){return e("<div/>").text(e.trim(this.search_field.val())).html()},i.prototype.winnow_results_set_highlight=function(){var e,t;return t=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),e=t.length?t.first():this.search_results.find(".active-result").first(),null!=e?this.result_do_highlight(e):void 0},i.prototype.no_results=function(t){var i;return i=e('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),i.find("span").first().html(t),this.search_results.append(i),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},i.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},i.prototype.keydown_arrow=function(){var e;return this.results_showing&&this.result_highlight?(e=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(e):void 0:this.results_show()},i.prototype.keyup_arrow=function(){var e;return this.results_showing||this.is_multiple?this.result_highlight?(e=this.result_highlight.prevAll("li.active-result"),e.length?this.result_do_highlight(e.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},i.prototype.keydown_backstroke=function(){var e;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(e=this.search_container.siblings("li.search-choice").last(),e.length&&!e.hasClass("search-choice-disabled")?(this.pending_backstroke=e,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},i.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},i.prototype.keydown_checker=function(e){var t,i;switch(t=null!=(i=e.which)?i:e.keyCode,this.search_field_scale(),8!==t&&this.pending_backstroke&&this.clear_backstroke(),t){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(e),this.mouse_on_container=!1;break;case 13:this.results_showing&&e.preventDefault();break;case 32:this.disable_search&&e.preventDefault();break;case 38:e.preventDefault(),this.keyup_arrow();break;case 40:e.preventDefault(),this.keydown_arrow()}},i.prototype.search_field_scale=function(){var t,i,s,r,n,o,a,c,l;if(this.is_multiple){for(s=0,a=0,n="position:absolute; left: -1000px; top: -1000px; display:none;",o=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],c=0,l=o.length;l>c;c++)r=o[c],n+=r+":"+this.search_field.css(r)+";";return t=e("<div />",{style:n}),t.text(this.search_field.val()),e("body").append(t),a=t.width()+25,t.remove(),i=this.container.outerWidth(),a>i-10&&(a=i-10),this.search_field.css({width:a+"px"})}},i}(t)}).call(this)}.apply(e,arguments)})}(this),function(e){define("angular-chosen",["angular","jquery-chosen"],function(){return function(){(function(){var e=[].indexOf||function(e){for(var t=0,i=this.length;i>t;t++)if(t in this&&this[t]===e)return t;return-1};angular.module("localytics.directives",[]),angular.module("localytics.directives").directive("chosen",["$timeout",function(t){var i,s,r,n;return s=/^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/,i=["persistentCreateOption","createOptionText","createOption","skipNoResults","noResultsText","allowSingleDeselect","disableSearchThreshold","disableSearch","enableSplitWordSearch","inheritSelectClasses","maxSelectedOptions","placeholderTextMultiple","placeholderTextSingle","searchContains","singleBackstrokeDelete","displayDisabledOptions","displaySelectedOptions","width","includeGroupLabelInSelected","maxShownResults"],n=function(e){return e.replace(/[A-Z]/g,function(e){return"_"+e.toLowerCase()})},r=function(e){var t;if(angular.isArray(e))return 0===e.length;if(angular.isObject(e))for(t in e)if(e.hasOwnProperty(t))return!1;return!0},{restrict:"A",require:"?ngModel",priority:1,link:function(o,a,c,l){var u,h,d,p,_,f,m,g,v,b,y;return o.disabledValuesHistory=o.disabledValuesHistory?o.disabledValuesHistory:[],a=$(a),a.addClass("localytics-chosen"),_=o.$eval(c.chosen)||{},angular.forEach(c,function(t,s){return e.call(i,s)>=0?c.$observe(s,function(e){return _[n(s)]="{{"===String(a.attr(c.$attr[s])).slice(0,2)?e:o.$eval(e),v()}):void 0}),m=function(){return a.addClass("loading").attr("disabled",!0).trigger("chosen:updated")},g=function(){return a.removeClass("loading"),angular.isDefined(c.disabled)?a.attr("disabled",c.disabled):a.attr("disabled",!1),a.trigger("chosen:updated")},u=null,h=!1,d=function(){var e;return u?a.trigger("chosen:updated"):(t(function(){u=a.chosen(_).data("chosen")}),angular.isObject(u)?e=u.default_text:void 0)},v=function(){return h?a.attr("data-placeholder",u.results_none_found).attr("disabled",!0):a.removeAttr("data-placeholder"),a.trigger("chosen:updated")},l?(f=l.$render,l.$render=function(){return f(),d()},a.on("chosen:hiding_dropdown",function(){return o.$apply(function(){return l.$setTouched()})}),c.multiple&&(y=function(){return l.$viewValue},o.$watch(y,l.$render,!0))):d(),c.$observe("disabled",function(){return a.trigger("chosen:updated")}),c.ngOptions&&l?(p=c.ngOptions.match(s),b=p[7],o.$watchCollection(b,function(e){var i;return i=t(function(){return angular.isUndefined(e)?m():(h=r(e),g(),v())})}),o.$on("$destroy",function(){return"undefined"!=typeof timer&&null!==timer?t.cancel(timer):void 0})):void 0}}}])}).call(this)}.apply(e,arguments)})}(this),define("app/services/contacts",["angular","lodash","cjt/util/locale","cjt/io/uapi-request","cjt/io/uapi","cjt/modules","cjt/services/APICatcher"],function(e,t,i,s){"use strict";var r=e.module("cpanel.siteMonitor.contactsService",["cjt2.services.apicatcher"]);r.factory("contacts",["$q","APICatcher","PAGE",function(e,t){var i=function(){};return i.prototype=Object.create(t),i.prototype.getStoreEmailAddress=function(){var e=this,t=new s.Class;return t.initialize("Monitoring","get_store_email_address"),e.promise(t).then(function(e){return e.data})},i.prototype.list=function(){var e=this,t=new s.Class;return t.initialize("Monitoring","list_contacts"),e.promise(t).then(function(e){return e.data.response.contacts||[]})},i.prototype.get=function(e){var t=this;if("string"!=typeof e||""===e)throw new Error("The `id` argument is required.");var i=new s.Class;return i.initialize("Monitoring","get_contact"),i.addArgument("id",e),t.promise(i).then(function(e){return e.data.response})},i.prototype.create=function(e,t){var i=this;if("string"!=typeof e||""===e)throw new Error("The `name` argument is required.");if("string"!=typeof t||""===t)throw new Error("The `email` argument is required.");var r=new s.Class;return r.initialize("Monitoring","create_contact"),r.addArgument("name",e),r.addArgument("email",t),i.promise(r).then(function(e){if(e.error)throw new Error(e.error);if(e.id)return e.id;throw new Error("Unknown response")})},new i}])}),define("app/services/batch",["angular"],function(e){"use strict";var t=e.module("cpanel.siteMonitor.batchService",[]);t.factory("batch",["$q",function(e){return{uniform:function(t,i,s,r,n){var o=t.length,a={},c=0;return new e(function(l){!function u(){if(o>c){var h=t.slice(c,c+i).map(function(e){return s(e).then(function(t){a[r(e)]=t,n&&n(e)}).catch(function(t){n&&n(e,t)})});return e.all(h).finally(function(){c+=i,u()})}l(a)}()})}}}])}),define("app/directives/whatsShowingDirective",["angular","cjt/util/locale","cjt/core"],function(e,t,i){"use strict";var s=e.module("cpanel.siteMonitor.whatsShowingDirective",[]);s.directive("whatsShowing",function(){var e="directives/whatsShowingDirective.phtml",s="site-monitor/"+e;return{templateUrl:i.config.debug?i.buildFullPath(s):e,restrict:"EA",scope:{start:"=",limit:"=",total:"="},transclude:!0,controller:["$scope",function(e){e.LOCALE=t}]}})}),define("app/directives/itemListerDirective",["angular","cjt/util/locale","cjt/core","ngRoute","ngSanitize","cjt/modules","cjt/services/cpanel/componentSettingSaverService","app/services/sites","cjt/directives/toggleSortDirective","cjt/directives/searchDirective","cjt/directives/pageSizeDirective","app/directives/whatsShowingDirective","cjt/filters/startFromFilter","cjt/decorators/paginationDecorator"],function(e,t,i){"use strict";var s=e.module("cpanel.siteMonitor.itemListerDirective",["cpanel.siteMonitor.whatsShowingDirective","ngRoute","ngSanitize","cjt2.filters.startFrom"]);s.directive("itemLister",["$window","$log","componentSettingSaverService",function(s,r,n){var o="itemLister",a="directives/itemListerDirective.phtml",c="site-monitor/"+a;return{templateUrl:i.config.debug?i.buildFullPath(c):a,restrict:"EA",scope:{parentID:"@id",items:"=",headers:"=",configuration:"="},transclude:!0,replace:!0,link:function(t,i){function s(e){a.append(e)}function r(e){e.setAttribute("id",t.parentID+"_transcludePoint"),e.setAttribute("ng-if","filteredItems.length"),c.replaceWith(e)}function n(t){e.element(t).hasClass("lister-controls")?s(t):r(t)}function o(){a=i.find("#"+t.parentID+"_transcludedControls"),c=i.find("#"+t.parentID+"_transcludePoint");var s=i.find("div.transcluded"),r=s.children();e.forEach(r,n),s.remove()}var a,c;setTimeout(o,2)},controller:["$routeParams","$scope","$filter","ITEM_LISTER_CONSTANTS","sites","PAGE","alertService",function(i,a,c,l,u,h,d){function p(e){return""!==a.filterValue?S.filter(e,a.filterValue,!1):e}function f(e){return""!==a.sort.sortDirection&&""!==a.sort.sortBy?("batchSelect"===a.sort.sortBy&&(a.sort.sortBy="domain"),S.orderBy(e,a.sort.sortBy,"asc"!==a.sort.sortDirection)):e}function m(e){if(a.totalItems>_.min(a.pageSizes)){var t=(a.currentPage-1)*a.pageSize,i=a.pageSize;e=S.startFrom(e,t),e=S.limitTo(e,i),a.showPager=!0,a.start=t+1,a.limit=t+e.length}else a.showPager=!1,a.start=0===e.length?0:1,a.limit=e.length;return e}function g(e){if(!a.loadingInitialState){var t={totalItems:a.totalItems,currentPage:a.currentPage,pageSize:a.pageSize,start:a.start,limit:a.limit,lastInteractedItem:e,filterValue:a.filterValue,sort:{sortDirection:a.sort.sortDirection,sortBy:a.sort.sortBy}};n.set(o,t)}}function v(e,t){t.interactionID&&g(t.interactionID)}function b(){var e=!0;u.get().then(function(t){for(var i=0;i<t.length;i++)if(!t[i].selected){e=!1;break}a.selectAll=e,y(t)})}function y(e){var t=e.filter(function(e){return e.selected});a.disableBtn=t.length?!1:!0}function w(t){e.extend(a,t,{filterValue:i.q})}a.PAGE=d,a.LOCALE=t,a.viewCallbacks=[],a.disableBtn=!0;var S={filter:c("filter"),orderBy:c("orderBy"),startFrom:c("startFrom"),limitTo:c("limitTo")};a.itemClicked=function(e,t){a.disableBtn=!0,a.$emit(l.ITEM_CLICKED_EVENT,{actionType:e,items:t})},this.getHeaders=function(){return a.headers},this.registerViewCallback=function(e){a.viewCallbacks.push(e),e(a.filteredItems)},this.deregisterViewCallback=function(e){for(var t=a.viewCallbacks.length-1;t>=0;t--)a.viewCallbacks[t]===e&&a.viewCallbacks.splice(t,1)},a.updateView=function(){var t=[];t=p(a.items),a.totalItems=t.length,t=f(t),t=m(t),a.filteredItems=t,g(),e.forEach(a.viewCallbacks,function(e){e(a.filteredItems)}),a.$emit(l.ITEM_LISTER_UPDATED_EVENT,{meta:{filterValue:a.filterValue}})},a.focusSearch=function(){e.element(document).find("#"+a.parentID+"_search_input").focus(),s.scrollTop=0},a.configurationClicked=function(e){a.$emit(e)},a.monitorClicked=function(e){a.$emit(e)},a.toggleSelect=function(){u.get().then(function(e){for(var t=0;t<e.length;t++){var i=e[t];i.selected=a.selectAll}a.disableBtn=a.selectAll?!1:!0})},a.hasSelected=function(){u.get().then(function(e){for(var t=0;t<e.length;t++)if(e[t].selected)return!0;return!1})},a.getSelected=function(){var e=a.items,t=e.filter(function(e){return e.selected});return t},a.$on(l.ITEM_CLICKED_EVENT,v),a.$on(l.ITEM_SELECT_EVENT,b),a.$on(l.MONITOR_CHANGE_EVENT,function(){a.disableBtn=!1,b(),a.focusSearch()}),e.extend(a,{maxPages:5,totalItems:a.items.length,filteredItems:[],currentPage:1,pageSize:20,pageSizes:[20,50,100,500],start:0,limit:20,filterValue:"",sort:{sortDirection:"asc",sortBy:a.headers&&a.headers.length?a.headers[0].field:""}},{filterValue:i.q}),a.loadingInitialState=!0,n.register(o).then(w,r.error).finally(function(){a.loadingInitialState=!1,a.updateView()}),this.showConfigColumn=a.showConfigColumn=a.configuration&&a.configuration.length,a.$on("$destroy",function(){n.unregister(o)}),a.updateView(),a.$watch("items",a.updateView)}]}}])}),define("app/directives/docrootDirective",["angular","lodash","cjt/core"],function(e,t,i){"use strict";var s=e.module("cpanel.siteMonitor.docrootDirective",[]);s.value("PAGE",PAGE),s.directive("docroot",function(){var e="directives/docrootDirective.phtml",s="site-monitor/"+e;return{templateUrl:i.config.debug?i.buildFullPath(s):e,restrict:"E",scope:{parentID:"@id",rawDocroot:"@docroot",homedir:"@"},controller:["$scope","PAGE",function(e,i){function s(i){e.fullDocroot=encodeURIComponent(i);var s=new RegExp("^"+t.escapeRegExp(e.homedir)+"/?");return e.docroot=i.replace(s,""),e.docroot="/"===e.docroot?"":e.docroot,e.docroot}e.fileManager=i.fileManager,e.$watch("rawDocroot",s),s(e.rawDocroot)}]}})}),define("app/directives/monitorDirective",["angular","lodash","cjt/core","cjt/util/locale","app/models/monitor-state.enum","cjt/directives/spinnerDirective"],function(e,t,i,s,r){"use strict";var n=e.module("cpanel.siteMonitor.monitorDirective",["cjt2.directives.spinner"]);n.directive("monitor",["spinnerAPI",function(e){var t="directives/monitorDirective.phtml",n="site-monitor/"+t;return{templateUrl:i.config.debug?i.buildFullPath(n):t,restrict:"E",require:"^monitors",scope:{monitor:"=data",parentID:"@parentID"},link:function(t){t.$watch("monitor.state",function(t,i,s){var n=s.makeSpinnerId(s.monitor);switch(t){case r.Creating:case r.Removing:e.start(n);break;default:e.stop(n)}},!0)},controller:["$scope","spinnerAPI",function(e){e.LOCALE=s,e.MonitorState=r,e.standardPorts={http:80,https:443},e.hasStandardPort=function(t,i){return e.standardPorts[t]===i},e.makeSpinnerId=function(t){return e.parentID+"_spinner_"+t.url()},e.monitorStateMessage=function(e){switch(e){case r.Creating:return s.maketext("Configuring…");case r.Removing:return s.maketext("Removing…");case r.Ready:return s.maketext("Active");case r.Error:return s.maketext("Failed");case r.None:default:return""}}}]}}])}),define("app/directives/monitorsDirective",["angular","lodash","cjt/core","cjt/util/locale","app/directives/monitorDirective"],function(e,t,i,s){"use strict";var r=e.module("cpanel.siteMonitor.monitorsDirective",["cpanel.siteMonitor.monitorDirective"]);r.directive("monitors",function(){var e="directives/monitorsDirective.phtml",t="site-monitor/"+e;return{templateUrl:i.config.debug?i.buildFullPath(t):e,restrict:"E",scope:{parentID:"@id",site:"=data"},controller:["$scope",function(e){e.LOCALE=s}]}})}),define("app/directives/siteItemListDirective",["lodash","angular","cjt/core","cjt/util/locale","app/models/domain-type.enum","app/directives/docrootDirective","app/directives/monitorsDirective"],function(e,t,i,s,r){"use strict";var n=t.module("cpanel.siteMonitor.siteItemListDirective",["cpanel.siteMonitor.docrootDirective","cpanel.siteMonitor.monitorsDirective"]);n.directive("siteItemList",[function(){var e="directives/siteItemListDirective.phtml",t="site-monitor/"+e;return{templateUrl:i.config.debug?i.buildFullPath(t):e,restrict:"EA",replace:!0,require:"^itemLister",scope:!0,link:function(e,t,i,r){e.LOCALE=s,e.showConfigColumn=r.showConfigColumn,e.headers=r.getHeaders(),e.updateView=function(t){e.sites=t},r.registerViewCallback(e.updateView.bind(e)),e.$on("$destroy",function(){r.deregisterViewCallback(e.updateView)})},controller:["$scope","ITEM_LISTER_CONSTANTS","PAGE","alertService","$timeout",function(e,t,i){e.isRTL=i.isRTL,e.DomainType=r,e.hasWebServerRole=i.hasWebServerRole,e.getSites=function(){return e.sites},e.itemClicked=function(i,s){e.$emit(t.ITEM_CLICKED_EVENT,{actionType:i,item:s,interactionID:s.domain})},e.itemSelected=function(i){e.$emit(t.ITEM_SELECT_EVENT,i)},e.$on(t.MONITOR_CHANGE_EVENT,function(t,i){e.updateView(i)})}]}}])}),define("app/services/dataStore",["angular"],function(e){"use strict";var t=e.module("cpanel.siteMonitor.dataStoreService",[]);t.factory("dataStore",["$window",function(t){return{save:function(i,s){t.localStorage.setItem(i,e.toJson(s))},get:function(i){var s=t.localStorage.getItem(i);return e.fromJson(s)},remove:function(e){t.localStorage.removeItem(e)},clear:function(){t.localStorage.clear()}}}])}),define("app/views/listSiteMonitors",["angular","cjt/util/locale","app/models/monitor-state.enum","app/models/monitor-type.enum","app/models/monitor","app/services/sites","app/services/monitoring","app/services/contacts","app/services/sitesCache","app/services/batch","cjt/services/alertService","app/directives/itemListerDirective","app/directives/siteItemListDirective","cjt/services/cpanel/componentSettingSaverService","cjt/services/viewNavigationApi","app/services/dataStore"],function(e,t,i,s,r){"use strict";var n=e.module("cpanel.siteMonitor.listSiteMonitors",["cpanel.siteMonitor.siteItemListDirective","cpanel.siteMonitor.itemListerDirective","cpanel.siteMonitor.monitoringService","cpanel.siteMonitor.batchService","cpanel.siteMonitor.contactsService","cjt2.services.viewNavigationApi","cjt2.services.alert","cpanel.siteMonitor.dataStoreService","cpanel.siteMonitor.sitesCacheService"]),o="siteMonitor.listView",a=n.controller("listSiteMonitors",["$scope","$location","$filter","$timeout","componentSettingSaverService","initialSites","viewNavigationApi","dataStore","sitesCache","sites","batch","monitoring","alertService","contacts","ITEM_LISTER_CONSTANTS","PAGE",function(e,n,a,c,l,u,h,d,p,_,f,m,g,v,b){function y(t,i){switch(i.actionType){case"enable_multiple":e.disableBtn=!0;var s=i.items,r=s.map(function(e){return{url:e.domain,fullUrl:"https://"+e.domain+"/",domain:e.domain}});d.save("post-subscribe",r),E(r).then(function(){w()});break;case"disable_multiple":e.disableBtn=!0;var s=i.items,r=s.filter(function(e){return e.monitors.length?!0:void 0}).map(function(e){var t=e.monitors[0];return{url:t.url(),id:t.id,domain:e.domain}});d.save("post-unsubscribe",r),S(r).then(function(){w()});break;case"enable":e.disableBtn=!0;var n=i.item,r=[n].map(function(e){return{url:e.domain,fullUrl:"https://"+e.domain+"/",domain:e.domain}});d.save("post-subscribe",r),E(r).then(function(){w()});break;case"disable":e.disableBtn=!0;var n=i.item,o=n.monitors[0],r=[{url:o.url(),id:o.id,domain:n.domain}];d.save("post-unsubscribe",r),S(r).then(function(){w()});break;case"manage":}}function w(){_.get({refresh:!0}).then(function(t){e.disableBtn=!1,x(),e.$broadcast(b.MONITOR_CHANGE_EVENT,t)})}function S(s){var r={error:[],success:[]};return f.uniform(s,2,function(t){var s=p.findMonitor(t.domain,t.url);return s&&(s.state=i.Removing,e.$applyAsync()),m.disable(t.id,t.url)},function(e){return e.url},function(s,n){var o=p.findMonitor(s.domain,s.url);n?(o&&(o.state=i.Error),g.add({type:"danger",message:t.maketext("Failed to remove the monitor [_1] with the error: [_2]",o.url(),n),closeable:!0,replace:!1}),r.error.push(o)):(o&&(o.state=i.Ready,e.$applyAsync()),r.success.push(o))}).then(function(){r.success.length>0&&r.error.length>0?g.success({message:t.maketext("The system successfully removed some of the requested monitors."),replace:!1}):r.success.length>0&&0===r.error.length&&g.success({message:t.maketext("The system successfully removed the requested monitors."),replace:!1})})}function E(n){return n.forEach(function(e){var t=p.findByDomainName(e.domain);if(t){var n=r.parseItem({url:e.fullUrl,name:e.url,type:s.https,state:i.None});t.addMonitor(n)}}),v.getStoreEmailAddress().then(function(s){if(!s){var r=t.maketext("The system could not find the an email address to use when setting up your monitors.");throw g.add({type:"danger",message:r,closeable:!0,replace:!1}),new Error(r)}var o={error:[],success:[]};return f.uniform(n,2,function(t){var r=p.findMonitor(t.domain,t.fullUrl);return r.state=i.Creating,e.$applyAsync(),m.enable(t.url,null,[s])},function(e){return e.url},function(s,r){var n=p.findMonitor(s.domain,s.fullUrl);r?(n.state=i.Error,g.add({type:"danger",message:t.maketext("Failed to create the monitor [_1] with the error: [_2]",n.url,r),closeable:!0,replace:!1}),o.error.push(n)):(n.state=i.Ready,o.success.push(n)),e.$applyAsync()}).then(function(){o.success.length>0&&o.error.length>0?g.success({message:t.maketext("The system successfully created some of the requested monitors."),replace:!1}):o.success.length>0&&0===o.error.length&&g.success({message:t.maketext("The system successfully created the requested monitors."),replace:!1})})})}function D(t){return e.showAssociatedSubdomains?!0:t.associatedAddonDomain?!1:!0}function x(){var t=a("filter")(p.get(),D);T=e.showAssociatedSubdomains,e.filteredSites=t}function k(){e.configuration.splice(0),A&&e.configuration.push(e.showAssociatedSubdomains?{label:t.maketext("Hide Associated Subdomains"),event:C.HIDE_ASSOCIATED}:{label:t.maketext("Show Associated Subdomains"),event:C.SHOW_ASSOCIATED})}var A,C={HIDE_ASSOCIATED:"hideAssociatedSubdomains",SHOW_ASSOCIATED:"showAssociatedSubdomains"};e.LOCALE=t,e.disableBtn=!1;var T=!0;e.toggleShowAssociatedSubdomains=function(){e.showAssociatedSubdomains=!e.showAssociatedSubdomains,l.set(o,{showAssociatedSubdomains:e.showAssociatedSubdomains}),x(),k()},e.getSites=function(){return T!==e.showAssociatedSubdomains&&x(),e.filteredSites},e.configuration=[],k(),e.$on(b.ITEM_CLICKED_EVENT,y),e.$on(C.SHOW_ASSOCIATED,e.toggleShowAssociatedSubdomains),e.$on(C.HIDE_ASSOCIATED,e.toggleShowAssociatedSubdomains),e.showAssociatedSubdomains=!1,e.headers=[{field:"batchSelect","class":"batch-select-column",sortable:!1,label:null},{field:"domain",sortable:!0,"class":"domain-column",label:t.maketext("Site")},{field:"documentRoot","class":"docroot-column",sortable:!0,label:t.maketext("Document Root"),hiddenInSmall:!0},{field:"monitors","class":"monitors-column",sortable:!0,label:t.maketext("Monitors"),hiddenInSmall:!0},{field:"actions","class":"actions-column",label:t.maketext("Actions"),hiddenInSmall:!0}],l.register(o).then(function(t){t&&e.showAssociatedSubdomains!==t.showAssociatedSubdomains&&(e.showAssociatedSubdomains=t.showAssociatedSubdomains,x(),k())}),e.$on("$destroy",function(){l.unregister(o)}),u instanceof Error?(g.add({type:"danger",message:u.message,closeable:!0,replace:!0}),e.filteredSites=[]):e.filteredSites=u}]);return a}),define("app/index",["angular","cjt/core","app/views/ROUTES","cjt/modules","ngRoute","ngAnimate","cjt/services/alertService","app/services/sites","app/services/sitesCache","cjt/directives/loadingPanel","cjt/decorators/alertAPIReporter","cjt/directives/alertList","angular-chosen","app/views/listSiteMonitors"],function(e,t,i){"use strict";return function(){e.module("cpanel.siteMonitor",["ngRoute","ngAnimate","cjt2.cpanel","cpanel.siteMonitor.sitesService","cpanel.siteMonitor.sitesCacheService","cjt2.directives.loadingPanel","cjt2.services.alert","localytics.directives","cpanel.siteMonitor.listSiteMonitors"]);var t=["cjt/bootstrap","cjt/directives/breadcrumbs","cjt/views/applicationController"];i.forEach(function(e){t.push("app/views/"+e.controller)});var s=require(t,function(t){var s=e.module("cpanel.siteMonitor");s.value("PAGE",PAGE),s.value("ITEM_LISTER_CONSTANTS",{ITEM_CLICKED_EVENT:"ClickEmitted",ITEM_SELECT_EVENT:"SelectEmitted",MONITOR_CHANGE_EVENT:"MonitorChangeEmitted"}),s.config(["$routeProvider","$animateProvider",function(e,t){t.classNameFilter(/^((?!no-animate).)*$/),i.forEach(function(t){var i={controller:t.controller,templateUrl:t.templateUrl,breadcrumb:t.breadcrumb,resolve:t.resolve};e.when(t.path,i)}),e.otherwise({redirectTo:"/"})}]),s.controller("main",["$scope","$rootScope","$location","alertService",function(e,t,i,s){t.$on("$routeChangeStart",function(){e.loading=!0,s.clear("danger")}),t.$on("$routeChangeSuccess",function(){e.loading=!1}),t.$on("$routeChangeError",function(){e.loading=!1})}]),t("#content","cpanel.siteMonitor")});return s}});
Back to Directory
File Manager