├── .editorconfig ├── .gitignore ├── .prettierrc.js ├── COMPILATION.md ├── LICENSE ├── README.md ├── README_2.md ├── appveyor.yml ├── dashboards └── glpi_app_dashboard.json ├── jest.config.js ├── package.json ├── screenshot1.png ├── src ├── dashboards │ └── glpi_app_dashboard.json ├── datasource │ ├── ConfigEditor.tsx │ ├── DataSource.ts │ ├── QueryEditor.tsx │ ├── img │ │ ├── logo.svg │ │ └── small.png │ ├── module.ts │ ├── plugin.json │ └── types.ts ├── img │ ├── logo.svg │ ├── screenshot1.png │ └── small.png ├── module.ts └── plugin.json ├── tsconfig.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | max_line_length = 120 11 | 12 | [*.{js,ts,tsx,scss}] 13 | quote_type = single 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | node_modules/ 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # Compiled binary addons (https://nodejs.org/api/addons.html) 23 | dist/ 24 | artifacts/ 25 | work/ 26 | ci/ 27 | e2e-results/ 28 | 29 | # Editor 30 | .idea 31 | 32 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | ...require("./node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json"), 3 | }; 4 | -------------------------------------------------------------------------------- /COMPILATION.md: -------------------------------------------------------------------------------- 1 | Due to a bug, after compiled the plugin, update file module.js and modify the begining: 2 | 3 | ``` 4 | define((function 5 | ``` 6 | 7 | by 8 | 9 | ``` 10 | define([],(function 11 | ``` 12 | 13 | Not find why I have this problem for the moment. 14 | See this bug report: https://github.com/grafana/grafana/issues/21785#issuecomment-581792397 15 | 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GLPI app for Grafana 2 | 3 | ## Introduction 4 | 5 | This application gets information in GLPI (Gestion Libre de Parc Informatique). It use the REST API added in 6 | version 9.1. You will be able to have graphs, singlestat, tables... of your data (tickets, devices, users...). 7 | 8 | ## screenshot 9 | 10 | This is an example: 11 | 12 | ![screenshot1](https://raw.githubusercontent.com/ddurieux/glpi_app_grafana/master/screenshot1.png) 13 | 14 | ## Datasource 15 | 16 | For the GLPI datasource, you will need: 17 | 18 | * the URL of the GLPI API (like http://127.0.0.1/glpi/apirest.php) 19 | * the App-token, you can generate and get it in GLPI in the menu Setup > General > API 20 | * the User token, you can generate and get it in the user account/preferences panel in GLPI (named API Token) 21 | * In the menu Setup > General > API, **Enable Rest API** and **Enable login with external** 22 | 23 | ## GLPI Webserver 24 | 25 | On your GLPI webserver, you need active the CORS. 26 | Documentation about [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) 27 | 28 | ### Apache 29 | 30 | ``` 31 | Header set Access-Control-Allow-Origin "*" 32 | Header set Access-Control-Allow-Methods "GET, POST, OPTIONS, PUT, DELETE" 33 | Header set Access-Control-Allow-Credentials true 34 | Header set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding, App-Token, Session-Token" 35 | ``` 36 | 37 | ### NGINX 38 | 39 | ``` 40 | add_header 'Access-Control-Allow-Origin' '*'; 41 | add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE'; 42 | add_header 'Access-Control-Allow-Credentials' 'true'; 43 | add_header 'Access-Control-Allow-Headers' 'Origin,Content-Type,Accept,Authorization,App-Token,Session-Token'; 44 | ``` 45 | 46 | 47 | ## Dashboard 48 | 49 | You can get a [simple dashboard here](https://grafana.com/dashboards/7568) 50 | 51 | ![screenshot1](https://user-images.githubusercontent.com/13823969/44227185-4b92a900-a192-11e8-838e-ee06ed9e7d34.png) 52 | 53 | ## Table panel 54 | 55 | Create a new Table panel and then edit the panel. 56 | Select the GLPI datasource and add a new Query in the panel Metrics. 57 | 58 | The configuration will require: 59 | 60 | * Query: do a search into GLPI and copy paste the URL here 61 | * Alias: the alias name of this query, it will appear in the panel 62 | * Timerange based on: define on which GLPI date field you will get the data. This field is used by the timerange defined in top of grafana 63 | * Count element: if the panel is a Table, select yes, otherwise keep to no 64 | * Is it a table?: to display the query result as a Table, check this option else uncheck. 65 | 66 | When *Is it a table* is checked, the query result will be displayed as a table and you can define up to 6 columns to be displayed. 67 | For each column in the table, select the query result field and the name of the column. 68 | 69 | When *Is it a table* is not checked, the query result is considered as a usual Grafana timeseries and it will displayed as is. See Grafana table panel for more information. 70 | 71 | ## Single stat panel 72 | 73 | 74 | ## Problem with server access 75 | 76 | If you have the message: `There isn't an active API client matching your IP address in the configuration (ip, ip)` where you have 2 IPs and the same, you need apply a patch into GLPI: 77 | 78 | ``` 79 | diff --git a/inc/api.class.php b/inc/api.class.php 80 | index 3ae2966ce..a4a18dc9e 100644 81 | --- a/inc/api.class.php 82 | +++ b/inc/api.class.php 83 | @@ -105,6 +105,10 @@ abstract class API extends CommonGLPI { 84 | 85 | // retrieve ip of client 86 | $this->iptxt = Toolbox::getRemoteIpAddress(); 87 | + $spl = explode(',', $this->iptxt); 88 | + if (count($spl) > 1) { 89 | + $this->iptxt = $spl[0]; 90 | + } 91 | $this->ipnum = (strstr($this->iptxt, ':')===false ? ip2long($this->iptxt) : ''); 92 | 93 | // check ip access 94 | ``` 95 | 96 | 97 | ## Bugs / features 98 | 99 | If you have a bug repoort or request feature, you can open issues in the [github repository](https://github.com/ddurieux/glpi_app_grafana) 100 | 101 | ## Professional support 102 | 103 | Do you need professional support, training, others? 104 | 105 | Please contact the [DCS Easyware company](https://www.dcsit-group.com/) / send a mail to [dcs.glpi@dcsit-group.com](mailto:dcs.glpi@dcsit-group.com) 106 | 107 | 108 | ## Changelog 109 | 110 | ### 2.0.1 111 | * compatibility with Grafana 9.x 112 | 113 | ### 2.0.0 (unreleased) 114 | * compatibility with Grafana 8.x 115 | * rewrite part of code to be easier to read 116 | 117 | ### 1.4.0 118 | * manage variables for GLPI datasource (use the variable name with `[[]]` like `[[myvar]]` in the query) 119 | * add type _query_ in the variable with copy / paste search like for standard queries (it use the name + id of item) 120 | 121 | ### 1.3.0 122 | 123 | * add Apache / NGINX configuration in the readme 124 | * add more instructions in the readme to configure API into GLPI 125 | * add link of a user dashboard in the readme 126 | * add the patch of GLPI in the readme when use the datasource in mode `server` 127 | * fix PHP timezone in the datasource 128 | * update dependencies (and so fix some vulnerabilities) 129 | * fix a bug in number elements displayed in the singlestat panel 130 | 131 | ### 1.2.0 132 | 133 | * allow to get a query count without selecting a date field 134 | * fix #16: no more need to force grunt for rebuilding 135 | * fix #17: fix error when receiving integer values not formated in strings 136 | * fix some typos 137 | * dev: allow to set/unset browser console log 138 | 139 | ### 1.1.0 140 | 141 | * compatibility with GLPI 9.2 142 | * autofill the field `Timerange based on` in the query 143 | * when adding a new query, add by default a ticket query instead `undefined` 144 | * get correct values in the tooltip when the mouse is hovering the graph 145 | * enhance error message when defining the datasource 146 | * add the possibility to have the count of elements by hour of the day with the panel `histogram` 147 | 148 | ### 1.0.0 149 | 150 | First version 151 | -------------------------------------------------------------------------------- /README_2.md: -------------------------------------------------------------------------------- 1 | # Grafana Data Source Plugin Template 2 | 3 | [![CircleCI](https://circleci.com/gh/grafana/simple-datasource/tree/master.svg?style=svg)](https://circleci.com/gh/grafana/simple-datasource/tree/master) 4 | 5 | This template is a starting point for building Grafana Data Source Plugins 6 | 7 | ## What is Grafana Data Source Plugin? 8 | Grafana supports a wide range of data sources, including Prometheus, MySQL, and even Datadog. There’s a good chance you can already visualize metrics from the systems you have set up. In some cases, though, you already have an in-house metrics solution that you’d like to add to your Grafana dashboards. Grafana Data Source Plugins enables integrating such solutions with Grafana. 9 | 10 | ## Getting started 11 | 1. Install dependencies 12 | ```BASH 13 | yarn install 14 | ``` 15 | 2. Build plugin in development mode or run in watch mode 16 | ```BASH 17 | yarn dev 18 | ``` 19 | or 20 | ```BASH 21 | yarn watch 22 | ``` 23 | 3. Build plugin in production mode 24 | ```BASH 25 | yarn build 26 | ``` 27 | 28 | ## Learn more 29 | - [Build a data source plugin tutorial](https://grafana.com/tutorials/build-a-data-source-plugin) 30 | - [Grafana documentation](https://grafana.com/docs/) 31 | - [Grafana Tutorials](https://grafana.com/tutorials/) - Grafana Tutorials are step-by-step guides that help you make the most of Grafana 32 | - [Grafana UI Library](https://developers.grafana.com/ui) - UI components to help you build interfaces using Grafana Design System 33 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Test against the latest version of this Node.js version 2 | environment: 3 | nodejs_version: "10" 4 | 5 | # Local NPM Modules 6 | cache: 7 | - node_modules 8 | 9 | # Install scripts. (runs after repo cloning) 10 | install: 11 | # Get the latest stable version of Node.js or io.js 12 | - ps: Install-Product node $env:nodejs_version 13 | # install modules 14 | - npm install -g yarn --quiet 15 | - yarn install --pure-lockfile 16 | 17 | # Post-install test scripts. 18 | test_script: 19 | # Output useful info for debugging. 20 | - node --version 21 | - npm --version 22 | 23 | # Run the build 24 | build_script: 25 | - yarn dev # This will also run prettier! 26 | - yarn build # make sure both scripts work 27 | -------------------------------------------------------------------------------- /dashboards/glpi_app_dashboard.json: -------------------------------------------------------------------------------- 1 | { 2 | "annotations": { 3 | "list": [] 4 | }, 5 | "editable": true, 6 | "gnetId": null, 7 | "graphTooltip": 0, 8 | "hideControls": false, 9 | "id": null, 10 | "links": [], 11 | "refresh": "1m", 12 | "rows": [ 13 | { 14 | "collapse": false, 15 | "height": "250px", 16 | "panels": [ 17 | { 18 | "cacheTimeout": null, 19 | "colorBackground": false, 20 | "colorValue": false, 21 | "colors": [ 22 | "rgba(50, 172, 45, 0.97)", 23 | "rgba(237, 129, 40, 0.89)", 24 | "rgba(245, 54, 54, 0.9)" 25 | ], 26 | "datasource": "mon glpi", 27 | "format": "none", 28 | "gauge": { 29 | "maxValue": 1000, 30 | "minValue": 0, 31 | "show": true, 32 | "thresholdLabels": false, 33 | "thresholdMarkers": true 34 | }, 35 | "id": 1, 36 | "interval": null, 37 | "links": [], 38 | "mappingType": 1, 39 | "mappingTypes": [ 40 | { 41 | "name": "value to text", 42 | "value": 1 43 | }, 44 | { 45 | "name": "range to text", 46 | "value": 2 47 | } 48 | ], 49 | "maxDataPoints": 100, 50 | "minSpan": 2, 51 | "nullPointMode": "connected", 52 | "nullText": null, 53 | "postfix": "", 54 | "postfixFontSize": "50%", 55 | "prefix": "", 56 | "prefixFontSize": "50%", 57 | "rangeMaps": [ 58 | { 59 | "from": "null", 60 | "text": "N/A", 61 | "to": "null" 62 | } 63 | ], 64 | "span": 2, 65 | "sparkline": { 66 | "fillColor": "rgba(31, 118, 189, 0.18)", 67 | "full": false, 68 | "lineColor": "rgb(31, 120, 193)", 69 | "show": true 70 | }, 71 | "tableColumn": "", 72 | "targets": [ 73 | { 74 | "alias": "tickets", 75 | "col_0": { 76 | "group": "Default", 77 | "label": "------", 78 | "number": "0" 79 | }, 80 | "col_1": { 81 | "group": "Default", 82 | "label": "------", 83 | "number": "0" 84 | }, 85 | "col_2": { 86 | "group": "Default", 87 | "label": "------", 88 | "number": "0" 89 | }, 90 | "col_3": { 91 | "group": "Default", 92 | "label": "------", 93 | "number": "0" 94 | }, 95 | "col_4": { 96 | "group": "Default", 97 | "label": "------", 98 | "number": "0" 99 | }, 100 | "col_5": { 101 | "group": "Default", 102 | "label": "------", 103 | "number": "0" 104 | }, 105 | "col_6": { 106 | "group": "Default", 107 | "label": "------", 108 | "number": "0" 109 | }, 110 | "col_7": { 111 | "group": "Default", 112 | "label": "------", 113 | "number": "0" 114 | }, 115 | "col_8": { 116 | "group": "Default", 117 | "label": "------", 118 | "number": "0" 119 | }, 120 | "col_9": { 121 | "group": "Default", 122 | "label": "------", 123 | "number": "0" 124 | }, 125 | "col_10": { 126 | "group": "Default", 127 | "label": "------", 128 | "number": "0" 129 | }, 130 | "col_11": { 131 | "group": "Default", 132 | "label": "------", 133 | "number": "0" 134 | }, 135 | "counter": true, 136 | "datefield": { 137 | "group": "Caractéristiques", 138 | "label": "Date d'ouverture", 139 | "number": "15" 140 | }, 141 | "dynamicsplit": { 142 | "group": "Default", 143 | "label": "------", 144 | "number": "0" 145 | }, 146 | "hide": false, 147 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=all&search=Rechercher&itemtype=Ticket&start=0", 148 | "refId": "A", 149 | "table": false 150 | } 151 | ], 152 | "thresholds": "600,800", 153 | "timeFrom": "2h", 154 | "timerangefield": "date_creation", 155 | "title": "Nombre de tickets créés (2 last hours)", 156 | "type": "singlestat", 157 | "valueFontSize": "150%", 158 | "valueMaps": [ 159 | { 160 | "op": "=", 161 | "text": "N/A", 162 | "value": "null" 163 | } 164 | ], 165 | "valueName": "total" 166 | }, 167 | { 168 | "aliasColors": {}, 169 | "bars": true, 170 | "dashLength": 10, 171 | "dashes": false, 172 | "datasource": "mon glpi", 173 | "fill": 1, 174 | "hideTimeOverride": true, 175 | "id": 3, 176 | "interval": "2m", 177 | "legend": { 178 | "alignAsTable": false, 179 | "avg": false, 180 | "current": false, 181 | "hideEmpty": false, 182 | "hideZero": false, 183 | "max": false, 184 | "min": false, 185 | "show": true, 186 | "total": false, 187 | "values": false 188 | }, 189 | "lines": false, 190 | "linewidth": 1, 191 | "links": [], 192 | "nullPointMode": "null as zero", 193 | "percentage": false, 194 | "percentagepoints": "55", 195 | "pointradius": 5, 196 | "points": false, 197 | "renderer": "flot", 198 | "seriesOverrides": [], 199 | "spaceLength": 10, 200 | "span": 10, 201 | "stack": true, 202 | "steppedLine": false, 203 | "targets": [ 204 | { 205 | "alias": "Incident", 206 | "col_0": { 207 | "group": "Default", 208 | "label": "------", 209 | "number": "0" 210 | }, 211 | "col_1": { 212 | "group": "Default", 213 | "label": "------", 214 | "number": "0" 215 | }, 216 | "col_2": { 217 | "group": "Default", 218 | "label": "------", 219 | "number": "0" 220 | }, 221 | "col_3": { 222 | "group": "Default", 223 | "label": "------", 224 | "number": "0" 225 | }, 226 | "col_4": { 227 | "group": "Default", 228 | "label": "------", 229 | "number": "0" 230 | }, 231 | "col_5": { 232 | "group": "Default", 233 | "label": "------", 234 | "number": "0" 235 | }, 236 | "col_6": { 237 | "group": "Default", 238 | "label": "------", 239 | "number": "0" 240 | }, 241 | "col_7": { 242 | "group": "Default", 243 | "label": "------", 244 | "number": "0" 245 | }, 246 | "col_8": { 247 | "group": "Default", 248 | "label": "------", 249 | "number": "0" 250 | }, 251 | "col_9": { 252 | "group": "Default", 253 | "label": "------", 254 | "number": "0" 255 | }, 256 | "col_10": { 257 | "group": "Default", 258 | "label": "------", 259 | "number": "0" 260 | }, 261 | "col_11": { 262 | "group": "Default", 263 | "label": "------", 264 | "number": "0" 265 | }, 266 | "counter": true, 267 | "datefield": { 268 | "group": "Caractéristiques", 269 | "label": "Date d'ouverture", 270 | "number": "15" 271 | }, 272 | "dynamicsplit": { 273 | "group": "Default", 274 | "label": "------", 275 | "number": "0" 276 | }, 277 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=notold&criteria[1][link]=AND&criteria[1][field]=14&criteria[1][searchtype]=equals&criteria[1][value]=1&search=Rechercher&itemtype=Ticket&start=0", 278 | "refId": "A", 279 | "table": false 280 | }, 281 | { 282 | "alias": "Demande", 283 | "col_0": { 284 | "group": "Default", 285 | "label": "------", 286 | "number": "0" 287 | }, 288 | "col_1": { 289 | "group": "Default", 290 | "label": "------", 291 | "number": "0" 292 | }, 293 | "col_2": { 294 | "group": "Default", 295 | "label": "------", 296 | "number": "0" 297 | }, 298 | "col_3": { 299 | "group": "Default", 300 | "label": "------", 301 | "number": "0" 302 | }, 303 | "col_4": { 304 | "group": "Default", 305 | "label": "------", 306 | "number": "0" 307 | }, 308 | "col_5": { 309 | "group": "Default", 310 | "label": "------", 311 | "number": "0" 312 | }, 313 | "col_6": { 314 | "group": "Default", 315 | "label": "------", 316 | "number": "0" 317 | }, 318 | "col_7": { 319 | "group": "Default", 320 | "label": "------", 321 | "number": "0" 322 | }, 323 | "col_8": { 324 | "group": "Default", 325 | "label": "------", 326 | "number": "0" 327 | }, 328 | "col_9": { 329 | "group": "Default", 330 | "label": "------", 331 | "number": "0" 332 | }, 333 | "col_10": { 334 | "group": "Default", 335 | "label": "------", 336 | "number": "0" 337 | }, 338 | "col_11": { 339 | "group": "Default", 340 | "label": "------", 341 | "number": "0" 342 | }, 343 | "counter": true, 344 | "datefield": { 345 | "group": "Caractéristiques", 346 | "label": "Date d'ouverture", 347 | "number": "15" 348 | }, 349 | "dynamicsplit": { 350 | "group": "Default", 351 | "label": "------", 352 | "number": "0" 353 | }, 354 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=notold&criteria[1][link]=AND&criteria[1][field]=14&criteria[1][searchtype]=equals&criteria[1][value]=2&search=Rechercher&itemtype=Ticket&start=0", 355 | "refId": "B", 356 | "table": false 357 | } 358 | ], 359 | "thresholds": [], 360 | "timeFrom": null, 361 | "timeShift": null, 362 | "timerangefield": "date_creation", 363 | "title": "Tickets", 364 | "tooltip": { 365 | "shared": true, 366 | "sort": 0, 367 | "value_type": "individual" 368 | }, 369 | "type": "graph", 370 | "xaxis": { 371 | "buckets": null, 372 | "mode": "time", 373 | "name": null, 374 | "show": true, 375 | "values": [ 376 | "total" 377 | ] 378 | }, 379 | "yaxes": [ 380 | { 381 | "format": "short", 382 | "label": null, 383 | "logBase": 1, 384 | "max": null, 385 | "min": null, 386 | "show": true 387 | }, 388 | { 389 | "format": "short", 390 | "label": null, 391 | "logBase": 1, 392 | "max": null, 393 | "min": null, 394 | "show": true 395 | } 396 | ] 397 | } 398 | ], 399 | "repeat": null, 400 | "repeatIteration": null, 401 | "repeatRowId": null, 402 | "showTitle": false, 403 | "title": "Dashboard Row", 404 | "titleSize": "h6" 405 | }, 406 | { 407 | "collapse": false, 408 | "height": 237, 409 | "panels": [ 410 | { 411 | "cacheTimeout": null, 412 | "colorBackground": false, 413 | "colorValue": false, 414 | "colors": [ 415 | "rgba(245, 54, 54, 0.9)", 416 | "rgba(237, 129, 40, 0.89)", 417 | "rgba(50, 172, 45, 0.97)" 418 | ], 419 | "datasource": "mon glpi", 420 | "format": "none", 421 | "gauge": { 422 | "maxValue": 100, 423 | "minValue": 0, 424 | "show": false, 425 | "thresholdLabels": false, 426 | "thresholdMarkers": true 427 | }, 428 | "id": 4, 429 | "interval": null, 430 | "links": [], 431 | "mappingType": 1, 432 | "mappingTypes": [ 433 | { 434 | "name": "value to text", 435 | "value": 1 436 | }, 437 | { 438 | "name": "range to text", 439 | "value": 2 440 | } 441 | ], 442 | "maxDataPoints": 100, 443 | "nullPointMode": "connected", 444 | "nullText": null, 445 | "postfix": "", 446 | "postfixFontSize": "50%", 447 | "prefix": "", 448 | "prefixFontSize": "50%", 449 | "rangeMaps": [ 450 | { 451 | "from": "null", 452 | "text": "N/A", 453 | "to": "null" 454 | } 455 | ], 456 | "span": 2, 457 | "sparkline": { 458 | "fillColor": "rgba(31, 118, 189, 0.18)", 459 | "full": false, 460 | "lineColor": "rgb(31, 120, 193)", 461 | "show": false 462 | }, 463 | "tableColumn": "", 464 | "targets": [ 465 | { 466 | "col_0": { 467 | "group": "Default", 468 | "label": "------", 469 | "number": "0" 470 | }, 471 | "col_1": { 472 | "group": "Default", 473 | "label": "------", 474 | "number": "0" 475 | }, 476 | "col_2": { 477 | "group": "Default", 478 | "label": "------", 479 | "number": "0" 480 | }, 481 | "col_3": { 482 | "group": "Default", 483 | "label": "------", 484 | "number": "0" 485 | }, 486 | "col_4": { 487 | "group": "Default", 488 | "label": "------", 489 | "number": "0" 490 | }, 491 | "col_5": { 492 | "group": "Default", 493 | "label": "------", 494 | "number": "0" 495 | }, 496 | "col_6": { 497 | "group": "Default", 498 | "label": "------", 499 | "number": "0" 500 | }, 501 | "col_7": { 502 | "group": "Default", 503 | "label": "------", 504 | "number": "0" 505 | }, 506 | "col_8": { 507 | "group": "Default", 508 | "label": "------", 509 | "number": "0" 510 | }, 511 | "col_9": { 512 | "group": "Default", 513 | "label": "------", 514 | "number": "0" 515 | }, 516 | "col_10": { 517 | "group": "Default", 518 | "label": "------", 519 | "number": "0" 520 | }, 521 | "col_11": { 522 | "group": "Default", 523 | "label": "------", 524 | "number": "0" 525 | }, 526 | "counter": true, 527 | "datefield": { 528 | "group": "Plugins", 529 | "label": "FusInv - Dernier inventaire", 530 | "number": "5150" 531 | }, 532 | "dynamicsplit": { 533 | "group": "Default", 534 | "label": "------", 535 | "number": "0" 536 | }, 537 | "query": "http://127.0.0.1/glpi090/front/computer.php?is_deleted=0&criteria[0][field]=121&criteria[0][searchtype]=contains&criteria[0][value]=&search=Rechercher&itemtype=Computer&start=0", 538 | "refId": "A", 539 | "table": true 540 | } 541 | ], 542 | "thresholds": "", 543 | "timeFrom": null, 544 | "timerangefield": "date_creation", 545 | "title": "Nombre d'inventaires FusionInventory", 546 | "type": "singlestat", 547 | "valueFontSize": "200%", 548 | "valueMaps": [ 549 | { 550 | "op": "=", 551 | "text": "0", 552 | "value": "null" 553 | } 554 | ], 555 | "valueName": "total" 556 | }, 557 | { 558 | "bgColor": null, 559 | "clockType": "24 hour", 560 | "countdownSettings": { 561 | "endCountdownTime": "2017-06-23T07:50:00.000Z", 562 | "endText": "00:00:00" 563 | }, 564 | "dateSettings": { 565 | "dateFormat": "YYYY-MM-DD", 566 | "fontSize": "26px", 567 | "fontWeight": "normal", 568 | "showDate": true 569 | }, 570 | "id": 13, 571 | "links": [], 572 | "mode": "time", 573 | "offsetFromUtc": null, 574 | "offsetFromUtcMinutes": null, 575 | "span": 2, 576 | "timeSettings": { 577 | "customFormat": "HH:mm:ss", 578 | "fontSize": "60px", 579 | "fontWeight": "normal" 580 | }, 581 | "title": "", 582 | "type": "grafana-clock-panel" 583 | }, 584 | { 585 | "cacheTimeout": null, 586 | "colorBackground": true, 587 | "colorValue": false, 588 | "colors": [ 589 | "rgba(0, 0, 0, 0)", 590 | "rgb(31, 29, 29)", 591 | "rgba(245, 54, 54, 0.9)" 592 | ], 593 | "datasource": "mon glpi", 594 | "format": "none", 595 | "gauge": { 596 | "maxValue": 100, 597 | "minValue": 0, 598 | "show": false, 599 | "thresholdLabels": false, 600 | "thresholdMarkers": true 601 | }, 602 | "id": 5, 603 | "interval": null, 604 | "links": [], 605 | "mappingType": 1, 606 | "mappingTypes": [ 607 | { 608 | "name": "value to text", 609 | "value": 1 610 | }, 611 | { 612 | "name": "range to text", 613 | "value": 2 614 | } 615 | ], 616 | "maxDataPoints": 100, 617 | "nullPointMode": "connected", 618 | "nullText": null, 619 | "postfix": "", 620 | "postfixFontSize": "50%", 621 | "prefix": "", 622 | "prefixFontSize": "50%", 623 | "rangeMaps": [ 624 | { 625 | "from": "null", 626 | "text": "N/A", 627 | "to": "null" 628 | } 629 | ], 630 | "span": 2, 631 | "sparkline": { 632 | "fillColor": "rgba(31, 118, 189, 0.18)", 633 | "full": false, 634 | "lineColor": "rgb(31, 120, 193)", 635 | "show": false 636 | }, 637 | "tableColumn": "", 638 | "targets": [ 639 | { 640 | "col_0": { 641 | "group": "", 642 | "label": "------", 643 | "number": "0" 644 | }, 645 | "col_1": { 646 | "group": "", 647 | "label": "------", 648 | "number": "0" 649 | }, 650 | "col_2": { 651 | "group": "", 652 | "label": "------", 653 | "number": "0" 654 | }, 655 | "col_3": { 656 | "group": "", 657 | "label": "------", 658 | "number": "0" 659 | }, 660 | "col_4": { 661 | "group": "", 662 | "label": "------", 663 | "number": "0" 664 | }, 665 | "col_5": { 666 | "group": "", 667 | "label": "------", 668 | "number": "0" 669 | }, 670 | "col_6": { 671 | "group": "Default", 672 | "label": "------", 673 | "number": "0" 674 | }, 675 | "col_7": { 676 | "group": "Default", 677 | "label": "------", 678 | "number": "0" 679 | }, 680 | "col_8": { 681 | "group": "Default", 682 | "label": "------", 683 | "number": "0" 684 | }, 685 | "col_9": { 686 | "group": "Default", 687 | "label": "------", 688 | "number": "0" 689 | }, 690 | "col_10": { 691 | "group": "Default", 692 | "label": "------", 693 | "number": "0" 694 | }, 695 | "col_11": { 696 | "group": "Default", 697 | "label": "------", 698 | "number": "0" 699 | }, 700 | "cols": {}, 701 | "counter": true, 702 | "datefield": { 703 | "group": "Caractéristiques", 704 | "label": "Date d'ouverture", 705 | "number": "15" 706 | }, 707 | "dynamicsplit": { 708 | "group": "Default", 709 | "label": "------", 710 | "number": "0" 711 | }, 712 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=notold&criteria[1][link]=AND&criteria[1][field]=71&criteria[1][searchtype]=contains&criteria[1][value]=vip&search=Rechercher&itemtype=Ticket&start=0", 713 | "refId": "A", 714 | "table": false 715 | } 716 | ], 717 | "thresholds": "0,1", 718 | "timerangefield": "date_creation", 719 | "title": "Tickets VIP", 720 | "transparent": false, 721 | "type": "singlestat", 722 | "valueFontSize": "200%", 723 | "valueMaps": [ 724 | { 725 | "op": "=", 726 | "text": "0", 727 | "value": "null" 728 | } 729 | ], 730 | "valueName": "total" 731 | }, 732 | { 733 | "aliasColors": {}, 734 | "cacheTimeout": null, 735 | "combine": { 736 | "label": "Others", 737 | "threshold": 0 738 | }, 739 | "datasource": "mon glpi", 740 | "fontSize": "80%", 741 | "format": "short", 742 | "height": "200px", 743 | "id": 8, 744 | "interval": null, 745 | "legend": { 746 | "percentage": true, 747 | "show": true, 748 | "values": true 749 | }, 750 | "legendType": "Under graph", 751 | "links": [], 752 | "maxDataPoints": 3, 753 | "nullPointMode": "connected", 754 | "pieType": "pie", 755 | "span": 3, 756 | "strokeWidth": 1, 757 | "targets": [ 758 | { 759 | "alias": "incident", 760 | "col_0": { 761 | "group": "Default", 762 | "label": "------", 763 | "number": "0" 764 | }, 765 | "col_1": { 766 | "group": "Default", 767 | "label": "------", 768 | "number": "0" 769 | }, 770 | "col_2": { 771 | "group": "Default", 772 | "label": "------", 773 | "number": "0" 774 | }, 775 | "col_3": { 776 | "group": "Default", 777 | "label": "------", 778 | "number": "0" 779 | }, 780 | "col_4": { 781 | "group": "Default", 782 | "label": "------", 783 | "number": "0" 784 | }, 785 | "col_5": { 786 | "group": "Default", 787 | "label": "------", 788 | "number": "0" 789 | }, 790 | "col_6": { 791 | "group": "Default", 792 | "label": "------", 793 | "number": "0" 794 | }, 795 | "col_7": { 796 | "group": "Default", 797 | "label": "------", 798 | "number": "0" 799 | }, 800 | "col_8": { 801 | "group": "Default", 802 | "label": "------", 803 | "number": "0" 804 | }, 805 | "col_9": { 806 | "group": "Default", 807 | "label": "------", 808 | "number": "0" 809 | }, 810 | "col_10": { 811 | "group": "Default", 812 | "label": "------", 813 | "number": "0" 814 | }, 815 | "col_11": { 816 | "group": "Default", 817 | "label": "------", 818 | "number": "0" 819 | }, 820 | "counter": true, 821 | "datefield": { 822 | "group": "Caractéristiques", 823 | "label": "Date d'ouverture", 824 | "number": "15" 825 | }, 826 | "dynamicsplit": { 827 | "group": "Default", 828 | "label": "------", 829 | "number": "0" 830 | }, 831 | "query": "127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=all&criteria[1][link]=AND&criteria[1][field]=14&criteria[1][searchtype]=equals&criteria[1][value]=1&search=Rechercher&itemtype=Ticket&start=0", 832 | "refId": "A", 833 | "table": false 834 | }, 835 | { 836 | "alias": "demande", 837 | "col_0": { 838 | "group": "Default", 839 | "label": "------", 840 | "number": "0" 841 | }, 842 | "col_1": { 843 | "group": "Default", 844 | "label": "------", 845 | "number": "0" 846 | }, 847 | "col_2": { 848 | "group": "Default", 849 | "label": "------", 850 | "number": "0" 851 | }, 852 | "col_3": { 853 | "group": "Default", 854 | "label": "------", 855 | "number": "0" 856 | }, 857 | "col_4": { 858 | "group": "Default", 859 | "label": "------", 860 | "number": "0" 861 | }, 862 | "col_5": { 863 | "group": "Default", 864 | "label": "------", 865 | "number": "0" 866 | }, 867 | "col_6": { 868 | "group": "Default", 869 | "label": "------", 870 | "number": "0" 871 | }, 872 | "col_7": { 873 | "group": "Default", 874 | "label": "------", 875 | "number": "0" 876 | }, 877 | "col_8": { 878 | "group": "Default", 879 | "label": "------", 880 | "number": "0" 881 | }, 882 | "col_9": { 883 | "group": "Default", 884 | "label": "------", 885 | "number": "0" 886 | }, 887 | "col_10": { 888 | "group": "Default", 889 | "label": "------", 890 | "number": "0" 891 | }, 892 | "col_11": { 893 | "group": "Default", 894 | "label": "------", 895 | "number": "0" 896 | }, 897 | "counter": true, 898 | "datefield": { 899 | "group": "Caractéristiques", 900 | "label": "Date d'ouverture", 901 | "number": "15" 902 | }, 903 | "dynamicsplit": { 904 | "group": "Default", 905 | "label": "------", 906 | "number": "0" 907 | }, 908 | "query": "127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=all&criteria[1][link]=AND&criteria[1][field]=14&criteria[1][searchtype]=equals&criteria[1][value]=2&search=Rechercher&itemtype=Ticket&start=0", 909 | "refId": "B", 910 | "table": false 911 | } 912 | ], 913 | "title": "Types de tickets", 914 | "type": "grafana-piechart-panel", 915 | "valueName": "total" 916 | }, 917 | { 918 | "cacheTimeout": null, 919 | "colorBackground": false, 920 | "colorValue": true, 921 | "colors": [ 922 | "rgba(50, 172, 45, 0.97)", 923 | "rgba(237, 129, 40, 0.89)", 924 | "rgba(245, 54, 54, 0.9)" 925 | ], 926 | "datasource": "mon glpi", 927 | "decimals": 0, 928 | "format": "none", 929 | "gauge": { 930 | "maxValue": 100, 931 | "minValue": 0, 932 | "show": false, 933 | "thresholdLabels": false, 934 | "thresholdMarkers": true 935 | }, 936 | "id": 11, 937 | "interval": null, 938 | "links": [], 939 | "mappingType": 1, 940 | "mappingTypes": [ 941 | { 942 | "name": "value to text", 943 | "value": 1 944 | }, 945 | { 946 | "name": "range to text", 947 | "value": 2 948 | } 949 | ], 950 | "maxDataPoints": 100, 951 | "minSpan": 3, 952 | "nullPointMode": "connected", 953 | "nullText": null, 954 | "postfix": "", 955 | "postfixFontSize": "50%", 956 | "prefix": "", 957 | "prefixFontSize": "50%", 958 | "rangeMaps": [ 959 | { 960 | "from": "null", 961 | "text": "N/A", 962 | "to": "null" 963 | } 964 | ], 965 | "repeat": null, 966 | "span": 3, 967 | "sparkline": { 968 | "fillColor": "rgba(31, 118, 189, 0.18)", 969 | "full": false, 970 | "lineColor": "rgb(31, 120, 193)", 971 | "show": false 972 | }, 973 | "tableColumn": "", 974 | "targets": [ 975 | { 976 | "col_0": { 977 | "group": "Default", 978 | "label": "------", 979 | "number": "0" 980 | }, 981 | "col_1": { 982 | "group": "Default", 983 | "label": "------", 984 | "number": "0" 985 | }, 986 | "col_2": { 987 | "group": "Default", 988 | "label": "------", 989 | "number": "0" 990 | }, 991 | "col_3": { 992 | "group": "Default", 993 | "label": "------", 994 | "number": "0" 995 | }, 996 | "col_4": { 997 | "group": "Default", 998 | "label": "------", 999 | "number": "0" 1000 | }, 1001 | "col_5": { 1002 | "group": "Default", 1003 | "label": "------", 1004 | "number": "0" 1005 | }, 1006 | "col_6": { 1007 | "group": "Default", 1008 | "label": "------", 1009 | "number": "0" 1010 | }, 1011 | "col_7": { 1012 | "group": "Default", 1013 | "label": "------", 1014 | "number": "0" 1015 | }, 1016 | "col_8": { 1017 | "group": "Default", 1018 | "label": "------", 1019 | "number": "0" 1020 | }, 1021 | "col_9": { 1022 | "group": "Default", 1023 | "label": "------", 1024 | "number": "0" 1025 | }, 1026 | "col_10": { 1027 | "group": "Default", 1028 | "label": "------", 1029 | "number": "0" 1030 | }, 1031 | "col_11": { 1032 | "group": "Default", 1033 | "label": "------", 1034 | "number": "0" 1035 | }, 1036 | "counter": true, 1037 | "datefield": { 1038 | "group": "Caractéristiques", 1039 | "label": "Date d'ouverture", 1040 | "number": "15" 1041 | }, 1042 | "dynamicsplit": { 1043 | "group": "Default", 1044 | "label": "------", 1045 | "number": "0" 1046 | }, 1047 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=process&search=Rechercher&itemtype=Ticket&start=0", 1048 | "refId": "A", 1049 | "table": false 1050 | } 1051 | ], 1052 | "thresholds": "600,800", 1053 | "title": "En cours", 1054 | "transparent": false, 1055 | "type": "singlestat", 1056 | "valueFontSize": "120%", 1057 | "valueMaps": [ 1058 | { 1059 | "op": "=", 1060 | "text": "0", 1061 | "value": "null" 1062 | } 1063 | ], 1064 | "valueName": "total" 1065 | } 1066 | ], 1067 | "repeat": null, 1068 | "repeatIteration": null, 1069 | "repeatRowId": null, 1070 | "showTitle": false, 1071 | "title": "Dashboard Row", 1072 | "titleSize": "h6" 1073 | }, 1074 | { 1075 | "collapse": false, 1076 | "height": 250, 1077 | "panels": [ 1078 | { 1079 | "columns": [], 1080 | "datasource": "mon glpi", 1081 | "filterNull": false, 1082 | "fontSize": "100%", 1083 | "height": "460px", 1084 | "id": 9, 1085 | "links": [], 1086 | "pageSize": 10, 1087 | "scroll": true, 1088 | "showHeader": true, 1089 | "sort": { 1090 | "col": 4, 1091 | "desc": true 1092 | }, 1093 | "span": 12, 1094 | "styles": [ 1095 | { 1096 | "alias": "", 1097 | "colorMode": null, 1098 | "colors": [ 1099 | "rgba(245, 54, 54, 0.9)", 1100 | "rgba(237, 129, 40, 0.89)", 1101 | "rgba(50, 172, 45, 0.97)" 1102 | ], 1103 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1104 | "decimals": 2, 1105 | "pattern": "Titre", 1106 | "sanitize": true, 1107 | "thresholds": [], 1108 | "type": "string", 1109 | "unit": "short" 1110 | } 1111 | ], 1112 | "targets": [ 1113 | { 1114 | "col_0": { 1115 | "group": "Caractéristiques", 1116 | "label": "Titre", 1117 | "number": "1" 1118 | }, 1119 | "col_0_alias": "", 1120 | "col_1": { 1121 | "group": "Demandeur", 1122 | "label": "Demandeur", 1123 | "number": "4" 1124 | }, 1125 | "col_1_alias": "", 1126 | "col_2": { 1127 | "group": "Caractéristiques", 1128 | "label": "Priorité", 1129 | "number": "3" 1130 | }, 1131 | "col_2_alias": "", 1132 | "col_3": { 1133 | "group": "Caractéristiques", 1134 | "label": "Entité", 1135 | "number": "80" 1136 | }, 1137 | "col_3_alias": "", 1138 | "col_4": { 1139 | "group": "Caractéristiques", 1140 | "label": "Date d'ouverture", 1141 | "number": "15" 1142 | }, 1143 | "col_5": { 1144 | "group": "Caractéristiques", 1145 | "label": "Catégorie", 1146 | "number": "7" 1147 | }, 1148 | "col_6": { 1149 | "group": "Default", 1150 | "label": "------", 1151 | "number": "0" 1152 | }, 1153 | "col_7": { 1154 | "group": "Default", 1155 | "label": "------", 1156 | "number": "0" 1157 | }, 1158 | "col_8": { 1159 | "group": "Default", 1160 | "label": "------", 1161 | "number": "0" 1162 | }, 1163 | "col_9": { 1164 | "group": "Default", 1165 | "label": "------", 1166 | "number": "0" 1167 | }, 1168 | "col_10": { 1169 | "group": "Default", 1170 | "label": "------", 1171 | "number": "0" 1172 | }, 1173 | "col_11": { 1174 | "group": "Default", 1175 | "label": "------", 1176 | "number": "0" 1177 | }, 1178 | "cols": { 1179 | "0": "1", 1180 | "1": "4", 1181 | "2": "3" 1182 | }, 1183 | "colsa": { 1184 | "group": "Caractéristiques", 1185 | "label": "Titre", 1186 | "number": "1" 1187 | }, 1188 | "counter": "yes", 1189 | "datefield": { 1190 | "group": "Caractéristiques", 1191 | "label": "Date d'ouverture", 1192 | "number": "15" 1193 | }, 1194 | "dynamicsplit": { 1195 | "group": "Default", 1196 | "label": "------", 1197 | "number": "0" 1198 | }, 1199 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=all&search=Rechercher&itemtype=Ticket&start=0", 1200 | "refId": "A", 1201 | "table": true 1202 | } 1203 | ], 1204 | "title": "Derniers tickets", 1205 | "transform": "table", 1206 | "type": "table" 1207 | } 1208 | ], 1209 | "repeat": null, 1210 | "repeatIteration": null, 1211 | "repeatRowId": null, 1212 | "showTitle": false, 1213 | "title": "Dashboard Row", 1214 | "titleSize": "h6" 1215 | }, 1216 | { 1217 | "collapse": false, 1218 | "height": 250, 1219 | "panels": [ 1220 | { 1221 | "columns": [], 1222 | "datasource": "mon glpi", 1223 | "filterNull": false, 1224 | "fontSize": "150%", 1225 | "height": "450px", 1226 | "id": 10, 1227 | "links": [], 1228 | "pageSize": null, 1229 | "scroll": true, 1230 | "showHeader": true, 1231 | "sort": { 1232 | "col": 0, 1233 | "desc": true 1234 | }, 1235 | "span": 12, 1236 | "styles": [ 1237 | { 1238 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1239 | "pattern": "Time", 1240 | "type": "date" 1241 | }, 1242 | { 1243 | "colorMode": null, 1244 | "colors": [ 1245 | "rgba(245, 54, 54, 0.9)", 1246 | "rgba(237, 129, 40, 0.89)", 1247 | "rgba(50, 172, 45, 0.97)" 1248 | ], 1249 | "decimals": 2, 1250 | "pattern": "/.*/", 1251 | "sanitize": true, 1252 | "thresholds": [], 1253 | "type": "string", 1254 | "unit": "short" 1255 | } 1256 | ], 1257 | "targets": [ 1258 | { 1259 | "col_0": { 1260 | "group": "Caractéristiques", 1261 | "label": "Titre", 1262 | "number": "1" 1263 | }, 1264 | "col_0_alias": "Informations", 1265 | "col_1": { 1266 | "group": "Caractéristiques", 1267 | "label": "Description", 1268 | "number": "4" 1269 | }, 1270 | "col_2": { 1271 | "group": "", 1272 | "label": "------", 1273 | "number": "0" 1274 | }, 1275 | "col_3": { 1276 | "group": "", 1277 | "label": "------", 1278 | "number": "0" 1279 | }, 1280 | "col_4": { 1281 | "group": "", 1282 | "label": "------", 1283 | "number": "0" 1284 | }, 1285 | "col_5": { 1286 | "group": "", 1287 | "label": "------", 1288 | "number": "0" 1289 | }, 1290 | "col_6": { 1291 | "group": "Default", 1292 | "label": "------", 1293 | "number": "0" 1294 | }, 1295 | "col_7": { 1296 | "group": "Default", 1297 | "label": "------", 1298 | "number": "0" 1299 | }, 1300 | "col_8": { 1301 | "group": "Default", 1302 | "label": "------", 1303 | "number": "0" 1304 | }, 1305 | "col_9": { 1306 | "group": "Default", 1307 | "label": "------", 1308 | "number": "0" 1309 | }, 1310 | "col_10": { 1311 | "group": "Default", 1312 | "label": "------", 1313 | "number": "0" 1314 | }, 1315 | "col_11": { 1316 | "group": "Default", 1317 | "label": "------", 1318 | "number": "0" 1319 | }, 1320 | "cols": {}, 1321 | "counter": true, 1322 | "datefield": { 1323 | "group": "Special / be careful", 1324 | "label": "Not use date, so get all data", 1325 | "number": "-1" 1326 | }, 1327 | "dynamicsplit": { 1328 | "group": "Default", 1329 | "label": "------", 1330 | "number": "0" 1331 | }, 1332 | "nocounterval": { 1333 | "group": "Documents", 1334 | "label": "Nombre de documents", 1335 | "number": "119" 1336 | }, 1337 | "query": "http://127.0.0.1/glpi090/front/reminder.php?criteria[0][field]=1&criteria[0][searchtype]=contains&criteria[0][value]=&search=Rechercher&itemtype=Reminder&start=0", 1338 | "refId": "A", 1339 | "table": true 1340 | } 1341 | ], 1342 | "title": "Informations importantes", 1343 | "transform": "table", 1344 | "transparent": true, 1345 | "type": "table" 1346 | } 1347 | ], 1348 | "repeat": null, 1349 | "repeatIteration": null, 1350 | "repeatRowId": null, 1351 | "showTitle": false, 1352 | "title": "Dashboard Row", 1353 | "titleSize": "h6" 1354 | } 1355 | ], 1356 | "schemaVersion": 14, 1357 | "style": "dark", 1358 | "tags": [ 1359 | "glpi-app", 1360 | "imported" 1361 | ], 1362 | "templating": { 1363 | "list": [] 1364 | }, 1365 | "time": { 1366 | "from": "now-6h", 1367 | "to": "now" 1368 | }, 1369 | "timepicker": { 1370 | "nowDelay": "", 1371 | "refresh_intervals": [ 1372 | "5s", 1373 | "10s", 1374 | "30s", 1375 | "1m", 1376 | "5m", 1377 | "15m", 1378 | "30m", 1379 | "1h", 1380 | "2h", 1381 | "1d" 1382 | ], 1383 | "time_options": [ 1384 | "5m", 1385 | "15m", 1386 | "1h", 1387 | "6h", 1388 | "12h", 1389 | "24h", 1390 | "2d", 1391 | "7d", 1392 | "30d" 1393 | ] 1394 | }, 1395 | "timezone": "browser", 1396 | "title": "GLPI dashboard demo", 1397 | "version": 25 1398 | } -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | // This file is needed because it is used by vscode and other tools that 2 | // call `jest` directly. However, unless you are doing anything special 3 | // do not edit this file 4 | 5 | const standard = require('@grafana/toolkit/src/config/jest.plugin.config'); 6 | 7 | // This process will use the same config that `yarn test` is using 8 | module.exports = standard.jestConfig(); 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ddurieux-glpi-app", 3 | "version": "2.1.0", 4 | "description": "Plugin GLPI description", 5 | "scripts": { 6 | "build": "grafana-toolkit plugin:build", 7 | "test": "grafana-toolkit plugin:test", 8 | "dev": "grafana-toolkit plugin:dev", 9 | "watch": "grafana-toolkit plugin:dev --watch" 10 | }, 11 | "author": "David Durieux", 12 | "license": "AGPL-3.0-or-later", 13 | "devDependencies": { 14 | "@grafana/data": "9.2.5", 15 | "@grafana/toolkit": "9.2.5", 16 | "@grafana/ui": "9.2.5", 17 | "@testing-library/jest-dom": "^5.16.5", 18 | "@testing-library/react": "^13.4.0", 19 | "@types/lodash": "4.14.189" 20 | }, 21 | "engines": { 22 | "node": ">=14" 23 | }, 24 | "dependencies": { 25 | "@grafana/runtime": "9.2.5", 26 | "sanitize-html": "2.7.3", 27 | "striptags": "^3.1.1" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ddurieux/glpi_app_grafana/fa55689222a68db43aa0f390ae5c72b7060e7eff/screenshot1.png -------------------------------------------------------------------------------- /src/dashboards/glpi_app_dashboard.json: -------------------------------------------------------------------------------- 1 | { 2 | "annotations": { 3 | "list": [] 4 | }, 5 | "editable": true, 6 | "gnetId": null, 7 | "graphTooltip": 0, 8 | "hideControls": false, 9 | "id": null, 10 | "links": [], 11 | "refresh": "1m", 12 | "rows": [ 13 | { 14 | "collapse": false, 15 | "height": "250px", 16 | "panels": [ 17 | { 18 | "cacheTimeout": null, 19 | "colorBackground": false, 20 | "colorValue": false, 21 | "colors": [ 22 | "rgba(50, 172, 45, 0.97)", 23 | "rgba(237, 129, 40, 0.89)", 24 | "rgba(245, 54, 54, 0.9)" 25 | ], 26 | "datasource": "mon glpi", 27 | "format": "none", 28 | "gauge": { 29 | "maxValue": 1000, 30 | "minValue": 0, 31 | "show": true, 32 | "thresholdLabels": false, 33 | "thresholdMarkers": true 34 | }, 35 | "id": 1, 36 | "interval": null, 37 | "links": [], 38 | "mappingType": 1, 39 | "mappingTypes": [ 40 | { 41 | "name": "value to text", 42 | "value": 1 43 | }, 44 | { 45 | "name": "range to text", 46 | "value": 2 47 | } 48 | ], 49 | "maxDataPoints": 100, 50 | "minSpan": 2, 51 | "nullPointMode": "connected", 52 | "nullText": null, 53 | "postfix": "", 54 | "postfixFontSize": "50%", 55 | "prefix": "", 56 | "prefixFontSize": "50%", 57 | "rangeMaps": [ 58 | { 59 | "from": "null", 60 | "text": "N/A", 61 | "to": "null" 62 | } 63 | ], 64 | "span": 2, 65 | "sparkline": { 66 | "fillColor": "rgba(31, 118, 189, 0.18)", 67 | "full": false, 68 | "lineColor": "rgb(31, 120, 193)", 69 | "show": true 70 | }, 71 | "tableColumn": "", 72 | "targets": [ 73 | { 74 | "alias": "tickets", 75 | "col_0": { 76 | "group": "Default", 77 | "label": "------", 78 | "number": "0" 79 | }, 80 | "col_1": { 81 | "group": "Default", 82 | "label": "------", 83 | "number": "0" 84 | }, 85 | "col_2": { 86 | "group": "Default", 87 | "label": "------", 88 | "number": "0" 89 | }, 90 | "col_3": { 91 | "group": "Default", 92 | "label": "------", 93 | "number": "0" 94 | }, 95 | "col_4": { 96 | "group": "Default", 97 | "label": "------", 98 | "number": "0" 99 | }, 100 | "col_5": { 101 | "group": "Default", 102 | "label": "------", 103 | "number": "0" 104 | }, 105 | "col_6": { 106 | "group": "Default", 107 | "label": "------", 108 | "number": "0" 109 | }, 110 | "col_7": { 111 | "group": "Default", 112 | "label": "------", 113 | "number": "0" 114 | }, 115 | "col_8": { 116 | "group": "Default", 117 | "label": "------", 118 | "number": "0" 119 | }, 120 | "col_9": { 121 | "group": "Default", 122 | "label": "------", 123 | "number": "0" 124 | }, 125 | "col_10": { 126 | "group": "Default", 127 | "label": "------", 128 | "number": "0" 129 | }, 130 | "col_11": { 131 | "group": "Default", 132 | "label": "------", 133 | "number": "0" 134 | }, 135 | "counter": true, 136 | "datefield": { 137 | "group": "Caractéristiques", 138 | "label": "Date d'ouverture", 139 | "number": "15" 140 | }, 141 | "dynamicsplit": { 142 | "group": "Default", 143 | "label": "------", 144 | "number": "0" 145 | }, 146 | "hide": false, 147 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=all&search=Rechercher&itemtype=Ticket&start=0", 148 | "refId": "A", 149 | "table": false 150 | } 151 | ], 152 | "thresholds": "600,800", 153 | "timeFrom": "2h", 154 | "timerangefield": "date_creation", 155 | "title": "Nombre de tickets créés (2 last hours)", 156 | "type": "singlestat", 157 | "valueFontSize": "150%", 158 | "valueMaps": [ 159 | { 160 | "op": "=", 161 | "text": "N/A", 162 | "value": "null" 163 | } 164 | ], 165 | "valueName": "total" 166 | }, 167 | { 168 | "aliasColors": {}, 169 | "bars": true, 170 | "dashLength": 10, 171 | "dashes": false, 172 | "datasource": "mon glpi", 173 | "fill": 1, 174 | "hideTimeOverride": true, 175 | "id": 3, 176 | "interval": "2m", 177 | "legend": { 178 | "alignAsTable": false, 179 | "avg": false, 180 | "current": false, 181 | "hideEmpty": false, 182 | "hideZero": false, 183 | "max": false, 184 | "min": false, 185 | "show": true, 186 | "total": false, 187 | "values": false 188 | }, 189 | "lines": false, 190 | "linewidth": 1, 191 | "links": [], 192 | "nullPointMode": "null as zero", 193 | "percentage": false, 194 | "percentagepoints": "55", 195 | "pointradius": 5, 196 | "points": false, 197 | "renderer": "flot", 198 | "seriesOverrides": [], 199 | "spaceLength": 10, 200 | "span": 10, 201 | "stack": true, 202 | "steppedLine": false, 203 | "targets": [ 204 | { 205 | "alias": "Incident", 206 | "col_0": { 207 | "group": "Default", 208 | "label": "------", 209 | "number": "0" 210 | }, 211 | "col_1": { 212 | "group": "Default", 213 | "label": "------", 214 | "number": "0" 215 | }, 216 | "col_2": { 217 | "group": "Default", 218 | "label": "------", 219 | "number": "0" 220 | }, 221 | "col_3": { 222 | "group": "Default", 223 | "label": "------", 224 | "number": "0" 225 | }, 226 | "col_4": { 227 | "group": "Default", 228 | "label": "------", 229 | "number": "0" 230 | }, 231 | "col_5": { 232 | "group": "Default", 233 | "label": "------", 234 | "number": "0" 235 | }, 236 | "col_6": { 237 | "group": "Default", 238 | "label": "------", 239 | "number": "0" 240 | }, 241 | "col_7": { 242 | "group": "Default", 243 | "label": "------", 244 | "number": "0" 245 | }, 246 | "col_8": { 247 | "group": "Default", 248 | "label": "------", 249 | "number": "0" 250 | }, 251 | "col_9": { 252 | "group": "Default", 253 | "label": "------", 254 | "number": "0" 255 | }, 256 | "col_10": { 257 | "group": "Default", 258 | "label": "------", 259 | "number": "0" 260 | }, 261 | "col_11": { 262 | "group": "Default", 263 | "label": "------", 264 | "number": "0" 265 | }, 266 | "counter": true, 267 | "datefield": { 268 | "group": "Caractéristiques", 269 | "label": "Date d'ouverture", 270 | "number": "15" 271 | }, 272 | "dynamicsplit": { 273 | "group": "Default", 274 | "label": "------", 275 | "number": "0" 276 | }, 277 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=notold&criteria[1][link]=AND&criteria[1][field]=14&criteria[1][searchtype]=equals&criteria[1][value]=1&search=Rechercher&itemtype=Ticket&start=0", 278 | "refId": "A", 279 | "table": false 280 | }, 281 | { 282 | "alias": "Demande", 283 | "col_0": { 284 | "group": "Default", 285 | "label": "------", 286 | "number": "0" 287 | }, 288 | "col_1": { 289 | "group": "Default", 290 | "label": "------", 291 | "number": "0" 292 | }, 293 | "col_2": { 294 | "group": "Default", 295 | "label": "------", 296 | "number": "0" 297 | }, 298 | "col_3": { 299 | "group": "Default", 300 | "label": "------", 301 | "number": "0" 302 | }, 303 | "col_4": { 304 | "group": "Default", 305 | "label": "------", 306 | "number": "0" 307 | }, 308 | "col_5": { 309 | "group": "Default", 310 | "label": "------", 311 | "number": "0" 312 | }, 313 | "col_6": { 314 | "group": "Default", 315 | "label": "------", 316 | "number": "0" 317 | }, 318 | "col_7": { 319 | "group": "Default", 320 | "label": "------", 321 | "number": "0" 322 | }, 323 | "col_8": { 324 | "group": "Default", 325 | "label": "------", 326 | "number": "0" 327 | }, 328 | "col_9": { 329 | "group": "Default", 330 | "label": "------", 331 | "number": "0" 332 | }, 333 | "col_10": { 334 | "group": "Default", 335 | "label": "------", 336 | "number": "0" 337 | }, 338 | "col_11": { 339 | "group": "Default", 340 | "label": "------", 341 | "number": "0" 342 | }, 343 | "counter": true, 344 | "datefield": { 345 | "group": "Caractéristiques", 346 | "label": "Date d'ouverture", 347 | "number": "15" 348 | }, 349 | "dynamicsplit": { 350 | "group": "Default", 351 | "label": "------", 352 | "number": "0" 353 | }, 354 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=notold&criteria[1][link]=AND&criteria[1][field]=14&criteria[1][searchtype]=equals&criteria[1][value]=2&search=Rechercher&itemtype=Ticket&start=0", 355 | "refId": "B", 356 | "table": false 357 | } 358 | ], 359 | "thresholds": [], 360 | "timeFrom": null, 361 | "timeShift": null, 362 | "timerangefield": "date_creation", 363 | "title": "Tickets", 364 | "tooltip": { 365 | "shared": true, 366 | "sort": 0, 367 | "value_type": "individual" 368 | }, 369 | "type": "graph", 370 | "xaxis": { 371 | "buckets": null, 372 | "mode": "time", 373 | "name": null, 374 | "show": true, 375 | "values": [ 376 | "total" 377 | ] 378 | }, 379 | "yaxes": [ 380 | { 381 | "format": "short", 382 | "label": null, 383 | "logBase": 1, 384 | "max": null, 385 | "min": null, 386 | "show": true 387 | }, 388 | { 389 | "format": "short", 390 | "label": null, 391 | "logBase": 1, 392 | "max": null, 393 | "min": null, 394 | "show": true 395 | } 396 | ] 397 | } 398 | ], 399 | "repeat": null, 400 | "repeatIteration": null, 401 | "repeatRowId": null, 402 | "showTitle": false, 403 | "title": "Dashboard Row", 404 | "titleSize": "h6" 405 | }, 406 | { 407 | "collapse": false, 408 | "height": 237, 409 | "panels": [ 410 | { 411 | "cacheTimeout": null, 412 | "colorBackground": false, 413 | "colorValue": false, 414 | "colors": [ 415 | "rgba(245, 54, 54, 0.9)", 416 | "rgba(237, 129, 40, 0.89)", 417 | "rgba(50, 172, 45, 0.97)" 418 | ], 419 | "datasource": "mon glpi", 420 | "format": "none", 421 | "gauge": { 422 | "maxValue": 100, 423 | "minValue": 0, 424 | "show": false, 425 | "thresholdLabels": false, 426 | "thresholdMarkers": true 427 | }, 428 | "id": 4, 429 | "interval": null, 430 | "links": [], 431 | "mappingType": 1, 432 | "mappingTypes": [ 433 | { 434 | "name": "value to text", 435 | "value": 1 436 | }, 437 | { 438 | "name": "range to text", 439 | "value": 2 440 | } 441 | ], 442 | "maxDataPoints": 100, 443 | "nullPointMode": "connected", 444 | "nullText": null, 445 | "postfix": "", 446 | "postfixFontSize": "50%", 447 | "prefix": "", 448 | "prefixFontSize": "50%", 449 | "rangeMaps": [ 450 | { 451 | "from": "null", 452 | "text": "N/A", 453 | "to": "null" 454 | } 455 | ], 456 | "span": 2, 457 | "sparkline": { 458 | "fillColor": "rgba(31, 118, 189, 0.18)", 459 | "full": false, 460 | "lineColor": "rgb(31, 120, 193)", 461 | "show": false 462 | }, 463 | "tableColumn": "", 464 | "targets": [ 465 | { 466 | "col_0": { 467 | "group": "Default", 468 | "label": "------", 469 | "number": "0" 470 | }, 471 | "col_1": { 472 | "group": "Default", 473 | "label": "------", 474 | "number": "0" 475 | }, 476 | "col_2": { 477 | "group": "Default", 478 | "label": "------", 479 | "number": "0" 480 | }, 481 | "col_3": { 482 | "group": "Default", 483 | "label": "------", 484 | "number": "0" 485 | }, 486 | "col_4": { 487 | "group": "Default", 488 | "label": "------", 489 | "number": "0" 490 | }, 491 | "col_5": { 492 | "group": "Default", 493 | "label": "------", 494 | "number": "0" 495 | }, 496 | "col_6": { 497 | "group": "Default", 498 | "label": "------", 499 | "number": "0" 500 | }, 501 | "col_7": { 502 | "group": "Default", 503 | "label": "------", 504 | "number": "0" 505 | }, 506 | "col_8": { 507 | "group": "Default", 508 | "label": "------", 509 | "number": "0" 510 | }, 511 | "col_9": { 512 | "group": "Default", 513 | "label": "------", 514 | "number": "0" 515 | }, 516 | "col_10": { 517 | "group": "Default", 518 | "label": "------", 519 | "number": "0" 520 | }, 521 | "col_11": { 522 | "group": "Default", 523 | "label": "------", 524 | "number": "0" 525 | }, 526 | "counter": true, 527 | "datefield": { 528 | "group": "Plugins", 529 | "label": "FusInv - Dernier inventaire", 530 | "number": "5150" 531 | }, 532 | "dynamicsplit": { 533 | "group": "Default", 534 | "label": "------", 535 | "number": "0" 536 | }, 537 | "query": "http://127.0.0.1/glpi090/front/computer.php?is_deleted=0&criteria[0][field]=121&criteria[0][searchtype]=contains&criteria[0][value]=&search=Rechercher&itemtype=Computer&start=0", 538 | "refId": "A", 539 | "table": true 540 | } 541 | ], 542 | "thresholds": "", 543 | "timeFrom": null, 544 | "timerangefield": "date_creation", 545 | "title": "Nombre d'inventaires FusionInventory", 546 | "type": "singlestat", 547 | "valueFontSize": "200%", 548 | "valueMaps": [ 549 | { 550 | "op": "=", 551 | "text": "0", 552 | "value": "null" 553 | } 554 | ], 555 | "valueName": "total" 556 | }, 557 | { 558 | "bgColor": null, 559 | "clockType": "24 hour", 560 | "countdownSettings": { 561 | "endCountdownTime": "2017-06-23T07:50:00.000Z", 562 | "endText": "00:00:00" 563 | }, 564 | "dateSettings": { 565 | "dateFormat": "YYYY-MM-DD", 566 | "fontSize": "26px", 567 | "fontWeight": "normal", 568 | "showDate": true 569 | }, 570 | "id": 13, 571 | "links": [], 572 | "mode": "time", 573 | "offsetFromUtc": null, 574 | "offsetFromUtcMinutes": null, 575 | "span": 2, 576 | "timeSettings": { 577 | "customFormat": "HH:mm:ss", 578 | "fontSize": "60px", 579 | "fontWeight": "normal" 580 | }, 581 | "title": "", 582 | "type": "grafana-clock-panel" 583 | }, 584 | { 585 | "cacheTimeout": null, 586 | "colorBackground": true, 587 | "colorValue": false, 588 | "colors": [ 589 | "rgba(0, 0, 0, 0)", 590 | "rgb(31, 29, 29)", 591 | "rgba(245, 54, 54, 0.9)" 592 | ], 593 | "datasource": "mon glpi", 594 | "format": "none", 595 | "gauge": { 596 | "maxValue": 100, 597 | "minValue": 0, 598 | "show": false, 599 | "thresholdLabels": false, 600 | "thresholdMarkers": true 601 | }, 602 | "id": 5, 603 | "interval": null, 604 | "links": [], 605 | "mappingType": 1, 606 | "mappingTypes": [ 607 | { 608 | "name": "value to text", 609 | "value": 1 610 | }, 611 | { 612 | "name": "range to text", 613 | "value": 2 614 | } 615 | ], 616 | "maxDataPoints": 100, 617 | "nullPointMode": "connected", 618 | "nullText": null, 619 | "postfix": "", 620 | "postfixFontSize": "50%", 621 | "prefix": "", 622 | "prefixFontSize": "50%", 623 | "rangeMaps": [ 624 | { 625 | "from": "null", 626 | "text": "N/A", 627 | "to": "null" 628 | } 629 | ], 630 | "span": 2, 631 | "sparkline": { 632 | "fillColor": "rgba(31, 118, 189, 0.18)", 633 | "full": false, 634 | "lineColor": "rgb(31, 120, 193)", 635 | "show": false 636 | }, 637 | "tableColumn": "", 638 | "targets": [ 639 | { 640 | "col_0": { 641 | "group": "", 642 | "label": "------", 643 | "number": "0" 644 | }, 645 | "col_1": { 646 | "group": "", 647 | "label": "------", 648 | "number": "0" 649 | }, 650 | "col_2": { 651 | "group": "", 652 | "label": "------", 653 | "number": "0" 654 | }, 655 | "col_3": { 656 | "group": "", 657 | "label": "------", 658 | "number": "0" 659 | }, 660 | "col_4": { 661 | "group": "", 662 | "label": "------", 663 | "number": "0" 664 | }, 665 | "col_5": { 666 | "group": "", 667 | "label": "------", 668 | "number": "0" 669 | }, 670 | "col_6": { 671 | "group": "Default", 672 | "label": "------", 673 | "number": "0" 674 | }, 675 | "col_7": { 676 | "group": "Default", 677 | "label": "------", 678 | "number": "0" 679 | }, 680 | "col_8": { 681 | "group": "Default", 682 | "label": "------", 683 | "number": "0" 684 | }, 685 | "col_9": { 686 | "group": "Default", 687 | "label": "------", 688 | "number": "0" 689 | }, 690 | "col_10": { 691 | "group": "Default", 692 | "label": "------", 693 | "number": "0" 694 | }, 695 | "col_11": { 696 | "group": "Default", 697 | "label": "------", 698 | "number": "0" 699 | }, 700 | "cols": {}, 701 | "counter": true, 702 | "datefield": { 703 | "group": "Caractéristiques", 704 | "label": "Date d'ouverture", 705 | "number": "15" 706 | }, 707 | "dynamicsplit": { 708 | "group": "Default", 709 | "label": "------", 710 | "number": "0" 711 | }, 712 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=notold&criteria[1][link]=AND&criteria[1][field]=71&criteria[1][searchtype]=contains&criteria[1][value]=vip&search=Rechercher&itemtype=Ticket&start=0", 713 | "refId": "A", 714 | "table": false 715 | } 716 | ], 717 | "thresholds": "0,1", 718 | "timerangefield": "date_creation", 719 | "title": "Tickets VIP", 720 | "transparent": false, 721 | "type": "singlestat", 722 | "valueFontSize": "200%", 723 | "valueMaps": [ 724 | { 725 | "op": "=", 726 | "text": "0", 727 | "value": "null" 728 | } 729 | ], 730 | "valueName": "total" 731 | }, 732 | { 733 | "aliasColors": {}, 734 | "cacheTimeout": null, 735 | "combine": { 736 | "label": "Others", 737 | "threshold": 0 738 | }, 739 | "datasource": "mon glpi", 740 | "fontSize": "80%", 741 | "format": "short", 742 | "height": "200px", 743 | "id": 8, 744 | "interval": null, 745 | "legend": { 746 | "percentage": true, 747 | "show": true, 748 | "values": true 749 | }, 750 | "legendType": "Under graph", 751 | "links": [], 752 | "maxDataPoints": 3, 753 | "nullPointMode": "connected", 754 | "pieType": "pie", 755 | "span": 3, 756 | "strokeWidth": 1, 757 | "targets": [ 758 | { 759 | "alias": "incident", 760 | "col_0": { 761 | "group": "Default", 762 | "label": "------", 763 | "number": "0" 764 | }, 765 | "col_1": { 766 | "group": "Default", 767 | "label": "------", 768 | "number": "0" 769 | }, 770 | "col_2": { 771 | "group": "Default", 772 | "label": "------", 773 | "number": "0" 774 | }, 775 | "col_3": { 776 | "group": "Default", 777 | "label": "------", 778 | "number": "0" 779 | }, 780 | "col_4": { 781 | "group": "Default", 782 | "label": "------", 783 | "number": "0" 784 | }, 785 | "col_5": { 786 | "group": "Default", 787 | "label": "------", 788 | "number": "0" 789 | }, 790 | "col_6": { 791 | "group": "Default", 792 | "label": "------", 793 | "number": "0" 794 | }, 795 | "col_7": { 796 | "group": "Default", 797 | "label": "------", 798 | "number": "0" 799 | }, 800 | "col_8": { 801 | "group": "Default", 802 | "label": "------", 803 | "number": "0" 804 | }, 805 | "col_9": { 806 | "group": "Default", 807 | "label": "------", 808 | "number": "0" 809 | }, 810 | "col_10": { 811 | "group": "Default", 812 | "label": "------", 813 | "number": "0" 814 | }, 815 | "col_11": { 816 | "group": "Default", 817 | "label": "------", 818 | "number": "0" 819 | }, 820 | "counter": true, 821 | "datefield": { 822 | "group": "Caractéristiques", 823 | "label": "Date d'ouverture", 824 | "number": "15" 825 | }, 826 | "dynamicsplit": { 827 | "group": "Default", 828 | "label": "------", 829 | "number": "0" 830 | }, 831 | "query": "127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=all&criteria[1][link]=AND&criteria[1][field]=14&criteria[1][searchtype]=equals&criteria[1][value]=1&search=Rechercher&itemtype=Ticket&start=0", 832 | "refId": "A", 833 | "table": false 834 | }, 835 | { 836 | "alias": "demande", 837 | "col_0": { 838 | "group": "Default", 839 | "label": "------", 840 | "number": "0" 841 | }, 842 | "col_1": { 843 | "group": "Default", 844 | "label": "------", 845 | "number": "0" 846 | }, 847 | "col_2": { 848 | "group": "Default", 849 | "label": "------", 850 | "number": "0" 851 | }, 852 | "col_3": { 853 | "group": "Default", 854 | "label": "------", 855 | "number": "0" 856 | }, 857 | "col_4": { 858 | "group": "Default", 859 | "label": "------", 860 | "number": "0" 861 | }, 862 | "col_5": { 863 | "group": "Default", 864 | "label": "------", 865 | "number": "0" 866 | }, 867 | "col_6": { 868 | "group": "Default", 869 | "label": "------", 870 | "number": "0" 871 | }, 872 | "col_7": { 873 | "group": "Default", 874 | "label": "------", 875 | "number": "0" 876 | }, 877 | "col_8": { 878 | "group": "Default", 879 | "label": "------", 880 | "number": "0" 881 | }, 882 | "col_9": { 883 | "group": "Default", 884 | "label": "------", 885 | "number": "0" 886 | }, 887 | "col_10": { 888 | "group": "Default", 889 | "label": "------", 890 | "number": "0" 891 | }, 892 | "col_11": { 893 | "group": "Default", 894 | "label": "------", 895 | "number": "0" 896 | }, 897 | "counter": true, 898 | "datefield": { 899 | "group": "Caractéristiques", 900 | "label": "Date d'ouverture", 901 | "number": "15" 902 | }, 903 | "dynamicsplit": { 904 | "group": "Default", 905 | "label": "------", 906 | "number": "0" 907 | }, 908 | "query": "127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=all&criteria[1][link]=AND&criteria[1][field]=14&criteria[1][searchtype]=equals&criteria[1][value]=2&search=Rechercher&itemtype=Ticket&start=0", 909 | "refId": "B", 910 | "table": false 911 | } 912 | ], 913 | "title": "Types de tickets", 914 | "type": "grafana-piechart-panel", 915 | "valueName": "total" 916 | }, 917 | { 918 | "cacheTimeout": null, 919 | "colorBackground": false, 920 | "colorValue": true, 921 | "colors": [ 922 | "rgba(50, 172, 45, 0.97)", 923 | "rgba(237, 129, 40, 0.89)", 924 | "rgba(245, 54, 54, 0.9)" 925 | ], 926 | "datasource": "mon glpi", 927 | "decimals": 0, 928 | "format": "none", 929 | "gauge": { 930 | "maxValue": 100, 931 | "minValue": 0, 932 | "show": false, 933 | "thresholdLabels": false, 934 | "thresholdMarkers": true 935 | }, 936 | "id": 11, 937 | "interval": null, 938 | "links": [], 939 | "mappingType": 1, 940 | "mappingTypes": [ 941 | { 942 | "name": "value to text", 943 | "value": 1 944 | }, 945 | { 946 | "name": "range to text", 947 | "value": 2 948 | } 949 | ], 950 | "maxDataPoints": 100, 951 | "minSpan": 3, 952 | "nullPointMode": "connected", 953 | "nullText": null, 954 | "postfix": "", 955 | "postfixFontSize": "50%", 956 | "prefix": "", 957 | "prefixFontSize": "50%", 958 | "rangeMaps": [ 959 | { 960 | "from": "null", 961 | "text": "N/A", 962 | "to": "null" 963 | } 964 | ], 965 | "repeat": null, 966 | "span": 3, 967 | "sparkline": { 968 | "fillColor": "rgba(31, 118, 189, 0.18)", 969 | "full": false, 970 | "lineColor": "rgb(31, 120, 193)", 971 | "show": false 972 | }, 973 | "tableColumn": "", 974 | "targets": [ 975 | { 976 | "col_0": { 977 | "group": "Default", 978 | "label": "------", 979 | "number": "0" 980 | }, 981 | "col_1": { 982 | "group": "Default", 983 | "label": "------", 984 | "number": "0" 985 | }, 986 | "col_2": { 987 | "group": "Default", 988 | "label": "------", 989 | "number": "0" 990 | }, 991 | "col_3": { 992 | "group": "Default", 993 | "label": "------", 994 | "number": "0" 995 | }, 996 | "col_4": { 997 | "group": "Default", 998 | "label": "------", 999 | "number": "0" 1000 | }, 1001 | "col_5": { 1002 | "group": "Default", 1003 | "label": "------", 1004 | "number": "0" 1005 | }, 1006 | "col_6": { 1007 | "group": "Default", 1008 | "label": "------", 1009 | "number": "0" 1010 | }, 1011 | "col_7": { 1012 | "group": "Default", 1013 | "label": "------", 1014 | "number": "0" 1015 | }, 1016 | "col_8": { 1017 | "group": "Default", 1018 | "label": "------", 1019 | "number": "0" 1020 | }, 1021 | "col_9": { 1022 | "group": "Default", 1023 | "label": "------", 1024 | "number": "0" 1025 | }, 1026 | "col_10": { 1027 | "group": "Default", 1028 | "label": "------", 1029 | "number": "0" 1030 | }, 1031 | "col_11": { 1032 | "group": "Default", 1033 | "label": "------", 1034 | "number": "0" 1035 | }, 1036 | "counter": true, 1037 | "datefield": { 1038 | "group": "Caractéristiques", 1039 | "label": "Date d'ouverture", 1040 | "number": "15" 1041 | }, 1042 | "dynamicsplit": { 1043 | "group": "Default", 1044 | "label": "------", 1045 | "number": "0" 1046 | }, 1047 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=process&search=Rechercher&itemtype=Ticket&start=0", 1048 | "refId": "A", 1049 | "table": false 1050 | } 1051 | ], 1052 | "thresholds": "600,800", 1053 | "title": "En cours", 1054 | "transparent": false, 1055 | "type": "singlestat", 1056 | "valueFontSize": "120%", 1057 | "valueMaps": [ 1058 | { 1059 | "op": "=", 1060 | "text": "0", 1061 | "value": "null" 1062 | } 1063 | ], 1064 | "valueName": "total" 1065 | } 1066 | ], 1067 | "repeat": null, 1068 | "repeatIteration": null, 1069 | "repeatRowId": null, 1070 | "showTitle": false, 1071 | "title": "Dashboard Row", 1072 | "titleSize": "h6" 1073 | }, 1074 | { 1075 | "collapse": false, 1076 | "height": 250, 1077 | "panels": [ 1078 | { 1079 | "columns": [], 1080 | "datasource": "mon glpi", 1081 | "filterNull": false, 1082 | "fontSize": "100%", 1083 | "height": "460px", 1084 | "id": 9, 1085 | "links": [], 1086 | "pageSize": 10, 1087 | "scroll": true, 1088 | "showHeader": true, 1089 | "sort": { 1090 | "col": 4, 1091 | "desc": true 1092 | }, 1093 | "span": 12, 1094 | "styles": [ 1095 | { 1096 | "alias": "", 1097 | "colorMode": null, 1098 | "colors": [ 1099 | "rgba(245, 54, 54, 0.9)", 1100 | "rgba(237, 129, 40, 0.89)", 1101 | "rgba(50, 172, 45, 0.97)" 1102 | ], 1103 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1104 | "decimals": 2, 1105 | "pattern": "Titre", 1106 | "sanitize": true, 1107 | "thresholds": [], 1108 | "type": "string", 1109 | "unit": "short" 1110 | } 1111 | ], 1112 | "targets": [ 1113 | { 1114 | "col_0": { 1115 | "group": "Caractéristiques", 1116 | "label": "Titre", 1117 | "number": "1" 1118 | }, 1119 | "col_0_alias": "", 1120 | "col_1": { 1121 | "group": "Demandeur", 1122 | "label": "Demandeur", 1123 | "number": "4" 1124 | }, 1125 | "col_1_alias": "", 1126 | "col_2": { 1127 | "group": "Caractéristiques", 1128 | "label": "Priorité", 1129 | "number": "3" 1130 | }, 1131 | "col_2_alias": "", 1132 | "col_3": { 1133 | "group": "Caractéristiques", 1134 | "label": "Entité", 1135 | "number": "80" 1136 | }, 1137 | "col_3_alias": "", 1138 | "col_4": { 1139 | "group": "Caractéristiques", 1140 | "label": "Date d'ouverture", 1141 | "number": "15" 1142 | }, 1143 | "col_5": { 1144 | "group": "Caractéristiques", 1145 | "label": "Catégorie", 1146 | "number": "7" 1147 | }, 1148 | "col_6": { 1149 | "group": "Default", 1150 | "label": "------", 1151 | "number": "0" 1152 | }, 1153 | "col_7": { 1154 | "group": "Default", 1155 | "label": "------", 1156 | "number": "0" 1157 | }, 1158 | "col_8": { 1159 | "group": "Default", 1160 | "label": "------", 1161 | "number": "0" 1162 | }, 1163 | "col_9": { 1164 | "group": "Default", 1165 | "label": "------", 1166 | "number": "0" 1167 | }, 1168 | "col_10": { 1169 | "group": "Default", 1170 | "label": "------", 1171 | "number": "0" 1172 | }, 1173 | "col_11": { 1174 | "group": "Default", 1175 | "label": "------", 1176 | "number": "0" 1177 | }, 1178 | "cols": { 1179 | "0": "1", 1180 | "1": "4", 1181 | "2": "3" 1182 | }, 1183 | "colsa": { 1184 | "group": "Caractéristiques", 1185 | "label": "Titre", 1186 | "number": "1" 1187 | }, 1188 | "counter": "yes", 1189 | "datefield": { 1190 | "group": "Caractéristiques", 1191 | "label": "Date d'ouverture", 1192 | "number": "15" 1193 | }, 1194 | "dynamicsplit": { 1195 | "group": "Default", 1196 | "label": "------", 1197 | "number": "0" 1198 | }, 1199 | "query": "http://127.0.0.1/glpi090/front/ticket.php?is_deleted=0&criteria[0][field]=12&criteria[0][searchtype]=equals&criteria[0][value]=all&search=Rechercher&itemtype=Ticket&start=0", 1200 | "refId": "A", 1201 | "table": true 1202 | } 1203 | ], 1204 | "title": "Derniers tickets", 1205 | "transform": "table", 1206 | "type": "table" 1207 | } 1208 | ], 1209 | "repeat": null, 1210 | "repeatIteration": null, 1211 | "repeatRowId": null, 1212 | "showTitle": false, 1213 | "title": "Dashboard Row", 1214 | "titleSize": "h6" 1215 | }, 1216 | { 1217 | "collapse": false, 1218 | "height": 250, 1219 | "panels": [ 1220 | { 1221 | "columns": [], 1222 | "datasource": "mon glpi", 1223 | "filterNull": false, 1224 | "fontSize": "150%", 1225 | "height": "450px", 1226 | "id": 10, 1227 | "links": [], 1228 | "pageSize": null, 1229 | "scroll": true, 1230 | "showHeader": true, 1231 | "sort": { 1232 | "col": 0, 1233 | "desc": true 1234 | }, 1235 | "span": 12, 1236 | "styles": [ 1237 | { 1238 | "dateFormat": "YYYY-MM-DD HH:mm:ss", 1239 | "pattern": "Time", 1240 | "type": "date" 1241 | }, 1242 | { 1243 | "colorMode": null, 1244 | "colors": [ 1245 | "rgba(245, 54, 54, 0.9)", 1246 | "rgba(237, 129, 40, 0.89)", 1247 | "rgba(50, 172, 45, 0.97)" 1248 | ], 1249 | "decimals": 2, 1250 | "pattern": "/.*/", 1251 | "sanitize": true, 1252 | "thresholds": [], 1253 | "type": "string", 1254 | "unit": "short" 1255 | } 1256 | ], 1257 | "targets": [ 1258 | { 1259 | "col_0": { 1260 | "group": "Caractéristiques", 1261 | "label": "Titre", 1262 | "number": "1" 1263 | }, 1264 | "col_0_alias": "Informations", 1265 | "col_1": { 1266 | "group": "Caractéristiques", 1267 | "label": "Description", 1268 | "number": "4" 1269 | }, 1270 | "col_2": { 1271 | "group": "", 1272 | "label": "------", 1273 | "number": "0" 1274 | }, 1275 | "col_3": { 1276 | "group": "", 1277 | "label": "------", 1278 | "number": "0" 1279 | }, 1280 | "col_4": { 1281 | "group": "", 1282 | "label": "------", 1283 | "number": "0" 1284 | }, 1285 | "col_5": { 1286 | "group": "", 1287 | "label": "------", 1288 | "number": "0" 1289 | }, 1290 | "col_6": { 1291 | "group": "Default", 1292 | "label": "------", 1293 | "number": "0" 1294 | }, 1295 | "col_7": { 1296 | "group": "Default", 1297 | "label": "------", 1298 | "number": "0" 1299 | }, 1300 | "col_8": { 1301 | "group": "Default", 1302 | "label": "------", 1303 | "number": "0" 1304 | }, 1305 | "col_9": { 1306 | "group": "Default", 1307 | "label": "------", 1308 | "number": "0" 1309 | }, 1310 | "col_10": { 1311 | "group": "Default", 1312 | "label": "------", 1313 | "number": "0" 1314 | }, 1315 | "col_11": { 1316 | "group": "Default", 1317 | "label": "------", 1318 | "number": "0" 1319 | }, 1320 | "cols": {}, 1321 | "counter": true, 1322 | "datefield": { 1323 | "group": "Special / be careful", 1324 | "label": "Not use date, so get all data", 1325 | "number": "-1" 1326 | }, 1327 | "dynamicsplit": { 1328 | "group": "Default", 1329 | "label": "------", 1330 | "number": "0" 1331 | }, 1332 | "nocounterval": { 1333 | "group": "Documents", 1334 | "label": "Nombre de documents", 1335 | "number": "119" 1336 | }, 1337 | "query": "http://127.0.0.1/glpi090/front/reminder.php?criteria[0][field]=1&criteria[0][searchtype]=contains&criteria[0][value]=&search=Rechercher&itemtype=Reminder&start=0", 1338 | "refId": "A", 1339 | "table": true 1340 | } 1341 | ], 1342 | "title": "Informations importantes", 1343 | "transform": "table", 1344 | "transparent": true, 1345 | "type": "table" 1346 | } 1347 | ], 1348 | "repeat": null, 1349 | "repeatIteration": null, 1350 | "repeatRowId": null, 1351 | "showTitle": false, 1352 | "title": "Dashboard Row", 1353 | "titleSize": "h6" 1354 | } 1355 | ], 1356 | "schemaVersion": 14, 1357 | "style": "dark", 1358 | "tags": [ 1359 | "glpi-app", 1360 | "imported" 1361 | ], 1362 | "templating": { 1363 | "list": [] 1364 | }, 1365 | "time": { 1366 | "from": "now-6h", 1367 | "to": "now" 1368 | }, 1369 | "timepicker": { 1370 | "nowDelay": "", 1371 | "refresh_intervals": [ 1372 | "5s", 1373 | "10s", 1374 | "30s", 1375 | "1m", 1376 | "5m", 1377 | "15m", 1378 | "30m", 1379 | "1h", 1380 | "2h", 1381 | "1d" 1382 | ], 1383 | "time_options": [ 1384 | "5m", 1385 | "15m", 1386 | "1h", 1387 | "6h", 1388 | "12h", 1389 | "24h", 1390 | "2d", 1391 | "7d", 1392 | "30d" 1393 | ] 1394 | }, 1395 | "timezone": "browser", 1396 | "title": "GLPI dashboard demo", 1397 | "version": 25 1398 | } -------------------------------------------------------------------------------- /src/datasource/ConfigEditor.tsx: -------------------------------------------------------------------------------- 1 | import React, { ChangeEvent, PureComponent } from 'react'; 2 | import { LegacyForms } from '@grafana/ui'; 3 | import { DataSourcePluginOptionsEditorProps } from '@grafana/data'; 4 | import { MyDataSourceOptions, MySecureJsonData } from './types'; 5 | 6 | const { SecretFormField, FormField } = LegacyForms; 7 | 8 | interface Props extends DataSourcePluginOptionsEditorProps {} 9 | 10 | interface State {} 11 | 12 | export class ConfigEditor extends PureComponent { 13 | onUrlChange = (event: ChangeEvent) => { 14 | const { onOptionsChange, options } = this.props; 15 | const jsonData = { 16 | ...options.jsonData, 17 | url: event.target.value, 18 | }; 19 | onOptionsChange({ ...options, jsonData }); 20 | }; 21 | 22 | onTimeZoneChange = (event: ChangeEvent) => { 23 | const { onOptionsChange, options } = this.props; 24 | const jsonData = { 25 | ...options.jsonData, 26 | timeZone: event.target.value, 27 | }; 28 | onOptionsChange({ ...options, jsonData }); 29 | }; 30 | 31 | // Secure field (only sent to the backend) 32 | onAppTokenChange = (event: ChangeEvent) => { 33 | const { onOptionsChange, options } = this.props; 34 | onOptionsChange({ 35 | ...options, 36 | secureJsonData: { 37 | ...options.secureJsonData, 38 | appToken: event.target.value, 39 | }, 40 | }); 41 | }; 42 | 43 | onResetAppToken = () => { 44 | const { onOptionsChange, options } = this.props; 45 | onOptionsChange({ 46 | ...options, 47 | secureJsonFields: { 48 | ...options.secureJsonFields, 49 | appToken: false, 50 | }, 51 | secureJsonData: { 52 | ...options.secureJsonData, 53 | appToken: '', 54 | }, 55 | }); 56 | }; 57 | 58 | onUserTokenChange = (event: ChangeEvent) => { 59 | const { onOptionsChange, options } = this.props; 60 | onOptionsChange({ 61 | ...options, 62 | secureJsonData: { 63 | ...options.secureJsonData, 64 | userToken: event.target.value, 65 | }, 66 | }); 67 | }; 68 | 69 | onResetUserToken = () => { 70 | const { onOptionsChange, options } = this.props; 71 | onOptionsChange({ 72 | ...options, 73 | secureJsonFields: { 74 | ...options.secureJsonFields, 75 | userToken: false, 76 | }, 77 | secureJsonData: { 78 | ...options.secureJsonData, 79 | userToken: '', 80 | }, 81 | }); 82 | }; 83 | 84 | render() { 85 | this.migrateConfig(); 86 | 87 | let { options } = this.props; 88 | const { jsonData, secureJsonFields } = options; 89 | const secureJsonData = (options.secureJsonData || {}) as MySecureJsonData; 90 | 91 | return ( 92 |
93 |
94 | 102 |
103 | 104 |
105 |
106 | 116 |
117 |
118 | 119 |
120 |
121 | 131 |
132 |
133 | 134 |
135 | 143 |
144 |
145 | ); 146 | } 147 | 148 | private migrateConfig() { 149 | console.log(this.props.options); 150 | if (this.props.options.jsonData.url === undefined && this.props.options.url !== undefined) { 151 | this.props.options.access = 'proxy'; 152 | this.props.options.jsonData.url = this.props.options.url; 153 | this.props.options.jsonData.timeZone = this.props.options.jsonData.timezone; 154 | 155 | const { onOptionsChange, options } = this.props; 156 | onOptionsChange({ 157 | ...options, 158 | secureJsonData: { 159 | ...options.secureJsonData, 160 | appToken: this.props.options.jsonData.apptoken, 161 | userToken: this.props.options.jsonData.token, 162 | }, 163 | }); 164 | // delete this.props.options.url; 165 | delete this.props.options.jsonData.timezone; 166 | delete this.props.options.jsonData.apptoken; 167 | delete this.props.options.jsonData.token; 168 | } 169 | console.log('migrate', this.props.options.jsonData); 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /src/datasource/DataSource.ts: -------------------------------------------------------------------------------- 1 | let striptags = require('striptags'); 2 | let sanitizeHtml = require('sanitize-html'); 3 | 4 | import { 5 | DataQueryRequest, 6 | DataQueryResponse, 7 | DataSourceApi, 8 | DataSourceInstanceSettings, 9 | MutableDataFrame, 10 | FieldType, 11 | } from '@grafana/data'; 12 | import { getBackendSrv } from '@grafana/runtime'; 13 | import { MyQuery, MyDataSourceOptions } from './types'; 14 | 15 | export class DataSource extends DataSourceApi { 16 | url?: string; 17 | sessionToken?: string; 18 | 19 | constructor(public instanceSettings: DataSourceInstanceSettings) { 20 | super(instanceSettings); 21 | 22 | this.url = instanceSettings.url; 23 | this.sessionToken = ''; 24 | } 25 | 26 | async query(options: DataQueryRequest): Promise { 27 | const { range } = options; 28 | 29 | const requestFrom = Math.round(options.range.from.valueOf() / 1000); 30 | const requestTo = Math.round(options.range.to.valueOf() / 1000); 31 | 32 | const promises = options.targets.map(query => 33 | this.doRequest(query, requestFrom, requestTo).then(async response => { 34 | // let name = ''; 35 | // if (query.alias !== '') { 36 | // name = query.alias; 37 | // } 38 | 39 | let dataIntervals: any[] = []; 40 | let splitTypes: any[] = []; 41 | let from = 0; 42 | let to = 0; 43 | let frames: any = {}; 44 | 45 | if (query.table) { 46 | // case it's table 47 | let fields = []; 48 | 49 | const queryUrl = decodeURI(query.queryUrl); 50 | const searchq = queryUrl.split('.php?'); 51 | if (searchq[1] === undefined) { 52 | return; 53 | } 54 | const url = searchq[0].split('/'); 55 | const itemtype = url[url.length - 1]; 56 | 57 | let listSearchOptions = await this.getListSearchOptions(itemtype); 58 | for (let column of query.columns) { 59 | let alias = column.alias; 60 | if (alias === undefined || alias === '') { 61 | alias = listSearchOptions.data[column.field].name; 62 | } 63 | fields.push({ 64 | name: alias, 65 | type: FieldType.string, 66 | }); 67 | } 68 | 69 | frames['table'] = new MutableDataFrame({ 70 | name: 'table', 71 | // refId: query.refId, 72 | fields, 73 | }); 74 | if (response !== undefined && response.data.data_html !== undefined) { 75 | response.data.data_html.forEach((point: any) => { 76 | let myFrame: any[] = []; 77 | for (let column of query.columns) { 78 | if (point[column.field].includes("class='invisible'")) { 79 | const textSplitInvisible = point[column.field].split("class='invisible'"); 80 | point[column.field] = textSplitInvisible[0]; 81 | } 82 | myFrame.push(striptags(sanitizeHtml(point[column.field]))); 83 | } 84 | frames['table'].appendRow(myFrame); 85 | }); 86 | } 87 | } else { 88 | // case it's NOT table 89 | if (response !== undefined && response.data.data_html !== undefined) { 90 | response.data.data_html.forEach((point: any) => { 91 | let pointTime = 0; 92 | let splitType = ''; 93 | 94 | if (query.datefield !== -1) { 95 | let intervalMs = 0; 96 | if (options.intervalMs) { 97 | intervalMs = options.intervalMs; 98 | } 99 | pointTime = new Date(this.formatDate(point[query.datefield])).getTime() - intervalMs; 100 | from = range.from.valueOf(); 101 | to = range.to.valueOf(); 102 | } else { 103 | from = 9000000000; 104 | to = 9000000000; 105 | } 106 | splitType = '[empty]'; 107 | if (query.dynamicsplit > 0) { 108 | // Clean HTML 109 | splitType = striptags(sanitizeHtml(point[query.dynamicsplit])); 110 | splitType = splitType.replace(' ', ''); 111 | if (splitType === '') { 112 | splitType = '[empty]'; 113 | } 114 | } else { 115 | if (query.alias !== undefined && query.alias !== '') { 116 | splitType = query.alias; 117 | } 118 | } 119 | if (!splitTypes.includes(splitType)) { 120 | let intervalMs = 0; 121 | if (options.intervalMs) { 122 | intervalMs = options.intervalMs; 123 | } 124 | dataIntervals = this.definedataIntervals(dataIntervals, from, to, intervalMs, splitType); 125 | splitTypes.push(splitType); 126 | } 127 | for (let dataInterval of dataIntervals) { 128 | // update values 129 | if (dataInterval.splitType === splitType && pointTime < dataInterval.time) { 130 | if (!query.counter && query.nocounterval !== 0) { 131 | dataInterval.value += point[query.nocounterval]; 132 | } else { 133 | // it's counter 134 | dataInterval.value += 1; 135 | } 136 | break; 137 | } 138 | } 139 | }); 140 | if (dataIntervals.length === 0 && query.datefield === -1) { 141 | dataIntervals.push({ 142 | time: 9000000000, 143 | value: 0, 144 | splitType: '', 145 | }); 146 | } 147 | } 148 | for (let dataInterval of dataIntervals) { 149 | if (frames[dataInterval.splitType] === undefined) { 150 | frames[dataInterval.splitType] = new MutableDataFrame({ 151 | // refId: query.refId, 152 | fields: [ 153 | { name: 'time', type: FieldType.time }, 154 | { name: dataInterval.splitType, type: FieldType.number }, 155 | ], 156 | }); 157 | } 158 | let intervalMs = 0; 159 | if (options.intervalMs) { 160 | intervalMs = options.intervalMs; 161 | } 162 | frames[dataInterval.splitType].appendRow([dataInterval.time + intervalMs / 2, dataInterval.value]); 163 | } 164 | } 165 | return frames; 166 | }) 167 | ); 168 | return Promise.all(promises).then(data => { 169 | let newData = []; 170 | for (let dataLvl1 of data) { 171 | for (let prop in dataLvl1) { 172 | newData.push(dataLvl1[prop]); 173 | } 174 | } 175 | return { data: newData }; 176 | }); 177 | } 178 | 179 | async getListSearchOptions(itemType: string) { 180 | await this.checkSessionToken(); 181 | const options: any = { 182 | url: this.url + '/query/listSearchOptions/' + itemType, 183 | method: 'GET', 184 | headers: { 'Session-Token': this.sessionToken }, 185 | }; 186 | 187 | return await getBackendSrv() 188 | .datasourceRequest(options) 189 | .catch((err: any) => { 190 | if (err.data && err.data.error) { 191 | throw new Error('GLPI error: ' + err.data.message); 192 | } 193 | return err; 194 | }); 195 | } 196 | 197 | async testDatasource() { 198 | // Implement a health check for your data source. 199 | if (this.instanceSettings.jsonData.url === '') { 200 | throw new Error('GLPI URL must be filled'); 201 | } 202 | let result = await this.getSession(); 203 | if (result.data.session_token !== undefined) { 204 | return { 205 | status: 'success', 206 | message: 'Success', 207 | }; 208 | } else { 209 | return { 210 | status: 'error', 211 | message: result.data, 212 | }; 213 | } 214 | } 215 | 216 | async checkSessionToken() { 217 | if (this.sessionToken === '') { 218 | const response = await this.getSession(); 219 | this.sessionToken = response.data.session_token; 220 | } 221 | } 222 | 223 | async getSession() { 224 | const options: any = { 225 | url: this.url + '/initSession', 226 | method: 'GET', 227 | }; 228 | 229 | getBackendSrv().datasourceRequest(options); 230 | 231 | return await getBackendSrv() 232 | .datasourceRequest(options) 233 | .catch((err: any) => { 234 | if (err.data && err.data.error) { 235 | throw new Error('GLPI error: ' + err.data.message); 236 | } 237 | return err; 238 | }); 239 | } 240 | 241 | async doRequest(query: MyQuery, from: number, to: number) { 242 | await this.checkSessionToken(); 243 | 244 | // Convert data when it's from old version (before grafana 7) 245 | query = this.convertQuery(query); 246 | 247 | // Prepare data to send 248 | const queryUrl = decodeURI(query.queryUrl); 249 | const searchq = queryUrl.split('.php?'); 250 | if (searchq[1] === undefined) { 251 | return; 252 | } 253 | const url = searchq[0].split('/'); 254 | const itemtype = url[url.length - 1]; 255 | 256 | const dateISOFrom = new Date(from * 1e3).toISOString(); 257 | const urlStartDate = dateISOFrom.slice(0, -14) + ' ' + dateISOFrom.slice(-13, -5); 258 | const dateISOTo = new Date(to * 1e3).toISOString(); 259 | const urlEndDate = dateISOTo.slice(0, -14) + ' ' + dateISOTo.slice(-13, -5); 260 | 261 | let params: any = {}; 262 | 263 | const splitArgs = searchq[1].split('&'); 264 | let criteriaIndex = 0; 265 | let otherParams: any = {}; 266 | for (let arg of splitArgs) { 267 | const match = arg.match(/^criteria\[(\d+)\]/); 268 | 269 | if (match === null) { 270 | const paramSplit = arg.split('='); 271 | otherParams[paramSplit[0]] = paramSplit[1]; 272 | } else { 273 | if (parseInt(match[1], 10) > criteriaIndex) { 274 | criteriaIndex = parseInt(match[1], 10); 275 | } 276 | let paramSplit = arg.split('='); 277 | if (paramSplit[0].includes('value')) { 278 | // hack because glpi interface replace space with + but API not understand it 279 | paramSplit[1] = paramSplit[1].replace('+', ' '); 280 | } 281 | params[paramSplit[0]] = paramSplit[1]; 282 | } 283 | } 284 | 285 | if (query.datefield > -1) { 286 | criteriaIndex += 1; 287 | params['criteria[' + criteriaIndex + '][link]'] = 'AND'; 288 | params['criteria[' + criteriaIndex + '][field]'] = query.datefield; 289 | params['criteria[' + criteriaIndex + '][searchtype]'] = 'morethan'; 290 | params['criteria[' + criteriaIndex + '][value]'] = urlStartDate; 291 | 292 | criteriaIndex += 1; 293 | params['criteria[' + criteriaIndex + '][link]'] = 'AND'; 294 | params['criteria[' + criteriaIndex + '][field]'] = query.datefield; 295 | params['criteria[' + criteriaIndex + '][searchtype]'] = 'lessthan'; 296 | params['criteria[' + criteriaIndex + '][value]'] = urlEndDate; 297 | } 298 | let forcedisplayIndex = 0; 299 | otherParams['forcedisplay[' + forcedisplayIndex + ']'] = 0; 300 | 301 | if (query.dynamicsplit > 0) { 302 | forcedisplayIndex += 1; 303 | otherParams['forcedisplay[' + forcedisplayIndex + ']'] = query.dynamicsplit; 304 | } 305 | if (!query.counter && query.nocounterval !== 0) { 306 | forcedisplayIndex += 1; 307 | otherParams['forcedisplay[' + forcedisplayIndex + ']'] = query.nocounterval; 308 | } 309 | if (query.table) { 310 | for (const column of query.columns) { 311 | forcedisplayIndex += 1; 312 | otherParams['forcedisplay[' + forcedisplayIndex + ']'] = column.field; 313 | } 314 | } 315 | 316 | otherParams['range'] = '0-2000000'; 317 | otherParams['giveItems'] = 'true'; 318 | 319 | params = Object.assign(params, otherParams); 320 | if (params._glpi_csrf_token !== undefined) { 321 | delete params._glpi_csrf_token; 322 | } 323 | 324 | const options: any = { 325 | method: 'GET', 326 | url: this.url + '/query/search/' + itemtype, 327 | headers: { 'Session-Token': this.sessionToken }, 328 | params, 329 | }; 330 | 331 | const result = await getBackendSrv().datasourceRequest(options); 332 | 333 | return result; 334 | } 335 | 336 | private definedataIntervals(dataIntervals: any[], from: number, to: number, interval: number, splitType: string) { 337 | let currentTime = from; 338 | while (currentTime <= to) { 339 | dataIntervals.push({ 340 | time: currentTime, 341 | value: 0, 342 | splitType: splitType, 343 | }); 344 | currentTime += interval; 345 | } 346 | return dataIntervals; 347 | } 348 | 349 | convertQuery(query: any) { 350 | if (query.query !== undefined) { 351 | query.queryUrl = query.query; 352 | query.datefield = parseInt(query.datefield.number, 10); 353 | query.dynamicsplit = parseInt(query.dynamicsplit.number, 10); 354 | if (query.nocounterval !== undefined && query.nocounterval.number !== undefined) { 355 | query.nocounterval = parseInt(query.nocounterval.number, 10); 356 | } 357 | delete query.query; 358 | if (query.columns === undefined) { 359 | query.columns = []; 360 | } 361 | let i = 0; 362 | while (i <= 11) { 363 | if (query['col_' + i].number !== undefined && parseInt(query['col_' + i].number, 10) !== 0) { 364 | let alias = ''; 365 | if (!query['col_' + i + '_alias'] !== undefined) { 366 | alias = query['col_' + i + '_alias']; 367 | } 368 | query.columns.push({ 369 | field: parseInt(query['col_' + i].number, 10), 370 | alias, 371 | }); 372 | } 373 | delete query['col_' + i]; 374 | delete query['col_' + i + '_alias']; 375 | i += 1; 376 | } 377 | } 378 | return query; 379 | } 380 | 381 | formatDate(myDate: string) { 382 | // Because on some GLPI instance, date format is day-month-year instead year-month-day 383 | const match = myDate.match(/^(\d{2})-(\d{2})-(\d{4}) (.*)$/); 384 | if (match === null) { 385 | return myDate; 386 | } else { 387 | return match[3] + '-' + match[2] + '-' + match[1] + ' ' + match[4]; 388 | } 389 | return myDate; 390 | } 391 | } 392 | -------------------------------------------------------------------------------- /src/datasource/QueryEditor.tsx: -------------------------------------------------------------------------------- 1 | import defaults from 'lodash/defaults'; 2 | import React, { ChangeEvent, PureComponent } from 'react'; 3 | import { LegacyForms, InlineFormLabel, Button } from '@grafana/ui'; 4 | import { QueryEditorProps } from '@grafana/data'; 5 | import { DataSource } from './DataSource'; 6 | import { defaultQuery, MyDataSourceOptions, MyQuery } from './types'; 7 | 8 | const { FormField, Select, Switch } = LegacyForms; 9 | 10 | type Props = QueryEditorProps; 11 | 12 | export class QueryEditor extends PureComponent { 13 | searchOptions: any[]; 14 | searchOptionsDatetime: any[]; 15 | searchOptionsNumber: any[]; 16 | itemtype?: string; 17 | 18 | constructor(props: Props, context: React.Context) { 19 | super(props, context); 20 | this.searchOptions = []; 21 | this.searchOptionsDatetime = []; 22 | this.searchOptionsNumber = []; 23 | this.itemtype = ''; 24 | 25 | this.getListSearchOptions(true); 26 | } 27 | 28 | onQueryUrlChange = (event: ChangeEvent) => { 29 | const { onChange, query, onRunQuery } = this.props; 30 | onChange({ ...query, queryUrl: event.target.value }); 31 | this.getListSearchOptions(false, event.target.value); 32 | // executes the query 33 | onRunQuery(); 34 | }; 35 | 36 | onAliasChange = (event: ChangeEvent) => { 37 | const { onChange, query, onRunQuery } = this.props; 38 | onChange({ ...query, alias: event.target.value }); 39 | // executes the query 40 | onRunQuery(); 41 | }; 42 | 43 | onDatefieldValue = (event: any) => { 44 | const { onChange, query, onRunQuery } = this.props; 45 | onChange({ ...query, datefield: event.value }); 46 | // executes the query 47 | onRunQuery(); 48 | }; 49 | 50 | onDynamicsplitValue = (event: any) => { 51 | const { onChange, query, onRunQuery } = this.props; 52 | onChange({ ...query, dynamicsplit: event.value }); 53 | // executes the query 54 | onRunQuery(); 55 | }; 56 | 57 | onCounterChange = (event: any) => { 58 | const { onChange, query, onRunQuery } = this.props; 59 | onChange({ ...query, counter: event.target.checked }); 60 | // executes the query 61 | onRunQuery(); 62 | }; 63 | 64 | onNocountervalValue = (event: any) => { 65 | const { onChange, query, onRunQuery } = this.props; 66 | onChange({ ...query, nocounterval: event.value }); 67 | // executes the query 68 | onRunQuery(); 69 | }; 70 | 71 | onTableChange = (event: any) => { 72 | const { onChange, query, onRunQuery } = this.props; 73 | onChange({ ...query, table: event.target.checked }); 74 | // executes the query 75 | onRunQuery(); 76 | }; 77 | 78 | addColumn = () => { 79 | const { query, onRunQuery } = this.props; 80 | query.columns.push({ 81 | field: 0, 82 | alias: '', 83 | }); 84 | onRunQuery(); 85 | }; 86 | 87 | removeColumn = (idx: number) => { 88 | const { query, onRunQuery } = this.props; 89 | query.columns.splice(idx, 1); 90 | onRunQuery(); 91 | }; 92 | 93 | onColumnValue = (event: any, idx: number) => { 94 | const { query, onRunQuery } = this.props; 95 | query.columns[idx].field = event.value; 96 | onRunQuery(); 97 | }; 98 | 99 | onColumnAliasValue = (event: ChangeEvent, idx: number) => { 100 | const { query, onRunQuery } = this.props; 101 | query.columns[idx].alias = event.target.value; 102 | onRunQuery(); 103 | }; 104 | 105 | async getListSearchOptions(runQuery: boolean, newUrl: string|null = null) { 106 | // Get the itemtype from queryUrl 107 | const query = defaults(this.props.query, defaultQuery); 108 | 109 | const queryUrl = decodeURI(query.queryUrl); 110 | let searchq: any[] = []; 111 | 112 | if (newUrl !== null) { 113 | searchq = newUrl.split('.php?'); 114 | } else { 115 | searchq = queryUrl.split('.php?'); 116 | } 117 | const url = searchq[0].split('/'); 118 | const itemtype = url[url.length - 1]; 119 | 120 | if (itemtype !== '' && itemtype !== this.itemtype) { 121 | this.itemtype = itemtype; 122 | const res = await this.props.datasource.getListSearchOptions(itemtype); 123 | this.searchOptionsDatetime.push({ 124 | label: 'Do not use date search (get all data)', 125 | value: -1, 126 | }); 127 | this.searchOptions.push({ 128 | label: 'Do not use split (get all data)', 129 | value: -1, 130 | }); 131 | for (let key of Object.keys(res.data)) { 132 | if (res.data[key].table === undefined) { 133 | continue; 134 | } 135 | if (res.data[key].datatype === 'date' || res.data[key].datatype === 'datetime') { 136 | this.searchOptionsDatetime.push({ 137 | label: res.data[key].name, 138 | value: parseInt(key, 10), 139 | description: 'uid: ' + res.data[key].uid, 140 | }); 141 | } 142 | // datatype number 143 | if ( 144 | res.data[key].datatype === 'timestamp' || 145 | res.data[key].datatype === 'count' || 146 | res.data[key].datatype === 'number' || 147 | res.data[key].datatype === 'integer' 148 | ) { 149 | this.searchOptionsNumber.push({ 150 | label: res.data[key].name, 151 | value: parseInt(key, 10), 152 | description: 'uid: ' + res.data[key].uid, 153 | }); 154 | } 155 | 156 | this.searchOptions.push({ 157 | label: res.data[key].name, 158 | value: parseInt(key, 10), 159 | description: 'uid: ' + res.data[key].uid, 160 | }); 161 | } 162 | if (runQuery) { 163 | const { onRunQuery } = this.props; 164 | onRunQuery(); 165 | } 166 | } 167 | } 168 | 169 | render() { 170 | this.migrateConfig(); 171 | 172 | const query = defaults(this.props.query, defaultQuery); 173 | const { queryUrl, alias, datefield, dynamicsplit, counter, nocounterval, table, columns } = query; 174 | 175 | const datefieldSelected = this.searchOptionsDatetime.find(i => i.value === datefield); 176 | const dynamicsplitSelected = this.searchOptions.find(i => i.value === dynamicsplit); 177 | const nocountervalSelected = this.searchOptionsNumber.find(i => i.value === nocounterval); 178 | 179 | return ( 180 |
181 |
182 | 191 |
192 |
193 | 194 | 195 | 196 | {'Timerange based on'} 197 | 198 | 'No options found'} 224 | value={dynamicsplitSelected} 225 | /> 226 |
227 |
228 | 234 | {!counter && ( 235 | 236 | {'Field value to use'} 237 | 238 | )} 239 | {!counter && ( 240 | this.onColumnValue(e, idx)} 274 | options={this.searchOptions} 275 | // isSearchable={isSearchable} 276 | maxMenuHeight={500} 277 | placeholder={'Choose the field'} 278 | noOptionsMessage={() => 'No options found'} 279 | value={this.searchOptions.find(i => i.value === el.field)} 280 | /> 281 | this.onColumnAliasValue(e, idx)} 286 | type="text" 287 | /> 288 | 293 |
294 | ))} 295 | {table && ( 296 | 304 | )} 305 |
306 | ); 307 | } 308 | 309 | private migrateConfig() { 310 | if (this.props.query.query !== undefined) { 311 | this.props.query.queryUrl = this.props.query.query; 312 | this.props.query.datefield = parseInt(this.props.query.datefield.number, 10); 313 | this.props.query.dynamicsplit = parseInt(this.props.query.dynamicsplit.number, 10); 314 | if (this.props.query.nocounterval !== undefined && this.props.query.nocounterval.number !== undefined) { 315 | this.props.query.nocounterval = parseInt(this.props.query.nocounterval.number, 10); 316 | } 317 | delete this.props.query.query; 318 | this.props.query.columns = []; 319 | 320 | // No loop because error on access property 321 | // col_0 322 | if ( 323 | this.props.query.col_0.number !== undefined && 324 | this.props.query.col_0.number !== undefined && 325 | parseInt(this.props.query.col_0.number, 10) !== 0 326 | ) { 327 | let alias = ''; 328 | if (!this.props.query.col_0_alias !== undefined) { 329 | alias = this.props.query.col_0_alias; 330 | } 331 | this.props.query.columns.push({ 332 | field: parseInt(this.props.query.col_0.number, 10), 333 | alias, 334 | }); 335 | } 336 | delete this.props.query.col_0; 337 | delete this.props.query.col_0_alias; 338 | 339 | // col_1 340 | if ( 341 | this.props.query.col_1.number !== undefined && 342 | this.props.query.col_1.number !== undefined && 343 | parseInt(this.props.query.col_1.number, 10) !== 0 344 | ) { 345 | let alias = ''; 346 | if (!this.props.query.col_1_alias !== undefined) { 347 | alias = this.props.query.col_1_alias; 348 | } 349 | this.props.query.columns.push({ 350 | field: parseInt(this.props.query.col_1.number, 10), 351 | alias, 352 | }); 353 | } 354 | delete this.props.query.col_1; 355 | delete this.props.query.col_1_alias; 356 | 357 | // col_2 358 | if ( 359 | this.props.query.col_2.number !== undefined && 360 | this.props.query.col_2.number !== undefined && 361 | parseInt(this.props.query.col_2.number, 10) !== 0 362 | ) { 363 | let alias = ''; 364 | if (!this.props.query.col_2_alias !== undefined) { 365 | alias = this.props.query.col_2_alias; 366 | } 367 | this.props.query.columns.push({ 368 | field: parseInt(this.props.query.col_2.number, 10), 369 | alias, 370 | }); 371 | } 372 | delete this.props.query.col_2; 373 | delete this.props.query.col_2_alias; 374 | 375 | // col_3 376 | if ( 377 | this.props.query.col_3.number !== undefined && 378 | this.props.query.col_3.number !== undefined && 379 | parseInt(this.props.query.col_3.number, 10) !== 0 380 | ) { 381 | let alias = ''; 382 | if (!this.props.query.col_3_alias !== undefined) { 383 | alias = this.props.query.col_3_alias; 384 | } 385 | this.props.query.columns.push({ 386 | field: parseInt(this.props.query.col_3.number, 10), 387 | alias, 388 | }); 389 | } 390 | delete this.props.query.col_3; 391 | delete this.props.query.col_3_alias; 392 | 393 | // col_4 394 | if ( 395 | this.props.query.col_4.number !== undefined && 396 | this.props.query.col_4.number !== undefined && 397 | parseInt(this.props.query.col_4.number, 10) !== 0 398 | ) { 399 | let alias = ''; 400 | if (!this.props.query.col_4_alias !== undefined) { 401 | alias = this.props.query.col_4_alias; 402 | } 403 | this.props.query.columns.push({ 404 | field: parseInt(this.props.query.col_4.number, 10), 405 | alias, 406 | }); 407 | } 408 | delete this.props.query.col_4; 409 | delete this.props.query.col_4_alias; 410 | 411 | // col_5 412 | if ( 413 | this.props.query.col_5.number !== undefined && 414 | this.props.query.col_5.number !== undefined && 415 | parseInt(this.props.query.col_5.number, 10) !== 0 416 | ) { 417 | let alias = ''; 418 | if (!this.props.query.col_5_alias !== undefined) { 419 | alias = this.props.query.col_5_alias; 420 | } 421 | this.props.query.columns.push({ 422 | field: parseInt(this.props.query.col_5.number, 10), 423 | alias, 424 | }); 425 | } 426 | delete this.props.query.col_5; 427 | delete this.props.query.col_5_alias; 428 | 429 | // col_6 430 | if ( 431 | this.props.query.col_6.number !== undefined && 432 | this.props.query.col_6.number !== undefined && 433 | parseInt(this.props.query.col_6.number, 10) !== 0 434 | ) { 435 | let alias = ''; 436 | if (!this.props.query.col_6_alias !== undefined) { 437 | alias = this.props.query.col_6_alias; 438 | } 439 | this.props.query.columns.push({ 440 | field: parseInt(this.props.query.col_6.number, 10), 441 | alias, 442 | }); 443 | } 444 | delete this.props.query.col_6; 445 | delete this.props.query.col_6_alias; 446 | 447 | // col_7 448 | if ( 449 | this.props.query.col_7.number !== undefined && 450 | this.props.query.col_7.number !== undefined && 451 | parseInt(this.props.query.col_7.number, 10) !== 0 452 | ) { 453 | let alias = ''; 454 | if (!this.props.query.col_7_alias !== undefined) { 455 | alias = this.props.query.col_7_alias; 456 | } 457 | this.props.query.columns.push({ 458 | field: parseInt(this.props.query.col_7.number, 10), 459 | alias, 460 | }); 461 | } 462 | delete this.props.query.col_7; 463 | delete this.props.query.col_7_alias; 464 | 465 | // col_8 466 | if ( 467 | this.props.query.col_8.number !== undefined && 468 | this.props.query.col_8.number !== undefined && 469 | parseInt(this.props.query.col_8.number, 10) !== 0 470 | ) { 471 | let alias = ''; 472 | if (!this.props.query.col_8_alias !== undefined) { 473 | alias = this.props.query.col_8_alias; 474 | } 475 | this.props.query.columns.push({ 476 | field: parseInt(this.props.query.col_8.number, 10), 477 | alias, 478 | }); 479 | } 480 | delete this.props.query.col_8; 481 | delete this.props.query.col_8_alias; 482 | 483 | // col_9 484 | if ( 485 | this.props.query.col_9.number !== undefined && 486 | this.props.query.col_9.number !== undefined && 487 | parseInt(this.props.query.col_9.number, 10) !== 0 488 | ) { 489 | let alias = ''; 490 | if (!this.props.query.col_9_alias !== undefined) { 491 | alias = this.props.query.col_9_alias; 492 | } 493 | this.props.query.columns.push({ 494 | field: parseInt(this.props.query.col_9.number, 10), 495 | alias, 496 | }); 497 | } 498 | delete this.props.query.col_9; 499 | delete this.props.query.col_9_alias; 500 | 501 | // col_10 502 | if ( 503 | this.props.query.col_10.number !== undefined && 504 | this.props.query.col_10.number !== undefined && 505 | parseInt(this.props.query.col_10.number, 10) !== 0 506 | ) { 507 | let alias = ''; 508 | if (!this.props.query.col_10_alias !== undefined) { 509 | alias = this.props.query.col_10_alias; 510 | } 511 | this.props.query.columns.push({ 512 | field: parseInt(this.props.query.col_10.number, 10), 513 | alias, 514 | }); 515 | } 516 | delete this.props.query.col_10; 517 | delete this.props.query.col_10_alias; 518 | 519 | // col_11 520 | if ( 521 | this.props.query.col_11.number !== undefined && 522 | this.props.query.col_11.number !== undefined && 523 | parseInt(this.props.query.col_11.number, 10) !== 0 524 | ) { 525 | let alias = ''; 526 | if (!this.props.query.col_11_alias !== undefined) { 527 | alias = this.props.query.col_11_alias; 528 | } 529 | this.props.query.columns.push({ 530 | field: parseInt(this.props.query.col_11.number, 10), 531 | alias, 532 | }); 533 | } 534 | delete this.props.query.col_11; 535 | delete this.props.query.col_11_alias; 536 | } 537 | } 538 | } 539 | -------------------------------------------------------------------------------- /src/datasource/img/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/datasource/img/small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ddurieux/glpi_app_grafana/fa55689222a68db43aa0f390ae5c72b7060e7eff/src/datasource/img/small.png -------------------------------------------------------------------------------- /src/datasource/module.ts: -------------------------------------------------------------------------------- 1 | import { DataSourcePlugin } from '@grafana/data'; 2 | import { DataSource } from './DataSource'; 3 | import { ConfigEditor } from './ConfigEditor'; 4 | import { QueryEditor } from './QueryEditor'; 5 | import { MyQuery, MyDataSourceOptions } from './types'; 6 | 7 | export const plugin = new DataSourcePlugin(DataSource) 8 | .setConfigEditor(ConfigEditor) 9 | .setQueryEditor(QueryEditor); 10 | -------------------------------------------------------------------------------- /src/datasource/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "datasource", 3 | "name": "GLPI API", 4 | "id": "ddurieux-glpi-datasource", 5 | "metrics": true, 6 | "info": { 7 | "description": "GLPI app for Grafana", 8 | "author": { 9 | "name": "David Durieux && DCS", 10 | "url": "https://github.com/ddurieux/glpi_app_grafana" 11 | }, 12 | "keywords": [ 13 | "glpi app" 14 | ], 15 | "logos": { 16 | "small": "img/small.png", 17 | "large": "img/small.png" 18 | }, 19 | "links": [ 20 | { 21 | "name": "Project site (github)", 22 | "url": "https://github.com/ddurieux/glpi_app_grafana" 23 | }, 24 | { 25 | "name": "License & Terms", 26 | "url": "https://raw.githubusercontent.com/ddurieux/glpi_app_grafana/master/LICENSE" 27 | }, 28 | { 29 | "name": "GLPI Project", 30 | "url": "http://glpi-project.org/" 31 | }, 32 | { 33 | "name": "DCS", 34 | "url": "https://www.dcsit-group.com/" 35 | } 36 | ], 37 | "screenshots": [], 38 | "version": "%VERSION%", 39 | "updated": "%TODAY%" 40 | }, 41 | "dependencies": { 42 | "grafanaVersion": "9.x.x", 43 | "grafanaDependency": ">=9.0.0", 44 | "plugins": [] 45 | }, 46 | "routes": [ 47 | { 48 | "path": "initSession", 49 | "url": "{{ .JsonData.url }}/initSession", 50 | "headers": [ 51 | { 52 | "name": "App-Token", 53 | "content": "{{ .SecureJsonData.appToken }}" 54 | }, 55 | { 56 | "name": "Authorization", 57 | "content": "user_token {{ .SecureJsonData.userToken }}" 58 | } 59 | ] 60 | }, 61 | { 62 | "path": "query", 63 | "url": "{{ .JsonData.url }}", 64 | "headers": [ 65 | { 66 | "name": "App-Token", 67 | "content": "{{ .SecureJsonData.appToken }}" 68 | } 69 | ] 70 | } 71 | ], 72 | "autoEnabled": true 73 | } 74 | -------------------------------------------------------------------------------- /src/datasource/types.ts: -------------------------------------------------------------------------------- 1 | import { DataQuery, DataSourceJsonData } from '@grafana/data'; 2 | 3 | export interface MyQuery extends DataQuery { 4 | queryUrl: string; 5 | alias: string; 6 | datefield: any; // must be number but old version of plugin has bee an object 7 | dynamicsplit: any; // must be number but old version of plugin has bee an object 8 | counter: boolean; 9 | nocounterval: any; // must be number but old version of plugin has bee an object 10 | table: boolean; 11 | columns: any[]; 12 | 13 | // Old values 14 | query?: string; 15 | col_0?: any; 16 | col_1?: any; 17 | col_2?: any; 18 | col_3?: any; 19 | col_4?: any; 20 | col_5?: any; 21 | col_6?: any; 22 | col_7?: any; 23 | col_8?: any; 24 | col_9?: any; 25 | col_10?: any; 26 | col_11?: any; 27 | col_0_alias?: any; 28 | col_1_alias?: any; 29 | col_2_alias?: any; 30 | col_3_alias?: any; 31 | col_4_alias?: any; 32 | col_5_alias?: any; 33 | col_6_alias?: any; 34 | col_7_alias?: any; 35 | col_8_alias?: any; 36 | col_9_alias?: any; 37 | col_10_alias?: any; 38 | col_11_alias?: any; 39 | 40 | // histogram 41 | // nocounterval 42 | // table 43 | // metrics 44 | } 45 | 46 | export const defaultQuery: Partial = { 47 | queryUrl: '', 48 | alias: '', 49 | datefield: -1, 50 | dynamicsplit: -1, 51 | counter: true, 52 | nocounterval: 0, 53 | table: false, 54 | columns: [ 55 | { 56 | field: 0, 57 | alias: '', 58 | }, 59 | ], 60 | }; 61 | 62 | /** 63 | * These are options configured for each DataSource instance 64 | */ 65 | export interface MyDataSourceOptions extends DataSourceJsonData { 66 | url?: string; 67 | timeZone?: string; 68 | 69 | // Old values 70 | timezone?: string; 71 | apptoken?: string; 72 | token?: string; 73 | } 74 | 75 | /** 76 | * Value that is used in the backend, but never sent over HTTP to the frontend 77 | */ 78 | export interface MySecureJsonData { 79 | appToken?: string; 80 | userToken?: string; 81 | } 82 | -------------------------------------------------------------------------------- /src/img/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/img/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ddurieux/glpi_app_grafana/fa55689222a68db43aa0f390ae5c72b7060e7eff/src/img/screenshot1.png -------------------------------------------------------------------------------- /src/img/small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ddurieux/glpi_app_grafana/fa55689222a68db43aa0f390ae5c72b7060e7eff/src/img/small.png -------------------------------------------------------------------------------- /src/module.ts: -------------------------------------------------------------------------------- 1 | export class GlpiAppConfigCtrl {} 2 | export { GlpiAppConfigCtrl as ConfigCtrl }; 3 | -------------------------------------------------------------------------------- /src/plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "app", 3 | "name": "glpi", 4 | "id": "ddurieux-glpi-app", 5 | 6 | "info": { 7 | "description": "GLPI app for Grafana", 8 | "author": { 9 | "name": "David Durieux && DCS Easyware", 10 | "url": "https://github.com/ddurieux/glpi_app_grafana" 11 | }, 12 | "keywords": ["glpi app","glpi","David Durieux"], 13 | "logos": { 14 | "small": "img/small.png", 15 | "large": "img/small.png" 16 | }, 17 | "links": [ 18 | {"name": "Project site (github)", "url": "https://github.com/ddurieux/glpi_app_grafana"}, 19 | {"name": "License & Terms", "url": "https://raw.githubusercontent.com/ddurieux/glpi_app_grafana/master/LICENSE"}, 20 | {"name": "Blog of David Durieux", "url": "https://david.durieux.family/"}, 21 | {"name": "GLPI Project", "url": "http://glpi-project.org/"}, 22 | {"name": "DCS Easyware", "url": "https://www.dcsit-group.com/"} 23 | ], 24 | "version": "2.1.0", 25 | "updated": "2022-10-18", 26 | "screenshots": [ 27 | {"name": "dashboard", "path": "img/screenshot1.png"} 28 | ] 29 | }, 30 | 31 | "includes": [ 32 | {"type": "dashboard", "name": "GLPI App Dashboard", "path": "dashboards/glpi_app_dashboard.json"}, 33 | {"type": "datasource", "name": "GLPI API"} 34 | ], 35 | 36 | "dependencies": { 37 | "grafanaVersion": "9.x.x", 38 | "grafanaDependency": ">=9.0.0", 39 | "plugins": [] 40 | }, 41 | "autoEnabled": true 42 | } 43 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/@grafana/toolkit/src/config/tsconfig.plugin.json", 3 | "include": ["src", "types"], 4 | "compilerOptions": { 5 | "rootDir": "./src", 6 | "baseUrl": "./src", 7 | "typeRoots": ["./node_modules/@types"] 8 | } 9 | } 10 | --------------------------------------------------------------------------------