-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SWC-7064, SWC-7092 - Use Elemental2 for JsInterop models #5559
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
import com.google.gwt.core.client.JavaScriptObject; | ||
import com.google.gwt.dom.client.Element; | ||
import com.google.gwt.xhr.client.XMLHttpRequest; | ||
import elemental2.dom.Blob; | ||
import org.sagebionetworks.repo.model.file.FileHandleAssociateType; | ||
import org.sagebionetworks.web.client.callback.MD5Callback; | ||
import org.sagebionetworks.web.client.widget.provenance.nchart.LayoutResult; | ||
|
@@ -43,10 +44,6 @@ public LayoutResult nChartlayout( | |
|
||
public void setPageDescription(String newDescription); | ||
|
||
public JavaScriptObject getFileList(String fileFieldId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved these to a new |
||
|
||
public JavaScriptObject getFileBlob(int index, JavaScriptObject fileList); | ||
|
||
public void uploadFileChunk( | ||
String contentType, | ||
JavaScriptObject blob, | ||
|
@@ -57,15 +54,13 @@ public void uploadFileChunk( | |
ProgressCallback callback | ||
); | ||
|
||
public String getContentType(JavaScriptObject fileList, int index); | ||
|
||
public boolean isFileAPISupported(); | ||
|
||
public boolean isElementExists(String elementId); | ||
|
||
public String getFileUrl(String fileFieldId); | ||
|
||
public void getFileMd5(JavaScriptObject blob, MD5Callback callback); | ||
public void getFileMd5(Blob blob, MD5Callback callback); | ||
|
||
public void getFilePartMd5( | ||
JavaScriptObject blob, | ||
|
@@ -74,12 +69,6 @@ public void getFilePartMd5( | |
MD5Callback md5Callback | ||
); | ||
|
||
public double getFileSize(JavaScriptObject blob); | ||
|
||
String[] getMultipleUploadFileNames(JavaScriptObject fileList); | ||
|
||
String getWebkitRelativePath(JavaScriptObject fileList, int index); | ||
|
||
public void consoleLog(String message); | ||
|
||
public void consoleError(String message); | ||
|
@@ -117,8 +106,6 @@ public void getFilePartMd5( | |
|
||
boolean elementSupportsAttribute(Element el, String attribute); | ||
|
||
Element getElementById(String elementId); | ||
|
||
String getCdnEndpoint(); | ||
|
||
String getAccessTokenCookieUrl(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.sagebionetworks.web.client; | ||
|
||
import com.google.gwt.dom.client.Element; | ||
import elemental2.dom.Blob; | ||
import elemental2.dom.FileList; | ||
import org.sagebionetworks.web.client.callback.MD5Callback; | ||
|
||
public interface SynapseJsInteropUtils { | ||
FileList getFileList(String fileFieldId); | ||
|
||
String[] getMultipleUploadFileNames(FileList fileList); | ||
|
||
String getWebkitRelativePath(FileList fileList, double index); | ||
|
||
Element getElementById(String elementId); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.sagebionetworks.web.client; | ||
|
||
import com.google.gwt.dom.client.Document; | ||
import com.google.gwt.dom.client.Element; | ||
import elemental2.dom.Blob; | ||
import elemental2.dom.DomGlobal; | ||
import elemental2.dom.File; | ||
import elemental2.dom.FileList; | ||
import elemental2.dom.HTMLInputElement; | ||
import jsinterop.base.Js; | ||
import org.sagebionetworks.web.client.callback.MD5Callback; | ||
|
||
public class SynapseJsInteropUtilsImpl implements SynapseJsInteropUtils { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rewrote all of these from JSNI to JsInterop using the Elemental2 classes |
||
|
||
@Override | ||
public FileList getFileList(String fileFieldId) { | ||
elemental2.dom.Element fileToUploadElement = | ||
DomGlobal.document.getElementById(fileFieldId); | ||
if ( | ||
fileToUploadElement instanceof HTMLInputElement && | ||
((HTMLInputElement) fileToUploadElement).files != null | ||
) return ((HTMLInputElement) fileToUploadElement).files; | ||
|
||
return null; | ||
} | ||
|
||
private static String getFilesSelected(FileList fileList) { | ||
StringBuilder out = new StringBuilder(); | ||
for (double i = 0; i < fileList.length; i++) { | ||
File file = fileList.item(i); | ||
out.append(file.name).append(';'); | ||
} | ||
return out.toString(); | ||
} | ||
|
||
@Override | ||
public String[] getMultipleUploadFileNames(FileList fileList) { | ||
String unSplitNames = getFilesSelected(fileList); | ||
if (unSplitNames.isEmpty()) return null; | ||
return unSplitNames.split(";"); | ||
} | ||
|
||
@Override | ||
public String getWebkitRelativePath(FileList fileList, double index) { | ||
return (String) Js | ||
.asPropertyMap(fileList.item(index)) | ||
.get("webkitRelativePath"); | ||
} | ||
Comment on lines
+43
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Elemental2's |
||
|
||
@Override | ||
public Element getElementById(String elementId) { | ||
return Document.get().getElementById(elementId); | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elemental2 provides JsInterop bindings for browser APIs.