r9651: Start to group all SWAT specific windowing, widgets, etc. in one
[tprouty/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/swat.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("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
111 window.onresize = function() 
112 {
113         w.setWidth(docX());
114         w.setHeight(docY());
115 }
116
117 function showReg()
118 {
119         document.js.add('/scripting/client/regedit.js');
120
121         var regWin = new QxWindow("Registry Editor");
122         regWin._onclosebuttonclick = function(e)
123         {
124                 this.close();
125                 e.stopPropagation();
126                 document.js.remove('/scripting/client/regedit.js');
127         };
128         with(regWin) {
129                 setTop(100);
130                 setLeft(100);
131                 setMinWidth(450);
132                 setMinHeight(450);
133         }
134         
135         var regedit = regedit_widget("ncalrpc:");
136         regWin.add(regedit);
137         w.add(regWin);
138         regWin.setVisible('true');
139 }
140
141 function startSwat()
142 {
143         var sMenu = new QxMenu;
144         with(sMenu) {
145                 setWidth(150);
146                 setHeight(150);
147         }
148
149         var srvMenu = new QxMenu;
150         var srv1 = new QxMenuButton("LDAP Server", null);
151         var srv2 = new QxMenuButton("CDAP Server", null);
152         var srv3 = new QxMenuButton("RPC Server", null);
153         var srv4 = new QxMenuButton("NBT Server", null);
154         var srv5 = new QxMenuButton("WINS Server", null);
155         var srv6 = new QxMenuButton("Kerberos Server", null);
156         srvMenu.add(srv1, srv2, srv3, srv4, srv5, srv6);
157         w.add(srvMenu);
158         srvMenu.setVisible(false);
159
160         var editReg = new QxCommand;
161         editReg.addEventListener("execute", function() {
162                 showReg();
163         });
164
165         var espMenu = new QxMenu;
166         var esp1 = new QxMenuButton("Registry Editor", null, editReg);
167         espMenu.add(esp1);
168         w.add(espMenu);
169         espMenu.setVisible(false);
170
171         var opt1 = new QxMenuButton("Servers", null)
172         opt1.addEventListener("mouseover", function() {
173                 srvMenu.setVisible(true);
174                 srvMenu.setLeft(this.getComputedPageBoxRight() + 4);
175                 srvMenu.setTop(this.getComputedPageBoxTop() - 3);
176                 if (espMenu.getVisible()) {
177                         espMenu.setVisible(false);
178                 } else if (newMenu.getVisible()) {
179                         newMenu.setVisible(false);
180                 }
181         }); 
182
183         var openWin = new QxCommand;
184         openWin.addEventListener("execute", function() {
185                 blankW();
186         });
187
188         var newMenu = new QxMenu;
189         var new1 = new QxMenuButton("Window", null, openWin);
190         newMenu.add(new1);
191         w.add(newMenu);
192         newMenu.setVisible(false);
193
194         var opt2 = new QxMenuButton("Installation", null);
195         var opt3 = new QxMenuButton("Configuration", null);
196         var opt4 = new QxMenuButton("ESP Tests", null);
197         opt4.addEventListener("mouseover", function() {
198                 espMenu.setVisible(true);
199                 espMenu.setLeft(this.getComputedPageBoxRight() + 4);
200                 espMenu.setTop(this.getComputedPageBoxTop() - 3);
201                 if (srvMenu.getVisible()) {
202                         srvMenu.setVisible(false);
203                 } else if (newMenu.getVisible()) {
204                         newMenu.setVisible(false);
205                 }
206         }); 
207         var opt5 = new QxMenuButton("Documentation", null);
208         var opt6 = new QxMenuButton("New", null);
209         opt6.addEventListener("mouseover", function() {
210                 newMenu.setVisible(true);
211                 newMenu.setLeft(this.getComputedPageBoxRight() + 4);
212                 newMenu.setTop(this.getComputedPageBoxTop() - 3);
213                 if (srvMenu.getVisible()) {
214                         srvMenu.setVisible(false);
215                 } else if (espMenu.getVisible()) {
216                         espMenu.setVisible(false);
217                 }
218         }); 
219         var sep1 = new QxMenuSeparator();
220         var sep2 = new QxMenuSeparator();
221
222         sMenu.add(opt1, opt2, opt3, sep1, opt4, sep2, opt5, opt6);
223         sMenu.setLeft(0);
224         sMenu.setTop(docY() - 150);
225         w.add(sMenu);
226         sMenu.setVisible(true);
227 }
228 </script>
229
230 <div id="toolbar">
231 <h3><a href="javascript:startSwat()">SWAT (Start)</a></h3>
232 </div>
233
234 <% page_footer(); %>