2020-11-30 16:52:13 +00:00
|
|
|
import Component from '@glimmer/component';
|
2019-06-21 10:42:40 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-11-30 16:52:13 +00:00
|
|
|
import { action } from '@ember/object';
|
2020-06-17 09:25:54 +00:00
|
|
|
import chart from './chart.xstate';
|
2019-06-21 10:42:40 +00:00
|
|
|
|
2020-11-30 16:52:13 +00:00
|
|
|
export default class CopyButton extends Component {
|
|
|
|
@service('clipboard/os') clipboard;
|
|
|
|
@service('dom') dom;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
2020-06-17 09:25:54 +00:00
|
|
|
this.chart = chart;
|
2020-05-12 12:36:03 +00:00
|
|
|
this.guid = this.dom.guid(this);
|
|
|
|
this._listeners = this.dom.listeners();
|
2020-11-30 16:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
connect() {
|
2020-06-17 09:25:54 +00:00
|
|
|
this._listeners.add(this.clipboard.execute(`#${this.guid} button`), {
|
|
|
|
success: () => this.dispatch('SUCCESS'),
|
|
|
|
error: () => this.dispatch('ERROR'),
|
2019-06-21 10:42:40 +00:00
|
|
|
});
|
2020-11-30 16:52:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
disconnect() {
|
|
|
|
this._listeners.remove();
|
|
|
|
}
|
|
|
|
}
|