snackbar: with progressbar

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I8a3231a0f61eb97c9daeff3e92afb7d3b640a957
This commit is contained in:
Szymon Kłos 2023-10-04 07:41:38 +02:00 committed by pedropintosilva
parent 91d5a23d76
commit d0c3d09fb2
2 changed files with 33 additions and 5 deletions

View file

@ -76,7 +76,7 @@ L.Control.JSDialogBuilder = L.Control.extend({
this._controlHandlers = {}; this._controlHandlers = {};
this._controlHandlers['radiobutton'] = this._radiobuttonControl; this._controlHandlers['radiobutton'] = this._radiobuttonControl;
this._controlHandlers['progresssbar'] = JSDialog.progressbar; this._controlHandlers['progressbar'] = JSDialog.progressbar;
this._controlHandlers['checkbox'] = this._checkboxControl; this._controlHandlers['checkbox'] = this._checkboxControl;
this._controlHandlers['basespinfield'] = this.baseSpinField; this._controlHandlers['basespinfield'] = this.baseSpinField;
this._controlHandlers['spinfield'] = this._spinfieldControl; this._controlHandlers['spinfield'] = this._spinfieldControl;

View file

@ -917,7 +917,7 @@ L.Control.UIManager = L.Control.extend({
// Snack bar // Snack bar
showSnackbar: function(label, action, callback, timeout) { showSnackbar: function(label, action, callback, timeout, hasProgress) {
if (!app.socket) if (!app.socket)
return; return;
@ -940,6 +940,7 @@ L.Control.UIManager = L.Control.extend({
type: 'container', type: 'container',
children: [ children: [
action ? {id: 'label', type: 'fixedtext', text: label} : {id: 'label-no-action', type: 'fixedtext', text: label}, action ? {id: 'label', type: 'fixedtext', text: label} : {id: 'label-no-action', type: 'fixedtext', text: label},
hasProgress ? {id: 'progress', type: 'progressbar', value: 0, maxValue: 100} : {},
action ? {id: 'button', type: 'pushbutton', text: action} : {} action ? {id: 'button', type: 'pushbutton', text: action} : {}
] ]
} }
@ -961,6 +962,32 @@ L.Control.UIManager = L.Control.extend({
app.socket._onMessage({textMsg: 'jsdialog: ' + JSON.stringify(json), callback: builderCallback}); app.socket._onMessage({textMsg: 'jsdialog: ' + JSON.stringify(json), callback: builderCallback});
}, },
/// shows snackbar with progress
showProgressBar: function(message, buttonText, callback) {
this.showSnackbar(message, buttonText, callback, -1, true);
},
/// sets progressbar status, value should be in range 0-100
setSnackbarProgress: function(value) {
if (!app.socket)
return;
var json = {
id: 'snackbar',
jsontype: 'dialog',
type: 'snackbar',
action: 'update',
control: {
id: 'progress',
type: 'progressbar',
value: value,
maxValue: 100
}
};
app.socket._onMessage({textMsg: 'jsdialog: ' + JSON.stringify(json)});
},
// Modals // Modals
/// shows modal dialog /// shows modal dialog
@ -1105,7 +1132,8 @@ L.Control.UIManager = L.Control.extend({
} }
}, },
showProgressBar: function(id, title, message, buttonText, callback, value, maxValue) { /// shows modal dialog with progress
showProgressBarDialog: function(id, title, message, buttonText, callback, value, maxValue) {
var dialogId = this.generateModalId(id); var dialogId = this.generateModalId(id);
var responseButtonId = dialogId + '-response'; var responseButtonId = dialogId + '-response';
@ -1122,8 +1150,8 @@ L.Control.UIManager = L.Control.extend({
text: message text: message
}, },
{ {
id: dialogId + '-progresssbar', id: dialogId + '-progressbar',
type: 'progresssbar', type: 'progressbar',
value: (value !== undefined && value !== null ? value: 0), value: (value !== undefined && value !== null ? value: 0),
maxValue: (maxValue !== undefined && maxValue !== null ? maxValue: 100) maxValue: (maxValue !== undefined && maxValue !== null ? maxValue: 100)
}, },