move some stats to events

This commit is contained in:
Stewart Allen 2020-04-18 11:34:54 -04:00
commit 194284f16d
3 changed files with 8 additions and 13 deletions

View file

@ -24,7 +24,7 @@ let gs_kiri_export = exports;
function exportPrint() {
let currentPrint = API.print.get();
if (currentPrint) {
STATS.add(`ua_${API.mode.get_lower()}_export`);
API.event.emit('export', API.mode.get());
switch (API.mode.get()) {
case 'LASER': return exportPrintLaser(currentPrint);
case 'FDM': return exportPrintGCODE(currentPrint);

View file

@ -539,10 +539,10 @@ var gs_kiri_init = exports;
function setDeviceCode(code, devicename) {
try {
STATS.set(`ud_${API.mode.get_lower()}`, devicename);
if (typeof(code) === 'string') code = js2o(code) || {};
API.event.emit('device.set', devicename);
let mode = API.mode.get(),
current = settings(),
local = isLocalDevice(devicename),
@ -968,8 +968,6 @@ var gs_kiri_init = exports;
API.dialog.show('tools');
UI.toolSelect.focus();
STATS.add('ua_get_tools');
}
function showDevices() {
@ -978,7 +976,6 @@ var gs_kiri_init = exports;
API.ajax("/api/filters-"+API.mode.get_lower(), function(flvalue) {
if (!flvalue) return;
renderDevices(js2o(flvalue));
STATS.add('ua_get_devs');
});
}
@ -1743,6 +1740,7 @@ var gs_kiri_init = exports;
scr.setAttribute('src','/code/'+lib+'.js');
DOC.body.appendChild(scr);
STATS.add('load_'+lib);
API.event.emit('load.lib', lib);
});
// load CSS extensions

View file

@ -684,8 +684,7 @@ self.kiri.copyright = exports.COPYRIGHT;
currentPrint.render();
// on done
STATS.add(`ua_${getModeLower()}_print`);
API.event.emit('print', getMode());
SPACE.platform.add(currentPrint.group);
SPACE.update();
@ -774,7 +773,7 @@ self.kiri.copyright = exports.COPYRIGHT;
// update segment time
if (lastMsg) segtimes[segNumber+"_"+lastMsg] = mark - startTime;
DBUG.log(segtimes);
STATS.add(`ua_${getModeLower()}_slice`);
API.event.emit('slice', getMode());
updateSliderMax(true);
if (preserveMax != API.var.layer_max) {
preserveLayer = API.var.layer_max;
@ -1757,7 +1756,6 @@ self.kiri.copyright = exports.COPYRIGHT;
hideDialog();
if (!local) {
WIN.open("//wiki.grid.space/wiki/Kiri:Moto", "_help");
STATS.add('ua_help');
return;
}
ajax(local, function(html) {
@ -1765,8 +1763,8 @@ self.kiri.copyright = exports.COPYRIGHT;
$('help-close').onclick = hideModal;
$('kiri-version').innerHTML = `<i>${LANG.version} ${KIRI.version}</i>`;
showModal('help');
STATS.add('ua_help');
});
API.event.emit('help.show', local);
}
function showLocal() {
@ -1883,8 +1881,6 @@ self.kiri.copyright = exports.COPYRIGHT;
if (settings.cdev[mode]) {
settings.device = clone(settings.cdev[mode]);
}
// update device stat for FDM/CAM
STATS.set(`ud_${getModeLower()}`, settings.filter[mode] || 'default');
MODE = MODES[mode];
// updates right-hand menu by enabling/disabling fields
UC.setMode(MODE);
@ -1910,6 +1906,7 @@ self.kiri.copyright = exports.COPYRIGHT;
if (settings.device.new) {
API.show.devices();
}
API.event.emit("mode.set", mode);
}
function updateSkipSliceView() {