|
@@ -5,16 +5,79 @@
|
|
|
<label>Enable smbd (Samba Sharing Service)</label>
|
|
|
</div>
|
|
|
|
|
|
-<h3>Samba Share Lists</h3>
|
|
|
+<h3><i class="ui green share alternate icon"></i> Samba Share Lists</h3>
|
|
|
<p>A list of SMB shares currently written into smb.conf</p>
|
|
|
<div id="sharelist">
|
|
|
|
|
|
</div>
|
|
|
<div class="ui divider"></div>
|
|
|
-<h3>Add Samba Share</h3>
|
|
|
+<h3><i class="ui green circle add icon"></i> Add Samba Share</h3>
|
|
|
<p>Create a new SMB share folder from local disk</p>
|
|
|
+<form class="ui form" id="shareForm">
|
|
|
+ <div class="field">
|
|
|
+ <label for="shareName">Share Name</label>
|
|
|
+ <input type="text" id="shareName" placeholder="Share Name">
|
|
|
+ </div>
|
|
|
+ <div class="field">
|
|
|
+ <label for="sharePath">Share Path</label>
|
|
|
+ <input type="text" id="sharePath" placeholder="/home/user/myshare">
|
|
|
+ <small><i class="ui yellow exclamation triangle icon"></i> The folder path must be an absolute full path exists on your local disk. e.g. /home/user/myshare/ </small>
|
|
|
+ </div>
|
|
|
+ <div class="field">
|
|
|
+ <label for="validUsers">Valid Users</label>
|
|
|
+ <select multiple="" class="ui search dropdown" id="validUsers">
|
|
|
+ <option value="user1">User 1</option>
|
|
|
+ <option value="user2">User 2</option>
|
|
|
+ <option value="user3">User 3</option>
|
|
|
+ <!-- Add options for all users in the system -->
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="field">
|
|
|
+ <div class="ui checkbox">
|
|
|
+ <input type="checkbox" id="readOnly">
|
|
|
+ <label for="readOnly">Read Only<br>
|
|
|
+ <small>Set all files in this share to READ ONLY mode</small></label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="field">
|
|
|
+ <div class="ui checkbox">
|
|
|
+ <input type="checkbox" id="browseable" checked>
|
|
|
+ <label for="browseable">Browseable <br>
|
|
|
+ <small>Make this share discoverable</small></label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="field">
|
|
|
+ <div class="ui checkbox">
|
|
|
+ <input type="checkbox" id="allowGuest">
|
|
|
+ <label for="allowGuest">Allow Guest<br>
|
|
|
+ <small>Enable guest account on this share</small></label>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <button type="button" class="ui small basic button" onclick="submitForm()"><i class="ui green circle add icon"></i> Create Share</button>
|
|
|
+</form>
|
|
|
+</div>
|
|
|
+
|
|
|
<script>
|
|
|
+ $("#validUsers").dropdown();
|
|
|
+ $("#shareForm").find("checkbox").checkbox();
|
|
|
+
|
|
|
+ //Load all the users in the samba database
|
|
|
+ function initSambaUserList(){
|
|
|
+ $.get("../../system/storage/samba/listUsers", function(data){
|
|
|
+ if (data.error == undefined){
|
|
|
+ $("#validUsers").html("");
|
|
|
+ if (data.length == 0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ data.forEach(function(userinfo){
|
|
|
+ $("#validUsers").append(`<option value="${userinfo.UnixUsername}">${userinfo.UnixUsername}</option>`);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ initSambaUserList();
|
|
|
|
|
|
+ //List the current shares in smb.conf
|
|
|
function initShareListTable(){
|
|
|
$.get("../../system/storage/samba/list", function(data){
|
|
|
if (data.error){
|
|
@@ -26,6 +89,7 @@
|
|
|
}
|
|
|
initShareListTable();
|
|
|
|
|
|
+ //Load current smbd state
|
|
|
function initSmbdState(){
|
|
|
$.get("../../system/storage/samba/status", function(data){
|
|
|
if (data.error != undefined){
|
|
@@ -71,8 +135,8 @@
|
|
|
<table class="ui basic celled unstackable table">
|
|
|
<thead>
|
|
|
<tr>
|
|
|
- <th>Name</th>
|
|
|
- <th>Path</th>
|
|
|
+ <th><i class="ui yellow folder icon"></i> Name</th>
|
|
|
+ <th><i class="ui grey hdd icon"></i> Path</th>
|
|
|
<th>Valid Users</th>
|
|
|
<th>Read Only</th>
|
|
|
<th>Browseable</th>
|
|
@@ -87,13 +151,13 @@
|
|
|
data.forEach(item => {
|
|
|
table += `
|
|
|
<tr>
|
|
|
- <td><i class="ui yellow folder icon"></i> ${item.Name}</td>
|
|
|
- <td><i class="ui grey hdd icon"></i> ${item.Path}</td>
|
|
|
+ <td>${item.Name}</td>
|
|
|
+ <td>${item.Path}</td>
|
|
|
<td>${item.ValidUsers.join(", ")}</td>
|
|
|
<td>${item.ReadOnly?'<i class="ui green check icon"></i>':'<i class="ui red times icon"></i>'}</td>
|
|
|
<td>${item.Browseable?'<i class="ui green check icon"></i>':'<i class="ui red times icon"></i>'}</td>
|
|
|
<td>${item.GuestOk?'<i class="ui green check icon"></i>':'<i class="ui red times icon"></i>'}</td>
|
|
|
- <td><button class="ui basic circular mini red icon button"><i class="ui trash icon"></i> Remove</button></td>
|
|
|
+ <td><button class="ui basic circular mini red icon button" onclick="deleteSMBShare('${item.Name}');"><i class="ui trash icon"></i> Remove</button></td>
|
|
|
</tr>
|
|
|
`;
|
|
|
});
|
|
@@ -107,4 +171,25 @@
|
|
|
// Insert the table into the div
|
|
|
$("#sharelist").html(table);
|
|
|
}
|
|
|
+
|
|
|
+ //Delete the given smb share name
|
|
|
+ function deleteSMBShare(smbShareName){
|
|
|
+ if (confirm("Confirm remove share " + smbShareName + " ?")){
|
|
|
+ $.ajax({
|
|
|
+ url: "../../system/storage/samba/remove",
|
|
|
+ method: "POST",
|
|
|
+ data:{
|
|
|
+ "name": smbShareName,
|
|
|
+ },
|
|
|
+ success: function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+ msgbox(data.error, false);
|
|
|
+ }else{
|
|
|
+ msgbox("SMB share removed");
|
|
|
+ initShareListTable();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
</script>
|