Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.elemental2</groupId>
<artifactId>elemental2-core</artifactId>
<version>1.0.0-beta-1</version>
</dependency>
<dependency>
<groupId>com.google.elemental2</groupId>
<artifactId>elemental2-dom</artifactId>
<version>1.0.0-beta-1</version>
</dependency>
</dependencies>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ protected void initDropzone(Element e, Element template, String previews, Elemen
uploader.on("error", (file, response) -> {
String code = "200";
if (file.xhr != null) {
code = file.xhr.status;
code = String.valueOf(file.xhr.status);
}

if (response.indexOf("401") >= 0) {
response = "Unauthorized. Your session may have expired. Log in and try again.";
globalResponse = response;
UnauthorizedEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr.status, file.xhr.statusText, response));
UnauthorizedEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr, response));
}

if (response.indexOf("404") >= 0) {
Expand All @@ -255,7 +255,7 @@ protected void initDropzone(Element e, Element template, String previews, Elemen
}

$(file.previewElement).find("#error-message").html(response);
ErrorEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr.status, file.xhr.statusText, response));
ErrorEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr, response));
});

uploader.on("totaluploadprogress", (progress, file, response) -> {
Expand All @@ -273,16 +273,16 @@ protected void initDropzone(Element e, Element template, String previews, Elemen
});

uploader.on("sending", file -> {
SendingEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr.status, file.xhr.statusText));
SendingEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr));
});

uploader.on("success", (file, response) -> {
globalResponse = response;
SuccessEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr.status, file.xhr.statusText, response));
SuccessEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr, response));
});

uploader.on("complete", file -> {
CompleteEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr.status, file.xhr.statusText, globalResponse));
CompleteEvent.fire(this, convertUploadFile(file), new UploadResponse(file.xhr, globalResponse));
});

uploader.on("canceled", file -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
package gwt.material.design.addins.client.fileuploader.base;

import elemental2.dom.XMLHttpRequest;

/**
* Upload Response with Code (e.g 404, 503, 200) and message ("File Upload url not found etc."
*
Expand All @@ -29,16 +31,19 @@ public class UploadResponse {
private String code;
private String message;
private String body;
private final XMLHttpRequest xhr;

public UploadResponse(String code, String message) {
this.code = code;
this.message = message;
public UploadResponse(XMLHttpRequest xhr) {
this.code = String.valueOf(xhr.status);
this.message = xhr.statusText;
this.xhr=xhr;
}

public UploadResponse(String code, String message, String body) {
this.code = code;
this.message = message;
public UploadResponse(XMLHttpRequest xhr, String body) {
this.code = String.valueOf(xhr.status);
this.message = xhr.statusText;
this.body = body;
this.xhr=xhr;
}

public String getCode() {
Expand All @@ -64,4 +69,8 @@ public String getBody() {
public void setBody(String body) {
this.body = body;
}

public XMLHttpRequest getXhr() {
return xhr;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package gwt.material.design.addins.client.fileuploader.js;

import com.google.gwt.dom.client.Element;
import elemental2.dom.XMLHttpRequest;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
Expand All @@ -40,7 +41,7 @@ public class File {
public String type;

@JsProperty
public XHR xhr;
public XMLHttpRequest xhr;

@JsProperty
public Element previewElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.google.gwt.core.Core"/>
<inherits name="gwt.material.design.jquery.JQuery"/>
<inherits name="elemental2.core.Core"/>
<inherits name="elemental2.dom.Dom"/>

<!-- Specify the paths for translatable code -->
<source path='client'/>
Expand Down