upload: make the button text configurable
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
import coreModule from 'app/core/core_module';
|
import coreModule from 'app/core/core_module';
|
||||||
import appEvents from 'app/core/app_events';
|
import appEvents from 'app/core/app_events';
|
||||||
|
import angular from 'angular';
|
||||||
|
|
||||||
const template = `
|
const template = `
|
||||||
<input type="file" id="dashupload" name="dashupload" class="hide" onchange="angular.element(this).scope().file_selected"/>
|
<input type="file" id="dashupload" name="dashupload" class="hide" onchange="angular.element(this).scope().file_selected"/>
|
||||||
<label class="btn btn-success" for="dashupload">
|
<label class="btn btn-success" for="dashupload">
|
||||||
<i class="fa fa-upload"></i>
|
<i class="fa fa-upload"></i>
|
||||||
Upload .json File
|
{{btnText}}
|
||||||
</label>
|
</label>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -16,8 +17,11 @@ function uploadDashboardDirective(timer, alertSrv, $location) {
|
|||||||
template: template,
|
template: template,
|
||||||
scope: {
|
scope: {
|
||||||
onUpload: '&',
|
onUpload: '&',
|
||||||
|
btnText: '@?',
|
||||||
},
|
},
|
||||||
link: (scope, elem) => {
|
link: (scope, elem) => {
|
||||||
|
scope.btnText = angular.isDefined(scope.btnText) ? scope.btnText : 'Upload .json File';
|
||||||
|
|
||||||
function file_selected(evt) {
|
function file_selected(evt) {
|
||||||
const files = evt.target.files; // FileList object
|
const files = evt.target.files; // FileList object
|
||||||
const readerOnload = () => {
|
const readerOnload = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user