Skip to content
Snippets Groups Projects
Commit 12cffaea authored by helene ortiz's avatar helene ortiz
Browse files

Change of proposal is forbidden if at least one command is running (or

paused) in the launch pad.
Button to enable/disable RAC is not only available for main clients but
now also to instrument responsibles or IT members or SCI members.
parent 2a9c888d
No related branches found
No related tags found
No related merge requests found
4.0.70 dd/mm/2020
------
* Change of proposal is forbidden if at least one command is running (or paused) in the launch pad.
* Button to enable/disable RAC is not only available for main clients but now also to instrument responsibles or IT members or SCI members.
4.0.69 13/11/2020
------
* Cameo 1.0.0 integrated.
......
......@@ -209,6 +209,11 @@ commandLineNoGrammarDefinedForThisInstrument=Command line unavailable. No gramma
commandLinePauseMessage=Execution is paused. Type ENTER to continue or x to stop or n to stop at end
commandLineNotSynchronised=Switch to box view forbidden while a command is running!
forbiddenChangeOfProposalWhileSomethingRunning=You cannot change proposal while commands are running in the server.
forbiddenChangeOfProposalWhileSomethingPaused=You cannot change proposal while commands are paused in the server.
changeOfProposalTitle=Change proposal
simulationTabCannotBeClosedWhileSomethingRunningOrPaused=You cannot close the simulation tab while something is running or paused.
simulationTabCannotBeClosedWhileSomethingRunningOrPausedTitle=Invalid action
......
......@@ -35,8 +35,13 @@ public class Proposal implements Comparable {
public final static String JSON_CODE = "code";
public final static String JSON_CYCLE = "cycle";
public final static String JSON_ACCOUNT = "account";
public final static String JSON_STAFF = "staff";
public final static String JSON_LOGIN = "login";
public final static String JSON_ROLES = "roles";
public final static String JSON_INSTRUMENT_RESPONSIBLE = "INSTRUMENT_RESPONSIBLE";
public final static String JSON_INSTRUMENT_CONTROL = "INSTRUMENT_CONTROL";
public final static String JSON_IT_SUPPORT = "IT_SUPPORT";
public final static String JSON_STAFF = "STAFF";
public static final int INTERNAL_USE_PROPOSAL_ID = 0;
......
......@@ -84,8 +84,13 @@ public class UserConnection {
private AuthenticationState state;
private boolean userIsStaff = false;
private boolean userIsInstrumentResponsible = false;
private boolean userIsInstrumentControl = false;
private boolean userIsITSupport = false;
private UserConnection() {
init();
}
......@@ -203,6 +208,10 @@ public class UserConnection {
if (jsonObject != null) {
JSONObject metadata = (JSONObject)jsonObject.get(Proposal.JSON_METADATA);
if (metadata != null) {
System.out.println("==============> " + metadata.toString());
long count = (Long)metadata.get(Proposal.JSON_COUNT);
System.out.println("Number of proposals for " + userName + " = " + count);
//Nomad.printToFile(writer, "Number of proposals for " + userName + " = " + count + "\n");
......@@ -212,6 +221,23 @@ public class UserConnection {
userIsStaff = false;
String login = "";
if (account != null) {
JSONArray roles = (JSONArray)account.get(Proposal.JSON_ROLES);
if (roles != null) {
for (int i = 0; i < roles.size(); i++) {
String role = (String)roles.get(i);
if (role.equals(Proposal.JSON_STAFF)) {
userIsStaff = true;
} else if (role.equals(Proposal.JSON_INSTRUMENT_RESPONSIBLE)) {
userIsInstrumentResponsible = true;
} else if (role.equals(Proposal.JSON_INSTRUMENT_CONTROL)) {
userIsInstrumentControl = true;
} else if (role.equals(Proposal.JSON_IT_SUPPORT)) {
userIsITSupport = true;
}
}
}
Object isStaffObject = account.get(Proposal.JSON_STAFF);
if (isStaffObject != null) {
userIsStaff = (Boolean)isStaffObject;
......@@ -221,7 +247,7 @@ public class UserConnection {
login = (String)loginObject;
}
}
System.out.println("User " + login + " is staff ? " + userIsStaff);
System.out.println("User " + login + " is staff ? " + userIsStaff + " / is IT ? " + userIsITSupport + " / is SCI ? " + userIsInstrumentControl + " / is IR ? " + userIsInstrumentResponsible);
}
JSONArray data = (JSONArray)jsonObject.get(Proposal.JSON_DATA);
if (data != null) {
......@@ -453,5 +479,18 @@ public class UserConnection {
public boolean userIsStaff() {
return userIsStaff;
}
public boolean userIsInstrumentResponsible() {
return userIsInstrumentResponsible;
}
public boolean userIsIT() {
return userIsITSupport;
}
public boolean userIsSCI() {
return userIsInstrumentControl;
}
}
......@@ -27,6 +27,8 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import fr.ill.ics.client.control.command.CommandWindow;
import fr.ill.ics.client.control.command.ServerCommandZone;
import fr.ill.ics.client.control.login.UserConnection;
import fr.ill.ics.client.view.MainWindowPeer;
import fr.ill.ics.client.view.factory.WidgetFactory;
......@@ -267,9 +269,16 @@ public class SWTLoginPopup extends SWTAuthenticationPopup {
dispose();
authenticationPeer.openProposalPopup(openingX, openingY);
ServerCommandZone serverCommandZone = (ServerCommandZone)CommandWindow.getInstance().getServerTabButton().getCommandZone();
MainWindowPeer.getInstance().setCursorToDefault();
if (serverCommandZone.somethingRunning()) {
DialogManager.getInstance().nomadMessageDialog("forbiddenChangeOfProposalWhileSomethingRunning", "changeOfProposalTitle");
} else if (serverCommandZone.somethingPaused()) {
DialogManager.getInstance().nomadMessageDialog("forbiddenChangeOfProposalWhileSomethingPaused", "changeOfProposalTitle");
} else {
authenticationPeer.openProposalPopup(openingX, openingY);
MainWindowPeer.getInstance().setCursorToDefault();
}
}
......
......@@ -31,6 +31,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import fr.ill.ics.client.control.login.UserConnection;
import fr.ill.ics.client.control.remote.RemoteControlManager;
import fr.ill.ics.client.control.token.TokenManager;
import fr.ill.ics.client.control.users.ConnectedUsersManager;
......@@ -105,7 +106,8 @@ public class SWTTokenWidget extends TokenWidget {
}
});
if (ConfigManager.getInstance().isMainClient()) {
// Button to enable/disable RAC is only available to main client OR instrument responsibles OR IT members OR SCI members
if (ConfigManager.getInstance().isMainClient() || UserConnection.getInstance().userIsInstrumentResponsible() || UserConnection.getInstance().userIsIT()|| UserConnection.getInstance().userIsSCI()) {
remoteCanvas = SWTWidgetFactory.getInstance().createCanvas(tabIndexCanvas, SWT.NONE, true);
remoteCanvas.setBackground(SWTColorFactory.getTabIndexColor());
setRemoteImageAndToolTip();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment