add user avatar to header
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function AppHeaderDirective(eventsService, appState) {
|
||||
function AppHeaderDirective(eventsService, appState, userService) {
|
||||
|
||||
function link(scope, el, attr, ctrl) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// the null is important because we do an explicit bool check on this in the view
|
||||
// the avatar is by default the umbraco logo
|
||||
scope.authenticated = null;
|
||||
scope.user = null;
|
||||
scope.avatar = [
|
||||
{ value: "assets/img/application/logo.png" },
|
||||
{ value: "assets/img/application/logo@2x.png" },
|
||||
@@ -19,11 +20,39 @@
|
||||
// when a user logs out or timesout
|
||||
evts.push(eventsService.on("app.notAuthenticated", function() {
|
||||
scope.authenticated = false;
|
||||
scope.user = null;
|
||||
}));
|
||||
|
||||
// when the application is ready and the user is authorized setup the data
|
||||
evts.push(eventsService.on("app.ready", function(evt, data) {
|
||||
|
||||
scope.authenticated = true;
|
||||
scope.user = data.user;
|
||||
|
||||
if (scope.user.avatars) {
|
||||
scope.avatar = [];
|
||||
if (angular.isArray(scope.user.avatars)) {
|
||||
for (var i = 0; i < scope.user.avatars.length; i++) {
|
||||
scope.avatar.push({ value: scope.user.avatars[i] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
evts.push(eventsService.on("app.userRefresh", function(evt) {
|
||||
userService.refreshCurrentUser().then(function(data) {
|
||||
scope.user = data;
|
||||
|
||||
if (scope.user.avatars) {
|
||||
scope.avatar = [];
|
||||
if (angular.isArray(scope.user.avatars)) {
|
||||
for (var i = 0; i < scope.user.avatars.length; i++) {
|
||||
scope.avatar.push({ value: scope.user.avatars[i] });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
// toggle the help dialog by raising the global app state to toggle the help drawer
|
||||
|
||||
@@ -56,15 +56,6 @@ function MainController($scope, $rootScope, $location, $routeParams, $timeout, $
|
||||
if ($scope.user.locale) {
|
||||
tmhDynamicLocale.set($scope.user.locale);
|
||||
}
|
||||
|
||||
if ($scope.user.avatars) {
|
||||
$scope.avatar = [];
|
||||
if (angular.isArray($scope.user.avatars)) {
|
||||
for (var i = 0; i < $scope.user.avatars.length; i++) {
|
||||
$scope.avatar.push({ value: $scope.user.avatars[i] });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
@@ -110,16 +101,6 @@ function MainController($scope, $rootScope, $location, $routeParams, $timeout, $
|
||||
tmhDynamicLocale.set($scope.user.locale);
|
||||
}
|
||||
|
||||
if ($scope.user.avatars) {
|
||||
|
||||
$scope.avatar = [];
|
||||
if (angular.isArray($scope.user.avatars)) {
|
||||
for (var i = 0; i < $scope.user.avatars.length; i++) {
|
||||
$scope.avatar.push({ value: $scope.user.avatars[i] });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
evts.push(eventsService.on("app.ysod", function (name, error) {
|
||||
|
||||
Reference in New Issue
Block a user