View | Details | Raw Unified | Return to bug 44009
Collapse All | Expand All

(-)a/management/univention-management-console-module-udm/umc/js/udm/TileView.js (-24 / +3 lines)
 Lines 26-32    Link Here 
26
 * /usr/share/common-licenses/AGPL-3; if not, see
26
 * /usr/share/common-licenses/AGPL-3; if not, see
27
 * <http://www.gnu.org/licenses/>.
27
 * <http://www.gnu.org/licenses/>.
28
 */
28
 */
29
/*global define, window*/
29
/*global define*/
30
30
31
define([
31
define([
32
	"dojo/_base/declare",
32
	"dojo/_base/declare",
 Lines 42-75   define([ Link Here 
42
42
43
		necessaryUdmValues: ["displayName", "mailPrimaryAddress", "firstname", "lastname"], 
43
		necessaryUdmValues: ["displayName", "mailPrimaryAddress", "firstname", "lastname"], 
44
44
45
		_queryTimer: null,
46
47
		_queryCache: null,
48
49
		_userImageNodes: {},
45
		_userImageNodes: {},
50
46
51
		grid: null,
47
		grid: null,
52
48
53
		setPicture: function(item) {
49
		setPicture: function(item) {
54
			if (this._queryTimer) {
50
			var url = lang.replace('/univention/command/udm/properties/users/user/jpegPhoto.jpg?dn={0}', [encodeURIComponent(item.$dn$)]);
55
				this.grid.moduleStore.get(item.$dn$);
51
			put(this._userImageNodes[item.$dn$], {style: lang.replace('background-image: url("{0}")', [url])});
56
			} else {
57
				this._queryCache = this.grid.moduleStore.transaction();
58
				this._queryTimer = window.setTimeout(lang.hitch(this, "_setPictures"), 100);
59
				this.grid.moduleStore.get(item.$dn$);
60
			}
61
		},
62
63
		_setPictures: function() {
64
			this._queryTimer = null;
65
			this._queryCache.commit().then(lang.hitch(this, function(data) {
66
				array.forEach(data, function(item){
67
					if (item.jpegPhoto) {
68
						//put(this._userImageNodes[item.$dn$], "+img.umcGridTileIcon[src=data:image/jpeg;base64," + item.jpegPhoto + "]");
69
						put(this._userImageNodes[item.$dn$], "+div.umcGridTileIcon[style=background-image: url(data:image/jpeg;base64," + item.jpegPhoto + ")]");
70
					}
71
				}, this);
72
			}));
73
		},
52
		},
74
53
75
		_getInitials: function(item) {
54
		_getInitials: function(item) {
(-)a/management/univention-management-console-module-udm/umc/python/udm/__init__.py (+25 lines)
 Lines 544-549   class Instance(Base, ProgressMixin): Link Here 
544
					MODULE.process('The LDAP object for the LDAP DN %s could not be found' % ldap_dn)
544
					MODULE.process('The LDAP object for the LDAP DN %s could not be found' % ldap_dn)
545
		return result
545
		return result
546
546
547
	@allow_get_request
548
	@sanitize(dn=DNSanitizer(required=True))
549
	def jpeg_photo(self, request):
550
		thread = notifier.threads.Simple('GetJpeg', notifier.Callback(self._get_jpeg_photo, request), notifier.Callback(self.thread_finished_callback, request))
551
		thread.run()
552
553
	def _get_jpeg_photo(self, request):
554
		dn = request.options['dn']
555
		module = get_module('users/user', dn)
556
		if module is None:
557
			self.finished(request.id, '', mimetype='image/jpeg')
558
			return
559
		obj = module.get(dn)
560
		if obj is None:
561
			self.finished(request.id, '', mimetype='image/jpeg')
562
			return
563
		data = obj.info.get('jpegPhoto', '').decode('base64')  # TODO: scale down to 50x50px
564
		headers = {
565
			# 'Last-Modified': obj.info['modifyTimestamp'] # TODO: enable for users/user
566
			# 'ETag': '' : TODO generate
567
			'Cache-Control': 'max-age=2592000',
568
			#'Expires': '',
569
		}
570
		self.finished(request.id, data, mimetype='image/jpeg', headers=headers)
571
547
	@sanitize(
572
	@sanitize(
548
		objectPropertyValue=PropertySearchSanitizer(
573
		objectPropertyValue=PropertySearchSanitizer(
549
			add_asterisks=ADD_ASTERISKS,
574
			add_asterisks=ADD_ASTERISKS,
(-)a/management/univention-management-console-module-udm/umc/udm.xml (+1 lines)
 Lines 317-321    Link Here 
317
		<command name="udm/reports/get" function="reports_get" />
317
		<command name="udm/reports/get" function="reports_get" />
318
		<command name="udm/request_new_license" function="request_new_license" />
318
		<command name="udm/request_new_license" function="request_new_license" />
319
		<command name="udm/meta_info" function="meta_info" />
319
		<command name="udm/meta_info" function="meta_info" />
320
		<command name="udm/properties/users/user/jpegPhoto.jpg" function="jpeg_photo" />
320
	</module>
321
	</module>
321
</umc>
322
</umc>

Return to bug 44009