(window.webpackJsonp=window.webpackJsonp||[]).push([[203],{193:function(e,t,n){"use strict";n.r(t);n(7),n(28);const o=angular.module("graphdb.framework.jmx.queries.controllers",["ui.bootstrap","toastr","graphdb.framework.rest.monitoring.service"]);o.controller("QueriesCtrl",["$scope","$uibModal","toastr","$interval","$repositories","$jwtAuth","ModalService","MonitoringRestService","$translate","AuthTokenService",function(e,t,n,o,r,i,s,u,c,a){e.loader=!0,e.stringLimit=500,e.expanded={},e.error="",e.paused=!1;const l=document.createElement("a");e.parseNode=function(e){if(null==e)return null;let t="local";if(e.indexOf("://localhost:")<0&&e.indexOf("://localhost/")<0){l.href=e;let n=l.hostname;(function(e){const t=e.split(".");for(let e=0,n=0;e<t.length;e++)if(parseInt(t[e],10)>=0&&parseInt(t[e],10)<=255?n++:n=0,4===n)return!0;return!1})(l.hostname)||(n=l.hostname.split(".")[0]),t=n+":"+l.port}const n=e.match(/\/repositories\/([^\/]+)#(\d+)/);return[n[2],t,n[1]]},e.togglePause=function(){e.paused=!e.paused},e.getQueries=function(){e.getQueriesRunning||e.paused||e.error||!r.getActiveRepository()||(e.getQueriesRunning=!0,u.monitorQuery(r.getActiveRepository()).success((function(t){const n=t;e.noQueries=0===n.length,e.queries={};for(let t=0;t<n.length;t++)n[t].parsedNode=e.parseNode(n[t].node),e.queries[n[t].trackId]=n[t];e.noActiveRepository=!1,e.loader=!1,e.getQueriesRunning=!1})).error((function(t){e.error=getError(t),e.loader=!1,e.getQueriesRunning=!1})))};const d=o((function(){r.isActiveRepoOntopType()||e.getQueries()}),1e3);e.$on("$destroy",(function(){o.cancel(d)})),e.deleteQueryHttp=function(t){e.loader=!0,u.deleteQuery(t,r.getActiveRepository()).success((function(){n.success(c.instant("abort.request.sent.msg")),e.loader=!1})).error((function(t){const o=getError(t);n.error(o,c.instant("common.error")),e.loader=!1}))},e.abortQuery=function(t){s.openSimpleModal({title:c.instant("confirm.abort"),message:c.instant("confirm.abort.warning.msg"),warning:!0}).result.then((function(){e.deleteQueryHttp(t)}))},e.downloadQuery=function(e){const t="query_"+e+".rq";let n="/rest/monitor/repository/"+r.getActiveRepository()+"/query/download?query="+encodeURIComponent(e)+"&filename="+encodeURIComponent(t);i.isAuthenticated()&&(n=n+"&authToken="+encodeURIComponent(a.getAuthToken())),window.open(n,"_blank")},e.toggleQueryExpanded=function(t){e.expanded[t]=!e.expanded[t]}}]),o.controller("DeleteQueryCtrl",["$scope","$uibModalInstance",function(e,t){e.ok=function(){t.close()},e.cancel=function(){t.dismiss("cancel")}}])}}]);