12 |
- "use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5032],{63773:(t,e,a)=>{a.d(e,{O:()=>s});var i=a(43215),r=a(90923);const n={http:80,https:443,ftp:21};class s{constructor(){this.absUrl=this.wrapInDeprecationWarning(this.absUrl),this.hash=this.wrapInDeprecationWarning(this.hash),this.host=this.wrapInDeprecationWarning(this.host),this.path=this.wrapInDeprecationWarning(this.path),this.port=this.wrapInDeprecationWarning(this.port,"window.location"),this.protocol=this.wrapInDeprecationWarning(this.protocol,"window.location"),this.replace=this.wrapInDeprecationWarning(this.replace),this.search=this.wrapInDeprecationWarning(this.search),this.state=this.wrapInDeprecationWarning(this.state),this.url=this.wrapInDeprecationWarning(this.url)}wrapInDeprecationWarning(t,e){let a=this;return function(){return(0,i.deprecationWarning)("$location",t.name,e||"locationService"),t.apply(a,arguments)}}absUrl(){return`${window.location.origin}${this.url()}`}hash(t){if((0,r.navigationLogger)("AngularLocationWrapper",!1,"Angular compat layer: hash"),t)throw new Error("AngularLocationWrapper method not implemented.");return r.locationService.getLocation().hash.slice(1)}host(){return new URL(window.location.href).hostname}path(t){(0,r.navigationLogger)("AngularLocationWrapper",!1,"Angular compat layer: path");const e=r.locationService.getLocation();if(null!=t){let a=String(t);a=a.startsWith("/")?a:`/${a}`;const i=new URL(`${window.location.origin}${a}`);return r.locationService.push({pathname:i.pathname,search:i.search.length>0?i.search:e.search,hash:i.hash.length>0?i.hash:e.hash}),this}return null===t?(r.locationService.push("/"),this):e.pathname}port(){const t=new URL(window.location.href);return parseInt(t.port,10)||n[t.protocol]||null}protocol(){return new URL(window.location.href).protocol.slice(0,-1)}replace(){throw new Error("AngularLocationWrapper method not implemented.")}search(t,e){if((0,r.navigationLogger)("AngularLocationWrapper",!1,"Angular compat layer: search"),!t)return r.locationService.getSearchObject();if(t&&arguments.length>1)return r.locationService.partial({[t]:e}),this;if(t){let e;e="object"==typeof t?Object.assign({},t):(0,r.locationSearchToObject)(t);for(const t of Object.keys(e))null!==e[t]&&void 0!==e[t]||delete e[t];const a=i.urlUtil.renderUrl(r.locationService.getLocation().pathname,e);r.locationService.push(a)}return this}state(t){throw(0,r.navigationLogger)("AngularLocationWrapper",!1,"Angular compat layer: state"),new Error("AngularLocationWrapper method not implemented.")}url(t){if((0,r.navigationLogger)("AngularLocationWrapper",!1,"Angular compat layer: url"),void 0!==t)return t.startsWith("#")?r.locationService.push(Object.assign({},r.locationService.getLocation(),{hash:t})):t.startsWith("?")?r.locationService.push(Object.assign({},r.locationService.getLocation(),{search:t})):0===t.trim().length?r.locationService.push("/"):r.locationService.push(t),r.locationService;const e=r.locationService.getLocation();return`${e.pathname}${e.search}${e.hash}`}}},15866:(t,e,a)=>{a.d(e,{k:()=>l});var i=a(82897),r=a(43215),n=a(91082),s=a(60301);function o(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}class l extends n.q{constructor(t,e){super(t,e),o(this,"contextSrv",void 0),o(this,"datasourceSrv",void 0),o(this,"timeSrv",void 0),o(this,"templateSrv",void 0),o(this,"interval",void 0),o(this,"intervalMs",void 0),o(this,"resolution",void 0),o(this,"timeInfo",void 0),o(this,"skipDataOnInit",!1),o(this,"dataList",[]),o(this,"querySubscription",void 0),o(this,"useDataFrames",!1),o(this,"panelData",void 0),o(this,"panelDataObserver",{next:t=>{if(this.panelData=t,t.state===r.LoadingState.Error&&(this.loading=!1,this.processDataError(t.error)),t.state===r.LoadingState.Loading)return this.loading=!0,void this.angularDirtyCheck();if(t.request){const{timeInfo:e}=t.request;e&&(this.timeInfo=e)}if(t.timeRange&&(this.range=t.timeRange),this.useDataFrames)this.handleDataFrames(t.series);else{const e=t.series.map((t=>(0,r.toLegacyResponseData)(t)));this.handleQueryResult({data:e})}this.angularDirtyCheck()}}),this.contextSrv=e.get("contextSrv"),this.datasourceSrv=e.get("datasourceSrv"),this.timeSrv=e.get("timeSrv"),this.templateSrv=e.get("templateSrv"),this.panel.datasource=this.panel.datasource||null,this.events.on(r.PanelEvents.refresh,this.onMetricsPanelRefresh.bind(this)),this.events.on(r.PanelEvents.panelTeardown,this.onPanelTearDown.bind(this)),this.events.on(r.PanelEvents.componentDidMount,this.onMetricsPanelMounted.bind(this))}onMetricsPanelMounted(){const t=this.panel.getQueryRunner();this.querySubscription=t.getData({withTransforms:!0,withFieldConfig:!0}).subscribe(this.panelDataObserver)}onPanelTearDown(){this.querySubscription&&(this.querySubscription.unsubscribe(),this.querySubscription=null)}onMetricsPanelRefresh(){if(!this.otherPanelInFullscreenMode()){if(this.panel.snapshotData){this.updateTimeRange();let t=this.panel.snapshotData;return(0,i.isArray)(t)||(t=t.data),this.panelData={state:r.LoadingState.Done,series:t,timeRange:this.range},this.$timeout((()=>{this.events.emit(r.PanelEvents.dataSnapshotLoad,t)}))}return delete this.error,this.loading=!0,this.datasourceSrv.get(this.panel.datasource,this.panel.scopedVars).then(this.issueQueries.bind(this)).catch((t=>{this.processDataError(t)}))}}processDataError(t){t.cancelled?console.log("Panel request cancelled",t):(this.error=t.message||"Request Error",t.data&&(t.data.message?this.error=t.data.message:t.data.error&&(this.error=t.data.error)),this.angularDirtyCheck())}angularDirtyCheck(){this.$scope.$root.$$phase||this.$scope.$digest()}updateTimeRange(t){this.datasource=t||this.datasource,this.range=this.timeSrv.timeRange();const e=(0,s.W1)(this.panel,this.range);this.timeInfo=e.timeInfo,this.range=e.timeRange}issueQueries(t){this.updateTimeRange(t),this.datasource=t;const e=this.panel;return e.getQueryRunner().run({datasource:e.datasource,queries:e.targets,panelId:e.id,dashboardId:this.dashboard.id,timezone:this.dashboard.getTimezone(),timeInfo:this.timeInfo,timeRange:this.range,maxDataPoints:e.maxDataPoints||this.width,minInterval:e.interval,scopedVars:e.scopedVars,cacheTimeout:e.cacheTimeout,transformations:e.transformations})}handleDataFrames(t){this.loading=!1,this.dashboard&&this.dashboard.snapshot&&(this.panel.snapshotData=t.map((t=>(0,r.toDataFrameDTO)(t))));try{this.events.emit(r.PanelEvents.dataFramesReceived,t)}catch(t){this.processDataError(t)}}handleQueryResult(t){this.loading=!1,this.dashboard.snapshot&&(this.panel.snapshotData=t.data),t&&t.data||(console.log("Data source query result invalid, missing data field:",t),t={data:[]});try{this.events.emit(r.PanelEvents.dataReceived,t.data)}catch(t){this.processDataError(t)}}}},91082:(t,e,a)=>{a.d(e,{q:()=>h});var i=a(82897),r=a(43215),n=a(63773),s=a(78837),o=a(98163);function l(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}class h{constructor(t,e){var a,i;l(this,"panel",void 0),l(this,"error",void 0),l(this,"pluginName",""),l(this,"pluginId",""),l(this,"editorTabs",void 0),l(this,"$scope",void 0),l(this,"$injector",void 0),l(this,"$timeout",void 0),l(this,"editModeInitiated",!1),l(this,"containerHeight",void 0),l(this,"events",void 0),l(this,"loading",!1),l(this,"timing",void 0),l(this,"$location",void 0),l(this,"onPluginTypeChange",(t=>{})),this.panel=null!==(a=this.panel)&&void 0!==a?a:t.$parent.panel,this.dashboard=null!==(i=this.dashboard)&&void 0!==i?i:t.$parent.dashboard,this.$injector=e,this.$scope=t,this.$timeout=e.get("$timeout"),this.editorTabs=[],this.$location=new n.O,this.events=new r.EventBusSrv,this.timing={};const o=s.ZP.panels[this.panel.type];o&&(this.pluginId=o.id,this.pluginName=o.name),t.$on(r.PanelEvents.componentDidMount.name,(()=>this.panelDidMount()))}panelDidMount(){this.events.emit(r.PanelEvents.componentDidMount),this.events.emit(r.PanelEvents.initialized),this.dashboard.panelInitialized(this.panel)}renderingCompleted(){o.rv.renderingCompleted()}refresh(){this.panel.refresh()}publishAppEvent(t,e){this.$scope.$root.appEvent(t,e)}initEditMode(){this.editModeInitiated||(this.editModeInitiated=!0,this.events.emit(r.PanelEvents.editModeInitialized))}addEditorTab(t,e,a,r){const n={title:t,directiveFn:e,icon:r};(0,i.isString)(e)&&(n.directiveFn=()=>({templateUrl:e})),a?this.editorTabs.splice(a,0,n):this.editorTabs.push(n)}getExtendedMenu(){const t=[];return this.events.emit(r.PanelEvents.initPanelActions,t),t}async getAdditionalMenuItems(){return[]}otherPanelInFullscreenMode(){return this.dashboard.otherPanelInFullscreen(this.panel)}render(t){this.events.emit(r.PanelEvents.render,t)}}},88643:(t,e,a)=>{a.d(e,{G:()=>n});var i=a(82897);function r(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}class n{constructor(t,e){var a,n,s,o,l;r(this,"target",void 0),r(this,"datasource",void 0),r(this,"panelCtrl",void 0),r(this,"panel",void 0),r(this,"hasRawMode",void 0),r(this,"error",void 0),r(this,"isLastQuery",void 0),this.$scope=t,this.$injector=e,this.panelCtrl=null!==(a=this.panelCtrl)&&void 0!==a?a:t.ctrl.panelCtrl,this.target=null!==(n=this.target)&&void 0!==n?n:t.ctrl.target,this.datasource=null!==(s=this.datasource)&&void 0!==s?s:t.ctrl.datasource,this.panel=null!==(o=null===(l=this.panelCtrl)||void 0===l?void 0:l.panel)&&void 0!==o?o:t.ctrl.panelCtrl.panel,this.isLastQuery=(0,i.indexOf)(this.panel.targets,this.target)===this.panel.targets.length-1}refresh(){this.panelCtrl.refresh()}}},4344:(t,e,a)=>{let i;a.d(e,{HX:()=>i,Xr:()=>r,wP:()=>n}),function(t){t.Password="password",t.BasicAuthPassword="basicAuthPassword"}(i||(i={}));const r=(t,e)=>a=>{a.preventDefault(),t.current[e]=void 0,t.current.secureJsonFields[e]=!1,t.current.secureJsonData=t.current.secureJsonData||{},t.current.secureJsonData[e]=""},n=(t,e)=>a=>{t.current.secureJsonData=t.current.secureJsonData||{},t.current.secureJsonData[e]=a.currentTarget.value}},58701:(t,e,a)=>{a.r(e),a.d(e,{plugin:()=>R});var i=a(43215),r=a(4344);function n(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}class s{constructor(t){n(this,"onPasswordReset",void 0),n(this,"onPasswordChange",void 0),n(this,"showUserCredentials",!1),n(this,"showTlsConfig",!1),n(this,"showCertificateConfig",!1),this.current=t.ctrl.current,this.current.jsonData.encrypt=this.current.jsonData.encrypt||"false",this.current.jsonData.sslRootCertFile=this.current.jsonData.sslRootCertFile||"",this.current.jsonData.tlsSkipVerify=this.current.jsonData.tlsSkipVerify||!1,this.current.jsonData.serverName=this.current.jsonData.serverName||"",this.current.jsonData.authenticationType=this.current.jsonData.authenticationType||"SQL Server Authentication",this.onPasswordReset=(0,r.Xr)(this,r.HX.Password),this.onPasswordChange=(0,r.wP)(this,r.HX.Password),this.onAuthenticationTypeChange(),this.onEncryptChange()}onAuthenticationTypeChange(){"Windows Authentication"===this.current.jsonData.authenticationType&&(this.current.user="",this.current.password=""),this.showUserCredentials="Windows Authentication"!==this.current.jsonData.authenticationType}onEncryptChange(){this.showTlsConfig="true"===this.current.jsonData.encrypt,this.showCertificateConfig=this.showTlsConfig&&!1===this.current.jsonData.tlsSkipVerify}}s.$inject=["$scope"],n(s,"templateUrl","partials/config.html");var o=a(82897),l=a(58788),h=a(2937),c=a(10010),u=a(76913),d=a(69649),p=a(90923),m=a(62362),v=a(7166);class g{transformMetricFindResponse(t){const e=(0,p.toDataQueryResponse)(t).data;if(!e||!e.length)return[];const a=e[0],i=[],r=a.fields.find((t=>"__text"===t.name)),n=a.fields.find((t=>"__value"===t.name));if(r&&n)for(let t=0;t<r.values.length;t++)i.push({text:""+r.values.get(t),value:""+n.values.get(t)});else i.push(...a.fields.flatMap((t=>t.values.toArray())).map((t=>({text:t}))));return Array.from(new Set(i.map((t=>t.text)))).map((t=>{var e;return{text:t,value:null===(e=i.find((e=>e.text===t)))||void 0===e?void 0:e.value}}))}async transformAnnotationResponse(t,e){const a=(0,p.toDataQueryResponse)({data:e}).data;if(!a||!a.length)return[];const i=a[0],r=i.fields.find((t=>"time"===t.name));if(!r)return Promise.reject({message:"Missing mandatory time column (with time column alias) in annotation query."});const n=i.fields.find((t=>"timeend"===t.name)),s=i.fields.find((t=>"text"===t.name)),o=i.fields.find((t=>"tags"===t.name)),l=[];for(let e=0;e<i.length;e++){const a=n&&n.values.get(e)?Math.floor(n.values.get(e)):void 0;l.push({annotation:t.annotation,time:Math.floor(r.values.get(e)),timeEnd:a,text:s&&s.values.get(e)?s.values.get(e):"",tags:o&&o.values.get(e)?o.values.get(e).trim().split(/\s*,\s*/):[]})}return l}}function f(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}class b extends p.DataSourceWithBackend{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(0,v.J)();super(t),f(this,"id",void 0),f(this,"name",void 0),f(this,"responseParser",void 0),f(this,"interval",void 0),this.templateSrv=e,this.name=t.name,this.id=t.id,this.responseParser=new g;const a=t.jsonData||{};this.interval=a.timeInterval||"1m"}interpolateVariable(t,e){if("string"==typeof t)return e.multi||e.includeAll?"'"+t.replace(/'/g,"''")+"'":t;if("number"==typeof t)return t;return(0,o.map)(t,(e=>"number"==typeof t?t:"'"+e.replace(/'/g,"''")+"'")).join(",")}interpolateVariablesInQueries(t,e){let a=t;return t&&t.length>0&&(a=t.map((t=>Object.assign({},t,{datasource:this.getRef(),rawSql:this.templateSrv.replace(t.rawSql,e,this.interpolateVariable),rawQuery:!0})))),a}applyTemplateVariables(t,e){return{refId:t.refId,datasource:this.getRef(),rawSql:this.templateSrv.replace(t.rawSql,e,this.interpolateVariable),format:t.format}}async annotationQuery(t){if(!t.annotation.rawQuery)return Promise.reject({message:"Query missing in annotation definition"});const e={refId:t.annotation.name,datasource:this.getRef(),rawSql:this.templateSrv.replace(t.annotation.rawQuery,t.scopedVars,this.interpolateVariable),format:"table"};return(0,l.n)((0,p.getBackendSrv)().fetch({url:"/api/ds/query",method:"POST",data:{from:t.range.from.valueOf().toString(),to:t.range.to.valueOf().toString(),queries:[e]},requestId:t.annotation.name}).pipe((0,c.U)((async e=>await this.responseParser.transformAnnotationResponse(t,e.data)))))}filterQuery(t){return!t.hide}metricFindQuery(t,e){var a,i,r,n;let s="tempvar";e&&e.variable&&e.variable.name&&(s=e.variable.name);const o=null==e?void 0:e.range,d={refId:s,datasource:this.getRef(),rawSql:this.templateSrv.replace(t,{},this.interpolateVariable),format:"table"};return(0,l.n)((0,p.getBackendSrv)().fetch({url:"/api/ds/query",method:"POST",data:{from:null==o||null===(a=o.from)||void 0===a||null===(i=a.valueOf())||void 0===i?void 0:i.toString(),to:null==o||null===(r=o.to)||void 0===r||null===(n=r.valueOf())||void 0===n?void 0:n.toString(),queries:[d]},requestId:s}).pipe((0,c.U)((t=>this.responseParser.transformMetricFindResponse(t))),(0,u.K)((t=>(0,h.of)([])))))}testDatasource(){return(0,l.n)((0,p.getBackendSrv)().fetch({url:"/api/ds/query",method:"POST",data:{from:"5m",to:"now",queries:[{refId:"A",intervalMs:1,maxDataPoints:1,datasource:this.getRef(),rawSql:"SELECT 1",format:"table"}]}}).pipe((0,d.h)({status:"success",message:"Database Connection OK"}),(0,u.K)((t=>(0,h.of)((0,m.Gw)(t))))))}targetContainsTemplate(t){const e=t.rawSql.replace("$__","");return this.templateSrv.containsTemplate(e)}}var w=a(60974);function S(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}class y extends w.QueryCtrl{constructor(t,e){super(t,e),S(this,"formats",void 0),S(this,"lastQueryMeta",void 0),S(this,"lastQueryError",void 0),S(this,"showHelp",!1),this.target.format=this.target.format||"time_series",this.target.alias="",this.formats=[{text:"Time series",value:"time_series"},{text:"Table",value:"table"}],this.target.rawSql||("table"===this.panelCtrl.panel.type?(this.target.format="table",this.target.rawSql="SELECT 1"):this.target.rawSql="SELECT\n $__timeEpoch(<time_column>),\n <value column> as value,\n <series name column> as metric\nFROM\n <table name>\nWHERE\n $__timeFilter(time_column)\nORDER BY\n <time_column> ASC"),this.panelCtrl.events.on(i.PanelEvents.dataReceived,this.onDataReceived.bind(this),t),this.panelCtrl.events.on(i.PanelEvents.dataError,this.onDataError.bind(this),t)}onDataReceived(t){var e;this.lastQueryError=void 0,this.lastQueryMeta=null===(e=t[0])||void 0===e?void 0:e.meta}onDataError(t){if(t.data&&t.data.results){const e=t.data.results[this.target.refId];e&&(this.lastQueryError=e.error)}}}y.$inject=["$scope","$injector"],S(y,"templateUrl","partials/query.editor.html");class D{constructor(t){this.annotation=t.ctrl.annotation,this.annotation.rawQuery=this.annotation.rawQuery||"SELECT\n <time_column> as time,\n <text_column> as text,\n <tags_column> as tags\n FROM\n <table name>\n WHERE\n $__timeFilter(time_column)\n ORDER BY\n <time_column> ASC"}}var P,C,E;D.$inject=["$scope"],E="partials/annotations.editor.html",(C="templateUrl")in(P=D)?Object.defineProperty(P,C,{value:E,enumerable:!0,configurable:!0,writable:!0}):P[C]=E;const R=new i.DataSourcePlugin(b).setQueryCtrl(y).setConfigCtrl(s).setAnnotationQueryCtrl(D)},60974:(t,e,a)=>{a.r(e),a.d(e,{MetricsPanelCtrl:()=>h,PanelCtrl:()=>l,QueryCtrl:()=>c,loadPluginCss:()=>r.loadPluginCss});var i=a(43215),r=a(90923),n=a(15866),s=a(91082),o=a(88643);const l=(0,i.makeClassES5Compatible)(s.q),h=(0,i.makeClassES5Compatible)(n.k),c=(0,i.makeClassES5Compatible)(o.G)}}]);
- //# sourceMappingURL=mssqlPlugin.3ed9f6af8e8372075bfd.js.map
|