833ed08bbad2493384aaf6a1df416158f3bcf77e
[samba.git] / swat / desktop / index.esp
1 <% 
2 libinclude("base.js");
3         page_header("desktop", "Virtual Desktop Design Test", "desktop");
4 %>
5
6 <script type="text/javascript" src="/scripting/client/encoder.js"></script>
7 <script type="text/javascript" src="/scripting/client/call.js"></script>
8 <script type="text/javascript" src="/scripting/client/js_scripts.js"></script>
9 <script type="text/javascript" src="/scripting/client/desktop.js"></script>
10
11 <script type="text/javascript">
12
13 function showMessage(m)
14 {
15         var message = new QxWindow();
16         with(message) {
17                 setWidth(300);
18                 setTop("35%");
19                 setLeft("35%");
20                 setShowMaximize(false);
21                 setShowMinimize(false);
22         }
23
24         var note = new QxAtom(m);
25         with(note) {
26                 setTop(10);
27                 setLeft(10);
28         }
29
30         var ok = new QxButton("OK");
31         with(ok) {
32                 setLeft("42%");
33                 setBottom(2);
34         }
35         ok.addEventListener("click", function() {
36                 w.remove(message);
37         });
38
39         message.add(note);
40         message.add(ok);
41         w.add(message);
42         message.setVisible(true);
43 }
44
45 function blankW()
46 {
47         var blank = new Window.standard('SWAT');
48         w.add(blank);
49         blank.setVisible(true);
50 }
51
52 function showContextMenu(e)
53 {
54         var aboutCmd = new QxCommand();
55         aboutCmd.addEventListener("execute", function() {
56                 showMessage("SWAT, the Samba Web Administration Tool.<br/>This tool is currently under development.");
57         });
58
59         var newWin = new QxCommand();
60         newWin.addEventListener("execute", blankW);
61
62         cmenu = new QxMenu;
63
64         var sub1 = new QxMenuButton("About SWAT", null, aboutCmd);
65         var sep = new QxMenuSeparator();
66         var sub2 = new QxMenuButton("New Window", null, newWin);
67
68         cmenu.add(sub1, sep, sub2);
69
70         cmenu.setLeft(e.getClientX());
71         cmenu.setTop(e.getClientY());
72         w.add(cmenu);
73         cmenu.setVisible(true);
74 }
75
76 /*** init the page for qooxdoo ***/
77 document.js.add('/scripting/client/status.js');
78 window.application.main = function()
79 {
80         var doc = this.getClientWindow().getClientDocument();
81         // Don't declare local with var
82         w = new QxWidget();
83         with(w) {
84                 setTop(0);
85                 setLeft(0);
86                 setWidth(docX());
87                 setHeight(docY());
88         }
89         doc.addEventListener("contextmenu", showContextMenu);
90         doc.add(w);
91
92
93         // Always open with stats
94         var win = new QxWindow();
95         win._onclosebuttonclick = function(e)
96         {
97                 this.close();
98                 e.stopPropagation();
99                 document.js.remove('/scripting/client/status.js');
100         };
101         with(win) {
102                 setTop(50);
103                 setRight(50);
104                 setHeight(175);
105         }
106         w.add(win);
107         getServerStatus(win);
108 }
109
110 window.onresize = function() 
111 {
112         w.setWidth(docX());
113         w.setHeight(docY());
114 }
115
116 function showReg()
117 {
118         document.js.add('/scripting/client/regedit.js');
119
120         var regWin = new QxWindow("Registry Editor");
121         regWin._onclosebuttonclick = function(e)
122         {
123                 this.close();
124                 e.stopPropagation();
125                 document.js.remove('/scripting/client/regedit.js');
126         };
127         with(regWin) {
128                 setTop(100);
129                 setLeft(100);
130                 setMinWidth(450);
131                 setMinHeight(450);
132         }
133         
134         var regedit = regedit_widget("ncalrpc:");
135         regWin.add(regedit);
136         w.add(regWin);
137         regWin.setVisible('true');
138 }
139
140 function startSwat()
141 {
142         var sMenu = new QxMenu;
143         with(sMenu) {
144                 setWidth(150);
145                 setHeight(150);
146         }
147
148         var srvMenu = new QxMenu;
149         var srv1 = new QxMenuButton("LDAP Server", null);
150         var srv2 = new QxMenuButton("CDAP Server", null);
151         var srv3 = new QxMenuButton("RPC Server", null);
152         var srv4 = new QxMenuButton("NBT Server", null);
153         var srv5 = new QxMenuButton("WINS Server", null);
154         var srv6 = new QxMenuButton("Kerberos Server", null);
155         srvMenu.add(srv1, srv2, srv3, srv4, srv5, srv6);
156         w.add(srvMenu);
157         srvMenu.setVisible(false);
158
159         var editReg = new QxCommand;
160         editReg.addEventListener("execute", function() {
161                 showReg();
162         });
163
164         var espMenu = new QxMenu;
165         var esp1 = new QxMenuButton("Registry Editor", null, editReg);
166         espMenu.add(esp1);
167         w.add(espMenu);
168         espMenu.setVisible(false);
169
170         var opt1 = new QxMenuButton("Servers", null)
171         opt1.addEventListener("mouseover", function() {
172                 srvMenu.setVisible(true);
173                 srvMenu.setLeft(this.getComputedPageBoxRight() + 4);
174                 srvMenu.setTop(this.getComputedPageBoxTop() - 3);
175                 if (espMenu.getVisible()) {
176                         espMenu.setVisible(false);
177                 } else if (newMenu.getVisible()) {
178                         newMenu.setVisible(false);
179                 }
180         }); 
181
182         var openWin = new QxCommand;
183         openWin.addEventListener("execute", function() {
184                 blankW();
185         });
186
187         var newMenu = new QxMenu;
188         var new1 = new QxMenuButton("Window", null, openWin);
189         newMenu.add(new1);
190         w.add(newMenu);
191         newMenu.setVisible(false);
192
193         var opt2 = new QxMenuButton("Installation", null);
194         var opt3 = new QxMenuButton("Configuration", null);
195         var opt4 = new QxMenuButton("ESP Tests", null);
196         opt4.addEventListener("mouseover", function() {
197                 espMenu.setVisible(true);
198                 espMenu.setLeft(this.getComputedPageBoxRight() + 4);
199                 espMenu.setTop(this.getComputedPageBoxTop() - 3);
200                 if (srvMenu.getVisible()) {
201                         srvMenu.setVisible(false);
202                 } else if (newMenu.getVisible()) {
203                         newMenu.setVisible(false);
204                 }
205         }); 
206         var opt5 = new QxMenuButton("Documentation", null);
207         var opt6 = new QxMenuButton("New", null);
208         opt6.addEventListener("mouseover", function() {
209                 newMenu.setVisible(true);
210                 newMenu.setLeft(this.getComputedPageBoxRight() + 4);
211                 newMenu.setTop(this.getComputedPageBoxTop() - 3);
212                 if (srvMenu.getVisible()) {
213                         srvMenu.setVisible(false);
214                 } else if (espMenu.getVisible()) {
215                         espMenu.setVisible(false);
216                 }
217         }); 
218         var sep1 = new QxMenuSeparator();
219         var sep2 = new QxMenuSeparator();
220
221         sMenu.add(opt1, opt2, opt3, sep1, opt4, sep2, opt5, opt6);
222         sMenu.setLeft(0);
223         sMenu.setTop(docY() - 150);
224         w.add(sMenu);
225         sMenu.setVisible(true);
226 }
227 </script>
228
229 <div id="toolbar">
230 <h3><a href="javascript:startSwat()">SWAT (Start)</a></h3>
231 </div>
232
233 <% page_footer(); %>