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