View | Details | Raw Unified | Return to bug 22902 | Differences between
and this patch

Collapse All | Expand All

(-)univention-cupsadmin (-4 / +7 lines)
 Lines 50-60    Link Here 
50
50
51
# argv[0] should be something like .../univention-cups... Cut
51
# argv[0] should be something like .../univention-cups... Cut
52
# univention-cups from it
52
# univention-cups from it
53
if os.path.basename(cmd)=="univention-cups-enable" or os.path.basename(cmd)=="univention-cups-disable":
53
#
54
	cmd=os.path.basename(cmd).replace("univention-cups-", "/usr/bin/cups")
54
# cupsenable and -disable aren't located in /usr/bin anymore
55
else:
55
#if os.path.basename(cmd)=="univention-cups-enable" or os.path.basename(cmd)=="univention-cups-disable":
56
	cmd=os.path.basename(cmd).replace("univention-cups-", "/usr/sbin/cups")
56
#	cmd=os.path.basename(cmd).replace("univention-cups-", "/usr/bin/cups")
57
#else:
57
58
59
cmd=os.path.basename(cmd).replace("univention-cups-", "/usr/sbin/cups")
60
58
# check if target executable exists
61
# check if target executable exists
59
if not(os.path.exists(cmd)):
62
if not(os.path.exists(cmd)):
60
	print("Target executable %s does not exist. Exiting."%cmd)
63
	print("Target executable %s does not exist. Exiting."%cmd)
(-)debian/control (+15 lines)
 Lines 74-76    Link Here 
74
 integrated, directory driven solution for managing
74
 integrated, directory driven solution for managing
75
 corporate environments. For more information about UCS,
75
 corporate environments. For more information about UCS,
76
 refer to: http://www.univention.de/
76
 refer to: http://www.univention.de/
77
78
Package: univention-management-console-module-printers
79
Architecture: all
80
Depends: ${misc:Depends},
81
 univention-directory-manager-tools (>> 7.0.147),
82
 univention-management-console-server,
83
 univention-printserver (= ${source:Version})
84
Description: UMC module for printer administration
85
 This package contains the UMC module for the administration
86
 of configured printers.
87
 .
88
 It is part of Univention Corporate Server (UCS), an
89
 integrated, directory driven solution for managing
90
 corporate environments. For more information about UCS,
91
 refer to: http://www.univention.de/
(-)debian/rules (+1 lines)
 Lines 37-42    Link Here 
37
	msgfmt --check -o $@ $<
37
	msgfmt --check -o $@ $<
38
38
39
override_dh_auto_build: $(MO_FILES)
39
override_dh_auto_build: $(MO_FILES)
40
	dh-umc-module-build
40
	dh_auto_build
41
	dh_auto_build
41
42
42
override_dh_auto_test:
43
override_dh_auto_test:
(-)35univention-management-console-module-printers.inst (+49 lines)
Line 0    Link Here 
1
#!/bin/sh
2
# -*- coding: utf-8 -*-
3
#
4
# Univention Management Console Module top
5
#  join script
6
#
7
# Copyright 2011 Univention GmbH
8
#
9
# http://www.univention.de/
10
#
11
# All rights reserved.
12
#
13
# The source code of this program is made available
14
# under the terms of the GNU Affero General Public License version 3
15
# (GNU AGPL V3) as published by the Free Software Foundation.
16
#
17
# Binary versions of this program provided by Univention to you as
18
# well as other copyrighted, protected or trademarked materials like
19
# Logos, graphics, fonts, specific documentations and configurations,
20
# cryptographic keys etc. are subject to a license agreement between
21
# you and Univention and not subject to the GNU AGPL V3.
22
#
23
# In the case you use this program under the terms of the GNU AGPL V3,
24
# the program is provided in the hope that it will be useful,
25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
# GNU Affero General Public License for more details.
28
#
29
# You should have received a copy of the GNU Affero General Public
30
# License with the Debian GNU/Linux or Univention distribution in file
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
33
34
VERSION=1
35
36
. /usr/share/univention-join/joinscripthelper.lib
37
. /usr/share/univention-lib/umc.sh
38
39
joinscript_init
40
41
umc_init
42
umc_operation_create "printers-all" "Printer Administration" "" "printers/*"
43
umc_policy_append "default-umc-all" "printers-all"
44
45
joinscript_save_current_version
46
47
exit 0
48
49
(-)umc/python/printers/de.po (+14 lines)
Line 0    Link Here 
1
# This file is auto-generated by the dh-umc tools and should not be edited!
2
#, fuzzy
3
msgid ""
4
msgstr ""
5
"Project-Id-Version: univention-management-console-module-printers\n"
6
"Report-Msgid-Bugs-To: packages@univention.de\n"
7
"POT-Creation-Date: 2011-11-07 12:45+0100\n"
8
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
9
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
10
"Language-Team: LANGUAGE <LL@li.org>\n"
11
"Language: \n"
12
"MIME-Version: 1.0\n"
13
"Content-Type: text/plain; charset=UTF-8\n"
14
"Content-Transfer-Encoding: 8bit\n"
(-)umc/python/printers/__init__.py (+366 lines)
Line 0    Link Here 
1
#!/usr/bin/python2.6
2
# -*- coding: utf-8 -*-
3
#
4
# Univention Management Console
5
#  module: updater
6
#
7
# Copyright 2011 Univention GmbH
8
#
9
# http://www.univention.de/
10
#
11
# All rights reserved.
12
#
13
# The source code of this program is made available
14
# under the terms of the GNU Affero General Public License version 3
15
# (GNU AGPL V3) as published by the Free Software Foundation.
16
#
17
# Binary versions of this program provided by Univention to you as
18
# well as other copyrighted, protected or trademarked materials like
19
# Logos, graphics, fonts, specific documentations and configurations,
20
# cryptographic keys etc. are subject to a license agreement between
21
# you and Univention and not subject to the GNU AGPL V3.
22
#
23
# In the case you use this program under the terms of the GNU AGPL V3,
24
# the program is provided in the hope that it will be useful,
25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
# GNU Affero General Public License for more details.
28
#
29
# You should have received a copy of the GNU Affero General Public
30
# License with the Debian GNU/Linux or Univention distribution in file
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
33
34
import pprint
35
import subprocess
36
import univention.management.console as umc
37
import univention.management.console.modules as umcm
38
import univention.config_registry
39
40
from fnmatch import *
41
import re
42
import string
43
import subprocess
44
45
from univention.management.console.log import MODULE
46
from univention.management.console.protocol.definitions import *
47
48
_ = umc.Translation('univention-management-console-module-printers').translate
49
50
class Instance(umcm.Base):
51
	
52
	def init(self):
53
		
54
		self.ucr = univention.config_registry.ConfigRegistry()
55
		self.ucr.load()
56
		
57
		self._hostname = self.ucr.get('hostname')
58
		
59
60
	def list_printers(self,request):
61
		""" Lists the printers for the overview grid. """
62
		
63
		# ----------- DEBUG -----------------
64
		MODULE.info("printers/query invoked with:")
65
		pp = pprint.PrettyPrinter(indent=4)
66
		st = pp.pformat(request.options).split("\n")
67
		for s in st:
68
			MODULE.info("   << %s" % s)
69
		# -----------------------------------
70
		
71
		key = request.options.get('key','printer')
72
		pattern = request.options.get('pattern','*')
73
		
74
		quota = self._quota_enabled()		# we need it later
75
		
76
		result = []
77
		plist = self._list_printers()
78
		for element in plist:
79
			try:
80
				printer = element['printer']
81
				data = self._printer_details(printer)
82
				for field in data:
83
					element[field] = data[field]
84
				# filter according to query
85
				if fnmatch(element[key],pattern):
86
					if printer in quota:
87
						element['quota'] = quota[printer]
88
					else:
89
						element['quota'] = False
90
					result.append(element)
91
			except:
92
				pass
93
				
94
		# ---------- DEBUG --------------
95
		MODULE.info("printers/query returns:")
96
		pp = pprint.PrettyPrinter(indent=4)
97
		st = ''
98
		if len(result) > 5:
99
			tmp = result[0:5]
100
			MODULE.info("   >> %d entries, first 5 are:" % len(result))
101
			st = pp.pformat(tmp).split("\n")
102
		else:
103
			st = pp.pformat(result).split("\n")
104
		for s in st:
105
			MODULE.info("   >> %s" % s)
106
		# --------------------------------
107
108
		self.finished(request.id,result)
109
110
	def get(self,request):
111
		""" gets detail data for one printer. """
112
		
113
		# ----------- DEBUG -----------------
114
		MODULE.info("printers/get invoked with:")
115
		pp = pprint.PrettyPrinter(indent=4)
116
		st = pp.pformat(request.options).split("\n")
117
		for s in st:
118
			MODULE.info("   << %s" % s)
119
		# -----------------------------------
120
121
		printer = request.options.get('printer','')
122
		result = self._printer_details(printer)
123
		result['printer'] = printer
124
		result['status'] = self._printer_status(printer)
125
		result['quota'] = self._quota_enabled(printer)
126
		
127
		# ---------- DEBUG --------------
128
		MODULE.info("printers/get returns:")
129
		pp = pprint.PrettyPrinter(indent=4)
130
		st = pp.pformat(result).split("\n")
131
		for s in st:
132
			MODULE.info("   >> %s" % s)
133
		# --------------------------------
134
135
		self.finished(request.id,result)
136
137
	def list_jobs(self,request):
138
		""" returns list of jobs for one printer. """
139
		
140
		# ----------- DEBUG -----------------
141
		MODULE.info("printers/jobs/query invoked with:")
142
		pp = pprint.PrettyPrinter(indent=4)
143
		st = pp.pformat(request.options).split("\n")
144
		for s in st:
145
			MODULE.info("   << %s" % s)
146
		# -----------------------------------
147
		
148
		result = self._job_list(request.options.get('printer',''))
149
		
150
		# ---------- DEBUG --------------
151
		MODULE.info("printers/jobs/query returns:")
152
		pp = pprint.PrettyPrinter(indent=4)
153
		st = ''
154
		if len(result) > 5:
155
			tmp = result[0:5]
156
			MODULE.info("   >> %d entries, first 5 are:" % len(result))
157
			st = pp.pformat(tmp).split("\n")
158
		else:
159
			st = pp.pformat(result).split("\n")
160
		for s in st:
161
			MODULE.info("   >> %s" % s)
162
		# --------------------------------
163
164
		self.finished(request.id,result)
165
		
166
	def list_quota(self,request):
167
		""" lists all quota entries related to this printer. """
168
		
169
		# fill a dummy result table.
170
		printer = request.options.get('printer','')
171
		result = []
172
		
173
		self.finished(request.id,result)
174
		
175
	def enable(self,request):
176
		""" can enable or disable a printer, depending on args.
177
			returns empty string on success, else error message. 
178
		"""
179
		
180
		# ----------- DEBUG -----------------
181
		MODULE.info("printers/enable invoked with:")
182
		pp = pprint.PrettyPrinter(indent=4)
183
		st = pp.pformat(request.options).split("\n")
184
		for s in st:
185
			MODULE.info("   << %s" % s)
186
		# -----------------------------------
187
		
188
		printer = request.options.get('printer','')
189
		on = request.options.get('on',False)
190
		
191
		result = self._enable_printer(printer,on)
192
		
193
		# ---------- DEBUG --------------
194
		MODULE.info("printers/enable returns:")
195
		pp = pprint.PrettyPrinter(indent=4)
196
		st = pp.pformat(result).split("\n")
197
		for s in st:
198
			MODULE.info("   >> %s" % s)
199
		# --------------------------------
200
201
		self.finished(request.id, result)
202
		
203
	def cancel(self,request):
204
		""" cancels one or more print jobs. Job IDs are passed
205
			as an array that can be directly passed on to the
206
			_shell_command() method
207
		"""
208
209
		# ----------- DEBUG -----------------
210
		MODULE.info("printers/jobs/cancel invoked with:")
211
		pp = pprint.PrettyPrinter(indent=4)
212
		st = pp.pformat(request.options).split("\n")
213
		for s in st:
214
			MODULE.info("   << %s" % s)
215
		# -----------------------------------
216
		
217
		jobs = request.options['jobs']
218
		printer = request.options.get('printer','')
219
		result = self._cancel_jobs(printer,jobs)
220
		
221
		# ---------- DEBUG --------------
222
		MODULE.info("printers/jobs/cancel returns:")
223
		pp = pprint.PrettyPrinter(indent=4)
224
		st = pp.pformat(result).split("\n")
225
		for s in st:
226
			MODULE.info("   >> %s" % s)
227
		# --------------------------------
228
229
		self.finished(request.id, result)
230
		
231
		
232
		
233
	# ----------------------- Internal functions -------------------------
234
235
	def _job_list(self,printer):
236
		""" lists jobs for a given printer, directly suitable for the grid """
237
		
238
		# *** NOTE *** we don't set language to 'neutral' since it is useful
239
		#				to get localized date/time strings.
240
		
241
		result = []
242
		(stdout,stderr,status) = self._shell_command(['/usr/bin/lpstat','-o',printer])
243
		expr = re.compile('\s*(\S+)\s+(\S+)\s+(\d+)\s*(.*?)$')
244
		if status == 0:
245
			for line in stdout.split("\n"):
246
				mobj = expr.match(line)
247
				if mobj:
248
					entry = {
249
						'job':		mobj.group(1),
250
						'owner':	mobj.group(2),
251
						'size':		mobj.group(3),
252
						'date':		mobj.group(4)
253
					}
254
					result.append(entry)
255
		return result
256
	
257
	def _list_printers(self):
258
		""" returns a list of printers, along with their 'enabled' status. """
259
		
260
		result = []
261
		expr = re.compile('printer\s+(\S+)\s.*?(\S+abled)')
262
		(stdout,stderr,status) = self._shell_command(['/usr/bin/lpstat','-p'],{'LANG':'C'})
263
		if status == 0:
264
			for line in stdout.split("\n"):
265
				mobj = expr.match(line)
266
				if mobj:
267
					entry = { 'printer' : mobj.group(1), 'status': mobj.group(2) }
268
					result.append(entry)
269
		return result
270
	
271
	def _printer_status(self,printer):
272
		""" returns the 'enabled' status of a printer """
273
		
274
		(stdout,stderr,status) = self._shell_command(['/usr/bin/lpstat','-p',printer],{'LANG':'C'})
275
		if status == 0:
276
			if ' enabled ' in stdout:
277
				return 'enabled'
278
			if ' disabled ' in stdout:
279
				return 'disabled'
280
		return 'unknown'
281
	
282
	def _printer_details(self,printer):
283
		""" returns as much as possible details about a printer. """
284
		
285
		result = {}
286
		expr = re.compile('\s+([^\s\:]+)\:\s*(.*?)$')
287
		(stdout,stderr,status) = self._shell_command(['/usr/bin/lpstat','-l','-p',printer],{'LANG':'C'})
288
		if status == 0:
289
			for line in stdout.split("\n"):
290
				mobj = expr.match(line)
291
				if mobj:
292
					result[mobj.group(1).lower()] = mobj.group(2)
293
		result['server'] = self._hostname
294
		return result
295
	
296
	def _enable_printer(self,printer,on):
297
		""" internal function that enables/disables a printer.
298
			returns empty string or error message.
299
		"""
300
		
301
		cmd = 'univention-cups-enable' if on else 'univention-cups-disable'
302
		(stdout,stderr,status) = self._shell_command([cmd,printer])
303
		
304
		if status:
305
			return stderr
306
		
307
		# Q: What do these tools return if the cups command being called returns with error?
308
		# A: They return zero, the exit code meant for success.
309
		#
310
		# Q: Which is the channel where these tools print the ERROR message?
311
		# A: On STDOUT, as the name suggests.
312
		#
313
		# Q: What do these tools print on success?
314
		# A: Two newlines, instead of nothing.
315
		if re.search('\S',stdout):
316
			return stdout
317
		
318
		return ''
319
	
320
	def _quota_enabled(self,printer=None):
321
		""" returns a dictionary with printer names and their 'quota active' status.
322
			if printer is specified, returns only quota status for this printer.
323
		"""
324
		
325
		result = {}
326
		expr = re.compile('device for (\S+)\:\s*(\S+)$')
327
		(stdout,stderr,status) = self._shell_command(['/usr/bin/lpstat','-v'],{'LANG':'C'})
328
		if status == 0:
329
			for line in stdout.split("\n"):
330
				match = expr.match(line)
331
				if match:
332
					quota = False
333
					if match.group(2).startswith('cupspykota'):
334
						quota = True
335
					result[match.group(1)] = quota
336
		# No printer specified: return the whole list.
337
		if printer == None:
338
			return result
339
		
340
		# Printer specified: return its quota value or False if not found.
341
		if printer in result:
342
			return result[printer]
343
		return False
344
	
345
	def _cancel_jobs(self,printer,jobs):
346
		""" internal function that cancels a list of jobs.
347
			returns empty string or error message.
348
		"""
349
		
350
		args = ['/usr/bin/cancel','-U','%s$' % self._hostname]
351
		for job in jobs:
352
			args.append(job)
353
		args.append(printer)
354
		(stdout,stderr,status) = self._shell_command(args)
355
		
356
		if status:
357
			return stderr
358
		return ''
359
		
360
	def _shell_command(self,args,env=None):
361
		
362
		proc = subprocess.Popen(args=args, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
363
		outputs = proc.communicate()
364
		
365
		return (outputs[0],outputs[1],proc.returncode)
366
			
(-)umc/printers.xml (+35 lines)
Line 0    Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<umc version="2.0">
3
  <module id="printers" icon="printing" version="1.0">
4
	<name>Printer Administration</name>
5
	<description>Manage defined printers</description>
6
	<categories>
7
	  <category name="system"/>
8
	</categories>
9
10
	<command name="printers/query" function="list_printers"/>
11
12
	<command name="printers/get" function="get">
13
		<attribute name="printer" syntax="String"/>
14
	</command>
15
16
	<command name="printers/enable" function="enable">
17
		<attribute name="printer" syntax="String"/>
18
		<attribute name="on" syntax="Bool"/>
19
	</command>
20
21
	<command name="printers/jobs/query" function="list_jobs">
22
		<attribute name="printer" syntax="String"/>
23
	</command>
24
25
	<command name="printers/jobs/cancel" function="cancel">
26
		<attribute name="printer" syntax="String"/>
27
		<attribute name="jobs" syntax="String"/>
28
	</command>
29
30
	<command name="printers/quota/query" function="list_quota">
31
		<attribute name="printer" syntax="String"/>
32
	</command>
33
34
  </module>
35
</umc>
(-)umc/de.po (+20 lines)
Line 0    Link Here 
1
# This file is auto-generated by the dh-umc tools and should not be edited!
2
msgid ""
3
msgstr ""
4
"Project-Id-Version: univention-management-console-module-printers\n"
5
"Report-Msgid-Bugs-To: packages@univention.de\n"
6
"POT-Creation-Date: Mon, 07 Nov 2011 12:45:12 +0100\n"
7
"PO-Revision-Date: \n"
8
"Last-Translator: Univention GmbH <packages@univention.de>\n"
9
"Language-Team: Univention GmbH <packages@univention.de>\n"
10
"Language: de\n"
11
"MIME-Version: 1.0\n"
12
"Content-Type: text/plain; charset=UTF-8\n"
13
"Content-Transfer-Encoding: 8bit\n"
14
15
msgid "Manage defined printers"
16
msgstr "Drucker verwalten"
17
18
msgid "Printer Administration"
19
msgstr "Druckerverwaltung"
20
(-)umc/syntax/printers.xml (+5 lines)
Line 0    Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<umc version="2.0">
3
  <definitions>
4
  </definitions>
5
</umc>
(-)umc/js/printers.js (+129 lines)
Line 0    Link Here 
1
/*global console MyError dojo dojox dijit umc window */
2
3
dojo.provide("umc.modules.printers"); 
4
5
dojo.require("umc.i18n");
6
dojo.require("umc.dialog");
7
dojo.require("umc.widgets.ConfirmDialog");
8
dojo.require("umc.tools");
9
10
// ----------- sub pages ---------------
11
dojo.require("umc.modules._printers.OverviewPage");
12
dojo.require("umc.modules._printers.DetailPage");
13
dojo.require("umc.modules._printers.QuotaPage");
14
15
dojo.declare("umc.modules.printers", [
16
	umc.widgets.Module,
17
	umc.i18n.Mixin
18
	],
19
{
20
21
	i18nClass: 			'umc.modules.printers',
22
	
23
	_quota_from_page:	'',			// remembers the page from which the 'editQuota' was called
24
	
25
	buildRendering: function() {
26
27
		this.inherited(arguments);
28
		
29
		this._pages = {
30
			'overview':		new umc.modules._printers.OverviewPage(),
31
			'detail':		new umc.modules._printers.DetailPage(),
32
			'quota':		new umc.modules._printers.QuotaPage()
33
		};
34
35
		// forIn behaves like forEach just for dicts :) ... important it checks for hasOwnProperty!
36
		umc.tools.forIn(this._pages, function(iname, ipage) {
37
			this.addChild(ipage);
38
		}, this);
39
40
		// -------------- Events for page switching ----------------
41
42
		dojo.connect(this._pages['overview'],'openDetail',dojo.hitch(this,function(args) {
43
			this._switch_page('detail',args);
44
		}));
45
		
46
		dojo.connect(this._pages['overview'],'editQuota',dojo.hitch(this, function(args) {
47
			this._quota_from_page = 'overview';
48
			this._switch_page('quota',args);
49
		}));
50
		
51
		dojo.connect(this._pages['detail'],'editQuota',dojo.hitch(this, function(args) {
52
			this._quota_from_page = 'detail';
53
			this._switch_page('quota',args);
54
		}));
55
		
56
		dojo.connect(this._pages['detail'],'closeDetail',dojo.hitch(this, function(args) {
57
			this._switch_page('overview',args);
58
		}));
59
		
60
		dojo.connect(this._pages['quota'],'closeQuota',dojo.hitch(this, function(args) {
61
			this._switch_page(this._quota_from_page,args);
62
		}));
63
		
64
		// ------------- work events: printer management ---------------
65
		
66
		dojo.connect(this._pages['overview'],'managePrinter',dojo.hitch(this, function(printer,func,callback) {
67
			this._manage_printer(printer,func,callback);
68
		}));
69
		dojo.connect(this._pages['detail'],'managePrinter',dojo.hitch(this, function(printer,func,callback) {
70
			this._manage_printer(printer,func,callback);
71
		}));
72
 	},
73
 	
74
 	startup: function() {
75
 		
76
 		this.inherited(arguments);
77
 		
78
 		this._switch_page('overview');
79
 	},
80
 	
81
 	_switch_page: function(name, args) {
82
 		
83
 		if ((args) && (typeof (this._pages[name].setArgs) == 'function'))
84
		{
85
			this._pages[name].setArgs(args);
86
		}
87
 		
88
 		this.selectChild(this._pages[name]);
89
 		
90
 	},
91
 	
92
 	// Most management functions can be called from overview or detail view, so we write
93
 	// the functions here.
94
 	_manage_printer: function(printer,func,callback) {
95
 		
96
 		var cmd = '';
97
 		var args = {};
98
 		switch(func)
99
 		{
100
 			case 'activate':
101
 				cmd = 'printers/enable';
102
 				args = { printer: printer, on: true };
103
 				break;
104
 			case 'deactivate':
105
 				cmd = 'printers/enable';
106
 				args = { printer: printer, on: false };
107
 				break;
108
 		}
109
 		if (cmd)
110
 		{
111
 			umc.tools.umcpCommand(cmd,args).then(
112
 				dojo.hitch(this, function(data) {
113
 					if (data.result.length)
114
 					{
115
 						callback(false,data.result);
116
 					}
117
 					else
118
 					{
119
 						callback(true);
120
 					}
121
 				}),
122
 				dojo.hitch(this, function(data) {
123
 					callback(false,data.result);
124
 				})
125
 			);
126
 		}
127
 	}
128
	
129
});
(-)umc/js/de.po (+208 lines)
Line 0    Link Here 
1
# This file is auto-generated by the dh-umc tools and should not be edited!
2
#, fuzzy
3
msgid ""
4
msgstr ""
5
"Project-Id-Version: univention-management-console-module-printers\n"
6
"Report-Msgid-Bugs-To: packages@univention.de\n"
7
"POT-Creation-Date: 2011-11-09 17:57+0100\n"
8
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
9
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
10
"Language-Team: LANGUAGE <LL@li.org>\n"
11
"Language: \n"
12
"MIME-Version: 1.0\n"
13
"Content-Type: text/plain; charset=UTF-8\n"
14
"Content-Transfer-Encoding: 8bit\n"
15
16
#: umc/js/_printers/DetailPage.js:59 umc/js/_printers/OverviewPage.js:133
17
msgid "Activate"
18
msgstr "Aktivieren"
19
20
#: umc/js/_printers/DetailPage.js:60
21
msgid "Activate this printer"
22
msgstr "diesen Drucker aktivieren"
23
24
#: umc/js/_printers/QuotaPage.js:88
25
msgid "Back"
26
msgstr "zurück"
27
28
#: umc/js/_printers/DetailPage.js:151
29
msgid "Back to overview"
30
msgstr "Zurück zur Übersicht"
31
32
#: umc/js/_printers/DetailPage.js:129
33
msgid "Cancel"
34
msgstr "Abbrechen"
35
36
#: umc/js/_printers/DetailPage.js:130
37
msgid "Cancel this job/these jobs"
38
msgstr "Diesen Druckauftrag (oder mehrere) abbrechen"
39
40
#: umc/js/_printers/QuotaPage.js:25
41
msgid "Current quota records for printer"
42
msgstr "Aktuelle Quota-Einträge für diesen Drucker"
43
44
#: umc/js/_printers/DetailPage.js:71 umc/js/_printers/OverviewPage.js:151
45
msgid "Deactivate"
46
msgstr "Deaktivieren"
47
48
#: umc/js/_printers/DetailPage.js:72
49
msgid "Deactivate this printer"
50
msgstr "diesen Drucker deaktivieren"
51
52
#: umc/js/_printers/DetailPage.js:232 umc/js/_printers/OverviewPage.js:53
53
#: umc/js/_printers/OverviewPage.js:118
54
msgid "Description"
55
msgstr "Beschreibung"
56
57
#: umc/js/_printers/DetailPage.js:222
58
msgid "Details for printer <b>{printer}</b>"
59
msgstr "Details für Drucker <b>{printer}</b>"
60
61
#: umc/js/_printers/QuotaPage.js:81
62
msgid "Edit"
63
msgstr ""
64
65
#: umc/js/_printers/DetailPage.js:83 umc/js/_printers/OverviewPage.js:169
66
msgid "Edit quota"
67
msgstr "Quota bearbeiten"
68
69
#: umc/js/_printers/DetailPage.js:84
70
msgid "Edit quota related to this printer"
71
msgstr "Quota-Einträge für diesen Drucker bearbeiten"
72
73
#: umc/js/_printers/QuotaPage.js:63
74
msgid "Hard limit"
75
msgstr "Hard limit"
76
77
#: umc/js/_printers/DetailPage.js:110
78
msgid "Job"
79
msgstr "Druckauftrag"
80
81
#: umc/js/_printers/QuotaPage.js:67
82
msgid "Lifetime page counter"
83
msgstr "Seitenzähler"
84
85
#: umc/js/_printers/DetailPage.js:231 umc/js/_printers/OverviewPage.js:54
86
#: umc/js/_printers/OverviewPage.js:114
87
msgid "Location"
88
msgstr "Ort"
89
90
#: umc/js/_printers/DetailPage.js:114
91
msgid "Owner"
92
msgstr "Eigentümer"
93
94
#: umc/js/_printers/QuotaPage.js:55
95
msgid "Pages used"
96
msgstr "gedruckte Seiten"
97
98
#: umc/js/_printers/OverviewPage.js:61
99
msgid "Pattern"
100
msgstr "Suchbegriff"
101
102
#: umc/js/_printers/OverviewPage.js:84
103
msgid "Printer"
104
msgstr "Drucker"
105
106
#: umc/js/_printers/OverviewPage.js:29 umc/js/_printers/OverviewPage.js:40
107
msgid "Printer administration"
108
msgstr "Druckerverwaltung"
109
110
#: umc/js/_printers/DetailPage.js:27 umc/js/_printers/DetailPage.js:38
111
msgid "Printer details"
112
msgstr "Druckerdetails"
113
114
#: umc/js/_printers/OverviewPage.js:52
115
msgid "Printer name"
116
msgstr "Druckername"
117
118
#: umc/js/_printers/QuotaPage.js:26 umc/js/_printers/QuotaPage.js:37
119
msgid "Printer quota"
120
msgstr "Druckername"
121
122
#: umc/js/_printers/DetailPage.js:229 umc/js/_printers/OverviewPage.js:103
123
msgid "Quota"
124
msgstr "Quota"
125
126
#: umc/js/_printers/QuotaPage.js:131
127
#, fuzzy
128
msgid "Quota entries for printer <b>{printer}</b>"
129
msgstr "Details für Drucker <b>{printer}</b>"
130
131
#: umc/js/_printers/QuotaPage.js:96
132
#, fuzzy
133
msgid "Refresh"
134
msgstr "Job-Liste aktualisieren"
135
136
#: umc/js/_printers/DetailPage.js:159
137
msgid "Refresh job list"
138
msgstr "Job-Liste aktualisieren"
139
140
#: umc/js/_printers/OverviewPage.js:180
141
msgid "Refresh printer list"
142
msgstr "Drucker-Liste aktualisieren"
143
144
#: umc/js/_printers/QuotaPage.js:74
145
msgid "Reset user quota"
146
msgstr "Quota für diesen Nutzer zurücksetzen"
147
148
#: umc/js/_printers/OverviewPage.js:50
149
msgid "Search key"
150
msgstr "Suchbegriff"
151
152
#: umc/js/_printers/DetailPage.js:224 umc/js/_printers/OverviewPage.js:80
153
msgid "Server"
154
msgstr "Server"
155
156
#: umc/js/_printers/DetailPage.js:118
157
msgid "Size"
158
msgstr "Größe"
159
160
#: umc/js/_printers/QuotaPage.js:59
161
msgid "Soft limit"
162
msgstr "Soft limit"
163
164
#: umc/js/_printers/DetailPage.js:225 umc/js/_printers/OverviewPage.js:88
165
msgid "Status"
166
msgstr "Status"
167
168
#: umc/js/_printers/DetailPage.js:122
169
msgid "Submitted at"
170
msgstr "beauftragt"
171
172
#: umc/js/_printers/OverviewPage.js:28
173
msgid "This module lets you manage the printers defined on your machine"
174
msgstr ""
175
"In diesem Modul können Sie die Drucker verwalten, die auf Ihrer Maschine "
176
"definiert sind."
177
178
#: umc/js/_printers/QuotaPage.js:51
179
msgid "User"
180
msgstr "Nutzer"
181
182
#: umc/js/_printers/OverviewPage.js:125
183
msgid "View details"
184
msgstr "Details ansehen"
185
186
#: umc/js/_printers/DetailPage.js:26
187
msgid ""
188
"You see the details of this printer and its print jobs. You can activate/"
189
"deactivate the printer, edit its quota definitions if quota is enabled, and "
190
"cancel print jobs."
191
msgstr ""
192
"Sie sehen die Details des Druckers sowie seine aktuellen Druckaufträge. Sie "
193
"können den Drucker aktivieren/deaktivieren, Quota-Einträge verwalten und "
194
"Druckaufträge abbrechen."
195
196
#: umc/js/_printers/DetailPage.js:218 umc/js/_printers/DetailPage.js:229
197
#: umc/js/_printers/OverviewPage.js:95 umc/js/_printers/OverviewPage.js:107
198
msgid "active"
199
msgstr "aktiv"
200
201
#: umc/js/_printers/DetailPage.js:219 umc/js/_printers/OverviewPage.js:96
202
#: umc/js/_printers/OverviewPage.js:109
203
msgid "inactive"
204
msgstr "inaktiv"
205
206
#: umc/js/_printers/DetailPage.js:215 umc/js/_printers/OverviewPage.js:98
207
msgid "unknown"
208
msgstr "unbekannt"
(-)umc/js/_printers/QuotaPage.js (+140 lines)
Line 0    Link Here 
1
/*global console MyError dojo dojox dijit umc */
2
3
dojo.provide("umc.modules._printers.QuotaPage");
4
5
dojo.require("umc.i18n");
6
dojo.require("umc.dialog");
7
dojo.require("umc.store");
8
dojo.require("umc.tools");
9
10
dojo.require("umc.widgets.Page");
11
dojo.require("umc.widgets.Grid");
12
dojo.require("umc.widgets.Form");
13
14
dojo.declare("umc.modules._printers.QuotaPage",
15
[
16
	umc.widgets.Page,
17
	umc.i18n.Mixin
18
], {
19
20
	i18nClass:              'umc.modules.printers',
21
	
22
	postMixInProperties: function() {
23
		
24
		dojo.mixin(this,{
25
			helpText:		this._("Current quota records for printer"),
26
			headerText:		this._("Printer quota")
27
		});
28
		
29
		this.inherited(arguments);
30
	},
31
32
    buildRendering: function() {
33
34
        this.inherited(arguments);
35
36
        var pane = new umc.widgets.ExpandingTitlePane({
37
        	title:				this._("Printer quota")
38
        });
39
        this.addChild(pane);
40
        
41
        this._head = new umc.widgets.Text({
42
        	region:			'top',
43
        	content:		'',
44
        	style:			'padding-bottom:1em;font-size:115%;'
45
        });
46
        pane.addChild(this._head);
47
        
48
        var columns = [
49
			{
50
				name:		'user',
51
				label:		this._("User")
52
			},
53
			{
54
				name:		'used',
55
				label:		this._("Pages used")
56
			},
57
			{
58
				name:		'soft',
59
				label:		this._("Soft limit")
60
			},
61
			{
62
				name:		'hard',
63
				label:		this._("Hard limit")
64
			},
65
			{
66
				name:		'total',
67
				label:		this._("Lifetime page counter")
68
			}
69
        ];
70
        
71
        var actions = [
72
			{
73
				name:				'clear',
74
				label:				this._("Reset user quota"),
75
				callback: dojo.hitch(this, function(ids) {
76
					// TODO do something useful here
77
				})
78
			},
79
			{
80
				name:				'edit',
81
				label:				this._("Edit"),
82
				callback: dojo.hitch(this, function(ids) {
83
					// TODO do something useful here
84
				})
85
			},
86
			{
87
				name:				'back',
88
				label:				this._("Back"),
89
				isContextAction:	false,
90
				callback: dojo.hitch(this, function() {
91
					this.closeQuota();
92
				})
93
			},
94
			{
95
				name:				'refresh',
96
				label:				this._("Refresh"),
97
				isContextAction:	false,
98
				callback: dojo.hitch(this, function() {
99
					this._refresh_view();
100
				})
101
			}
102
        ];
103
        
104
        this._grid = new umc.widgets.Grid({
105
        	region:			'center',
106
        	columns:		columns,
107
        	actions:		actions,
108
        	moduleStore:	umc.store.getModuleStore('user','printers/quota')
109
        });
110
        pane.addChild(this._grid);
111
        
112
	},
113
    
114
	// Calling page passes args here. Arg is here the printer ID.
115
	setArgs: function(args) {
116
		
117
		this._printer_id = args;
118
		this._refresh_view();
119
	},
120
	
121
	onHide: function() {
122
		// force clean state
123
		this._head.set('content','');		// clear header text
124
		this._grid.filter();				// clear grid data
125
	},
126
	
127
	// called when the page is shown, but can equally be called
128
	// on a manual or automatic refresh.
129
	_refresh_view: function() {
130
		
131
		this._head.set('content',dojo.replace(this._("Quota entries for printer <b>{printer}</b>"),{printer:this._printer_id}));
132
		
133
		// read current quota list
134
		this._grid.filter({printer:this._printer_id});
135
	},
136
	
137
    // main module listens here to return to the detail page
138
    closeQuota: function(args) {
139
    }
140
});
(-)umc/js/_printers/DetailPage.js (+297 lines)
Line 0    Link Here 
1
/*global console MyError dojo dojox dijit umc */
2
3
dojo.provide("umc.modules._printers.DetailPage");
4
5
dojo.require("umc.i18n");
6
dojo.require("umc.dialog");
7
dojo.require("umc.store");
8
dojo.require("umc.tools");
9
10
dojo.require("umc.widgets.Page");
11
dojo.require("umc.widgets.Grid");
12
dojo.require("umc.widgets.Form");
13
14
dojo.declare("umc.modules._printers.DetailPage",
15
[
16
	umc.widgets.Page,
17
	umc.i18n.Mixin
18
], {
19
20
	i18nClass:              'umc.modules.printers',
21
	_printer_id:			'',
22
	
23
	postMixInProperties: function() {
24
		
25
		dojo.mixin(this,{
26
			helpText:		this._("You see the details of this printer and its print jobs. You can activate/deactivate the printer, edit its quota definitions if quota is enabled, and cancel print jobs."),
27
			headerText:		this._("Printer details")
28
		});
29
		
30
		this.inherited(arguments);
31
	},
32
33
    buildRendering: function() {
34
35
        this.inherited(arguments);
36
37
        var pane = new umc.widgets.ExpandingTitlePane({
38
        	title:				this._("Printer details")
39
        });
40
        this.addChild(pane);
41
        
42
        var f_widgets = [
43
			{
44
				name:				'message',
45
				type:				'Text',
46
				content:			'<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;',
47
				style:				'padding-bottom:.5em;'		// force bottom distance to the buttons
48
			}
49
        ];
50
        
51
        var f_layout = [
52
	        [ 'message' ],
53
	        [ 'activate', 'deactivate', 'editquota', 'submit' ]
54
        ];
55
        
56
        var f_buttons = [
57
			{
58
				name:		'activate',
59
				label:		this._("Activate"),
60
				title:		this._("Activate this printer"),
61
				onClick:	dojo.hitch(this, function() {
62
					this.managePrinter(this._printer_id,'activate',
63
						dojo.hitch(this, function(success,message) {
64
							this._manage_callback(success,message);
65
						})
66
					);
67
				})
68
			},
69
			{
70
				name:		'deactivate',
71
				label:		this._("Deactivate"),
72
				title:		this._("Deactivate this printer"),
73
				onClick:	dojo.hitch(this, function() {
74
					this.managePrinter(this._printer_id,'deactivate',
75
						dojo.hitch(this, function(success,message) {
76
							this._manage_callback(success,message);
77
						})
78
					);
79
				})
80
			},
81
			{
82
				name:		'editquota',
83
				label:		this._("Edit quota"),
84
				title:		this._("Edit quota related to this printer"),
85
				onClick:	dojo.hitch(this, function() {
86
					this.editQuota(this._printer_id);
87
				})
88
			},
89
			// only to stop the Form class from adding a hidden submit button into
90
			// an additional row, thus mangling my layout...
91
			{
92
				name:		'submit',
93
				label:		'nothing'
94
			}
95
		];
96
        
97
        // we make this a form so we can add buttons 
98
        this._head = new umc.widgets.Form({
99
        	region:			'top',
100
        	widgets:		f_widgets,
101
        	buttons:		f_buttons,
102
        	layout:			f_layout,
103
        	onSubmit:		function() {}		// don't want to have any kind of submit here!
104
        });
105
        pane.addChild(this._head);
106
        
107
        var columns = [
108
		   {
109
			   name:		'job',
110
			   label:		this._("Job")
111
		   },
112
		   {
113
			   name:		'owner',
114
			   label:		this._("Owner")
115
		   },
116
		   {
117
			   name:		'size',
118
			   label:		this._("Size")
119
		   },
120
		   {
121
			   name:		'date',
122
			   label:		this._("Submitted at")
123
		   }
124
        ];
125
        
126
        var actions = [
127
			{
128
				name:				'cancel',
129
				label:				this._("Cancel"),
130
				title:				this._("Cancel this job/these jobs"),
131
				isMultiAction:		true,
132
				isStandardAction:	true,
133
				callback: dojo.hitch(this, function(ids) {
134
					umc.tools.umcpCommand('printers/jobs/cancel',{jobs: ids, printer:this._printer_id}).then(
135
						dojo.hitch(this,function(data) {
136
							if (data.result)
137
							{
138
								umc.dialog.alert(data.result);
139
							}
140
							this._refresh_view();
141
						}),
142
						dojo.hitch(this,function(data) {
143
							umc.tools.alert(data.message);
144
							this._refresh_view();
145
						})
146
					);
147
				})
148
			},
149
			{
150
				name:				'back',
151
				label:				this._("Back to overview"),
152
				isContextAction:	false,
153
				callback: dojo.hitch(this, function() {
154
	        		this.closeDetail();
155
	        	})
156
			},
157
			{
158
				name:				'refresh',
159
				label:				this._("Refresh job list"),
160
				isContextAction:	false,
161
	        	callback: dojo.hitch(this, function() {
162
	        		this._refresh_view();
163
	        	})
164
			}
165
        ];
166
        
167
        this._grid = new umc.widgets.Grid({
168
        	region:			'center',
169
        	columns:		columns,
170
        	actions:		actions,
171
        	moduleStore:	umc.store.getModuleStore('job','printers/jobs')
172
        });
173
        pane.addChild(this._grid);
174
                
175
	},
176
    
177
	// Overview page passes args here. Arg is here the printer ID.
178
	setArgs: function(args) {
179
		
180
		this._printer_id = args;				
181
		this._refresh_view();
182
	},
183
	
184
	// no matter where we came from: if the page is to be shown we
185
	// have to refresh all data elements.
186
	onShow: function() {
187
		this._refresh_view();
188
	},
189
	
190
	// called when the page is shown, but can equally be called
191
	// on a manual or automatic refresh.
192
	_refresh_view: function() {
193
		
194
		// if the function is called before setArgs has given us a valid printer name
195
		// then we should simply do nothing.
196
		if (! this._printer_id)
197
		{
198
			return;
199
		}
200
		
201
		umc.tools.umcpCommand('printers/get',{printer:this._printer_id}).then(
202
			dojo.hitch(this, function(data) {
203
				
204
				// Yes I know, I should have this done by the layout capabilities of
205
				// the Form class... but given the fact that this is only an informative
206
				// overview message I've decided to wrap it into a single 'Text' element,
207
				// containing a <p>..</p> and a <table>.
208
				var res = data.result;
209
				// styles
210
				var st_h = 'font-size:115%;text-decoration:underline;';	// header line
211
				var st_l = 'text-align:right;padding-left:1em;';		// left column
212
				var st_r = 'padding-left:.5em;';						// right column
213
				
214
				// status text must be translated in our official wording...
215
				var status = this._("unknown");
216
				switch(res['status'])
217
				{
218
					case 'enabled': status = this._("active"); break;
219
					case 'disabled':status = this._("inactive"); break;
220
				}
221
				
222
				var txt = "<p style='" + st_h + "'>" + dojo.replace(this._("Details for printer <b>{printer}</b>"),res) + '</p>';
223
				txt += "<table>\n";
224
				txt += "<tr><td style='" + st_l + "'>" + this._("Server")		+ ":</td><td style='" + st_r + "'>" + res['server']			+ "</td></tr>\n";
225
				txt += "<tr><td style='" + st_l + "'>" + this._("Status")		+ ":</td><td style='" + st_r + "'>" + status				+ "</td></tr>\n";
226
				// show this only if quota is enabled
227
				if (res['quota'])
228
				{
229
					txt += "<tr><td style='" + st_l + "'>" + this._("Quota")		+ ":</td><td style='" + st_r + "'>" + this._("active")		+ "</td></tr>\n";
230
				}
231
				txt += "<tr><td style='" + st_l + "'>" + this._("Location")		+ ":</td><td style='" + st_r + "'>" + res['location']		+ "</td></tr>\n";
232
				txt += "<tr><td style='" + st_l + "'>" + this._("Description")	+ ":</td><td style='" + st_r + "'>" + res['description']	+ "</td></tr>\n";
233
				txt += "</table>\n";
234
				
235
				this._head.getWidget('message').set('content',txt);
236
				
237
				// show/hide corresponding buttons
238
				
239
				this._show_button('activate',res['status'] == 'disabled');
240
				this._show_button('deactivate',res['status'] == 'enabled');
241
				this._show_button('editquota',res['quota']);
242
				this._show_button('submit',false);			// always invisible.
243
				
244
				this.layout();		// whenever you change a non-center region of a BorderLayout...
245
			}),
246
			dojo.hitch(this, function(data) {
247
				this._grid.filter();		// clears stale grid data
248
			})
249
		);
250
		
251
		// read job list
252
		this._grid.filter({printer:this._printer_id});
253
	},
254
	
255
	_show_button: function(button,on) {
256
		
257
		try
258
		{
259
			dojo.toggleClass(this._head._buttons[button].domNode,'dijitHidden',!on);
260
		}
261
		catch(ex)
262
		{
263
			console.error("show_button(" + button + "," + on + "): " + ex.message);
264
		}
265
	},
266
	
267
    _manage_callback: function(success,message) {
268
    	
269
    	if (success)
270
    	{
271
    		this._refresh_view();
272
    	}
273
    	else
274
    	{
275
    		umc.dialog.alert(message);
276
    	}
277
    },
278
    
279
	// main module listens here, to carry out direct printer
280
	// management functions.
281
	managePrinter: function(printer,func,arg) {
282
	},
283
	
284
    // main module listens here to return to the overview.
285
	// args are passed back to the Overview page.
286
    closeDetail: function(args) {
287
		// force clean state
288
		this._head.getWidget('message').set('content','<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;');		// six empty lines
289
		this._grid.filter();
290
    },
291
    
292
    // main module listens here to open the quota page.
293
    editQuota: function(args) {
294
    }
295
296
    
297
});
(-)umc/js/_printers/OverviewPage.js (+252 lines)
Line 0    Link Here 
1
/*global console MyError dojo dojox dijit umc */
2
3
dojo.provide("umc.modules._printers.OverviewPage");
4
5
dojo.require("umc.i18n");
6
dojo.require("umc.dialog");
7
dojo.require("umc.tools");
8
dojo.require("umc.store");
9
10
dojo.require("umc.widgets.Page");
11
dojo.require("umc.widgets.Grid");
12
dojo.require("umc.widgets.Form");
13
dojo.require("umc.widgets.SearchForm");
14
dojo.require("umc.widgets.ExpandingTitlePane");
15
16
dojo.declare("umc.modules._printers.OverviewPage",
17
[
18
	umc.widgets.Page,
19
	umc.i18n.Mixin
20
], {
21
22
	i18nClass:              'umc.modules.printers',
23
	_last_filter:			{ key: 'printer', pattern: '*' },
24
	
25
	postMixInProperties: function() {
26
		
27
		dojo.mixin(this,{
28
            helpText:		this._("This module lets you manage the printers defined on your machine"),
29
            headerText:		this._("Printer administration")
30
		});
31
		
32
		this.inherited(arguments);
33
	},
34
35
    buildRendering: function() {
36
37
        this.inherited(arguments);
38
        
39
        var pane = new umc.widgets.ExpandingTitlePane({
40
        	title:				this._("Printer administration")
41
        });
42
        this.addChild(pane);
43
        
44
        this._form = new umc.widgets.SearchForm({
45
        	region:					'top',
46
        	widgets: [
47
	          {
48
	        	  name:				'key',
49
	        	  type:				'ComboBox',
50
	        	  label:			this._("Search key"),
51
	        	  staticValues: [
52
					 { id: 'printer',		label: this._("Printer name")},
53
					 { id: 'description',	label: this._("Description")},
54
					 { id: 'location',		label: this._("Location") }
55
	        	  ],
56
	        	  sortStaticValues:	false
57
	          },
58
	          {
59
	        	  name:				'pattern',
60
	        	  type:				'TextBox',
61
	        	  label:			this._("Pattern"),
62
	        	  value:			'*'
63
	          }
64
        	],
65
        	layout: [
66
        	   [ 'key', 'pattern', 'submit' ]
67
        	],
68
        	onSearch: dojo.hitch(this, function(values) {
69
        		this._enable_search_button(false);
70
        		this._last_filter = values;			// save for easy refresh
71
        		this._grid.filter(values);
72
        	})
73
        });        
74
        this._enable_search_button(false);
75
        pane.addChild(this._form);
76
        
77
        var columns =  [
78
			{
79
				name:		'server',
80
				label:		this._("Server")
81
			},
82
			{
83
				name:		'printer',
84
				label:		this._("Printer")
85
			},
86
			{
87
				name:		'status',
88
				label:		this._("Status"),
89
				// 'enabled'/'disabled' are kind of keywords, just as they're returned
90
				// from cups if invoked without locale (LANG=C).
91
				// Our wording for this is 'active'/'inactive'.
92
				formatter:	dojo.hitch(this,function(value) {
93
					switch(value)
94
					{
95
						case 'enabled': 	return this._("active");
96
						case 'disabled':	return this._("inactive");
97
					}
98
					return this._("unknown");
99
				})
100
			},
101
			{
102
				name:		'quota',
103
				label:		this._("Quota"),
104
				formatter:	dojo.hitch(this,function(value) {
105
					if (value)		// only true or false?
106
					{
107
						return this._("active");
108
					}
109
					return this._("inactive");
110
				})
111
			},
112
			{
113
				name:		'location',
114
				label:		this._("Location")
115
			},
116
			{
117
				name:		'description',
118
				label:		this._("Description")
119
			}
120
		];
121
        
122
        var actions = [
123
			{
124
				name:		'open',
125
				label:		this._("View details"),
126
				callback:	dojo.hitch(this,function(id,values) {
127
					// 2.4 uses the printer ID as key property, so we do that as well.
128
					this.openDetail(id[0]);
129
				})
130
			},
131
			{
132
				name:		'activate',
133
				label:		this._("Activate"),
134
				callback:	dojo.hitch(this, function(ids) {
135
					// no multi action for now, but who knows...
136
					for (var p in ids)
137
					{
138
						this.managePrinter(ids[p],'activate',
139
							dojo.hitch(this, function(success,message) {
140
								this._manage_callback(success,message);
141
							})
142
						);
143
					}
144
				}),
145
				canExecute: dojo.hitch(this, function(values) {
146
					return (values['status'] == 'disabled');
147
				})
148
			},
149
			{
150
				name:		'deactivate',
151
				label:		this._("Deactivate"),
152
				callback:	dojo.hitch(this, function(ids) {
153
					// no multi action for now, but who knows...
154
					for (var p in ids)
155
					{
156
						this.managePrinter(ids[p],'deactivate',
157
							dojo.hitch(this, function(success,message) {
158
								this._manage_callback(success,message);
159
							})
160
						);
161
					}
162
				}),
163
				canExecute: dojo.hitch(this, function(values) {
164
					return (values['status'] == 'enabled');
165
				})
166
			},
167
			{
168
				name:				'editquota',
169
				label:				this._("Edit quota"),
170
				isStandardAction:	false,
171
				callback:	dojo.hitch(this,function(ids) {
172
					this.editQuota(ids[0]);
173
				}),
174
				canExecute:	dojo.hitch(this,function(values) {
175
					return (values['quota']);	// true or false
176
				})
177
			},
178
			{
179
				name:				'refresh',
180
				label:				this._("Refresh printer list"),
181
				isContextAction:	false,
182
				callback: dojo.hitch(this, function() {
183
					this._refresh_view();
184
				})
185
			}
186
	    ];
187
188
        this._grid = new umc.widgets.Grid({
189
        	columns:			columns,
190
        	region:				'center',
191
        	actions:			actions,
192
        	defaultAction:		'open',
193
            moduleStore:		umc.store.getModuleStore('printer','printers'),
194
            // fill grid on first open
195
            query:				{key:'printer', pattern: '*'},
196
            onFilterDone: dojo.hitch(this, function(success) {
197
        		this._enable_search_button(true);
198
            })
199
        });
200
        pane.addChild(this._grid);
201
        
202
        
203
    },
204
    
205
    _enable_search_button: function(on) {
206
    	this._form._buttons['submit'].setDisabled(! on);
207
    },
208
    
209
    // refreshes the grid. can be called manually (pressing the refresh button)
210
    // or automatically (as response to the managePrinter() result)
211
    _refresh_view: function() {
212
		this._grid.filter(this._last_filter);
213
    },
214
    
215
    // will be called with the result of 'managePrinter'
216
    _manage_callback: function(success,message) {
217
    	
218
    	if (success)
219
    	{
220
    		this._refresh_view();
221
    	}
222
    	else
223
    	{
224
    		umc.dialog.alert(message);
225
    	}
226
    },
227
    
228
    // when we come back from any kind of detail view that
229
    // could have invoked some actions... refresh our view.
230
    onShow: function() {
231
    	this._refresh_view();
232
    },
233
    
234
    // DetailPage gives results back here.
235
	setArgs: function(args) {
236
	},
237
	
238
	// main module listens here, to carry out direct printer
239
	// management functions.
240
	managePrinter: function(printer,func,callback) {
241
	},
242
	
243
	// main module listens here, to switch to the detail view.
244
	// args can propagate the id of the printer to show
245
	openDetail: function(args) {
246
	},
247
	
248
    // main module listens here to open the quota page.
249
    editQuota: function(args) {
250
    }
251
252
});

Return to bug 22902