smartlog-destination-local/ts/sl.destlocal.classes.ora.ts

62 lines
1.2 KiB
TypeScript
Raw Normal View History

import * as plugins from './sl.destlocal.plugins';
import { DestinationLocal } from './sl.destlocal.classes.destinationlocal';
2016-05-13 23:18:44 +00:00
export class Ora {
/**
* the destinationLocalInstance that ora talks to
*/
destinationLocalInstance: DestinationLocal;
/**
* the state of the current ora
*/
state: 'running' | 'stopped' | 'paused' = 'stopped';
/**
* the actual ora object
*/
2018-03-01 00:06:12 +00:00
private _oraObject;
constructor(destinationLocalInstanceArg: DestinationLocal = new DestinationLocal()) {
this.destinationLocalInstance = destinationLocalInstanceArg;
2017-03-11 11:30:18 +00:00
this._oraObject = plugins.ora({
spinner: 'dots',
2018-03-03 12:57:55 +00:00
text: '',
color: 'blue'
2018-03-01 00:06:12 +00:00
});
2017-03-11 11:30:18 +00:00
}
2017-03-11 11:30:18 +00:00
text(textArg) {
2018-03-01 00:06:12 +00:00
this._oraObject.text = textArg;
2017-03-11 11:30:18 +00:00
}
2016-10-16 00:26:43 +00:00
2017-03-11 11:30:18 +00:00
start(textArg?: string, colorArg?: string) {
2018-03-01 00:06:12 +00:00
if (textArg) {
this.text(textArg);
}
if (colorArg) {
this._oraObject.color = colorArg;
}
this.state = 'running';
2018-03-01 00:06:12 +00:00
this._oraObject.start();
2017-03-11 11:30:18 +00:00
}
2017-03-11 11:30:18 +00:00
end() {
2018-03-01 00:06:12 +00:00
this._oraObject.stop();
this._oraObject.clear();
this.state = 'stopped';
2017-03-11 11:30:18 +00:00
}
2018-11-04 12:22:45 +00:00
2017-03-11 11:30:18 +00:00
pause() {
2018-03-01 00:06:12 +00:00
this._oraObject.stop();
this.state = 'paused';
2017-03-11 11:30:18 +00:00
}
/**
* stop is an alias for end
*/
2018-03-01 00:06:12 +00:00
stop() {
this.end();
2017-03-11 11:30:18 +00:00
}
2016-10-16 00:26:43 +00:00
}