implement edit functions and add refresh button
This commit is contained in:
parent
498cc6f3ad
commit
9c6fd17a2a
|
@ -137,4 +137,10 @@
|
|||
|
||||
.grid-label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.nav-btn-group {
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
justify-content: flex-end;
|
||||
}
|
|
@ -32,7 +32,11 @@
|
|||
<body>
|
||||
<div class="flex-col outer-container">
|
||||
<div class="flex-row">
|
||||
<button class="pf-c-button pf-m-secondary" id="nav-up-dir-btn"><i class="fas fa-arrow-up"></i></button>
|
||||
<div class="nav-btn-group">
|
||||
<button class="pf-c-button pf-m-secondary" id="nav-up-dir-btn"><i class="fas fa-arrow-up"></i></button>
|
||||
<div class="horizontal-spacer"></div>
|
||||
<button class="pf-c-button pf-m-secondary" id="nav-refresh-btn"><i class="fas fa-sync"></i></button>
|
||||
</div>
|
||||
<div class="horizontal-spacer"></div>
|
||||
<div class="navigation-bar" id="pwd">
|
||||
/current/dir
|
||||
|
@ -58,6 +62,14 @@
|
|||
<span class="nav-property-pair-key">Name</span>
|
||||
<input type="text" class="nav-property-pair-value" id="nav-edit-filename"></input>
|
||||
</div>
|
||||
<div class="nav-property-pair">
|
||||
<span class="nav-property-pair-key">Owner</span>
|
||||
<input type="text" class="nav-property-pair-value" id="nav-edit-owner"></input>
|
||||
</div>
|
||||
<div class="nav-property-pair">
|
||||
<span class="nav-property-pair-key">Group</span>
|
||||
<input type="text" class="nav-property-pair-value" id="nav-edit-group"></input>
|
||||
</div>
|
||||
<div class="nav-property-pair">
|
||||
<div class="nav-property-pair-key">Mode</div>
|
||||
</div>
|
||||
|
@ -79,13 +91,11 @@
|
|||
<input type="checkbox" id="other-write"></input>
|
||||
<input type="checkbox" id="other-exec"></input>
|
||||
</div>
|
||||
<div class="nav-property-pair">
|
||||
<span class="nav-property-pair-key">Owner</span>
|
||||
<input type="text" class="nav-property-pair-value" id="nav-edit-owner"></input>
|
||||
</div>
|
||||
<div class="nav-property-pair">
|
||||
<span class="nav-property-pair-key">Group</span>
|
||||
<input type="text" class="nav-property-pair-value" id="nav-edit-group"></input>
|
||||
<div class="vertical-spacer"></div>
|
||||
<div class="nav-btn-group">
|
||||
<button class="pf-c-button pf-m-danger" id="nav-cancel-edit-btn">Cancel</button>
|
||||
<div class="horizontal-spacer"></div>
|
||||
<button class="pf-c-button pf-m-primary" id="nav-apply-edit-btn">Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -73,6 +73,27 @@ class NavEntry {
|
|||
get_properties() {
|
||||
return this.stat;
|
||||
}
|
||||
get_permissions() {
|
||||
return this.stat["mode"] & 0o777;
|
||||
}
|
||||
async chmod(/*int*/ new_perms) {
|
||||
await cockpit.spawn(
|
||||
["chmod", (new_perms & 0o777).toString(8), this.path_str()],
|
||||
{superuser: "try"}
|
||||
);
|
||||
}
|
||||
async chown(/*string*/ new_owner, /*string*/ new_group) {
|
||||
await cockpit.spawn(
|
||||
["chown", [new_owner, new_group].join(":"), this.path_str()],
|
||||
{superuser: "try"}
|
||||
);
|
||||
}
|
||||
async mv(/*string*/ new_path) {
|
||||
await cockpit.spawn(
|
||||
["mv", this.path_str(), [this.nav_window_ref.pwd().path_str(), new_path].join('/')],
|
||||
{superuser: "try"}
|
||||
);
|
||||
}
|
||||
show_properties() {
|
||||
var selected_name_fields = document.getElementsByClassName("nav-info-column-filename");
|
||||
for(let elem of selected_name_fields){
|
||||
|
@ -237,13 +258,24 @@ class NavWindow {
|
|||
document.getElementById("nav-show-properties").style.display = "block";
|
||||
document.getElementById("nav-edit-properties").style.display = "none";
|
||||
}
|
||||
async apply_edit_selected() {
|
||||
var new_name = document.getElementById("nav-edit-filename").value;
|
||||
await this.selected_entry.mv(new_name).catch(
|
||||
(e) => {
|
||||
console.log(e);
|
||||
window.alert(e);
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
let nav_window = new NavWindow();
|
||||
|
||||
function set_up_buttons() {
|
||||
document.getElementById("nav-up-dir-btn").addEventListener("click", nav_window.up.bind(nav_window));
|
||||
document.getElementById("nav-refresh-btn").addEventListener("click", nav_window.refresh.bind(nav_window));
|
||||
document.getElementById("nav-edit-properties-btn").addEventListener("click", nav_window.show_edit_selected.bind(nav_window));
|
||||
document.getElementById("nav-cancel-edit-btn").addEventListener("click", nav_window.hide_edit_selected.bind(nav_window));
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
|
Loading…
Reference in New Issue