implement applying changes to file
This commit is contained in:
parent
6c149c6e13
commit
ef44b1edd8
|
@ -92,22 +92,34 @@ class NavEntry {
|
||||||
return this.stat["mode"] & 0o777;
|
return this.stat["mode"] & 0o777;
|
||||||
}
|
}
|
||||||
async chmod(/*int*/ new_perms) {
|
async chmod(/*int*/ new_perms) {
|
||||||
await cockpit.spawn(
|
var proc = cockpit.spawn(
|
||||||
["chmod", (new_perms & 0o777).toString(8), this.path_str()],
|
["chmod", (new_perms & 0o777).toString(8), this.path_str()],
|
||||||
{superuser: "try"}
|
{superuser: "try", err:"out"}
|
||||||
);
|
);
|
||||||
|
proc.fail((e, data) => {
|
||||||
|
window.alert(data);
|
||||||
|
});
|
||||||
|
await proc;
|
||||||
}
|
}
|
||||||
async chown(/*string*/ new_owner, /*string*/ new_group) {
|
async chown(/*string*/ new_owner, /*string*/ new_group) {
|
||||||
await cockpit.spawn(
|
var proc = cockpit.spawn(
|
||||||
["chown", [new_owner, new_group].join(":"), this.path_str()],
|
["chown", [new_owner, new_group].join(":"), this.path_str()],
|
||||||
{superuser: "try"}
|
{superuser: "try", err:"out"}
|
||||||
);
|
);
|
||||||
|
proc.fail((e, data) => {
|
||||||
|
window.alert(data);
|
||||||
|
});
|
||||||
|
await proc;
|
||||||
}
|
}
|
||||||
async mv(/*string*/ new_path) {
|
async mv(/*string*/ new_path) {
|
||||||
await cockpit.spawn(
|
var proc = cockpit.spawn(
|
||||||
["mv", this.path_str(), [this.nav_window_ref.pwd().path_str(), new_path].join('/')],
|
["mv", this.path_str(), [this.nav_window_ref.pwd().path_str(), new_path].join('/')],
|
||||||
{superuser: "try"}
|
{superuser: "try", err:"out"}
|
||||||
);
|
);
|
||||||
|
proc.fail((e, data) => {
|
||||||
|
window.alert(data);
|
||||||
|
});
|
||||||
|
await proc;
|
||||||
}
|
}
|
||||||
show_properties() {
|
show_properties() {
|
||||||
var selected_name_fields = document.getElementsByClassName("nav-info-column-filename");
|
var selected_name_fields = document.getElementsByClassName("nav-info-column-filename");
|
||||||
|
@ -295,25 +307,20 @@ class NavWindow {
|
||||||
document.getElementById("nav-mode-preview").innerText = text;
|
document.getElementById("nav-mode-preview").innerText = text;
|
||||||
}
|
}
|
||||||
async apply_edit_selected() {
|
async apply_edit_selected() {
|
||||||
var new_name = document.getElementById("nav-edit-filename").value;
|
// do mv last so the rest don't fail from not finding it
|
||||||
if(new_name !== this.selected_entry.filename())
|
|
||||||
await this.selected_entry.mv(new_name).catch(
|
|
||||||
(e) => {
|
|
||||||
console.log(e);
|
|
||||||
window.alert(e);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
var new_owner = document.getElementById("nav-edit-owner").value;
|
var new_owner = document.getElementById("nav-edit-owner").value;
|
||||||
var new_group = document.getElementById("nav-edit-group").value;
|
var new_group = document.getElementById("nav-edit-group").value;
|
||||||
if(new_owner !== this.selected_entry.stat["owner"] || new_group !== this.selected_entry.stat["group"]){
|
if(new_owner !== this.selected_entry.stat["owner"] || new_group !== this.selected_entry.stat["group"]){
|
||||||
await this.selected_entry.chown(new_owner, new_group).catch(
|
await this.selected_entry.chown(new_owner, new_group).catch(/*ignore, caught in chown*/);
|
||||||
(e) => {
|
}
|
||||||
console.log(e);
|
var new_perms = this.get_new_permissions();
|
||||||
window.alert(e);
|
if((new_perms & 0o777) !== (this.selected_entry.stat["mode"] & 0o777)){
|
||||||
}
|
await this.selected_entry.chmod(new_perms).catch(/*ignore, caught in chmod*/);
|
||||||
);
|
}
|
||||||
|
var new_name = document.getElementById("nav-edit-filename").value;
|
||||||
|
if(new_name !== this.selected_entry.filename()){
|
||||||
|
await this.selected_entry.mv(new_name).catch(/*ignore, caught in mv*/);
|
||||||
}
|
}
|
||||||
window.alert(this.get_new_permissions().toString(8));
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
this.hide_edit_selected();
|
this.hide_edit_selected();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue