Merge pull request #13289 from grafana/stackdriver-plugin

Stackdriver Datasource - Fixes #6733
This commit is contained in:
Daniel Lee
2018-09-28 19:36:01 +02:00
committed by GitHub
45 changed files with 4189 additions and 164 deletions

View File

@@ -1,10 +1,12 @@
import coreModule from 'app/core/core_module';
import appEvents from 'app/core/app_events';
import angular from 'angular';
const template = `
<input type="file" id="dashupload" name="dashupload" class="hide"/>
<input type="file" id="dashupload" name="dashupload" class="hide" onchange="angular.element(this).scope().file_selected"/>
<label class="btn btn-success" for="dashupload">
<i class="fa fa-upload"></i>
Upload .json File
{{btnText}}
</label>
`;
@@ -15,8 +17,11 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
template: template,
scope: {
onUpload: '&',
btnText: '@?',
},
link: scope => {
link: (scope, elem) => {
scope.btnText = angular.isDefined(scope.btnText) ? scope.btnText : 'Upload .json File';
function file_selected(evt) {
const files = evt.target.files; // FileList object
const readerOnload = () => {
@@ -26,7 +31,7 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
dash = JSON.parse(e.target.result);
} catch (err) {
console.log(err);
scope.appEvent('alert-error', ['Import failed', 'JSON -> JS Serialization failed: ' + err.message]);
appEvents.emit('alert-error', ['Import failed', 'JSON -> JS Serialization failed: ' + err.message]);
return;
}
@@ -52,7 +57,7 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
// Check for the various File API support.
if (wnd.File && wnd.FileReader && wnd.FileList && wnd.Blob) {
// Something
document.getElementById('dashupload').addEventListener('change', file_selected, false);
elem[0].addEventListener('change', file_selected, false);
} else {
alertSrv.set('Oops', 'Sorry, the HTML5 File APIs are not fully supported in this browser.', 'error');
}

View File

@@ -11,6 +11,7 @@ import * as postgresPlugin from 'app/plugins/datasource/postgres/module';
import * as prometheusPlugin from 'app/plugins/datasource/prometheus/module';
import * as mssqlPlugin from 'app/plugins/datasource/mssql/module';
import * as testDataDSPlugin from 'app/plugins/datasource/testdata/module';
import * as stackdriverPlugin from 'app/plugins/datasource/stackdriver/module';
import * as textPanel from 'app/plugins/panel/text/module';
import * as graphPanel from 'app/plugins/panel/graph/module';
@@ -36,6 +37,7 @@ const builtInPlugins = {
'app/plugins/datasource/mssql/module': mssqlPlugin,
'app/plugins/datasource/prometheus/module': prometheusPlugin,
'app/plugins/datasource/testdata/module': testDataDSPlugin,
'app/plugins/datasource/stackdriver/module': stackdriverPlugin,
'app/plugins/panel/text/module': textPanel,
'app/plugins/panel/graph/module': graphPanel,

View File

@@ -31,11 +31,16 @@
</div>
</div>
<div class="alert alert-info gf-form-group" ng-if="ctrl.datasourceMeta.state === 'alpha'">
<div class="grafana-info-box" ng-if="ctrl.datasourceMeta.state === 'alpha'">
This plugin is marked as being in alpha state, which means it is in early development phase and
updates will include breaking changes.
</div>
<div class="grafana-info-box" ng-if="ctrl.datasourceMeta.state === 'beta'">
This plugin is marked as being in a beta development state. This means it is in currently in active development and could be
missing important features.
</div>
<rebuild-on-change property="ctrl.datasourceMeta.id">
<plugin-component type="datasource-config-ctrl">
</plugin-component>