From 0c4e74fb92b1a7ae29a1300e82a3149dc1f4a9fd Mon Sep 17 00:00:00 2001 From: loi Date: Mon, 25 Jul 2016 14:23:54 -0700 Subject: [PATCH 1/2] DM-6439: Remove GWT from build - remove GWT build from firefly - AnyFileUpload no longer pre-load fits images - fix firefly showing blank page when no results are present. should show drop-drown. --- src/firefly/build.gradle | 5 ---- .../server/servlets/AnyFileUpload.java | 30 ++----------------- .../java/edu/caltech/ipac/jsinterop.gwt.xml | 29 ------------------ src/firefly/js/Firefly.js | 8 +---- src/firefly/js/core/AppDataCntlr.js | 2 +- .../js/core/layout/FireflyLayoutManager.js | 1 + src/firefly/js/fireflyJSLib.js | 9 +++++- src/firefly/js/visualize/VisUtil.js | 8 +---- src/firefly/js/visualize/WebPlot.js | 4 +-- 9 files changed, 15 insertions(+), 81 deletions(-) delete mode 100644 src/firefly/java/edu/caltech/ipac/jsinterop.gwt.xml diff --git a/src/firefly/build.gradle b/src/firefly/build.gradle index 19fd5fb71d..53166e98ac 100644 --- a/src/firefly/build.gradle +++ b/src/firefly/build.gradle @@ -22,11 +22,6 @@ jar { includes = ['edu/caltech/ipac/**/*'] } -gwt { - modules = 'edu.caltech.ipac.jsinterop' - module_name = 'jsinterop' -} - ext.appConfig = { BuildMajor = "1" BuildMinor = "0" diff --git a/src/firefly/java/edu/caltech/ipac/firefly/server/servlets/AnyFileUpload.java b/src/firefly/java/edu/caltech/ipac/firefly/server/servlets/AnyFileUpload.java index 970d5add0e..f766bd280e 100644 --- a/src/firefly/java/edu/caltech/ipac/firefly/server/servlets/AnyFileUpload.java +++ b/src/firefly/java/edu/caltech/ipac/firefly/server/servlets/AnyFileUpload.java @@ -9,13 +9,10 @@ import edu.caltech.ipac.firefly.server.util.Logger; import edu.caltech.ipac.firefly.server.util.StopWatch; import edu.caltech.ipac.firefly.server.util.multipart.UploadFileInfo; -import edu.caltech.ipac.firefly.server.visualize.FitsCacher; import edu.caltech.ipac.util.FileUtil; import edu.caltech.ipac.util.IpacTableUtil; import edu.caltech.ipac.util.StringUtils; import edu.caltech.ipac.util.cache.StringKey; -import edu.caltech.ipac.visualize.plot.FitsRead; -import nom.tam.fits.Fits; import org.apache.commons.fileupload.FileItemIterator; import org.apache.commons.fileupload.FileItemStream; import org.apache.commons.fileupload.servlet.ServletFileUpload; @@ -23,7 +20,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; -import java.io.ByteArrayOutputStream; import java.util.HashMap; /** @@ -77,7 +73,7 @@ protected void processRequest(HttpServletRequest req, HttpServletResponse res) t String ext = resolveExt(fileName); FileType fType = resolveType(fileType, ext, file.getContentType()); File destDir = resolveDestDir(dest, fType); - boolean doPreload = resolvePreload(preload, fType); +// boolean doPreload = resolvePreload(preload, fType); // we are no longer pre-loading fits files. performance gain was not significant. File uf = File.createTempFile("upload_", ext, destDir); // other parts of system depend on file name starting with "upload_" String rPathInfo = ServerContext.replaceWithPrefix(uf); @@ -85,29 +81,7 @@ protected void processRequest(HttpServletRequest req, HttpServletResponse res) t UploadFileInfo fi= new UploadFileInfo(rPathInfo,uf,fileName,file.getContentType()); String fileCacheKey= overrideCacheKey!=null ? overrideCacheKey : rPathInfo; UserCache.getInstance().put(new StringKey(fileCacheKey), fi); - - if (doPreload && fType == FileType.FITS) { - - BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(uf), IpacTableUtil.FILE_IO_BUFFER_SIZE); - ByteArrayOutputStream pipe = new ByteArrayOutputStream(); - try { - byte[] buffer = new byte[IpacTableUtil.FILE_IO_BUFFER_SIZE]; - int read; - while ((read = inStream.read(buffer)) != -1) { - bos.write(buffer, 0, read); - pipe.write(buffer, 0, read); - } - - final Fits fits = new Fits(new ByteArrayInputStream(pipe.toByteArray())); - FitsRead[] frAry = FitsRead.createFitsReadArray(fits); - FitsCacher.addFitsReadToCache(uf, frAry); - - } finally { - FileUtil.silentClose(bos); - } - } else { - FileUtil.writeToFile(inStream, uf); - } + FileUtil.writeToFile(inStream, uf); sendReturnMsg(res, 200, null, fileCacheKey); Counters.getInstance().increment(Counters.Category.Upload, fi.getContentType()); diff --git a/src/firefly/java/edu/caltech/ipac/jsinterop.gwt.xml b/src/firefly/java/edu/caltech/ipac/jsinterop.gwt.xml deleted file mode 100644 index d8987c9d6d..0000000000 --- a/src/firefly/java/edu/caltech/ipac/jsinterop.gwt.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/firefly/js/Firefly.js b/src/firefly/js/Firefly.js index 11d51cc474..bf246b107c 100644 --- a/src/firefly/js/Firefly.js +++ b/src/firefly/js/Firefly.js @@ -9,7 +9,7 @@ import 'isomorphic-fetch'; import React from 'react'; import 'styles/global.css'; -import {APP_LOAD, dispatchUpdateAppData} from './core/AppDataCntlr.js'; +import {APP_LOAD} from './core/AppDataCntlr.js'; import {ExtensionJavaInterface } from './gwtinterface/ExtensionJavaInterface.js'; import {ExtensionResult } from './gwtinterface/ExtensionResult.js'; import {PlotCmdExtension } from './visualize/PlotCmdExtension.js'; @@ -47,12 +47,6 @@ const appFlux= { function fireflyInit() { - if (! window.ffgwt ) { - window.ffgwt = { - onLoaded: () => dispatchUpdateAppData({gwtLoaded: true}) - }; - } - if (! (window.firefly && window.firefly.initialized) ) { flux.bootstrap(); var touch= false; // ToDo: determine if we are on a touch device diff --git a/src/firefly/js/core/AppDataCntlr.js b/src/firefly/js/core/AppDataCntlr.js index 633b33355b..7379e78344 100644 --- a/src/firefly/js/core/AppDataCntlr.js +++ b/src/firefly/js/core/AppDataCntlr.js @@ -276,7 +276,7 @@ export function dispatchOnAppReady(callback) { /*---------------------------- EXPORTED FUNTIONS -----------------------------*/ export function isAppReady() { return getWsChannel() && get(flux.getState(), [APP_DATA_PATH, 'isReady']) && - (get(window, 'firefly.noGWT') || get(flux.getState(), [APP_DATA_PATH, 'gwtLoaded'])); + (!window.ffgwt || get(flux.getState(), [APP_DATA_PATH, 'gwtLoaded'])); } export function getMenu() { diff --git a/src/firefly/js/core/layout/FireflyLayoutManager.js b/src/firefly/js/core/layout/FireflyLayoutManager.js index 25a7da0ffa..cdf8e1c36c 100644 --- a/src/firefly/js/core/layout/FireflyLayoutManager.js +++ b/src/firefly/js/core/layout/FireflyLayoutManager.js @@ -94,6 +94,7 @@ export function* layoutManager({title, views='tables | images | xyPlots'}) { case ImagePlotCntlr.PLOT_IMAGE : dropDown = {visible: count === 0}; break; + case SHOW_DROPDOWN: case TABLE_REMOVE: case ImagePlotCntlr.DELETE_PLOT_VIEW: if (!get(dropDown, 'visible', false)) { diff --git a/src/firefly/js/fireflyJSLib.js b/src/firefly/js/fireflyJSLib.js index e1a27f027a..88437347ac 100644 --- a/src/firefly/js/fireflyJSLib.js +++ b/src/firefly/js/fireflyJSLib.js @@ -2,8 +2,15 @@ * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ -import {firefly} from 'firefly/Firefly.js'; +import {firefly} from './Firefly.js'; import {GwtEventHandler} from './core/messaging/MessageHandlers.js'; +import {dispatchUpdateAppData} from './core/AppDataCntlr.js'; + +if (! window.ffgwt ) { + window.ffgwt = { + onLoaded: () => dispatchUpdateAppData({gwtLoaded: true}) + }; +} firefly.bootstrap(); if (window.firefly.wsClient) { diff --git a/src/firefly/js/visualize/VisUtil.js b/src/firefly/js/visualize/VisUtil.js index 39dff585b4..3f5e9dbe8f 100644 --- a/src/firefly/js/visualize/VisUtil.js +++ b/src/firefly/js/visualize/VisUtil.js @@ -21,12 +21,6 @@ import {doConv} from '../astro/conv/CoordConv.js'; var {AllPlots} = window.ffgwt ? window.ffgwt.Visualize : {AllPlots:null}; -export const USE_GWT= false; - -const doCoordConversion= USE_GWT ? window.ffgwt.astro.CoordConv.doConv : doConv; - - - export const DtoR = Math.PI / 180.0; export const RtoD = 180.0 / Math.PI; @@ -101,7 +95,7 @@ export function convert(wpt, to= CoordinateSys.EQ_J2000) { if (!to || from==to) return wpt; const tobs= (from===CoordinateSys.EQ_B1950) ? 1983.5 : 0; - const ll = doCoordConversion( + const ll = doConv( from.getJsys(), from.getEquinox(), wpt.getLon(), wpt.getLat(), to.getJsys(), to.getEquinox(), tobs); diff --git a/src/firefly/js/visualize/WebPlot.js b/src/firefly/js/visualize/WebPlot.js index 2c89e568b6..d6c4ae268e 100644 --- a/src/firefly/js/visualize/WebPlot.js +++ b/src/firefly/js/visualize/WebPlot.js @@ -7,10 +7,8 @@ import {RequestType} from './RequestType.js'; import {isString} from 'lodash'; import CoordinateSys from './CoordSys.js'; -import {makeProjectionGWT} from './Projection.js'; import {makeProjection} from './projection/Projection.js'; import PlotState from './PlotState.js'; -import {USE_GWT} from './VisUtil.js'; @@ -121,7 +119,7 @@ export const WebPlot= { */ makeWebPlotData(plotId, wpInit, asOverlay= false) { - const projection= USE_GWT ? makeProjectionGWT(wpInit.projection) : makeProjection(wpInit.projectionJson); + const projection= makeProjection(wpInit.projectionJson); var plotState= PlotState.makePlotStateWithJson(wpInit.plotState); var zf= plotState.getZoomLevel(); From b91d151a4f64b9dc445b3fb528427faa8f4aaeab Mon Sep 17 00:00:00 2001 From: loi Date: Mon, 25 Jul 2016 15:13:44 -0700 Subject: [PATCH 2/2] DM-6439: remove temporary code. --- src/firefly/js/visualize/ImagePlotCntlr.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/firefly/js/visualize/ImagePlotCntlr.js b/src/firefly/js/visualize/ImagePlotCntlr.js index 3992b98266..27648244c7 100644 --- a/src/firefly/js/visualize/ImagePlotCntlr.js +++ b/src/firefly/js/visualize/ImagePlotCntlr.js @@ -876,20 +876,3 @@ function deletePlotView(state,action) { //============ end private functions ================================= //============ end private functions ================================= - - - -//============ TEMPORARY interface with GWT================================= - -/*globals ffgwt*/ - -if (window.ffgwt) { - const allPlots= ffgwt.Visualize.AllPlots.getInstance(); - allPlots.addListener({ - eventNotify(ev) { - if (ev.getName().getName()==='Replot') { - flux.process({type: ANY_CHANGE, payload: { } }); - } - } - }); -}