grafana/public/app/directives/grafanaVersionCheck.js

34 lines
967 B
JavaScript
Raw Normal View History

define([
'angular'
],
function (angular) {
'use strict';
angular
2014-07-28 11:11:52 -05:00
.module('grafana.directives')
.directive('grafanaVersionCheck', function($http, contextSrv) {
return {
restrict: 'A',
link: function(scope, elem) {
if (contextSrv.version === 'master') {
2014-08-27 03:41:27 -05:00
return;
}
2014-08-14 05:13:03 -05:00
$http({ method: 'GET', url: 'https://grafanarel.s3.amazonaws.com/latest.json' })
.then(function(response) {
if (!response.data || !response.data.version) {
return;
}
if (contextSrv.version !== response.data.version) {
elem.append('<i class="icon-info-sign"></i> ' +
'<a href="http://grafana.org/download" target="_blank"> ' +
'New version available: ' + response.data.version +
'</a>');
}
});
}
};
});
});