[ UP ] update cgi. add display percentege bar icons.
[archserver.git] / cgi / shares / list_lv.lua
blobf2d2964964ca8a76017a3ceaf4400c24f97b096b
1 #!/usr/bin/lua
3 dofile "libutil.lua"
5 local vgname = "sharevg"
6 local lvname = "homelv"
8 function no_lv()
9 print([[
10 <h3>共享状态</h3>
11 <br> <font ><strong>您的系统上还没有共享卷。</strong></font>
12 <hr>]])
14 ui_message_warning([[
15 <strong>共享卷</strong>是一个虚拟的磁盘,所有共享都会放在这个磁盘上,以方便管理。共享卷是由一个以上的硬盘或Raid组成的大的磁盘.
16 <a href="volumes_create_sharelv.cgi?todo=disks">点击此处创建共享卷</a>
17 </p>]])
18 end
20 function display()
21 local shares = smbshare.get()
22 local options = "<option id=_select style=\"color:blue;\" value=myselect selected>------ 共享列表 ------</option>"
23 local hiddens = [[<input type=hidden id="myselect">]]
24 local style = [[style="background-image:url(icons/volume.png);"]]
26 for s in pairs(shares) do
27 if s ~= "global" then
28 if not shares[s].comment then shares[s].comment="" end
29 if not shares[s].path then shares[s].path="" end
30 options = options..[[<option ]]..style..[[ value="]]..s..[[">]]..s..[[</option>]]
31 hiddens = hiddens..[[<input type=hidden id="]]..s..[[" value="]]..s.."|"..shares[s].path.."|"..shares[s].comment..[[">]]
32 end
33 end
35 print([[
36 <form action="shares_edit_share.cgi",method="post">
37 <table width="80%"><tr><td>
38 <select class="icon-menu" name="selTitle" size=10 id="titles" onchange="setOtherText(this)" width="100%">
40 ..options..
42 </select>
43 </td>
44 <td>
45 <div align="left">
46 <table width="90%" cellspacing="2" cellpadding="5" border="0">
47 <tr class=color_table_row1><td>
48 <strong>共享名称</strong>
49 <input type="text" id="share" name="share">
50 </td></tr>
51 <tr class=color_table_row2><td>
52 <strong>共享目录</strong>
53 <input type="text" id="path" name="path">
54 </td></tr>
55 <tr class=color_table_row1><td>
56 <strong>共享描述 </strong>
57 <input type="text" id="comment" name="comment">
58 </td></tr>
59 <tr><td>
60 <input type=hidden name=todo value="">
61 <input type="submit" value="新建共享" onclick="return mysubmit(1)">
62 <input type="submit" value="更新共享" onclick="return mysubmit(2)">
63 <input type="submit" value="删除共享" onclick="return mysubmit(3)">
64 </td></tr>
65 </table>
66 </div>
67 </td></tr>
68 </table>
70 ..hiddens..
72 </form>
74 <script>
75 function setOtherText(obj) {
76 if (!document.layers) {
77 var share = document.getElementById("share");
78 var path = document.getElementById("path");
79 var comment = document.getElementById("comment");
80 var str = document.getElementById(obj.value).value;
81 var arr = str.split("|");
82 share.value = arr[0];
83 if (arr[1] == null){
84 path.value = "";
85 } else
86 path.value = arr[1];
87 if (arr[2] == null){
88 comment.value = "";
89 }else
90 comment.value = arr[2];
94 function mysubmit(value) {
95 if (value == 1){
96 document.forms[0].todo.value="edit_create";
97 }else if (value == 2) {
98 document.forms[0].todo.value="edit_update";
99 } else if (value == 3) {
100 var ss = "您要删除共享\""+document.getElementById("share").value + "\"吗?";
101 if (confirm(ss)) {
102 document.forms[0].todo.value="delete";
103 document.forms[0].action="shares.cgi";
104 } else {
105 return false;
108 document.forms[0].submit();
110 </script>
114 -------------------------
115 --CGI OUTPUT
116 -------------------------
117 qp = ui_getqp()
118 if is_vg_exist(vgname) then
119 if not qp.todo then
120 print("<h3>共享管理</h3>")
121 display()
122 elseif qp.todo=="delete" then
123 if qp.share and qp.share ~= "" then
124 local sh_list = smbshare.get()
125 if not sh_list[qp.share] then
126 ui_message_err("共享 <strong>"..qp.share.."</strong>不存在<br>")
127 return
129 smbshare.remove(qp.share)
131 sh_list = smbshare.get()
132 if not sh_list[qp.share] then
133 print("共享 <strong>"..qp.share.."</strong>已删除<br>")
134 else
135 ui_message_err("共享 <strong>"..qp.share.."</strong>删除失败.<br>")
137 else
138 ui_message_err("请指定要删除的共享名.")
141 else
142 no_lv()