PageSourceSearch

https://zbcollections.ch/home/_270/core/directives/cmiUserInformation.js

js zbcollections.ch collected 2026-10-02 19:56:35 UTC 5,407 bytes, 151 lines download raw bytes

1(function () {
2    "use strict";
3
4    var CORE = app.core;
5
6    function Controller(_core, $rootScope, $scope, appEvents, settingsService, securityService, contentService, offlineModeService, navigationService, uiService, cmiUtilities) {
7        var _content = contentService,
8            _nav = navigationService,
9            _settings = _core.bindService(app.current,Controller,arguments,"settingsService"),
10            _url = _core.bindService(app.current,Controller,arguments,"urlBuilderService"),
11            _util = cmiUtilities;
12
13        function getUserInfo() {
14            var addSessionName = false,
15                session = securityService.getActiveSession(),
16                vorname = _settings.getUserSetting("user.Vorname"),
17                nachname = _settings.getUserSetting("user.Name") || _settings.getUserSetting("user.Nachname"),
18                info = "",
19                name;
20
21            if (_.isObject(session)) {
22                addSessionName = ($scope.sessionCount > 1);
23                info = session.username;
24            }
25            if (!_.isEmpty(vorname) && !_.isEmpty(nachname)) {
26                name = _util.addToString(vorname, " ", nachname);
27            }
28            if (_util.isNullOrWhitespace(name)) {
29                name = _settings.getUserSetting("user.BenutzerID");
30            }
31            info = name || info;
32            if (addSessionName) {
33                info = session.name + " - " + info;
34            }
35            return info;
36        }
37
38        function refresh() {
39            var isOffline = offlineModeService.isOffline(),
40                loggedIn,
41                languages,
42                supported;
43
44            $scope.sessionCount = $scope.getSessions().length;
45            loggedIn = $scope.isLoggedIn = securityService.isLoggedIn();
46            $scope.userInfo = getUserInfo();
47
48            var items = $scope.items = _url.getUserMenuItems();
49
50            $scope.supportsFavorites = _settings.supportsFavorites();
51            $scope.supportsHistory = _settings.supportsHistory();
52
53            $scope.supportsAccount = _settings.supportsAccount();
54            $scope.allowChangePassword = loggedIn && !isOffline && _settings.allowChangePassword();
55            $scope.allowMultiSessions = loggedIn && !isOffline && securityService.allowMultiSessions();
56
57            languages = _settings.getLanguages();
58            supported = $scope.supportedLanguages = languages.supports;
59            $scope.supportsLanguages = (supported.length > 1);
60
61            $scope.hasDropDown = true;
62            $scope.showReload = !(!securityService.allowOfflineData() && $rootScope.isOffline());
63        }
64
65        $scope.getSessions = securityService.getSessions;
66        $scope.getActiveSession = securityService.getActiveSession;
67        $scope.isNotActiveSession = function (session) {
68            return session !== $scope.getActiveSession();
69        };
70
71        $scope.showReload = false;
72
73        $scope.showSettings = settingsService.showSettings;
74
75        $scope.doLogout = function () {
76            $scope.goLogout();
77            // TODO STS: remove
78            //$scope.showDropDown = false;
79            //securityService.doLogout();
80        };
81
82        $scope.toggleDropDown = function () {
83            $scope.showDropDown = $scope.hasDropDown && !$scope.showDropDown;
84            if ($scope.showDropDown) {
85                $rootScope.$broadcast(appEvents.ui.closeDropDown, $scope);
86            }
87        };
88
89        $scope.switchSession = function (sessionId) {
90            var unblock = uiService.blockPage();
91            securityService.switchSession(sessionId).finally(unblock);
92            _nav.go("/");
93        };
94
95        $scope.goLogin = function () {
96            _nav.goAccount(_nav.routes.account.login);
97        };
98
99        $scope.goLogout = function () {
100            _nav.goAccount(_nav.routes.account.logout);
101        };
102
103        $scope.goSettings = function () {
104            _nav.go(_nav.routes.settings);
105        };
106
107        $scope.doReload = function () {
108            _content.alertIfDirty(function() {
109                location.reload();
110            });
111        };
112
113        $scope.goChangePassword = function () {
114            _nav.goAccount(_nav.routes.account.changePassword);
115        };
116
117        $scope.goFavorites = function () {
118            _nav.go(_nav.routes.favorites);
119        };
120        $scope.goHistory = function () {
121            _nav.go(_nav.routes.history);
122        };
123
124        // init & events
125        $scope.$on(appEvents.session.loggedIn, refresh);
126        $scope.$on(appEvents.session.loggedOut, refresh);
127        $scope.$on(appEvents.app.settingsLoaded, refresh);
128        $scope.$on(appEvents.app.userSettingsLoaded, refresh);
129        $scope.$on(offlineModeService.events.modeChanged, refresh);
130        
131        $scope.$on(appEvents.ui.closeDropDown, function (evt, except) {
132            if (except !== $scope) {
133                $scope.showDropDown = false;
134            }
135        });
136        $scope.$on('$routeChangeSuccess', function () {
137            $scope.showDropDown = false;
138            refresh();
139        });
140        refresh();
141    }
142
143    CORE.module.directive("cmiUserInformation", function () {
144        return {
145            restrict: "A",
146            replace: true,
147            templateUrl: CORE.path + "directives/cmiUserInformation.html",
148            controller: Controller
149        };
150    });
151}());

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.