Commit 58d0e336 authored by Andreas Gärtner's avatar Andreas Gärtner

Task #15739: Feature: Add possibility to change role without log out.

parent 7be47984
......@@ -148,6 +148,35 @@ Ext.define("ARSnova.controller.Auth", {
}
},
changeRole: function (role) {
console.debug("Controller: Auth.changeRole", role);
var mainTabPanel = ARSnova.app.mainTabPanel.tabPanel;
var hTP = mainTabPanel.homeTabPanel;
ARSnova.app.userRole =
role === ARSnova.app.USER_ROLE_STUDENT ||
role === ARSnova.app.USER_ROLE_SPEAKER ?
role : ARSnova.app.userRole;
switch (ARSnova.app.userRole) {
case ARSnova.app.USER_ROLE_STUDENT:
hTP.homePanel.checkLogin();
hTP.animateActiveItem(hTP.homePanel, {
type: 'flip',
direction: 'left'
});
break;
case ARSnova.app.USER_ROLE_SPEAKER:
hTP.animateActiveItem(hTP.mySessionsPanel, {
type: 'flip',
direction: 'right'
});
break;
}
localStorage.setItem('role', ARSnova.app.userRole);
},
checkLogin: function () {
console.debug("Controller: Auth.checkLogin");
var promise = new RSVP.Promise();
......
......@@ -45,22 +45,43 @@ Ext.define('ARSnova.view.home.HomePanel', {
initialize: function () {
var me = this;
var config = ARSnova.app.globalConfig;
var screenWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width;
this.callParent(arguments);
this.logoutButton = Ext.create('Ext.Button', {
text: Messages.LOGOUT,
align: 'left',
ui: 'back',
handler: function () {
ARSnova.app.getController('Auth').logout();
}
});
this.toolbar = Ext.create('Ext.Toolbar', {
this.roleIcon = Ext.create('Ext.Component', {
cls: 'roleIcon userRole',
hidden: (screenWidth < 370),
align: 'left'
});
this.changeRoleButton = Ext.create('Ext.Button', {
text: Messages.CHANGE_ROLE,
align: 'right',
ui: 'confirm',
handler: function () {
ARSnova.app.getController('Auth').changeRole(
ARSnova.app.USER_ROLE_SPEAKER
);
}
});
this.toolbar = Ext.create('Ext.TitleBar', {
title: 'Session',
docked: 'top',
ui: 'light',
items: [
this.logoutButton
this.logoutButton,
this.roleIcon,
this.changeRoleButton
]
});
......
......@@ -47,10 +47,12 @@ Ext.define('ARSnova.view.home.MySessionsPanel', {
var me = this;
var config = ARSnova.app.globalConfig;
var screenWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width;
this.logoutButton = Ext.create('Ext.Button', {
id: 'logout-button',
text: Messages.LOGOUT,
align: 'left',
ui: 'back',
hidden: true,
handler: function () {
......@@ -60,6 +62,7 @@ Ext.define('ARSnova.view.home.MySessionsPanel', {
this.backButton = Ext.create('Ext.Button', {
text: Messages.HOME,
align: 'left',
ui: 'back',
handler: function () {
var hTP = ARSnova.app.mainTabPanel.tabPanel.homeTabPanel;
......@@ -71,14 +74,33 @@ Ext.define('ARSnova.view.home.MySessionsPanel', {
}
});
this.toolbar = Ext.create('Ext.Toolbar', {
this.roleIcon = Ext.create('Ext.Component', {
cls: 'roleIcon speakerRole',
hidden: (screenWidth < 370),
align: 'left'
});
this.changeRoleButton = Ext.create('Ext.Button', {
text: Messages.CHANGE_ROLE,
align: 'right',
ui: 'confirm',
handler: function () {
ARSnova.app.getController('Auth').changeRole(
ARSnova.app.USER_ROLE_STUDENT
);
}
});
this.toolbar = Ext.create('Ext.TitleBar', {
title: Messages.SESSIONS,
cls: 'speakerTitleText',
docked: 'top',
ui: 'light',
items: [
this.backButton,
this.logoutButton
this.logoutButton,
this.roleIcon,
this.changeRoleButton
]
});
......
......@@ -38,3 +38,4 @@
@import 'app/components/loadingMask';
@import 'app/components/markdownEditor';
@import 'app/components/countdownTimer';
@import 'app/components/thumbnail';
......@@ -406,6 +406,23 @@
font-size: 100px;
}
.roleIcon {
font-size: 1.5em;
color: white;
font-family: "arsnova";
margin-left: 10px;
&.userRole:before {
content: "\e600";
margin-bottom: 2px;
}
&.speakerRole:before {
content: "\e615";
margin-bottom: 0px;
}
}
.icon-horizontal-list-config {
-moz-transform:rotate(90deg); /* Firefox */
-webkit-transform:rotate(90deg); /* Safari */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment