|
@@ -1,3 +1,10 @@
|
|
|
+<h3>Enable Samba Service</h3>
|
|
|
+<p>Change current systemctl state of smbd (start / stop).</p>
|
|
|
+<div class="ui toggle checkbox">
|
|
|
+ <input type="checkbox" id="enablesmbd">
|
|
|
+ <label>Enable smbd (Samba Sharing Service)</label>
|
|
|
+</div>
|
|
|
+
|
|
|
<h3>Samba Share Lists</h3>
|
|
|
<p>A list of SMB shares currently written into smb.conf</p>
|
|
|
<div id="sharelist">
|
|
@@ -8,7 +15,7 @@
|
|
|
<p>Create a new SMB share folder from local disk</p>
|
|
|
<script>
|
|
|
|
|
|
- function initShareListTable(){
|
|
|
+ function initShareListTable(){
|
|
|
$.get("../../system/storage/samba/list", function(data){
|
|
|
if (data.error){
|
|
|
msgbox(data.error, false);
|
|
@@ -18,6 +25,46 @@
|
|
|
});
|
|
|
}
|
|
|
initShareListTable();
|
|
|
+
|
|
|
+ function initSmbdState(){
|
|
|
+ $.get("../../system/storage/samba/status", function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+ //Error when loading smbd status
|
|
|
+ msgbox(data.error, false);
|
|
|
+ $("#enablesmbd").parent().addClass('disabled');
|
|
|
+ }else{
|
|
|
+ if (data == true){
|
|
|
+ $("#enablesmbd").parent().checkbox("set checked");
|
|
|
+ }else{
|
|
|
+ $("#enablesmbd").parent().checkbox("set unchecked");
|
|
|
+ }
|
|
|
+
|
|
|
+ //Bind checkbox event
|
|
|
+ $("#enablesmbd").on("change", function(data){
|
|
|
+ let isChecked = $("#enablesmbd")[0].checked;
|
|
|
+ $.ajax({
|
|
|
+ url: "../../system/storage/samba/status",
|
|
|
+ data: {
|
|
|
+ set: isChecked?"enable":"disable"
|
|
|
+ },
|
|
|
+ method: "POST",
|
|
|
+ success: function(data){
|
|
|
+ if (data.error != undefined){
|
|
|
+ msgbox(data.error, false);
|
|
|
+ $("#enablesmbd").off("change");
|
|
|
+ initSmbdState();
|
|
|
+ }else{
|
|
|
+ msgbox(`SMB Sharing ${isChecked?"enabled":"disabled"}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ initSmbdState();
|
|
|
+
|
|
|
+
|
|
|
function generateTable(data) {
|
|
|
// Start the table
|
|
|
let table = `
|