mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 01:23:32 -06:00
feat: Copy to clipboard now works in query troubleshooter
This commit is contained in:
parent
b8aa6a8e47
commit
5e090b84ec
@ -19,17 +19,26 @@ function (angular, require, coreModule, kbn) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
coreModule.default.directive('clipboardButton',function() {
|
coreModule.default.directive('clipboardButton', function() {
|
||||||
return function(scope, elem) {
|
return {
|
||||||
require(['vendor/clipboard/dist/clipboard'], function(Clipboard) {
|
scope: {
|
||||||
scope.clipboard = new Clipboard(elem[0]);
|
getText: '&clipboardButton'
|
||||||
});
|
},
|
||||||
|
link: function(scope, elem) {
|
||||||
|
require(['vendor/clipboard/dist/clipboard'], function(Clipboard) {
|
||||||
|
scope.clipboard = new Clipboard(elem[0], {
|
||||||
|
text: function() {
|
||||||
|
return scope.getText();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
scope.$on('$destroy', function() {
|
scope.$on('$destroy', function() {
|
||||||
if (scope.clipboard) {
|
if (scope.clipboard) {
|
||||||
scope.clipboard.destroy();
|
scope.clipboard.destroy();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -78,10 +87,10 @@ function (angular, require, coreModule, kbn) {
|
|||||||
text + tip + '</label>';
|
text + tip + '</label>';
|
||||||
|
|
||||||
var template =
|
var template =
|
||||||
'<input class="cr1" id="' + scope.$id + model + '" type="checkbox" ' +
|
'<input class="cr1" id="' + scope.$id + model + '" type="checkbox" ' +
|
||||||
' ng-model="' + model + '"' + ngchange +
|
' ng-model="' + model + '"' + ngchange +
|
||||||
' ng-checked="' + model + '"></input>' +
|
' ng-checked="' + model + '"></input>' +
|
||||||
' <label for="' + scope.$id + model + '" class="cr1"></label>';
|
' <label for="' + scope.$id + model + '" class="cr1"></label>';
|
||||||
|
|
||||||
template = template + label;
|
template = template + label;
|
||||||
elem.addClass('gf-form-checkbox');
|
elem.addClass('gf-form-checkbox');
|
||||||
@ -106,7 +115,7 @@ function (angular, require, coreModule, kbn) {
|
|||||||
var li = '<li' + (item.submenu && item.submenu.length ? ' class="dropdown-submenu"' : '') + '>' +
|
var li = '<li' + (item.submenu && item.submenu.length ? ' class="dropdown-submenu"' : '') + '>' +
|
||||||
'<a tabindex="-1" ng-href="' + (item.href || '') + '"' + (item.click ? ' ng-click="' + item.click + '"' : '') +
|
'<a tabindex="-1" ng-href="' + (item.href || '') + '"' + (item.click ? ' ng-click="' + item.click + '"' : '') +
|
||||||
(item.target ? ' target="' + item.target + '"' : '') + (item.method ? ' data-method="' + item.method + '"' : '') +
|
(item.target ? ' target="' + item.target + '"' : '') + (item.method ? ' data-method="' + item.method + '"' : '') +
|
||||||
'>' + (item.text || '') + '</a>';
|
'>' + (item.text || '') + '</a>';
|
||||||
|
|
||||||
if (item.submenu && item.submenu.length) {
|
if (item.submenu && item.submenu.length) {
|
||||||
li += buildTemplate(item.submenu).join('\n');
|
li += buildTemplate(item.submenu).join('\n');
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
<input type="text" data-share-panel-url class="gf-form-input" ng-model="shareUrl"></input>
|
<input type="text" data-share-panel-url class="gf-form-input" ng-model="shareUrl"></input>
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form">
|
<div class="gf-form">
|
||||||
<button class="btn btn-inverse" data-clipboard-text="{{shareUrl}}" clipboard-button><i class="fa fa-clipboard"></i> Copy</button>
|
<button class="btn btn-inverse" clipboard-button="getShareUrl()"><i class="fa fa-clipboard"></i> Copy</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -143,7 +143,7 @@
|
|||||||
{{snapshotUrl}}
|
{{snapshotUrl}}
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
<button class="btn btn-inverse" data-clipboard-text="{{snapshotUrl}}" clipboard-button><i class="fa fa-clipboard"></i> Copy Link</button>
|
<button class="btn btn-inverse" clipboard-button="getSnapshotUrl()"><i class="fa fa-clipboard"></i> Copy Link</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -88,6 +88,10 @@ function (angular, _, $, moment, config) {
|
|||||||
$scope.imageUrl += '&tz=UTC' + encodeURIComponent(moment().format("Z"));
|
$scope.imageUrl += '&tz=UTC' + encodeURIComponent(moment().format("Z"));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.getShareUrl = function() {
|
||||||
|
return $scope.shareUrl;
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -96,6 +96,10 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.getSnapshotUrl = function() {
|
||||||
|
return $scope.snapshotUrl;
|
||||||
|
};
|
||||||
|
|
||||||
$scope.scrubDashboard = function(dash) {
|
$scope.scrubDashboard = function(dash) {
|
||||||
// change title
|
// change title
|
||||||
dash.title = $scope.snapshot.name;
|
dash.title = $scope.snapshot.name;
|
||||||
|
@ -14,7 +14,7 @@ const template = `
|
|||||||
<a class="pointer" ng-click="ctrl.toggleExpand()" ng-show="ctrl.allNodesExpanded">
|
<a class="pointer" ng-click="ctrl.toggleExpand()" ng-show="ctrl.allNodesExpanded">
|
||||||
<i class="fa fa-expand"></i> Collapse All
|
<i class="fa fa-expand"></i> Collapse All
|
||||||
</a>
|
</a>
|
||||||
<a class="pointer" data-clipboard-text="adasda" clipboard-button><i class="fa fa-clipboard"></i> Copy to Clipboard</a>
|
<a class="pointer" clipboard-button="ctrl.getClipboardText()"><i class="fa fa-clipboard"></i> Copy to Clipboard</a>
|
||||||
</collapse-box-actions>
|
</collapse-box-actions>
|
||||||
<collapse-box-body>
|
<collapse-box-body>
|
||||||
<div class="query-troubleshooter-json"></div>
|
<div class="query-troubleshooter-json"></div>
|
||||||
@ -62,6 +62,12 @@ export class QueryTroubleshooterCtrl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getClipboardText() {
|
||||||
|
if (this.jsonExplorer) {
|
||||||
|
return JSON.stringify(this.jsonExplorer.json, null, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onRequestResponse(data) {
|
onRequestResponse(data) {
|
||||||
data = _.cloneDeep(data);
|
data = _.cloneDeep(data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user