diff --git a/dist/LICENSE b/dist/LICENSE new file mode 100644 index 00000000..261eeb9e --- /dev/null +++ b/dist/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/dist/MANIFEST.txt b/dist/MANIFEST.txt new file mode 100644 index 00000000..c281102a --- /dev/null +++ b/dist/MANIFEST.txt @@ -0,0 +1,31 @@ + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA512 + +{ + "plugin": "grafana-github-datasource", + "version": "1.0.5", + "files": { + "LICENSE": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", + "README.md": "4cbab1c5a1337163f6ded461ae5fff9af2a492893d9184e3e228a307844ab4cf", + "gfx_github_darwin_amd64": "82a3340e6faca7a85e7dbb54dfcbe059595f70ad06961eb907a5f18085dd395d", + "gfx_github_linux_arm64": "83618acd8f4232d37a4fe2334d8f691657a4c8153a388c5d006856db75e00053", + "module.js": "a1b6ce86c12f4aa44f723ea3163182aa44893a3f19125df3a7e3c4a8ad6dc0c8", + "module.js.LICENSE.txt": "0d8f66cd4afb566cb5b7e1540c68f43b939d3eba12ace290f18abc4f4cb53ed0", + "module.js.map": "9d3d8494631d4ce2bfa324e04b72cbd59ccc9a038ff5670e15969743156a342c", + "partials/annotations.editor.html": "dc91670aa0395cc1c64a4901d10125767bac5a88cc8c613a73a8f1765b224787", + "plugin.json": "34bb90635f921d0d772d6c6fe5f2cf7d48708e59e20bcf8aca04382903a605d0" + }, + "time": 1600175591690, + "keyId": "7e4d0c6a708866e7" +} +-----BEGIN PGP SIGNATURE----- +Version: OpenPGP.js v4.10.1 +Comment: https://openpgpjs.org + +wqEEARMKAAYFAl9gvecACgkQfk0ManCIZucq1QII/cgJ/KzLS14h8bh4Cnom +a+nkt2DKAD2GvOSwUXl7zM83D6Bu80knhDZ/ZLsIp6dybdUdMdtU7LLaDlxg +CeDKiXECCQFqFhkGfndcyFfcwdSaR7wXAetUJ/DjQOlqZRfGKfaXy69/Goko +u7tcgWfFjhbM52dWdWNFjL4Q726NfehLGAfC6g== +=QSuW +-----END PGP SIGNATURE----- diff --git a/dist/README.md b/dist/README.md new file mode 100644 index 00000000..864ae485 --- /dev/null +++ b/dist/README.md @@ -0,0 +1,117 @@ +# Grafana GitHub datasource + +[![CircleCI](https://circleci.com/gh/grafana/github-datasource.svg?style=svg)](https://circleci.com/gh/grafana/github-datasource) +[![David Dependency Status](https://david-dm.org/grafana/github-datasource.svg)](https://david-dm.org/grafana/github-datasource) +[![David Dev Dependency Status](https://david-dm.org/grafana/github-datasource/dev-status.svg)](https://david-dm.org/grafana/github-datasource/?type=dev) +[![Known Vulnerabilities](https://snyk.io/test/github/grafana/github-datasource/badge.svg)](https://snyk.io/test/github/grafana/github-datasource) + +[![Maintainability](https://api.codeclimate.com/v1/badges/30a924eb80d5f6b1cf9c/maintainability)](https://codeclimate.com/github/grafana/github-datasource/maintainability) +[![Test Coverage](https://api.codeclimate.com/v1/badges/30a924eb80d5f6b1cf9c/test_coverage)](https://codeclimate.com/github/grafana/github-datasource/test_coverage) + +The GitHub datasource allows GitHub API data to be visually represented in Grafana dashboards. + +## Github API V4 (graphql) + +This datasource uses the [`githubv4` package](https://github.com/shurcooL/githubv4), which is under active development. + +## Features + +### Backend +* [x] Releases +* [x] Commits +* [x] Repositories +* [x] Issues +* [x] Organizations +* [x] Labels +* [x] Milestones +* [x] Response Caching +* [ ] Deploys + +### Frontend +* [x] Visualize queries +* [x] Template variables +* [x] Annotations + +## Caching + +Caching on this plugin is always enabled. + +## Configuration + +Options: + +| Setting | Required | +|---------|----------| +| Access token | true | +| Default Organization | false | +| Default Repository | true | + +To create a new Access Token, navigate to [Personal Access Tokens](https://github.com/settings/tokens) and create a click "Generate new token." + +## Annotations + +Annotations overlay events on a graph. + +![Annotations on a graph](./docs/screenshots/annotations.png) + +With annotations, you can display: + +* Commits +* Issues +* Pull Requests +* Releases +* Tags + +on a graph. + +All annotations require that you select a field to display on the annotation, and a field that represents the time that the event occured. + +![Annotations editor](./docs/screenshots/annotations-editor.png) + +## Variables + +**Work in progress** + +Variables allow you to substitute values in a panel with pre-defined values. + +## Access Token Permissions + +For all repositories: +* `public_repo` +* `repo:status` +* `repo_deployment` +* `read:packages` + +* `user:read` +* `user:email` + +An extra setting is required for private repositories +* `repo (Full control of private repositories)` + + +## Frequently Asked Questions + +* I am using GitHub OAuth on Grafana. Can my users make requests with their individual GitHub accounts instead of a shared `access_token`? + +No. This requires changes in Grafana first. See [this issue](https://github.com/grafana/grafana/issues/26023) in the Grafana project. + +* Why does it sometimes take up to 5 minutes for my new pull request / new issue / new commit to show up? + +We have aggressive caching enabled due to GitHub's rate limiting policies. When selecting a time range like "Last hour", a combination of the queries for each panel and the time range is cached temporarily. + +* I am trying to use a template variable in the "Query" field and it's not working + +Template variables are currently not supported outside of the "Owner / Organization" and "Repository" fields. + +* Why are there two selection options for Pull Requests and Issue times when creating annotations? + +There are two times that affect an annotation: + +* The time range of the dashboard or panel +* The time that should be used to display the event on the graph + +The first selection is used to filter the events that display on the graph. For example, if you select "closed at", only events that were "closed" in your dashboard's time range will be displayed on the graph. + +The second selection is used to determine where on the graph the event should be displayed. + +Typically these will be the same, however there are some cases where you may want them to be different. diff --git a/dist/gfx_github_darwin_amd64 b/dist/gfx_github_darwin_amd64 new file mode 100755 index 00000000..40f71d34 Binary files /dev/null and b/dist/gfx_github_darwin_amd64 differ diff --git a/dist/gfx_github_linux_amd64 b/dist/gfx_github_linux_amd64 new file mode 100755 index 00000000..45419126 Binary files /dev/null and b/dist/gfx_github_linux_amd64 differ diff --git a/dist/gfx_github_linux_arm64 b/dist/gfx_github_linux_arm64 new file mode 100755 index 00000000..ad1870b3 Binary files /dev/null and b/dist/gfx_github_linux_arm64 differ diff --git a/dist/gfx_github_windows_amd64.exe b/dist/gfx_github_windows_amd64.exe new file mode 100755 index 00000000..47f98bbe Binary files /dev/null and b/dist/gfx_github_windows_amd64.exe differ diff --git a/dist/img/github.svg b/dist/img/github.svg new file mode 100644 index 00000000..cb534c99 --- /dev/null +++ b/dist/img/github.svg @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/dist/module.js b/dist/module.js new file mode 100644 index 00000000..e7903b44 --- /dev/null +++ b/dist/module.js @@ -0,0 +1,3 @@ +/*! For license information please see module.js.LICENSE.txt */ +define(["react","@grafana/ui","@grafana/data","@grafana/runtime","emotion","app/core/core_module","lodash"],(function(e,t,n,r,a,o,i){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=7)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t){e.exports=r},function(e,t){e.exports=a},function(e,t){e.exports=o},function(e,t){e.exports=i},function(e,t,n){"use strict";n.r(t);var r=n(2),a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function o(e,t){function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i}function f(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var p=n(3),d=function(e,t,n){return t?e.replace(t,n):t},m=function(e){return!!e.queryType},h={userId:"userId",login:"login",email:"email",avatarUrl:"avatarUrl",time:"time",timeEnd:"timeEnd",title:"title",text:"text",tags:"tags"};function g(e,t){var n,a,o,l,u,f,p,d=[];if(!e||!e.length)return d;var m=!1,g=!1,y={};try{for(var v=c(e.fields),b=v.next();!b.done;b=v.next()){y[(N=b.value).name.toLowerCase()]=N}}catch(e){n={error:e}}finally{try{b&&!b.done&&(a=v.return)&&a.call(v)}finally{if(n)throw n.error}}t=i({field:{},regex:{}},t);var E=[],w=i(i({},h),null==t?void 0:t.field);try{for(var C=c(Object.entries(w)),T=C.next();!T.done;T=C.next()){var q=s(T.value,2),O=q[0],x=q[1],k=x?x.toLowerCase():"";if(k&&y[k]){switch((_={key:O,field:y[k]}).key){case"time":m=!0;break;case"text":g=!0;break;case"tags":_.split=","}var j=t.regex[_.key];j&&(_.regex=new RegExp(j)),E.push(_)}}}catch(e){o={error:e}}finally{try{T&&!T.done&&(l=C.return)&&l.call(C)}finally{if(o)throw o.error}}if(!m){if(!(S=e.fields.find((function(e){return e.type===r.FieldType.time}))))return[];E.push({key:"time",field:S})}if(!g){var S;if(!(S=e.fields.find((function(e){return e.type===r.FieldType.string}))))return[];var F={key:"text",field:S};(null===(p=null==t?void 0:t.regex)||void 0===p?void 0:p.text)&&(F.regex=new RegExp(t.regex.text)),E.push(F)}for(var P=0;P= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import { GitHubQuery } from './types';\nimport { TemplateSrv } from '@grafana/runtime';\nimport { ScopedVars } from '@grafana/data';\n\nexport const replaceVariable = (t: TemplateSrv, value?: string, scoped: ScopedVars): string | undefined => {\n return !!value ? t.replace(value, scoped) : value;\n};\n\nexport const replaceVariables = (t: TemplateSrv, query: GitHubQuery, scoped: ScopedVars): GitHubQuery => {\n Object.keys(query).forEach(key => {\n if (typeof query[key] === 'string') {\n query[key] = replaceVariable(t, query[key], scoped);\n }\n });\n\n if (query.options) {\n const { options } = query;\n Object.keys(options).forEach(key => {\n if (typeof options[key] === 'string') {\n options[key] = replaceVariable(t, options[key], scoped);\n }\n });\n query.options = options;\n }\n\n return query;\n};\n","import { GitHubQuery } from './types';\n\nexport const isValid = (query: GitHubQuery): boolean => {\n // The current requirement is that the query has a querytype\n // TODO: have each option implement a validation function\n return !!query.queryType;\n};\n","import { AnnotationEvent, DataFrame, FieldType, Field, KeyValue } from '@grafana/data';\n\ninterface AnnotationEventNames {\n userId?: string;\n login?: string;\n email?: string;\n avatarUrl?: string;\n time?: string; // or first time\n timeEnd?: string;\n title?: string;\n text?: string; // or first string\n tags?: string; // Split on ','\n}\n\nconst defaultAnnotationEventFinder: AnnotationEventNames = {\n userId: 'userId',\n login: 'login',\n email: 'email',\n avatarUrl: 'avatarUrl',\n time: 'time',\n timeEnd: 'timeEnd',\n title: 'title',\n text: 'text',\n tags: 'tags',\n};\n\ninterface AnnotationEventFieldSetter {\n key: keyof AnnotationEventNames;\n field: Field;\n\n regex?: RegExp; // for text\n split?: string; // for tags\n}\n\nexport interface AnnotationsFromFrameOptions {\n field?: AnnotationEventNames;\n regex?: AnnotationEventNames;\n}\n\nexport function getAnnotationsFromFrame(frame: DataFrame, options?: AnnotationsFromFrameOptions): AnnotationEvent[] {\n const events: AnnotationEvent[] = [];\n if (!frame || !frame.length) {\n return events;\n }\n\n let hasTime = false;\n let hasText = false;\n const byName: KeyValue = {};\n for (const f of frame.fields) {\n byName[f.name.toLowerCase()] = f;\n }\n\n options = {\n field: {},\n regex: {},\n ...options,\n };\n\n const fields: AnnotationEventFieldSetter[] = [];\n const finder: AnnotationEventNames = {\n ...defaultAnnotationEventFinder,\n ...options?.field,\n };\n for (const [key, value] of Object.entries(finder)) {\n const lower = value ? value.toLowerCase() : '';\n if (lower && byName[lower]) {\n const v: AnnotationEventFieldSetter = {\n key: key as keyof AnnotationEventNames,\n field: byName[lower],\n };\n switch (v.key) {\n case 'time':\n hasTime = true;\n break;\n case 'text':\n hasText = true;\n break;\n case 'tags':\n v.split = ',';\n break;\n }\n const regex = options.regex![v.key];\n if (regex) {\n v.regex = new RegExp(regex);\n }\n fields.push(v);\n }\n }\n if (!hasTime) {\n const field = frame.fields.find(f => f.type === FieldType.time);\n if (!field) {\n return []; // no time fields exist\n }\n fields.push({\n key: 'time',\n field,\n });\n }\n\n if (!hasText) {\n const field = frame.fields.find(f => f.type === FieldType.string);\n if (!field) {\n return []; // no text fields exist\n }\n const setter: AnnotationEventFieldSetter = {\n key: 'text',\n field,\n };\n\n if (options?.regex?.text) {\n setter.regex = new RegExp(options.regex.text);\n }\n fields.push(setter);\n }\n\n // Add each value to the string\n for (let i = 0; i < frame.length; i++) {\n const anno: AnnotationEvent = {};\n for (const f of fields) {\n let v = f.field.values.get(i);\n if (f.regex) {\n const match = f.regex.exec(v);\n if (match) {\n v = match[1] ? match[1] : match[0];\n }\n }\n if (f.split) {\n v = (v as string).split(',');\n }\n (anno as any)[f.key] = v;\n }\n events.push(anno);\n }\n\n return events;\n}\n","import {\n AnnotationEvent,\n DataSourceInstanceSettings,\n MetricFindValue,\n DataQueryRequest,\n DataQueryResponse,\n DataFrame,\n DataFrameView,\n ScopedVars,\n} from '@grafana/data';\nimport { DataSourceWithBackend, getTemplateSrv } from '@grafana/runtime';\nimport { GithubDataSourceOptions, Label, GitHubQuery, GitHubVariableQuery } from './types';\nimport { replaceVariables } from './variables';\nimport { isValid } from './validation';\nimport { getAnnotationsFromFrame } from 'common/annotationsFromDataFrame';\n\nexport class DataSource extends DataSourceWithBackend {\n constructor(instanceSettings: DataSourceInstanceSettings) {\n super(instanceSettings);\n }\n\n templateSrv = getTemplateSrv();\n\n // Only execute queries that have a query type\n filterQuery = (query: GitHubQuery) => {\n return isValid(query);\n };\n\n applyTemplateVariables(query: GitHubQuery, scoped: ScopedVars): Record {\n return replaceVariables(this.templateSrv, query, scoped);\n }\n\n async getLabels(repository: string, owner: string, query?: string): Promise {\n return this.getResource('labels', {\n repository,\n owner,\n query,\n });\n }\n\n async annotationQuery(request: any): Promise {\n const { annotation } = request.annotation;\n\n const query = {\n targets: [\n {\n ...annotation,\n datasourceId: this.id,\n },\n ],\n range: request.range,\n interval: request.interval,\n } as DataQueryRequest;\n\n const res = await this.query(query).toPromise();\n\n if (!res?.data?.length) {\n return [];\n }\n return getAnnotationsFromFrame(res.data[0], {\n field: {\n // title: `${request.annotation.name} - ${annotation.queryType}`,\n time: annotation.timeField, // or first time field\n text: annotation.field || 'name',\n },\n });\n }\n\n async getChoices(query: GitHubQuery): Promise {\n const request = {\n targets: [\n {\n ...query,\n refId: 'metricFindQuery',\n },\n ],\n range: {\n to: {},\n from: {},\n },\n } as DataQueryRequest;\n\n try {\n const res = await this.query(request).toPromise();\n const columns = res.data[0]?.fields.map((f: any) => f.name) || [];\n return columns;\n } catch (err) {\n return Promise.reject(err);\n }\n }\n\n async metricFindQuery(query: GitHubVariableQuery, options: any): Promise {\n const request = {\n targets: [\n {\n ...query,\n refId: 'metricFindQuery',\n },\n ],\n range: options.range,\n rangeRaw: options.rangeRaw,\n } as DataQueryRequest;\n\n let res: DataQueryResponse;\n\n try {\n res = await this.query(request).toPromise();\n } catch (err) {\n return Promise.reject(err);\n }\n\n if (!res || !res.data || res.data.length < 0) {\n return [];\n }\n\n const view = new DataFrameView(res.data[0] as DataFrame);\n return view.map(item => {\n return {\n text: item[query.field || 'name'],\n };\n });\n }\n}\n","import { DataSourceJsonData } from '@grafana/data';\nimport { DataQuery } from '@grafana/data';\n\nexport interface Label {\n color: string;\n description: string;\n name: string;\n}\n\nexport interface RepositoryOptions {\n repository?: string;\n owner?: string;\n}\n\nexport interface GithubDataSourceOptions extends DataSourceJsonData, RepositoryOptions {\n // Any global settings\n}\n\nexport interface GithubSecureJsonData {\n // accessToken is set if the user is using a Personal Access Token to connect to GitHub\n accessToken?: string;\n}\n\nexport enum QueryType {\n Commits = 'Commits',\n Issues = 'Issues',\n Contributors = 'Contributors',\n Tags = 'Tags',\n Releases = 'Releases',\n Pull_Requests = 'Pull_Requests',\n Labels = 'Labels',\n Repositories = 'Repositories',\n Organizations = 'Organizations',\n GraphQL = 'GraphQL',\n Milestones = 'Milestones',\n Packages = 'Packages',\n}\n\nexport enum PackageType {\n NPM = 'NPM',\n RUBYGEMS = 'RUBYGEMS',\n MAVEN = 'MAVEN',\n DOCKER = 'DOCKER',\n DEBIAN = 'DEBIAN',\n NUGET = 'NUGET',\n PYPI = 'PYPI',\n}\n\nexport enum PullRequestTimeField {\n ClosedAt,\n CreatedAt,\n MergedAt,\n None,\n}\n\nexport enum IssueTimeField {\n CreatedAt,\n ClosedAt,\n}\n\nexport interface Indexable {\n [index: string]: any;\n}\n\nexport interface ReleasesOptions extends Indexable {}\nexport interface TagsOptions extends Indexable {}\nexport interface PullRequestsOptions extends Indexable {\n timeField?: PullRequestTimeField;\n query?: string;\n}\n\nexport interface CommitsOptions extends Indexable {\n gitRef?: string;\n}\n\nexport interface ContributorsOptions extends Indexable {\n query?: string;\n}\n\nexport interface LabelsOptions extends Indexable {\n query?: string;\n}\n\nexport interface IssuesOptions extends Indexable {\n timeField?: IssueTimeField;\n query?: string;\n}\n\nexport interface PackagesOptions extends Indexable {\n names?: string;\n packageType?: PackageType;\n}\n\nexport interface MilestonesOptions extends Indexable {\n query?: string;\n}\n\nexport interface GitHubQuery extends Indexable, DataQuery, RepositoryOptions {\n options?:\n | PullRequestsOptions\n | ReleasesOptions\n | LabelsOptions\n | TagsOptions\n | CommitsOptions\n | IssuesOptions\n | ContributorsOptions;\n}\n\nexport interface GitHubVariableQuery extends GitHubQuery {\n field?: string;\n}\n\nexport interface GitHubAnnotationQuery extends GitHubVariableQuery {\n timeField?: string;\n}\n\nexport const DefaultQueryType = QueryType.Issues;\n","import React, { PureComponent } from 'react';\nimport { DataSourcePluginOptionsEditorProps } from '@grafana/data';\nimport { LegacyForms, InfoBox, Icon } from '@grafana/ui';\nimport { GithubDataSourceOptions, GithubSecureJsonData } from '../types';\n\nexport type ConfigEditorProps = DataSourcePluginOptionsEditorProps;\n\nexport class ConfigEditor extends PureComponent {\n onSettingReset = (prop: string) => (event: any) => {\n this.onSettingUpdate(prop, false)({ target: { value: undefined } });\n };\n\n onSettingUpdate = (prop: string, set = true) => (event: any) => {\n const { onOptionsChange, options } = this.props;\n onOptionsChange({\n ...options,\n secureJsonData: {\n ...options.secureJsonData,\n [prop]: event.target.value,\n },\n secureJsonFields: {\n ...options.secureJsonFields,\n [prop]: set,\n },\n });\n };\n\n render() {\n const {\n options: { secureJsonData, secureJsonFields },\n } = this.props;\n const secureSettings = (secureJsonData || {}) as GithubSecureJsonData;\n return (\n <>\n \n

\n To create a new Access Token, navigate to{' '}\n \n Personal Access Tokens \n {' '}\n and create a click \"Generate new token.\"\n

\n

Ensure that your token has the following permissions:

\n

For all repositories:

\n
\n            
    \n
  • public_repo
  • \n
  • repo:status
  • \n
  • repo_deployment
  • \n
  • read:packages
  • \n
\n
    \n
  • user:read
  • \n
  • user:email
  • \n
\n
\n

An extra setting is required for private repositories:

\n
\n            
    \n
  • repo (Full control of private repositories)
  • \n
\n
\n
\n
\n

Service Account Access

\n
\n \n
\n
\n {/*
\n

Default Query Options

\n
\n Owner\n \n
\n
\n Repository\n \n
\n
*/}\n \n );\n }\n}\n\nexport default ConfigEditor;\n","import React, { InputHTMLAttributes, FunctionComponent } from 'react';\nimport { InlineFormLabel } from '@grafana/ui';\n\nexport interface Props extends InputHTMLAttributes {\n label: string;\n tooltip?: string;\n labelWidth?: number;\n children?: React.ReactNode;\n}\n\nexport const QueryField: FunctionComponent> = ({ label, labelWidth = 8, tooltip, children }) => (\n <>\n \n {label}\n \n {children}\n \n);\n\nexport const QueryRowTerminator = () => {\n return (\n
\n
\n
\n );\n};\n\nexport const QueryInlineField = ({ ...props }) => {\n return (\n \n \n \n );\n};\n\nexport const QueryEditorRow = (props: any) => {\n return (\n
\n {props.children}\n \n
\n );\n};\n","import React, { useState } from 'react';\nimport { Input, InlineFormLabel } from '@grafana/ui';\n\nimport { QueryEditorRow } from '../components/Forms';\nimport { RepositoryOptions } from '../types';\nimport { RightColumnWidth, LeftColumnWidth } from './QueryEditor';\n\ninterface Props extends RepositoryOptions {\n onChange: (value: RepositoryOptions) => void;\n}\n\nexport default (props: Props) => {\n const [repository, setRepository] = useState(props.repository || '');\n const [owner, setOwner] = useState(props.owner || '');\n\n return (\n \n \n Owner\n \n setOwner(el.currentTarget.value)}\n onBlur={el =>\n props.onChange({\n ...props,\n owner: el.currentTarget.value,\n })\n }\n />\n \n Repository\n \n setRepository(el.currentTarget.value)}\n onBlur={el =>\n props.onChange({\n ...props,\n repository: el.currentTarget.value,\n })\n }\n />\n \n );\n};\n","import React from 'react';\n\nexport default () => <>;\n","import React, { useState } from 'react';\nimport { Input } from '@grafana/ui';\n\nimport { QueryInlineField } from '../components/Forms';\nimport { CommitsOptions } from '../types';\nimport { RightColumnWidth, LeftColumnWidth } from './QueryEditor';\n\ninterface Props extends CommitsOptions {\n onChange: (value: CommitsOptions) => void;\n}\n\nexport default (props: Props) => {\n const [ref, setRef] = useState(props.gitRef || '');\n return (\n <>\n \n setRef(el.currentTarget.value)}\n onBlur={el => props.onChange({ ...props, gitRef: el.currentTarget.value })}\n />\n \n \n );\n};\n","import React, { useState } from 'react';\n\nimport { Input, Select } from '@grafana/ui';\nimport { SelectableValue } from '@grafana/data';\n\nimport { QueryInlineField } from '../components/Forms';\nimport { IssuesOptions, IssueTimeField } from '../types';\nimport { RightColumnWidth, LeftColumnWidth } from './QueryEditor';\n\ninterface Props extends IssuesOptions {\n onChange: (value: IssuesOptions) => void;\n}\n\nconst timeFieldOptions: Array> = Object.keys(IssueTimeField)\n .filter((_, i) => IssueTimeField[i] !== undefined)\n .map((_, i) => {\n return {\n label: `${IssueTimeField[i]}`,\n value: i as IssueTimeField,\n };\n });\n\nconst defaultTimeField = 0 as IssueTimeField;\n\nexport default (props: Props) => {\n const [query, setQuery] = useState(props.query || '');\n return (\n <>\n \n setQuery(el.currentTarget.value)}\n onBlur={el =>\n props.onChange({\n ...props,\n query: el.currentTarget.value,\n })\n }\n />\n \n \n \n props.onChange({\n ...props,\n timeField: opt.value,\n })\n }\n />\n \n \n );\n};\n","import React, { useState } from 'react';\n\nimport { Input } from '@grafana/ui';\n\nimport { QueryInlineField } from '../components/Forms';\nimport { MilestonesOptions } from '../types';\nimport { RightColumnWidth, LeftColumnWidth } from './QueryEditor';\n\ninterface Props extends MilestonesOptions {\n onChange: (value: MilestonesOptions) => void;\n}\n\nexport default (props: Props) => {\n const [query, setQuery] = useState(props.query || '');\n return (\n <>\n \n setQuery(el.currentTarget.value)}\n onBlur={el =>\n props.onChange({\n ...props,\n query: el.currentTarget.value,\n })\n }\n />\n \n \n );\n};\n","import React, { useState } from 'react';\n\nimport { Input, Select } from '@grafana/ui';\nimport { SelectableValue } from '@grafana/data';\n\nimport { QueryInlineField } from '../components/Forms';\nimport { PullRequestsOptions, PullRequestTimeField } from '../types';\n\nimport { RightColumnWidth, LeftColumnWidth } from './QueryEditor';\n\ninterface Props extends PullRequestsOptions {\n onChange: (value: PullRequestsOptions) => void;\n}\n\nconst timeFieldOptions: Array> = Object.keys(PullRequestTimeField)\n .filter((_, i) => PullRequestTimeField[i] !== undefined)\n .map((_, i) => {\n return {\n label: `${PullRequestTimeField[i]}`,\n value: i as PullRequestTimeField,\n };\n });\n\nconst defaultTimeField = timeFieldOptions[0].value;\n\nexport default (props: Props) => {\n const [query, setQuery] = useState(props.query || '');\n return (\n <>\n \n setQuery(el.currentTarget.value)}\n onBlur={el =>\n props.onChange({\n ...props,\n query: el.currentTarget.value,\n })\n }\n />\n \n \n \n props.onChange({\n ...props,\n timeField: opt.value,\n })\n }\n />\n \n \n );\n};\n","import React from 'react';\n\nexport default () => <>;\n","import React, { useState } from 'react';\nimport { Input } from '@grafana/ui';\n\nimport { QueryInlineField } from '../components/Forms';\nimport { ContributorsOptions } from '../types';\nimport { RightColumnWidth, LeftColumnWidth } from './QueryEditor';\n\ninterface Props extends ContributorsOptions {\n onChange: (value: ContributorsOptions) => void;\n}\n\nexport default (props: Props) => {\n const [query, setQuery] = useState(props.query || '');\n return (\n <>\n \n setQuery(el.currentTarget.value)}\n onBlur={el => props.onChange({ ...props, query: el.currentTarget.value })}\n />\n \n \n );\n};\n","import React, { useState } from 'react';\nimport { Input } from '@grafana/ui';\n\nimport { QueryInlineField } from '../components/Forms';\nimport { LabelsOptions } from '../types';\nimport { RightColumnWidth, LeftColumnWidth } from './QueryEditor';\n\ninterface Props extends LabelsOptions {\n onChange: (value: LabelsOptions) => void;\n}\n\nexport default (props: Props) => {\n const [query, setQuery] = useState(props.query || '');\n return (\n <>\n \n setQuery(el.currentTarget.value)}\n onBlur={el => props.onChange({ ...props, query: el.currentTarget.value })}\n />\n \n \n );\n};\n","import React, { useState } from 'react';\n\nimport { Input, Select } from '@grafana/ui';\nimport { SelectableValue } from '@grafana/data';\n\nimport { QueryInlineField } from '../components/Forms';\nimport { PackagesOptions, PackageType } from '../types';\nimport { RightColumnWidth, LeftColumnWidth } from './QueryEditor';\n\ninterface Props extends PackagesOptions {\n onChange: (value: PackagesOptions) => void;\n}\n\nconst DefaultPackageType = PackageType.NPM;\n\nconst packageTypeOptions: Array> = Object.keys(PackageType).map(v => {\n return {\n label: v.replace('/_/gi', ' '),\n value: v,\n };\n});\n\nexport default (props: Props) => {\n const [names, setNames] = useState(props.names || '');\n\n return (\n <>\n \n \n props.onChange({\n ...props,\n packageType: opt.value as PackageType,\n })\n }\n />\n \n \n setNames(el.currentTarget.value)}\n onBlur={el =>\n props.onChange({\n ...props.query,\n names: el.currentTarget.value,\n })\n }\n />\n \n \n );\n};\n","import React, { ReactNode, useCallback } from 'react';\nimport { QueryEditorProps, SelectableValue } from '@grafana/data';\nimport { Select } from '@grafana/ui';\n\nimport { DataSource } from '../DataSource';\nimport { GithubDataSourceOptions, GitHubQuery, QueryType, DefaultQueryType } from '../types';\nimport { QueryInlineField } from '../components/Forms';\nimport { isValid } from '../validation';\n\nimport QueryEditorRepository from './QueryEditorRepository';\nimport QueryEditorReleases from './QueryEditorReleases';\nimport QueryEditorCommits from './QueryEditorCommits';\nimport QueryEditorIssues from './QueryEditorIssues';\nimport QueryEditorMilestones from './QueryEditorMilestones';\nimport QueryEditorPullRequests from './QueryEditorPullRequests';\nimport QueryEditorTags from './QueryEditorTags';\nimport QueryEditorContributors from './QueryEditorContributors';\nimport QueryEditorLabels from './QueryEditorLabels';\nimport QueryEditorPackages from './QueryEditorPackages';\n\ninterface Props extends QueryEditorProps {\n queryTypes?: string[];\n}\nexport const LeftColumnWidth = 10;\nexport const RightColumnWidth = 36;\n\nconst queryEditors: {\n [key: string]: { component: (props: Props, onChange: (val: any) => void) => ReactNode };\n} = {\n [QueryType.Repositories]: {\n component: (_: Props, onChange: (val: any) => void) => <>,\n },\n [QueryType.Labels]: {\n component: (props: Props, onChange: (val: any) => void) => (\n \n ),\n },\n [QueryType.Contributors]: {\n component: (props: Props, onChange: (val: any) => void) => (\n \n ),\n },\n [QueryType.Tags]: {\n component: (props: Props, _: (val: any) => void) => ,\n },\n [QueryType.Releases]: {\n component: (props: Props, _: (val: any) => void) => ,\n },\n [QueryType.Commits]: {\n component: (props: Props, onChange: (val: any) => void) => (\n \n ),\n },\n [QueryType.Milestones]: {\n component: (props: Props, onChange: (val: any) => void) => (\n \n ),\n },\n [QueryType.Issues]: {\n component: (props: Props, onChange: (val: any) => void) => (\n \n ),\n },\n [QueryType.Packages]: {\n component: (props: Props, onChange: (val: any) => void) => (\n \n ),\n },\n [QueryType.Pull_Requests]: {\n component: (props: Props, onChange: (val: any) => void) => (\n \n ),\n },\n};\n\nconst queryTypeOptions: Array> = Object.keys(QueryType).map(v => {\n return {\n label: v.replace('/_/gi', ' '),\n value: v,\n };\n});\n\nexport default (props: Props) => {\n const onChange = useCallback(\n (value: GitHubQuery) => {\n props.onChange(value);\n\n if (isValid(value)) {\n props.onRunQuery();\n }\n },\n [props]\n );\n\n const onKeyChange = useCallback(\n (key: string, value: any) => {\n onChange({\n ...props.query,\n [key]: value,\n });\n },\n [onChange, props.query]\n );\n\n const queryEditor = queryEditors[props.query.queryType || DefaultQueryType];\n const queryTypes = props.queryTypes || Object.keys(queryEditors);\n return (\n <>\n \n queryTypes.includes(v.value!))}\n value={props.query.queryType}\n onChange={val => onKeyChange('queryType', val.value || DefaultQueryType)}\n />\n \n\n {\n onChange({\n ...props.query,\n ...repo,\n });\n }}\n />\n\n {queryEditor ? (\n queryEditor.component(props, (value: any) => onKeyChange('options', !!value ? value : undefined))\n ) : (\n Unsupported Query Type\n )}\n \n );\n};\n","import React from 'react';\nimport { Select, Spinner } from '@grafana/ui';\nimport { css } from 'emotion';\n\ninterface Props {\n onChange: (value: string) => void;\n value?: string;\n options: string[];\n width: number;\n loading: boolean;\n}\n\nconst containerCss = css`\n align-items: center;\n`;\n\nconst spannerCss = css`\n margin: 0px 3px;\n padding: 0px 3px;\n`;\n\nexport default (props: Props) => {\n const { onChange, options, value, width, loading } = props;\n return (\n
\n onChange(opt.value!)}\n width={width}\n disabled={loading}\n placeholder={loading ? 'Loading...' : 'Select...'}\n options={options.map(opt => {\n return {\n label: opt,\n value: opt,\n };\n })}\n />\n {loading && (\n
\n \n
\n )}\n
\n );\n};\n","import React, { useMemo, useState, useCallback } from 'react';\nimport coreModule from 'grafana/app/core/core_module';\n\nimport { AnnotationQueryRequest } from '@grafana/data';\n\nimport QueryEditor from './QueryEditor';\nimport { DataSource } from '../DataSource';\nimport { GitHubAnnotationQuery, QueryType } from '../types';\nimport { QueryInlineField } from '../components/Forms';\nimport FieldSelect from '../components/FieldSelect';\nimport { isValid } from '../validation';\n\ninterface Props {\n datasource: DataSource;\n annotation: AnnotationQueryRequest;\n change: (query: AnnotationQueryRequest) => void;\n}\n\nconst AnnotationQueryEditor = (props: Props) => {\n const [choices, setChoices] = useState();\n const { annotation } = props;\n\n useMemo(async () => {\n if (isValid(props.annotation.annotation)) {\n setChoices(await props.datasource.getChoices(props.annotation.annotation));\n }\n }, [props.annotation.annotation, props.datasource]);\n\n const onChange = useCallback(\n (query: GitHubAnnotationQuery) => {\n props.change({\n ...props.annotation,\n annotation: {\n ...annotation.annotation,\n ...query,\n datasource: props.datasource.name,\n },\n });\n },\n [props, annotation.annotation]\n );\n\n return (\n <>\n \n onChange({\n ...query,\n field: annotation.annotation.field,\n })\n }\n onRunQuery={() => {}}\n queryTypes={[\n QueryType.Commits,\n QueryType.Releases,\n QueryType.Pull_Requests,\n QueryType.Issues,\n QueryType.Milestones,\n ]}\n />\n\n {/* Only display the field selection items when the user has created an actual query */}\n {isValid(props.annotation.annotation) && (\n <>\n \n \n onChange({\n ...annotation.annotation,\n field: value,\n })\n }\n options={choices || []}\n width={64}\n value={annotation.annotation.field}\n loading={!choices}\n />\n \n \n \n onChange({\n ...annotation.annotation,\n timeField: value,\n })\n }\n options={choices || []}\n width={64}\n value={annotation.annotation.timeField}\n loading={!choices}\n />\n \n \n )}\n \n );\n};\n\ncoreModule.directive('githubAnnotationEditor', [\n 'reactDirective',\n (reactDirective: any) => {\n return reactDirective(AnnotationQueryEditor, ['annotation', 'datasource', 'change']);\n },\n]);\n","import './views/AnnotationQueryEditor';\nimport { GitHubAnnotationQuery, DefaultQueryType } from './types';\nimport { DataSource } from './DataSource';\nimport { AnnotationQueryRequest } from '@grafana/data';\nimport { defaultsDeep } from 'lodash';\n\nconst defaultQuery: GitHubAnnotationQuery = {\n queryType: DefaultQueryType,\n refId: '',\n};\n\nexport default class AnnotationCtrl {\n // @ts-ignore\n annotation: AnnotationQueryRequest;\n\n // @ts-ignore\n private datasource?: DataSource;\n\n static templateUrl = 'partials/annotations.editor.html';\n\n /** @ngInject */\n constructor() {\n // @ts-ignore\n this.annotation.annotation = defaultsDeep(this.annotation.annotation, defaultQuery);\n // @ts-ignore\n this.annotation.datasourceId = this.datasource.id;\n }\n\n onChange = (query: AnnotationQueryRequest) => {\n this.annotation.annotation = query.annotation;\n };\n}\n","import { DataSourcePlugin } from '@grafana/data';\nimport { DataSource } from './DataSource';\nimport ConfigEditor from './views/ConfigEditor';\nimport QueryEditor from './views/QueryEditor';\nimport VariableQueryEditor from './views/VariableQueryEditor';\nimport AnnotationCtrl from './annotations';\nimport { GitHubQuery, GithubDataSourceOptions, GithubSecureJsonData } from './types';\n\nexport const plugin = new DataSourcePlugin(\n DataSource\n)\n .setConfigEditor(ConfigEditor)\n .setVariableQueryEditor(VariableQueryEditor)\n .setQueryEditor(QueryEditor)\n .setAnnotationQueryCtrl(AnnotationCtrl);\n","import React, { useMemo, useState } from 'react';\n\nimport QueryEditor from './QueryEditor';\nimport { DataSource } from '../DataSource';\nimport { GitHubVariableQuery, DefaultQueryType, QueryType } from '../types';\nimport { QueryInlineField } from '../components/Forms';\nimport FieldSelect from '../components/FieldSelect';\nimport { isValid } from '../validation';\n\ninterface Props {\n query: GitHubVariableQuery;\n onChange: (query: GitHubVariableQuery, definition: string) => void;\n datasource: DataSource;\n}\n\nexport default (props: Props) => {\n const definition = `${props.datasource.name} - ${props.query.queryType || DefaultQueryType}`;\n const [choices, setChoices] = useState();\n\n useMemo(async () => {\n if (isValid(props.query)) {\n setChoices(await props.datasource.getChoices(props.query));\n }\n }, [props.query, props.datasource]);\n\n return (\n <>\n \n props.onChange(\n {\n ...query,\n field: props.query.field,\n },\n definition\n )\n }\n onRunQuery={() => {}}\n queryTypes={[\n QueryType.Repositories,\n QueryType.Contributors,\n QueryType.Tags,\n QueryType.Releases,\n QueryType.Labels,\n QueryType.Milestones,\n ]}\n />\n \n \n props.onChange(\n {\n ...props.query,\n field: value,\n },\n definition\n )\n }\n options={choices || []}\n width={64}\n value={props.query.field}\n loading={!choices}\n />\n \n \n );\n};\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/partials/annotations.editor.html b/dist/partials/annotations.editor.html new file mode 100644 index 00000000..2d700de6 --- /dev/null +++ b/dist/partials/annotations.editor.html @@ -0,0 +1,5 @@ + diff --git a/dist/plugin.json b/dist/plugin.json new file mode 100644 index 00000000..60c580da --- /dev/null +++ b/dist/plugin.json @@ -0,0 +1,46 @@ +{ + "type": "datasource", + "name": "Github Stats", + "id": "grafana-github-datasource", + "backend": true, + "executable": "gfx_github", + "annotations": true, + "alerting": true, + "metrics": true, + "info": { + "description": "Show data about github issues/pull requests", + "author": { + "name": "Grafana Labs", + "url": "https://grafana.com" + }, + "keywords": [ + "github", + "datasource" + ], + "logos": { + "small": "img/github.svg", + "large": "img/github.svg" + }, + "links": [ + { + "name": "Website", + "url": "https://github.com/grafana/github-datasource" + } + ], + "screenshots": [], + "version": "1.0.5", + "updated": "2020-09-15", + "build": { + "time": 1600175591409, + "repo": "git@github.com:grafana/github-datasource.git", + "branch": "v1.0.x", + "hash": "b29fc99f237a6dfed141d623f84fe4c441742e78", + "number": 316 + } + }, + "dependencies": { + "grafanaDependency": ">=7.1.0", + "grafanaVersion": "7.1.x", + "plugins": [] + } +} \ No newline at end of file