add workspace option to profile export
This commit is contained in:
parent
f2672adcb7
commit
457567b1c9
5 changed files with 88 additions and 14 deletions
1
notes.md
1
notes.md
|
|
@ -5,7 +5,6 @@
|
||||||
* cap path ends
|
* cap path ends
|
||||||
* help dialog
|
* help dialog
|
||||||
* full bug reports
|
* full bug reports
|
||||||
* .b64 export may not capture or restore tools properly
|
|
||||||
* onshape mouse mapping option
|
* onshape mouse mapping option
|
||||||
|
|
||||||
## 2.4
|
## 2.4
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,38 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ******************************************************************
|
/** ******************************************************************
|
||||||
* Object CODEC Functions
|
* Object Class CODEC Functions
|
||||||
******************************************************************* */
|
******************************************************************* */
|
||||||
|
|
||||||
|
KIRI.Widget.prototype.encode = function(state) {
|
||||||
|
const json = state._json_;
|
||||||
|
const geo = this.getGeoVertices();
|
||||||
|
const coded = {
|
||||||
|
type: 'widget',
|
||||||
|
id: this.id,
|
||||||
|
ver: 1, // for better future encodings
|
||||||
|
json: json, // safe for JSON (float32array mess)
|
||||||
|
group: this.group.id,
|
||||||
|
track: this.track,
|
||||||
|
geo: json ? Array.from(geo) : geo
|
||||||
|
};
|
||||||
|
return coded;
|
||||||
|
};
|
||||||
|
|
||||||
|
registerDecoder('widget', function(v, state) {
|
||||||
|
const id = v.id,
|
||||||
|
group = v.group || id,
|
||||||
|
track = v.track || undefined,
|
||||||
|
widget = KIRI.newWidget(id, KIRI.Widget.Groups.forid(group));
|
||||||
|
widget.loadVertices(v.json ? v.geo.toFloat32() : v.geo);
|
||||||
|
widget.saved = time();
|
||||||
|
if (track && track.pos) {
|
||||||
|
widget.track = track;
|
||||||
|
widget.move(track.pos.x, track.pos.y, track.pos.z, true);
|
||||||
|
}
|
||||||
|
return widget;
|
||||||
|
});
|
||||||
|
|
||||||
KIRI.Slice.prototype.encode = function(state) {
|
KIRI.Slice.prototype.encode = function(state) {
|
||||||
return {
|
return {
|
||||||
type: 'slice',
|
type: 'slice',
|
||||||
|
|
|
||||||
|
|
@ -539,12 +539,26 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function profileExport() {
|
function profileExport() {
|
||||||
UC.prompt("Export Profile Filename", "kiriconf").then(name => {
|
const opt = {pre: [
|
||||||
|
"<div class='f-col a-center'>",
|
||||||
|
" <h3>Profile Export</h3>",
|
||||||
|
" <label>This will create a backup of</label>",
|
||||||
|
" <label>your device profiles and settings</label>",
|
||||||
|
" <br>",
|
||||||
|
" <div class='f-row'>",
|
||||||
|
" <input id='incwork' type='checkbox'> include workspace",
|
||||||
|
" </div>",
|
||||||
|
"</div>"
|
||||||
|
]};
|
||||||
|
UC.confirm("Export Filename", {ok:true, cancel: false}, "km_conf", opt).then(name => {
|
||||||
if (name) {
|
if (name) {
|
||||||
let json = API.conf.export(),
|
let work = $('incwork').checked,
|
||||||
|
json = API.conf.export({work}),
|
||||||
blob = new Blob([json], {type: "octet/stream"}),
|
blob = new Blob([json], {type: "octet/stream"}),
|
||||||
url = WIN.URL.createObjectURL(blob);
|
url = WIN.URL.createObjectURL(blob);
|
||||||
$('mod-any').innerHTML = `<a id="sexport" href="${url}" download="${name}.b64">x</a>`;
|
$('mod-any').innerHTML = [
|
||||||
|
`<a id="sexport" href="${url}" download="${name}.b64">x</a>`
|
||||||
|
].join('');
|
||||||
$('sexport').click();
|
$('sexport').click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -2091,7 +2105,7 @@
|
||||||
$('view-arrange').onclick = API.platform.layout;
|
$('view-arrange').onclick = API.platform.layout;
|
||||||
$('view-top').onclick = SPACE.view.top;
|
$('view-top').onclick = SPACE.view.top;
|
||||||
$('view-home').onclick = SPACE.view.home;
|
$('view-home').onclick = SPACE.view.home;
|
||||||
$('view-clear').onclick = () => { API.platform.delete(API.widgets.all()) };
|
$('view-clear').onclick = API.platform.clear;
|
||||||
$('mode-fdm').onclick = () => { API.mode.set('FDM') };
|
$('mode-fdm').onclick = () => { API.mode.set('FDM') };
|
||||||
$('mode-sla').onclick = () => { API.mode.set('SLA') };
|
$('mode-sla').onclick = () => { API.mode.set('SLA') };
|
||||||
$('mode-cam').onclick = () => { API.mode.set('CAM') };
|
$('mode-cam').onclick = () => { API.mode.set('CAM') };
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,8 @@
|
||||||
set_font: SPACE.platform.setFont,
|
set_font: SPACE.platform.setFont,
|
||||||
set_axes: SPACE.platform.setAxes,
|
set_axes: SPACE.platform.setAxes,
|
||||||
set_volume: SPACE.platform.setVolume,
|
set_volume: SPACE.platform.setVolume,
|
||||||
top_z: () => { return topZ }
|
top_z: () => { return topZ },
|
||||||
|
clear: () => { platform.delete(WIDGETS.slice()) }
|
||||||
};
|
};
|
||||||
|
|
||||||
const color = {
|
const color = {
|
||||||
|
|
@ -1494,6 +1495,7 @@
|
||||||
if (LOCAL) console.log('import',data);
|
if (LOCAL) console.log('import',data);
|
||||||
let isSettings = (data.settings && data.version && data.time);
|
let isSettings = (data.settings && data.version && data.time);
|
||||||
let isDevice = (data.device && data.version && data.time);
|
let isDevice = (data.device && data.version && data.time);
|
||||||
|
let isWork = (data.work);
|
||||||
if (!isSettings && !isDevice) {
|
if (!isSettings && !isDevice) {
|
||||||
UC.alert('invalid settings or device format');
|
UC.alert('invalid settings or device format');
|
||||||
console.log('data',data);
|
console.log('data',data);
|
||||||
|
|
@ -1522,13 +1524,29 @@
|
||||||
API.show.devices();
|
API.show.devices();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isWork) {
|
||||||
|
API.platform.clear();
|
||||||
|
KIRI.codec.decode(data.work).forEach(widget => {
|
||||||
|
platform.add(widget, 0, true);
|
||||||
|
});
|
||||||
|
if (data.view) {
|
||||||
|
SPACE.view.load(data.view);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ask) {
|
if (ask) {
|
||||||
let prompt = `Import settings made in Kiri:Moto version ${data.version} on<br>${new Date(data.time)}?`;
|
let opt = {};
|
||||||
if (isDevice) {
|
let prompt = isDevice ?
|
||||||
prompt = `Import device "${data.device}"?`;
|
`Import device "${data.device}"?` :
|
||||||
|
`Import settings made in Kiri:Moto version ${data.version} on<br>${new Date(data.time)}?`;
|
||||||
|
if (data.screen) {
|
||||||
|
opt.pre = [
|
||||||
|
'<div class="f-col a-center">',
|
||||||
|
`<img src="${data.screen}" style="width:300px"/>`,
|
||||||
|
'</div>'
|
||||||
|
];
|
||||||
}
|
}
|
||||||
UC.confirm(prompt).then((yes) => {
|
UC.confirm(prompt,undefined,undefined,opt).then((yes) => {
|
||||||
if (yes) doit();
|
if (yes) doit();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1538,12 +1556,18 @@
|
||||||
|
|
||||||
function settingsExport(options) {
|
function settingsExport(options) {
|
||||||
const opts = options || {};
|
const opts = options || {};
|
||||||
const shot = opts.screen ? SPACE.screenshot() : undefined;
|
const note = opts.node || undefined;
|
||||||
|
const shot = opts.work || opts.screen ? SPACE.screenshot() : undefined;
|
||||||
|
const work = opts.work ? KIRI.codec.encode(WIDGETS,{_json_:true}) : undefined;
|
||||||
|
const view = opts.work ? SPACE.view.save() : undefined;
|
||||||
return btoa(JSON.stringify({
|
return btoa(JSON.stringify({
|
||||||
settings: settings,
|
settings: settings,
|
||||||
version: KIRI.version,
|
version: KIRI.version,
|
||||||
screen: shot,
|
screen: shot,
|
||||||
space: SPACE.info,
|
space: SPACE.info,
|
||||||
|
note: note,
|
||||||
|
work: work,
|
||||||
|
view: view,
|
||||||
moto: MOTO.id,
|
moto: MOTO.id,
|
||||||
init: SDB.getItem('kiri-init'),
|
init: SDB.getItem('kiri-init'),
|
||||||
time: Date.now()
|
time: Date.now()
|
||||||
|
|
@ -1934,6 +1958,7 @@
|
||||||
// updateStockVisibility();
|
// updateStockVisibility();
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case VIEWS.ARRANGE:
|
case VIEWS.ARRANGE:
|
||||||
|
complete = {};
|
||||||
UI.back.style.display = '';
|
UI.back.style.display = '';
|
||||||
UI.render.style.display = '';
|
UI.render.style.display = '';
|
||||||
UI.render.classList.add('lt-enabled');
|
UI.render.classList.add('lt-enabled');
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@
|
||||||
return confirm(message, {ok:true, cancel:false}, value);
|
return confirm(message, {ok:true, cancel:false}, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirm(message, buttons, input) {
|
function confirm(message, buttons, input, opt = {}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let btns = buttons || {
|
let btns = buttons || {
|
||||||
"yes": true,
|
"yes": true,
|
||||||
|
|
@ -90,6 +90,9 @@
|
||||||
`<div class="confirm f-col a-stretch">`,
|
`<div class="confirm f-col a-stretch">`,
|
||||||
`<label style="user-select:text">${message}</label>`,
|
`<label style="user-select:text">${message}</label>`,
|
||||||
];
|
];
|
||||||
|
if (opt.pre) {
|
||||||
|
html = opt.pre.appendAll(html);
|
||||||
|
}
|
||||||
let iid;
|
let iid;
|
||||||
if (input !== undefined) {
|
if (input !== undefined) {
|
||||||
iid = `confirm-input-${rnd}`;
|
iid = `confirm-input-${rnd}`;
|
||||||
|
|
@ -99,7 +102,11 @@
|
||||||
Object.entries(btns).forEach((row,i) => {
|
Object.entries(btns).forEach((row,i) => {
|
||||||
html.append(`<button id="confirm-${i}-${rnd}">${row[0]}</button>`);
|
html.append(`<button id="confirm-${i}-${rnd}">${row[0]}</button>`);
|
||||||
});
|
});
|
||||||
$('mod-any').innerHTML = html.append(`</div></div>`).join('');
|
html.append(`</div></div>`);
|
||||||
|
if (opt.post) {
|
||||||
|
html.appendAll(opt.post);
|
||||||
|
}
|
||||||
|
$('mod-any').innerHTML = html.join('');
|
||||||
function done(value) {
|
function done(value) {
|
||||||
KIRI.api.modal.hide();
|
KIRI.api.modal.hide();
|
||||||
setTimeout(() => { resolve(value) }, 150);
|
setTimeout(() => { resolve(value) }, 150);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue