]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/main/ws_info.xul
indent and disable some menu options
[Evergreen.git] / Open-ILS / xul / staff_client / server / main / ws_info.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Main, Authentication Window -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- PRESENTATION -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/auth.css" type="text/css"?>
10
11 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!-- LOCALIZATION -->
13 <!DOCTYPE window SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
14
15 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
16 <!-- OVERLAYS -->
17 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
18
19 <window id="wsinfo_win" 
20         onload="try { wsinfo_init(); } catch(E) { alert(E); }"
21         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
22
23
24         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
25         <!-- BEHAVIOR -->
26         <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
27         <scripts id="openils_util_scripts"/>
28
29         <script type="text/javascript" src="chrome://open_ils_staff_client/content/main/lang.js"/>
30         <script type="text/javascript" src="/xul/server/main/lang.js"/>
31         <script type="text/javascript" src="chrome://open_ils_staff_client/content/main/JSAN.js"/>
32         <script>
33         <![CDATA[
34
35                 function wsinfo_init() {
36
37                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
38
39                         if (typeof JSAN == 'undefined') {
40                                 throw(
41                                         "The JSAN library object is missing."
42                                 );
43                         }
44                         /////////////////////////////////////////////////////////////////////////////
45
46                         JSAN.errorLevel = "die"; // none, warn, or die
47                         JSAN.addRepository('/xul/server/');
48
49                         JSAN.use('util.error'); g.error = new util.error();
50                         JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
51                         JSAN.use('util.network'); g.network = new util.network();
52                         JSAN.use('util.widgets');
53                         JSAN.use('util.functional');
54
55                         g.aout_list = g.network.simple_request(
56                                 'FM_AOUT_RETRIEVE',
57                                 [ ]
58                         );
59                         g.aout_hash = {};
60                         for (var i = 0; i < g.aout_list.length; i++) {
61                                 g.aout_hash[ g.aout_list[i].id() ] = g.aout_list[i];
62                         }
63
64                         g.my_libs = g.network.simple_request(
65                                 'FM_AOU_RETRIEVE_RELATED_VIA_SESSION',
66                                 [ xulG.auth.session.key ]
67                         );
68
69                         g.my_libs_hash = {};
70                         for (var i = 0; i < g.my_libs.length; i++) {
71                                 g.my_libs_hash[ g.my_libs[i].id() ] = g.my_libs[i].shortname();
72                         }
73
74                         g.my_lib = g.network.simple_request(
75                                 'FM_AU_RETRIEVE_VIA_SESSION',
76                                 [ xulG.auth.session.key ]
77                         ).home_ou();
78
79                         g.tb = document.getElementById('wsname');
80
81                         render_menulist();
82
83                         g.ml.focus();
84                         
85                 }
86
87                 function render_menulist() {
88                         var x = document.getElementById('placeholder');
89                         util.widgets.remove_children( x );
90
91                         g.ml = util.widgets.make_menulist( 
92                                 util.functional.map_list( 
93                                         g.my_libs,
94                                         function(obj) { return [ 
95                                                 obj.shortname(), 
96                                                 obj.id(), 
97                                                 ( g.aout_hash[ obj.ou_type() ].can_have_users() == 0),
98                                                 ( g.aout_hash[ obj.ou_type() ].depth() ),
99                                         ]; }
100                                 ),
101                                 g.my_lib
102                         );
103
104                         x.appendChild( g.ml );
105                 }
106
107                 function register() {
108                         try {
109                                 var robj = g.network.simple_request(
110                                         'AUTH_WORKSTATION',
111                                         [ xulG.auth.session.key, g.tb.value, g.ml.value ]
112                                 );
113
114                                 if (robj.ilsevent) {
115                                         alert(js2JSON(robj));
116                                 } else {
117                                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead");
118                                         g.data.ws_info[ xulG.auth.controller.view.server_prompt.value ] = { 
119                                                 'name' : g.tb.value, 
120                                                 'owning_lib' : g.ml.value,
121                                                 'lib_shortname' : g.my_libs_hash[ g.ml.value ],
122                                         };
123                                         xulG.file.get('ws_info');
124                                         xulG.file.set_object(g.data.ws_info);
125                                         alert('Registration successful');
126                                         xulG.auth.logoff();
127                                 }
128                         } catch(E) {
129                                 alert(E);
130                         }
131                 }
132
133         ]]>
134         </script>
135
136         <vbox flex="1">
137                 <hbox id="placeholder"/>
138                 <hbox>
139                         <label value="Name" control="wsname"/>
140                         <textbox id="wsname" />
141                         <button label="Register" accesskey="R" oncommand="register();"/>
142                 </hbox>
143         </vbox>
144 </window>
145