mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
feat(instances): a VM's owners with their rights, and XML edits kept until saved
Settings > Users was a bold title, an unlabelled "+" and a table of names with a trash icon. The owner chose this layout from three rendered options: one list of owners, each with what it may do (change settings, delete the VM, change console settings, or power and console only), Edit rights and Remove, an empty state, and a labelled "Add owner". - Remove and Edit rights come back to the VM's Users tab: the return address carried #users unencoded, so it was lost, and Edit rights went to the user's account page. Both accounts views now go to a ?next page of this site. - The add-owner list offers only users who are not owners yet and not administrators, who can use every VM anyway; a superuser owner also took the only place when a VM may have one owner. - The unused del_owner view and URL are removed: the list uses the accounts page, which asks before removing an owner. XML: - An XML edit not saved yet is kept: the page no longer reloads itself when the VM's state changes, and the browser asks before leaving it. A state change lost the edit. - The button that opens the review dialog reads "Review changes"; it did not save, as "Change" suggested. Closing the dialog gives focus back to the editor.
This commit is contained in:
parent
1150b941be
commit
3d632f1592
12 changed files with 125 additions and 85 deletions
|
|
@ -1,6 +1,8 @@
|
|||
// The VM page's XML editor. Change shows the lines the edit changes in the
|
||||
// VM's definition (instances.views.change_xml), and Save in that dialog
|
||||
// The VM page's XML editor. Review changes shows the lines the edit changes
|
||||
// in the VM's definition (instances.views.change_xml), and Save in that dialog
|
||||
// defines it. A refusal shows in the dialog, and the edit stays in the editor.
|
||||
// An edit not saved yet keeps the page from reloading itself on a VM state
|
||||
// change (window.xmlEditUnsaved), and the browser asks before leaving it.
|
||||
(function () {
|
||||
var form = document.getElementById("xml-form");
|
||||
if (!form) {
|
||||
|
|
@ -16,6 +18,19 @@
|
|||
var diff = document.getElementById("xml-review-diff");
|
||||
var save = document.getElementById("xml-review-save");
|
||||
var reviewed = ""; // Save defines the XML the dialog shows, not later edits
|
||||
var clean = base; // the XML the page has: the opened definition, or the one Save just defined
|
||||
|
||||
window.xmlEditUnsaved = function () {
|
||||
return editor.getValue() !== clean;
|
||||
};
|
||||
window.addEventListener("beforeunload", function (event) {
|
||||
if (window.xmlEditUnsaved()) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
dialog.addEventListener("hidden.bs.modal", function () {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
// The answer: diff, saved, or error (detail when the VM is busy or moved).
|
||||
// Any other failure, such as a redirect, keeps the edit and says so.
|
||||
|
|
@ -70,6 +85,7 @@
|
|||
save.disabled = true;
|
||||
post(reviewed, true).then(function (answer) {
|
||||
if (answer.saved) {
|
||||
clean = reviewed;
|
||||
location.hash = "xmledit";
|
||||
location.reload();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue