SEBSERV-46 front-end implementation

This commit is contained in:
anhefti 2019-10-07 10:53:23 +02:00
parent 5b8f4c0eae
commit 2af692f9ff
5 changed files with 32 additions and 14 deletions

View file

@ -50,6 +50,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.download.SebExamConfigPlaintextD
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ExportConfigKey; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ExportConfigKey;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetExamConfigNode; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.GetExamConfigNode;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.ImportExamConfig;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.NewExamConfig; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.NewExamConfig;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfig; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.examconfig.SaveExamConfig;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser; import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser;
@ -94,13 +95,12 @@ public class SebExamConfigPropForm implements TemplateComposer {
protected SebExamConfigPropForm( protected SebExamConfigPropForm(
final PageService pageService, final PageService pageService,
final RestService restService,
final CurrentUser currentUser, final CurrentUser currentUser,
final DownloadService downloadService, final DownloadService downloadService,
@Value("${sebserver.gui.seb.exam.config.download.filename}") final String downloadFileName) { @Value("${sebserver.gui.seb.exam.config.download.filename}") final String downloadFileName) {
this.pageService = pageService; this.pageService = pageService;
this.restService = restService; this.restService = pageService.getRestService();
this.currentUser = currentUser; this.currentUser = currentUser;
this.downloadService = downloadService; this.downloadService = downloadService;
this.downloadFileName = downloadFileName; this.downloadFileName = downloadFileName;
@ -282,7 +282,9 @@ public class SebExamConfigPropForm implements TemplateComposer {
dialog.open( dialog.open(
FORM_IMPORT_TEXT_KEY, FORM_IMPORT_TEXT_KEY,
SebExamConfigPropForm::doImport, formHandle -> SebExamConfigPropForm.doImport(
pageService,
formHandle),
Utils.EMPTY_EXECUTION, Utils.EMPTY_EXECUTION,
importFormBuilder); importFormBuilder);
@ -290,15 +292,22 @@ public class SebExamConfigPropForm implements TemplateComposer {
}; };
} }
// TODO private static final void doImport(
private static final void doImport(final FormHandle<ConfigurationNode> formHandle) { final PageService pageService,
final FormHandle<ConfigurationNode> formHandle) {
final Form form = formHandle.getForm(); final Form form = formHandle.getForm();
final EntityKey entityKey = formHandle.getContext().getEntityKey(); final EntityKey entityKey = formHandle.getContext().getEntityKey();
final Control fieldControl = form.getFieldControl(IMPORT_FILE_ATTR_NAME); final Control fieldControl = form.getFieldControl(IMPORT_FILE_ATTR_NAME);
if (fieldControl != null && fieldControl instanceof FileUploadSelection) { if (fieldControl != null && fieldControl instanceof FileUploadSelection) {
final InputStream inputStream = ((FileUploadSelection) fieldControl).getInputStream(); final InputStream inputStream = ((FileUploadSelection) fieldControl).getInputStream();
if (inputStream != null) { if (inputStream != null) {
// TODO pageService.getRestService()
.getBuilder(ImportExamConfig.class)
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
.withBody(inputStream)
.call()
.getOrThrow();
} }
} }
} }

View file

@ -81,6 +81,11 @@ public interface PageService {
* @return the JSONMapper for parse, read and write JSON */ * @return the JSONMapper for parse, read and write JSON */
JSONMapper getJSONMapper(); JSONMapper getJSONMapper();
/** Get the RestService bean
*
* @return the RestService bean */
RestService getRestService();
/** Get the PageState of the current user. /** Get the PageState of the current user.
* *
* @return PageState of the current user. */ * @return PageState of the current user. */

View file

@ -41,6 +41,7 @@ import ch.ethz.seb.sebserver.gui.service.page.event.ActionPublishEvent;
import ch.ethz.seb.sebserver.gui.service.page.event.PageEvent; import ch.ethz.seb.sebserver.gui.service.page.event.PageEvent;
import ch.ethz.seb.sebserver.gui.service.page.event.PageEventListener; import ch.ethz.seb.sebserver.gui.service.page.event.PageEventListener;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall; import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestService;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.AuthorizationContextHolder; import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.AuthorizationContextHolder;
import ch.ethz.seb.sebserver.gui.table.TableBuilder; import ch.ethz.seb.sebserver.gui.table.TableBuilder;
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
@ -108,6 +109,15 @@ public class PageServiceImpl implements PageService {
return this.jsonMapper; return this.jsonMapper;
} }
@Override
public RestService getRestService() {
if (this.resourceService == null) {
return null;
}
return this.resourceService.getRestService();
}
@Override @Override
public PageState getCurrentState() { public PageState getCurrentState() {
try { try {

View file

@ -71,11 +71,4 @@ public interface RestService {
EntityType entityType, EntityType entityType,
CallType callType); CallType callType);
// /** Performs an activation Action on RestCall specified within the given Action.
// * The RestCall must be of CallType.ACTIVATION_ACTIVATE or CallType.ACTIVATION_DEACTIVATE
// *
// * @param action the Action that defines an entity activation
// * @return the successfully executed Action */
// <T> PageAction activation(PageAction action);
} }

View file

@ -261,7 +261,7 @@ public final class ClientConnectionTable {
private ClientConnectionData connectionData; private ClientConnectionData connectionData;
private int[] thresholdColorIndices; private int[] thresholdColorIndices;
private boolean duplicateChecked = false; private boolean duplicateChecked = false;
private final boolean duplicateMarked = false; private boolean duplicateMarked = false;
private boolean isDuplicate = false; private boolean isDuplicate = false;
UpdatableTableItem(final Long connectionId) { UpdatableTableItem(final Long connectionId) {
@ -299,6 +299,7 @@ public final class ClientConnectionTable {
void updateDuplicateColor(final TableItem tableItem) { void updateDuplicateColor(final TableItem tableItem) {
if (this.isDuplicate && this.duplicateChecked && !this.duplicateMarked) { if (this.isDuplicate && this.duplicateChecked && !this.duplicateMarked) {
tableItem.setBackground(0, ClientConnectionTable.this.statusData.color3); tableItem.setBackground(0, ClientConnectionTable.this.statusData.color3);
this.duplicateMarked = true;
} else { } else {
tableItem.setBackground(0, null); tableItem.setBackground(0, null);
} }