Artifact upload : on discard action interupt the ongoing upload -
reverted the changes Signed-off-by: Asharani <asharani.murugesh@in.bosch.com>
This commit is contained in:
@@ -15,5 +15,5 @@ package org.eclipse.hawkbit.ui.artifacts.event;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum UploadArtifactUIEvent {
|
public enum UploadArtifactUIEvent {
|
||||||
SHOW_DROP_HINTS, HIDE_DROP_HINTS, SOFTWARE_DRAG_START, SOFTWARE_TYPE_DRAG_START, UPDATE_UPLOAD_COUNT, HIDE_FILTER_BY_TYPE, SHOW_FILTER_BY_TYPE, DISCARD_DELETE_SOFTWARE, DISCARD_ALL_DELETE_SOFTWARE, DELETED_ALL_SOFWARE, DISCARD_DELETE_SOFTWARE_TYPE, DISCARD_ALL_DELETE_SOFTWARE_TYPE, DELETED_ALL_SOFWARE_TYPE, MINIMIZED_STATUS_POPUP, MAXIMIZED_STATUS_POPUP, UPLOAD_IN_PROGESS, DISCARD_UPLOAD, ARTIFACT_RESULT_POPUP_CLOSED
|
SHOW_DROP_HINTS, HIDE_DROP_HINTS, SOFTWARE_DRAG_START, SOFTWARE_TYPE_DRAG_START, UPDATE_UPLOAD_COUNT, HIDE_FILTER_BY_TYPE, SHOW_FILTER_BY_TYPE, DISCARD_DELETE_SOFTWARE, DISCARD_ALL_DELETE_SOFTWARE, DELETED_ALL_SOFWARE, DISCARD_DELETE_SOFTWARE_TYPE, DISCARD_ALL_DELETE_SOFTWARE_TYPE, DELETED_ALL_SOFWARE_TYPE, MINIMIZED_STATUS_POPUP, MAXIMIZED_STATUS_POPUP, UPLOAD_IN_PROGESS, ARTIFACT_RESULT_POPUP_CLOSED
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,24 +88,6 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
|||||||
this.mimeType = mimeType;
|
this.mimeType = mimeType;
|
||||||
this.i18n = SpringContextHelper.getBean(I18N.class);
|
this.i18n = SpringContextHelper.getBean(I18N.class);
|
||||||
this.eventBus = SpringContextHelper.getBean(EventBus.SessionEventBus.class);
|
this.eventBus = SpringContextHelper.getBean(EventBus.SessionEventBus.class);
|
||||||
eventBus.subscribe(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventBusListenerMethod(scope = EventScope.SESSION)
|
|
||||||
void onEvent(final UploadArtifactUIEvent event) {
|
|
||||||
if (event == UploadArtifactUIEvent.DISCARD_UPLOAD) {
|
|
||||||
UI.getCurrent().access(() ->intreruptUploadOnDiscard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
@PreDestroy
|
|
||||||
void destroy() {
|
|
||||||
/*
|
|
||||||
* It's good manners to do this, even though vaadin-spring will
|
|
||||||
* automatically unsubscribe when this UI is garbage collected.
|
|
||||||
*/
|
|
||||||
eventBus.unsubscribe(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -372,12 +354,4 @@ public class UploadHandler implements StreamVariable, Receiver, SucceededListene
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void intreruptUploadOnDiscard(){
|
|
||||||
if(upload!=null && upload.isUploading()){
|
|
||||||
upload.interruptUpload();
|
|
||||||
uploadInterrupted = true;
|
|
||||||
}
|
|
||||||
streamingInterrupted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
|
|
||||||
private Button uploadStatusButton;
|
private Button uploadStatusButton;
|
||||||
|
|
||||||
private Boolean changesDiscarded = Boolean.FALSE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the upload layout.
|
* Initialize the upload layout.
|
||||||
@@ -242,7 +241,6 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(final DragAndDropEvent event) {
|
public void drop(final DragAndDropEvent event) {
|
||||||
changesDiscarded = Boolean.FALSE;
|
|
||||||
if (validate(event)) {
|
if (validate(event)) {
|
||||||
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
|
final Html5File[] files = ((WrapperTransferable) event.getTransferable()).getFiles();
|
||||||
// reset the flag
|
// reset the flag
|
||||||
@@ -569,8 +567,6 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void clearUploadedFileDetails() {
|
protected void clearUploadedFileDetails() {
|
||||||
eventBus.publish(this, UploadArtifactUIEvent.DISCARD_UPLOAD);
|
|
||||||
changesDiscarded = Boolean.TRUE;
|
|
||||||
clearFileList();
|
clearFileList();
|
||||||
closeUploadStatusPopup();
|
closeUploadStatusPopup();
|
||||||
}
|
}
|
||||||
@@ -669,13 +665,11 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VerticalLayout getDropAreaLayout() {
|
VerticalLayout getDropAreaLayout() {
|
||||||
return dropAreaLayout;
|
return dropAreaLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onStartOfUpload() {
|
private void onStartOfUpload() {
|
||||||
changesDiscarded = Boolean.FALSE;
|
|
||||||
setUploadStatusButtonIconToInProgress();
|
setUploadStatusButtonIconToInProgress();
|
||||||
if (artifactUploadState.isStatusPopupMinimized()) {
|
if (artifactUploadState.isStatusPopupMinimized()) {
|
||||||
updateStatusButtonCount();
|
updateStatusButtonCount();
|
||||||
@@ -695,7 +689,6 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onUploadStreamingFailure(UploadStatusEvent event) {
|
private void onUploadStreamingFailure(UploadStatusEvent event) {
|
||||||
if (!changesDiscarded) {
|
|
||||||
/**
|
/**
|
||||||
* If upload interrupted because of duplicate file,do not remove the
|
* If upload interrupted because of duplicate file,do not remove the
|
||||||
* file already in upload list
|
* file already in upload list
|
||||||
@@ -720,7 +713,6 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
setUploadStatusButtonIconToFinished();
|
setUploadStatusButtonIconToFinished();
|
||||||
}
|
}
|
||||||
displayDuplicateValidationMessage();
|
displayDuplicateValidationMessage();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUploadSuccess(UploadStatusEvent event) {
|
private void onUploadSuccess(UploadStatusEvent event) {
|
||||||
@@ -753,9 +745,8 @@ public class UploadLayout extends VerticalLayout {
|
|||||||
* If upload interrupted because of duplicate file,do not remove the
|
* If upload interrupted because of duplicate file,do not remove the
|
||||||
* file already in upload list
|
* file already in upload list
|
||||||
**/
|
**/
|
||||||
if ((getDuplicateFileNamesList().isEmpty() || !getDuplicateFileNamesList().contains(
|
if (getDuplicateFileNamesList().isEmpty() || !getDuplicateFileNamesList().contains(
|
||||||
event.getUploadStatus().getFileName()))
|
event.getUploadStatus().getFileName())) {
|
||||||
&& !changesDiscarded) {
|
|
||||||
final SoftwareModule sw = getSoftwareModuleSelected();
|
final SoftwareModule sw = getSoftwareModuleSelected();
|
||||||
getFileSelected().remove(
|
getFileSelected().remove(
|
||||||
new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion()));
|
new CustomFile(event.getUploadStatus().getFileName(), sw.getName(), sw.getVersion()));
|
||||||
|
|||||||
Reference in New Issue
Block a user