grafana_version_check.js 860 B

12345678910111213141516171819202122232425262728293031
  1. define([
  2. '../core_module',
  3. ],
  4. function (coreModule) {
  5. 'use strict';
  6. coreModule.default.directive('grafanaVersionCheck', function($http, contextSrv) {
  7. return {
  8. restrict: 'A',
  9. link: function(scope, elem) {
  10. if (contextSrv.version === 'master') {
  11. return;
  12. }
  13. $http({ method: 'GET', url: 'https://grafanarel.s3.amazonaws.com/latest.json' })
  14. .then(function(response) {
  15. if (!response.data || !response.data.version) {
  16. return;
  17. }
  18. if (contextSrv.version !== response.data.version) {
  19. elem.append('<i class="icon-info-sign"></i> ' +
  20. '<a href="http://grafana.org/download" target="_blank"> ' +
  21. 'New version available: ' + response.data.version +
  22. '</a>');
  23. }
  24. });
  25. }
  26. };
  27. });
  28. });