Skip to content

Commit

Permalink
Merge 97d621f into 8953e20
Browse files Browse the repository at this point in the history
  • Loading branch information
briehl committed Apr 4, 2018
2 parents 8953e20 + 97d621f commit 2e9e756
Show file tree
Hide file tree
Showing 41 changed files with 2,061 additions and 567 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ test-frontend-e2e:
cd $(FRONTEND_TEST_DIR)
@echo "done"

# test-frontend-casper is an early-stage test, using a headless browser/scripting framework
# (CasperJS). Right now, it's intended to run tests that verify that viewer widgets work as
# intended.
#
# It requires an installed and running Narrative.
test-frontend-casper:
@echo "running frontend viewer tests"
python test/casper/run_tests.py
@echo "done"


build-docs:
cd src && export PYTHONPATH=`pwd` && python2.7 setup.py doc
-mkdir docs
Expand Down
3 changes: 2 additions & 1 deletion kbase-extension/static/kbase/config/feature-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"stagingDataViewer": true,
"jgiPublicStaging": true,
"advanced": false,
"developer": false
"developer": false,
"lazyWidgetRender": true
}
16 changes: 1 addition & 15 deletions kbase-extension/static/kbase/css/kbaseNarrative.css
Original file line number Diff line number Diff line change
Expand Up @@ -1448,14 +1448,6 @@ div#notebook_panel {
cursor: pointer;
}

.kb-cell-toolbar {
xborder-bottom: 1px silver solid;
}

.kb-cell-toolbar.collapsed {
xborder-bottom: none;
}

.kb-cell-toolbar .buttons {
font-weight: bold;
color: #CECECE !important;
Expand All @@ -1470,7 +1462,7 @@ div#notebook_panel {
height: 56px;
width: 56px;
padding: 0;
margin: 0 4px 0 4px;
margin-right: 4px;
vertical-align: top;
border: 0px red solid;
line-height: 56px;
Expand Down Expand Up @@ -1670,12 +1662,6 @@ div#notebook_panel {
border-bottom-color: #bce8f1;
}

.kb-func-panel .panel-footer {
/*background-color: #fff;
border-top: none; */
/*padding: 2px 15px;*/
}

/** output cell styling */
.kb-cell-output .panel {
border-radius: 0px;
Expand Down
53 changes: 52 additions & 1 deletion kbase-extension/static/kbase/js/api/upa.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,64 @@ define([
return deserial;
};

var changeUpaVersion = function(upa, newVersion) {
if (!isUpa(upa)) {
throw {
error: upa + ' is not a valid upa, so its version cannot be changed!'
};
}
if ((!(/^\d+$/.test(newVersion)) || newVersion <= 0)) {
throw {
error: newVersion + ' is not a valid version number!'
};
}
var newUpa = upa.replace(/^(.+\/)(\d+)$/, '$1' + newVersion);
return newUpa;
};

var serializeAll = function(upas) {
if (typeof upas === 'string') {
return serialize(upas);
}
else if (Array.isArray(upas)) {
return upas.map(function(upa) {
return serialize(upa);
});
}
else {
return Object.keys(upas).reduce(function(acc, key) {
acc[key] = serializeAll(upas[key]);
return acc;
}, {});
}
};

var deserializeAll = function(upas) {
if (typeof upas === 'string') {
return deserialize(upas);
}
else if (Array.isArray(upas)) {
return upas.map(function(upa) {
return deserialize(upa);
});
}
else {
return Object.keys(upas).reduce(function(acc, key) {
acc[key] = deserializeAll(upas[key]);
return acc;
}, {});
}
};

return {
serialize: serialize,
deserialize: deserialize,
serializeExternal: serializeExternal,
externalTag: externalTag,
isUpa: isUpa
isUpa: isUpa,
changeUpaVersion: changeUpaVersion,
serializeAll: serializeAll,
deserializeAll: deserializeAll
};
};

Expand Down
15 changes: 9 additions & 6 deletions kbase-extension/static/kbase/js/kbaseNarrative.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ define([
'notebook/js/notebook',
'util/display',
'util/bootstrapDialog',
'util/bootstrapAlert',
'util/timeFormat',
'text!kbase/templates/update_dialog_body.html',
'text!kbase/templates/document_version_change.html',
Expand Down Expand Up @@ -65,7 +64,6 @@ define([
Notebook,
DisplayUtil,
BootstrapDialog,
BootstrapAlert,
TimeFormat,
UpdateDialogBodyTemplate,
DocumentVersionDialogBodyTemplate,
Expand Down Expand Up @@ -391,7 +389,7 @@ define([
Narrative.prototype.showDocumentVersionDialog = function (newVerInfo) {
var bodyTemplate = Handlebars.compile(DocumentVersionDialogBodyTemplate);

var versionDialog = new BootstrapAlert({
var versionDialog = new BootstrapDialog({
title: 'Showing an older Narrative document',
body: bodyTemplate({
currentVer: this.documentVersionInfo,
Expand All @@ -400,7 +398,8 @@ define([
newDate: TimeFormat.readableTimestamp(newVerInfo[3]),
sameUser: this.documentVersionInfo[5] === newVerInfo[5],
readOnly: this.readonly
})
}),
alertOnly: true
});

versionDialog.show();
Expand Down Expand Up @@ -846,10 +845,11 @@ define([
*/
Narrative.prototype.addViewerCell = function(obj) {
if (Jupyter.narrative.readonly) {
new BootstrapAlert({
new BootstrapDialog({
type: 'warning',
title: 'Warning',
body: 'Read-only Narrative -- may not add a data viewer to this Narrative'
body: 'Read-only Narrative -- may not add a data viewer to this Narrative',
alertOnly: true
});
return;
}
Expand Down Expand Up @@ -951,6 +951,9 @@ define([
* get_cell_elements, which does this searching).
*/
Narrative.prototype.getCellIndexByKbaseId = function (id) {
if (!Jupyter.notebook) {
return null;
}
var cells = Jupyter.notebook.get_cells();
for (var i = 0; i < cells.length; i++) {
var c = cells[i];
Expand Down
91 changes: 0 additions & 91 deletions kbase-extension/static/kbase/js/util/bootstrapAlert.js

This file was deleted.

47 changes: 29 additions & 18 deletions kbase-extension/static/kbase/js/util/bootstrapDialog.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/*global define*/
/*jslint white: true*/
define (
[
'bootstrap',
'jquery'
], function (
bootstrap,
$
) {
define ([
'bootstrap',
'jquery'
], function (
bootstrap,
$
) {
'use strict';

/**
Expand All @@ -17,7 +16,9 @@ define (
* body: jquery node
* buttons: array of jquery nodes
* closeButton: boolean, default false
* enterToTrigger: boolean, default false
* enterToTrigger: boolean, default false,
* type: string, type of alert (from bootstrap text types: warning, error, etc.),
* alertOnly: create as an "alert" with a single "Close" button in the footer
* }
*/
var BootstrapDialog = function (options) {
Expand All @@ -36,6 +37,14 @@ define (
if (options.enterToTrigger) {
this.enterToTrigger = options.enterToTrigger;
}
if (options.alertOnly) {
options.closeButton = true;
options.buttons = [
$('<button type="button" class="btn btn-primary" data-dismiss="modal">')
.text('Close')
];
options.enterToTrigger = true;
}

this.initialize(options);
};
Expand All @@ -53,6 +62,9 @@ define (
if (options.title) {
this.setTitle(options.title);
}
if (options.type) {
this.$headerTitle.addClass('text-' + options.type);
}
if (options.body) {
this.setBody(options.body);
}
Expand Down Expand Up @@ -87,15 +99,14 @@ define (
}
if (this.enterToTrigger) {
this.$modal
.off('keypress')
.on('keypress', (function(e) {
if (e.keyCode === 13) {
e.stopPropagation();
e.preventDefault();

this.$footer.find('.btn:last').trigger('click');
}
}.bind(this)));
.off('keypress')
.on('keypress', (function(e) {
if (e.keyCode === 13) {
e.stopPropagation();
e.preventDefault();
this.$footer.find('button:last').trigger('click');
}
}.bind(this)));
}
};

Expand Down
Loading

0 comments on commit 2e9e756

Please sign in to comment.