Skip to content

firefly api related issues due to irsa integration. #107

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

Merged
merged 3 commits into from
Jun 21, 2016
Merged
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
33 changes: 22 additions & 11 deletions buildScript/loadScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,36 @@
*/


function loadScript(url, callback){
var script = document.createElement('script');
script.type = 'text/javascript';
function loadScript(loader, script, callback){
var scriptTag = document.createElement('script');
scriptTag.type = 'text/javascript';

if (script.readyState){ //IE
script.onreadystatechange = function(){
if (['loaded', 'complete'].includes(script.readyState)) {
script.onreadystatechange = null;
const url = getScriptURL(loader) + script;
if (scriptTag.readyState){ //IE
scriptTag.onreadystatechange = function(){
if (['loaded', 'complete'].includes(scriptTag.readyState)) {
scriptTag.onreadystatechange = null;
callback && callback();
}
};
} else { //Others
script.onload = function(){
scriptTag.onload = function(){
callback && callback();
};
}

script.src = url;
document.getElementsByTagName('head')[0].appendChild(script);
scriptTag.src = url;
document.getElementsByTagName('head')[0].appendChild(scriptTag);
}


function getScriptURL(loader) {
loader = loader || 'firefly_loader.js';
var scripts = document.getElementsByTagName('script');
var url = '/';
for (var i = 0; (i < scripts.length); i++) {
if (scripts[i].src.indexOf(loader) > -1) {
url = scripts[i].src.replace(loader, '');
}
}
return url;
};
4 changes: 2 additions & 2 deletions buildScript/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ function firefly_loader(loadScript, outpath, debug=true) {
if (fs.existsSync(path.resolve(outpath, 'jsinterop.nocache.js'))) {
callback = `,
function() {
loadScript('/${cxt_name}/jsinterop.nocache.js');
loadScript('firefly_loader.js', 'jsinterop.nocache.js');
}`;
}
var content = fs.readFileSync(loadScript);
content += `\nloadScript('/${cxt_name}/firefly-${hash}.js'${callback});`;
content += `\nloadScript('firefly_loader.js', 'firefly-${hash}.js'${callback});`;
var loader = path.join(outpath, 'firefly_loader.js');
fs.writeFileSync(loader, content);
});
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/html/demo/ffapi-highlevel-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@
type: 'selectable',
Title: 'old api: selectable table',
pageSize: 50,
rowHeight: 30,
tableOptions: "show-filter=true,show-title=true,show-toolbar=true,show-options=true,show-paging=true,show-save=true"
};
firefly.showTable(tblParams, 'oldSelectable');
var tblParams2 = {
source: 'http://web.ipac.caltech.edu/staff/roby/demo/WiseDemoTable.tbl',
type: 'basic',
Title: 'old api: basic table',
pageSize: 1000,
tableOptions: "show-toolbar=false"
Expand Down
10 changes: 5 additions & 5 deletions src/firefly/html/firefly.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
<link rel="apple-touch-icon" href="images/fftools-logo-57x57_ipad.png"/>
<link rel=”apple-touch-startup-image” href=”images/fftools-ipad_splash_768x1004.png”>
<title>IRSA Viewer</title>

<script>
window.firefly = {app: {}};
</script>
<script type="text/javascript" src="firefly_loader.js"></script>
</head>

<body style="margin: 0px;">
<script>
window.firefly = {app: {}};
</script>

<!-- attached loaction for firefly app -->
<div id='app'/>

<script type="text/javascript" src="firefly_loader.js"></script>
</body>

</html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import edu.caltech.ipac.firefly.server.util.Logger;
import edu.caltech.ipac.util.AppProperties;
import edu.caltech.ipac.util.FileUtil;
import edu.caltech.ipac.util.StringUtils;
import edu.jhu.util.StringUtil;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ private File getSourceFile(String source, TableServerRequest request) {

@Override
public void prepareTableMeta(TableMeta defaults, List<DataType> columns, ServerRequest request) {
for (Param p : request.getParams()) {
if (request.isInputParam(p.getName())) {
defaults.setAttribute(p.getName(), p.getValue());
}
}
String type = request.getParam(TBL_TYPE);
if (type == null || type.equals(TYPE_CATALOG)) {
UserCatalogQuery.addCatalogMeta(defaults,columns,request);
Expand Down
3 changes: 2 additions & 1 deletion src/firefly/js/FFEntryPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {get} from 'lodash';
import {firefly} from './Firefly.js';
import {FireflyViewer} from './core/FireflyViewer.js';
import {initApi} from './api/ApiBuild.js';
import {HELP_LOAD} from './core/AppDataCntlr.js';

/**
* By default, firefly.js will startup in api mode.
Expand Down Expand Up @@ -45,7 +46,7 @@ if (app) {
{label:'Catalogs CLASSIC', action:'IrsaCatalogDropDown'},
{label:'Test Searches', action:'TestSearches'},
{label:'Images', action:'ImageSelectDropDownCmd'},
{label:'Help', action:'overviewHelp', type:'COMMAND'},
{label:'Help', action:HELP_LOAD, type:'COMMAND'},
{label:'Example Js Dialog', action:'exampleDialog', type:'COMMAND'}
]
};
Expand Down
9 changes: 5 additions & 4 deletions src/firefly/js/api/ApiHighlevelBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ function oldApi(llApi, params, options) {
// options.?? = getBoolean(oldOpts, 'show-popout');
// options.?? = getBoolean(oldOpts, 'show-table-view');

var {Title, source, alt_source, type, filters, sortInfo, pageSize, startIdx, fixedLength} = params;
var {Title, source, alt_source, type, filters, sortInfo, pageSize, startIdx, fixedLength, expandable, rowHeight} = params;
var request = makeFileRequest(Title, source, alt_source, {filters, sortInfo, pageSize, startIdx});
if (type === 'basic') {
options.selectable = false;
}
options.selectable = type === 'selectable';
options.help_id = 'tables';
options.expandable = !!expandable;
options.rowHeight = rowHeight;
return request;
}

Expand Down
5 changes: 2 additions & 3 deletions src/firefly/js/core/JsonUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/*eslint prefer-template:0 */
import {get, has} from 'lodash';
import { getRootURL, getRootPath} from '../util/BrowserUtil.js';
import { getRootURL} from '../util/BrowserUtil.js';
import { encodeServerUrl, toBoolean } from '../util/WebUtil.js';
import {ServerParams} from '../data/ServerParams.js';
import {fetchUrl} from '../util/WebUtil.js';
Expand All @@ -17,7 +17,6 @@ import {fetchUrl} from '../util/WebUtil.js';

//const TIMEOUT = 10 * 60 * 1000; // 10 min
const DEF_BASE_URL = getRootURL() + 'sticky/CmdSrv';
const DEF_PATH = getRootPath() + 'sticky/CmdSrv';


function preparePostParamList(cmd,paramList) {
Expand Down Expand Up @@ -112,7 +111,7 @@ export const jsonRequest= function(baseUrl, cmd, paramList, doPost) {
* @param doPost
*/
export const doJsonRequest= function(cmd, paramList, doPost=false) {
return jsonRequest(DEF_PATH, cmd, paramList, doPost);
return jsonRequest(DEF_BASE_URL, cmd, paramList, doPost);
};

export const doService= function(doJsonP, cmd, paramList) {
Expand Down
4 changes: 4 additions & 0 deletions src/firefly/js/tables/TableConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class TableConnector {
* @param {number[]} selected array of selected row indices.
*/
onFilterSelected(selected) {
if (isEmpty(selected)) return;

var {tableModel, request} = TblUtil.getTblInfoById(this.tbl_id);
if (this.origTableModel) {
// not implemented yet
Expand Down Expand Up @@ -133,6 +135,8 @@ export class TableConnector {


function getRowIdFor(filePath, selected) {
if (isEmpty(selected)) return [];

const params = {id: 'Table__SelectedValues', columnName: 'ROWID', filePath, selectedRows: String(selected)};

return fetchUrl(TblUtil.SEARCH_SRV_PATH, {method: 'post', params}).then( (response) => {
Expand Down
4 changes: 2 additions & 2 deletions src/firefly/js/tables/TableUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import * as TblCntlr from './TablesCntlr.js';
import {SortInfo, SORT_ASC, UNSORTED} from './SortInfo.js';
import {flux} from '../Firefly.js';
import {fetchUrl, encodeServerUrl, encodeParams} from '../util/WebUtil.js';
import {getRootPath, getRootURL} from '../util/BrowserUtil.js';
import {getRootURL} from '../util/BrowserUtil.js';

export const SEARCH_SRV_PATH = getRootPath() + 'search/json';
export const SEARCH_SRV_PATH = getRootURL() + 'search/json';
const SAVE_TABLE_URL = getRootURL() + 'servlet/SaveAsIpacTable';
const INT_MAX = Math.pow(2,31) - 1;

Expand Down
7 changes: 6 additions & 1 deletion src/firefly/js/tables/ui/TablePanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {SelectInfo} from '../SelectInfo.js';
import {PagingBar} from '../../ui/PagingBar.jsx';
import {ToolbarButton} from '../../ui/ToolbarButton.jsx';
import {LO_MODE, LO_VIEW, dispatchSetLayoutMode} from '../../core/LayoutCntlr.js';
import {HelpIcon} from '../../ui/HelpIcon.jsx';
import FILTER from 'html/images/icons-2014/24x24_Filter.png';
import OUTLINE_EXPAND from 'html/images/icons-2014/24x24_ExpandArrowsWhiteOutline.png';

Expand Down Expand Up @@ -92,7 +93,7 @@ export class TablePanel extends Component {
}

render() {
const {selectable, expandable, expandedMode, border, renderers, title, removable,
const {selectable, expandable, expandedMode, border, renderers, title, removable, rowHeight, help_id,
showToolbar, showTitle, showOptionButton, showPaging, showSave, showFilterButton} = this.state;
var {totalRows, showLoading, columns, showOptions, showUnits, showFilters, textView, colSortDir} = this.state;
const {tbl_id, error, startIdx, hlRowIdx, currentPage, pageSize, selectInfo, showMask,
Expand Down Expand Up @@ -132,6 +133,7 @@ export class TablePanel extends Component {
<button onClick={this.expandTable}>
<img src={OUTLINE_EXPAND} title='Expand this panel to take up a larger area'/>
</button>}
{ help_id && <div style={{marginTop:-10}}> <HelpIcon helpId={help_id} /> </div>}
</div>
</div>
}
Expand All @@ -140,6 +142,7 @@ export class TablePanel extends Component {
columns={columns}
data={data}
hlRowIdx={hlRowIdx}
rowHeight = {rowHeight}
selectable={selectable}
showUnits={showUnits}
showFilters={showFilters}
Expand Down Expand Up @@ -175,11 +178,13 @@ TablePanel.propTypes = {
tbl_ui_id: PropTypes.string,
tableModel: PropTypes.object,
pageSize: PropTypes.number,
rowHeight: PropTypes.number,
selectable: PropTypes.bool,
expandedMode: PropTypes.bool,
expandable: PropTypes.bool,
border: PropTypes.bool,
title: PropTypes.string,
help_id: PropTypes.string,
removable: PropTypes.bool,
showUnits: PropTypes.bool,
showFilters: PropTypes.bool,
Expand Down
8 changes: 5 additions & 3 deletions src/firefly/js/tables/ui/TableRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import DESC_ICO from 'html/images/sort_desc.gif';
import FILTER_SELECTED_ICO from 'html/images/icons-2014/16x16_Filter.png';

const {Cell} = FixedDataTable;
const html_regex = /<.+>/;

// the components here are small and used by table only. not all props are defined.
/* eslint-disable react/prop-types */
Expand Down Expand Up @@ -168,10 +169,11 @@ export class TextCell extends React.Component {
// }
//
render() {
var val = getValue(this.props);
const lineHeight = this.props.height - 6 + 'px'; // 6 is the top/bottom padding.
val = (val.search(html_regex) >= 0) ? <div dangerouslySetInnerHTML={{__html: val}} /> : val;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, react actually call this prop "dangerous"

return (
<div className='public_fixedDataTableCell_cellContent'>
{getValue(this.props)}
</div>
<div style={{lineHeight}} className='public_fixedDataTableCell_cellContent'>{val}</div>
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/firefly/js/ui/FileUpload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {get} from 'lodash';
import {InputFieldView} from './InputFieldView.jsx';
import {fieldGroupConnector} from './FieldGroupConnector.jsx';
import {fetchUrl} from '../util/WebUtil.js';
import {getRootPath} from '../util/BrowserUtil.js';
import {getRootURL} from '../util/BrowserUtil.js';

import LOADING from 'html/images/gxt/loading.gif';
const UL_URL = getRootPath() + 'sticky/Firefly_FileUpload';
const UL_URL = getRootURL() + 'sticky/Firefly_FileUpload';


function FileUploadView({fileType, isLoading, label, valid, wrapperStyle, message, onChange, value}) {
Expand Down
4 changes: 2 additions & 2 deletions src/firefly/js/ui/PagingBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export class PagingBar extends Component {
onChange = {onPageChange}
actOn={['blur','enter']}
showWarning={false}
/> <div style={{fontSize: 'smaller'}} >&nbsp; of {totalPages}</div>
/> <div style={{fontSize: 'smaller', marginLeft: 3}} > of {totalPages}</div>
<button onClick={() => callbacks.onGotoPage(currentPage + 1)} className='paging_bar next' title='Next Page'/>
<button onClick={() => callbacks.onGotoPage(totalPages)} className='paging_bar last' title='Last Page'/>
<div style={{fontSize: 'smaller'}} > &nbsp; ({(startIdx+1).toLocaleString()} - {endIdx.toLocaleString()} of {totalRows.toLocaleString()})</div>
<div style={{fontSize: 'smaller', marginLeft: 3}} > ({(startIdx+1).toLocaleString()} - {endIdx.toLocaleString()} of {totalRows.toLocaleString()})</div>
{showLoading ? <img style={{width:14,height:14,marginTop: '3px'}} src={LOADING}/> : false}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/firefly/js/util/WebUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function getModuleName() {
export const encodeUrl= function(url, params) {

var rval = url.trim();
if ( !(rval.toLowerCase().startsWith('http') || rval.startsWith('/')) ) {
if ( !rval.toLowerCase().startsWith('http') ) {
rval = getRootURL() + rval;
}
if (!params) return rval;
Expand Down