Skip to content

Commit b69f977

Browse files
committed
- default table cell to render html content as html.
- fix firefly_loader.js to take into consideration the location of from where it is loaded. - paging bar show non-ascii characters in irsa's html
1 parent 54002e4 commit b69f977

File tree

11 files changed

+42
-33
lines changed

11 files changed

+42
-33
lines changed

buildScript/loadScript.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,35 @@
33
*/
44

55

6-
function loadScript(url, callback){
7-
var script = document.createElement('script');
8-
script.type = 'text/javascript';
6+
function loadScript(loader, script, callback){
7+
var scriptTag = document.createElement('script');
8+
scriptTag.type = 'text/javascript';
99

10-
if (script.readyState){ //IE
11-
script.onreadystatechange = function(){
12-
if (['loaded', 'complete'].includes(script.readyState)) {
13-
script.onreadystatechange = null;
10+
const url = getScriptURL(loader) + script;
11+
if (scriptTag.readyState){ //IE
12+
scriptTag.onreadystatechange = function(){
13+
if (['loaded', 'complete'].includes(scriptTag.readyState)) {
14+
scriptTag.onreadystatechange = null;
1415
callback && callback();
1516
}
1617
};
1718
} else { //Others
18-
script.onload = function(){
19+
scriptTag.onload = function(){
1920
callback && callback();
2021
};
2122
}
2223

23-
script.src = url;
24-
document.getElementsByTagName('head')[0].appendChild(script);
24+
scriptTag.src = url;
25+
document.getElementsByTagName('head')[0].appendChild(scriptTag);
2526
}
2627

27-
28+
function getScriptURL(loader = 'firefly_loader.js') {
29+
var scripts = document.getElementsByTagName('script');
30+
var url = '/';
31+
for (var i = 0; (i < scripts.length); i++) {
32+
if (scripts[i].src.indexOf(loader) > -1) {
33+
url = scripts[i].src.replace(loader, '');
34+
}
35+
}
36+
return url;
37+
};

buildScript/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,11 @@ function firefly_loader(loadScript, outpath, debug=true) {
254254
if (fs.existsSync(path.resolve(outpath, 'jsinterop.nocache.js'))) {
255255
callback = `,
256256
function() {
257-
loadScript('/${cxt_name}/jsinterop.nocache.js');
257+
loadScript('firefly_loader.js', 'jsinterop.nocache.js');
258258
}`;
259259
}
260260
var content = fs.readFileSync(loadScript);
261-
content += `\nloadScript('/${cxt_name}/firefly-${hash}.js'${callback});`;
261+
content += `\nloadScript('firefly_loader.js', 'firefly-${hash}.js'${callback});`;
262262
var loader = path.join(outpath, 'firefly_loader.js');
263263
fs.writeFileSync(loader, content);
264264
});

src/firefly/html/firefly.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
<link rel="apple-touch-icon" href="images/fftools-logo-57x57_ipad.png"/>
99
<link rel=”apple-touch-startup-image” href=”images/fftools-ipad_splash_768x1004.png”>
1010
<title>IRSA Viewer</title>
11+
12+
<script>
13+
window.firefly = {app: {}};
14+
</script>
15+
<script type="text/javascript" src="firefly_loader.js"></script>
1116
</head>
1217

1318
<body style="margin: 0px;">
14-
<script>
15-
window.firefly = {app: {}};
16-
</script>
17-
1819
<!-- attached loaction for firefly app -->
1920
<div id='app'/>
2021

21-
<script type="text/javascript" src="firefly_loader.js"></script>
2222
</body>
2323

2424
</html>

src/firefly/java/edu/caltech/ipac/firefly/server/AlertsMonitor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import edu.caltech.ipac.firefly.server.util.Logger;
88
import edu.caltech.ipac.util.AppProperties;
99
import edu.caltech.ipac.util.FileUtil;
10-
import edu.caltech.ipac.util.StringUtils;
11-
import edu.jhu.util.StringUtil;
1210

1311
import java.io.File;
1412
import java.io.IOException;

src/firefly/java/edu/caltech/ipac/firefly/server/query/tables/IpacTableFromSource.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ private File getSourceFile(String source, TableServerRequest request) {
108108

109109
@Override
110110
public void prepareTableMeta(TableMeta defaults, List<DataType> columns, ServerRequest request) {
111-
for (Param p : request.getParams()) {
112-
if (request.isInputParam(p.getName())) {
113-
defaults.setAttribute(p.getName(), p.getValue());
114-
}
115-
}
116111
String type = request.getParam(TBL_TYPE);
117112
if (type == null || type.equals(TYPE_CATALOG)) {
118113
UserCatalogQuery.addCatalogMeta(defaults,columns,request);

src/firefly/js/FFEntryPoint.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {get} from 'lodash';
1010
import {firefly} from './Firefly.js';
1111
import {FireflyViewer} from './core/FireflyViewer.js';
1212
import {initApi} from './api/ApiBuild.js';
13+
import {HELP_LOAD} from './core/AppDataCntlr.js';
1314

1415
/**
1516
* By default, firefly.js will startup in api mode.
@@ -45,7 +46,7 @@ if (app) {
4546
{label:'Catalogs CLASSIC', action:'IrsaCatalogDropDown'},
4647
{label:'Test Searches', action:'TestSearches'},
4748
{label:'Images', action:'ImageSelectDropDownCmd'},
48-
{label:'Help', action:'overviewHelp', type:'COMMAND'},
49+
{label:'Help', action:HELP_LOAD, type:'COMMAND'},
4950
{label:'Example Js Dialog', action:'exampleDialog', type:'COMMAND'}
5051
]
5152
};

src/firefly/js/tables/TableConnector.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export class TableConnector {
4444
* @param {number[]} selected array of selected row indices.
4545
*/
4646
onFilterSelected(selected) {
47+
if (isEmpty(selected)) return;
48+
4749
var {tableModel, request} = TblUtil.getTblInfoById(this.tbl_id);
4850
if (this.origTableModel) {
4951
// not implemented yet
@@ -133,6 +135,8 @@ export class TableConnector {
133135

134136

135137
function getRowIdFor(filePath, selected) {
138+
if (isEmpty(selected)) return [];
139+
136140
const params = {id: 'Table__SelectedValues', columnName: 'ROWID', filePath, selectedRows: String(selected)};
137141

138142
return fetchUrl(TblUtil.SEARCH_SRV_PATH, {method: 'post', params}).then( (response) => {

src/firefly/js/tables/TableUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {flux} from '../Firefly.js';
99
import {fetchUrl, encodeServerUrl, encodeParams} from '../util/WebUtil.js';
1010
import {getRootPath, getRootURL} from '../util/BrowserUtil.js';
1111

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

src/firefly/js/tables/ui/TableRenderer.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import DESC_ICO from 'html/images/sort_desc.gif';
1818
import FILTER_SELECTED_ICO from 'html/images/icons-2014/16x16_Filter.png';
1919

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

2223
// the components here are small and used by table only. not all props are defined.
2324
/* eslint-disable react/prop-types */
@@ -168,10 +169,10 @@ export class TextCell extends React.Component {
168169
// }
169170
//
170171
render() {
172+
var val = getValue(this.props);
173+
val = (val.search(html_regex) >= 0) ? <div dangerouslySetInnerHTML={{__html: val}} /> : val;
171174
return (
172-
<div className='public_fixedDataTableCell_cellContent'>
173-
{getValue(this.props)}
174-
</div>
175+
<div className='public_fixedDataTableCell_cellContent'>{val}</div>
175176
);
176177
}
177178
}

src/firefly/js/ui/PagingBar.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ export class PagingBar extends Component {
4242
onChange = {onPageChange}
4343
actOn={['blur','enter']}
4444
showWarning={false}
45-
/> <div style={{fontSize: 'smaller'}} >&nbsp; of {totalPages}</div>
45+
/> <div style={{fontSize: 'smaller', marginLeft: 3}} > of {totalPages}</div>
4646
<button onClick={() => callbacks.onGotoPage(currentPage + 1)} className='paging_bar next' title='Next Page'/>
4747
<button onClick={() => callbacks.onGotoPage(totalPages)} className='paging_bar last' title='Last Page'/>
48-
<div style={{fontSize: 'smaller'}} > &nbsp; ({(startIdx+1).toLocaleString()} - {endIdx.toLocaleString()} of {totalRows.toLocaleString()})</div>
48+
<div style={{fontSize: 'smaller', marginLeft: 3}} > ({(startIdx+1).toLocaleString()} - {endIdx.toLocaleString()} of {totalRows.toLocaleString()})</div>
4949
{showLoading ? <img style={{width:14,height:14,marginTop: '3px'}} src={LOADING}/> : false}
5050
</div>
5151
);

src/firefly/js/util/WebUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function getModuleName() {
3737
export const encodeUrl= function(url, params) {
3838

3939
var rval = url.trim();
40-
if ( !(rval.toLowerCase().startsWith('http') || rval.startsWith('/')) ) {
40+
if ( !rval.toLowerCase().startsWith('http') ) {
4141
rval = getRootURL() + rval;
4242
}
4343
if (!params) return rval;

0 commit comments

Comments
 (0)