add workspace option to profile export
This commit is contained in:
parent
f2672adcb7
commit
457567b1c9
5 changed files with 88 additions and 14 deletions
|
|
@ -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) {
|
||||
return {
|
||||
type: 'slice',
|
||||
|
|
|
|||
|
|
@ -539,12 +539,26 @@
|
|||
}
|
||||
|
||||
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) {
|
||||
let json = API.conf.export(),
|
||||
let work = $('incwork').checked,
|
||||
json = API.conf.export({work}),
|
||||
blob = new Blob([json], {type: "octet/stream"}),
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
|
@ -2091,7 +2105,7 @@
|
|||
$('view-arrange').onclick = API.platform.layout;
|
||||
$('view-top').onclick = SPACE.view.top;
|
||||
$('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-sla').onclick = () => { API.mode.set('SLA') };
|
||||
$('mode-cam').onclick = () => { API.mode.set('CAM') };
|
||||
|
|
|
|||
|
|
@ -107,7 +107,8 @@
|
|||
set_font: SPACE.platform.setFont,
|
||||
set_axes: SPACE.platform.setAxes,
|
||||
set_volume: SPACE.platform.setVolume,
|
||||
top_z: () => { return topZ }
|
||||
top_z: () => { return topZ },
|
||||
clear: () => { platform.delete(WIDGETS.slice()) }
|
||||
};
|
||||
|
||||
const color = {
|
||||
|
|
@ -1494,6 +1495,7 @@
|
|||
if (LOCAL) console.log('import',data);
|
||||
let isSettings = (data.settings && data.version && data.time);
|
||||
let isDevice = (data.device && data.version && data.time);
|
||||
let isWork = (data.work);
|
||||
if (!isSettings && !isDevice) {
|
||||
UC.alert('invalid settings or device format');
|
||||
console.log('data',data);
|
||||
|
|
@ -1522,13 +1524,29 @@
|
|||
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) {
|
||||
let prompt = `Import settings made in Kiri:Moto version ${data.version} on<br>${new Date(data.time)}?`;
|
||||
if (isDevice) {
|
||||
prompt = `Import device "${data.device}"?`;
|
||||
let opt = {};
|
||||
let prompt = isDevice ?
|
||||
`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();
|
||||
});
|
||||
} else {
|
||||
|
|
@ -1538,12 +1556,18 @@
|
|||
|
||||
function settingsExport(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({
|
||||
settings: settings,
|
||||
version: KIRI.version,
|
||||
screen: shot,
|
||||
space: SPACE.info,
|
||||
note: note,
|
||||
work: work,
|
||||
view: view,
|
||||
moto: MOTO.id,
|
||||
init: SDB.getItem('kiri-init'),
|
||||
time: Date.now()
|
||||
|
|
@ -1934,6 +1958,7 @@
|
|||
// updateStockVisibility();
|
||||
switch (mode) {
|
||||
case VIEWS.ARRANGE:
|
||||
complete = {};
|
||||
UI.back.style.display = '';
|
||||
UI.render.style.display = '';
|
||||
UI.render.classList.add('lt-enabled');
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@
|
|||
return confirm(message, {ok:true, cancel:false}, value);
|
||||
}
|
||||
|
||||
function confirm(message, buttons, input) {
|
||||
function confirm(message, buttons, input, opt = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let btns = buttons || {
|
||||
"yes": true,
|
||||
|
|
@ -90,6 +90,9 @@
|
|||
`<div class="confirm f-col a-stretch">`,
|
||||
`<label style="user-select:text">${message}</label>`,
|
||||
];
|
||||
if (opt.pre) {
|
||||
html = opt.pre.appendAll(html);
|
||||
}
|
||||
let iid;
|
||||
if (input !== undefined) {
|
||||
iid = `confirm-input-${rnd}`;
|
||||
|
|
@ -99,7 +102,11 @@
|
|||
Object.entries(btns).forEach((row,i) => {
|
||||
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) {
|
||||
KIRI.api.modal.hide();
|
||||
setTimeout(() => { resolve(value) }, 150);
|
||||
|
|
|
|||
Loading…
Reference in a new issue