Skip to content

Commit

Permalink
Closes OHDSI#235
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonysena committed Sep 19, 2016
1 parent cfa3b72 commit 6aaef25
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 10 deletions.
4 changes: 3 additions & 1 deletion js/components/cohort-comparison-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ define(['knockout', 'text!./cohort-comparison-browser.html', 'appConfig','cohort
},
{
title: 'Name',
data: 'name'
data: d => {
return '<span class=\'linkish\'>' + d.name + '</span>';
},
},
{
title: 'Created',
Expand Down
17 changes: 16 additions & 1 deletion js/components/cohort-comparison-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</li>
<li role="presentation" data-bind="visible: config.cohortComparisonResultsEnabled, css: { active: $component.tabMode() == 'results' }, click: function() { $component.tabMode('results') };"><a>Results</a>
</li>
<li role="presentation" data-bind="css: { active: $component.tabMode() == 'export' }, click: function() { $component.tabMode('export') };"><a>Export</a>
<li role="presentation" data-bind="css: { active: $component.tabMode() == 'export' }, click: function() { $component.tabMode('export') };"><a>Utilities</a>
</li>
</ul>

Expand Down Expand Up @@ -575,6 +575,8 @@
<ul class="nav nav-pills">
<li role="presentation" data-bind="css: {active: $component.expressionMode() == 'print' }, click: function() {$component.expressionMode('print') };"><a>Print Friendly</a></li>
<li role="presentation" data-bind="css: {active: $component.expressionMode() == 'rcode' }, click: function() {$component.expressionMode('rcode') };"><a>R Code</a></li>
<li role="presentation" data-bind="css: {active: $component.expressionMode() == 'import' }, click: function() {$component.expressionMode('import') };"><a>Import</a></li>
<li role="presentation" data-bind="css: {active: $component.expressionMode() == 'export' }, click: function() {$component.expressionMode('export') };"><a>Export</a></li>
</ul>
<div role="tabpanel" data-bind="visible: $component.expressionMode() == 'print'" class="tab-pane">
<div class="paddedWrapper">
Expand All @@ -586,6 +588,19 @@
<cohort-comparison-r-code params="cohortComparison: $component.cohortComparison"></cohort-comparison-r-code>
</div>
</div>
<div role="tabpanel" data-bind="visible: $component.expressionMode() == 'import'" class="tab-pane">
<div class="paddedWrapper">
<textarea class="code" style="width: 100%; height: 300px" data-bind="textInput: $component.importJSON"></textarea>
<div style="text-align: right">
<button class="btn btn-sm btn-primary" data-bind="click: $component.import">Import</button>
</div>
</div>
</div>
<div role="tabpanel" data-bind="visible: $component.expressionMode() == 'export'" class="tab-pane">
<div class="paddedWrapper">
<textarea class="code" style="width: 100%; height: 300px" data-bind="textInput: $component.expressionJSON"></textarea>
</div>
</div>
</div>
</div>
</div>
Expand Down
30 changes: 28 additions & 2 deletions js/components/cohort-comparison-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,24 @@ define(['jquery', 'knockout', 'text!./cohort-comparison-manager.html', 'lodash',
self.options = options;
self.expressionMode = ko.observable('print');
self.om = ko.observable();

self.modifiedJSON = "";
self.importJSON = ko.observable();
self.expressionJSON = ko.pureComputed({
read: function () {
return ko.toJSON(self.cohortComparison(), function (key, value) {
if (value === 0 || value) {
delete value.analysisId;
delete value.name;
return value;
} else {
return
}
}, 2);
},
write: function (value) {
self.modifiedJSON = value;
}
});

// for balance chart
self.chartObj = ko.observable();
Expand Down Expand Up @@ -834,7 +851,16 @@ define(['jquery', 'knockout', 'text!./cohort-comparison-manager.html', 'lodash',
self.monitorJobExecution(c.executionId, sourceKey);
}
});
};
};

self.import = function () {
if (self.importJSON().length > 0) {
var updatedExpression = JSON.parse(self.importJSON());
self.cohortComparison(new ComparativeCohortAnalysis(updatedExpression));
self.importJSON("");
self.tabMode('specification');
}
};

// startup actions

Expand Down
29 changes: 27 additions & 2 deletions js/components/ir-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
</li>

<li role="presentation" data-bind="css: { active: $component.activeTab() == 'generation' }, click: function() { $component.activeTab('generation') };">
<a>Generation</a>
<a>Generation</a>
</li>

<li role="presentation" data-bind="css: { active: $component.activeTab() == 'utilities' }, click: function() { $component.activeTab('utilities') };"><a>Utilities</a>
</li>

</ul>
<div class="tab-content">
<div role="tabpanel" data-bind="css: { active: $component.activeTab() == 'definition' }" class="tab-pane">
Expand All @@ -53,7 +57,28 @@
eventListener: [{ event: 'click', selector: 'button.removeResult', callback: removeResult}, {event: 'click', selector: 'button.execute', callback: onExecuteClick}]" class="tab-pane">
<ir-analysis-results params="sources: filteredSources, analysisCohorts: analysisCohorts"></ir-analysis-results>
</div>
</div>
<div role="tabpanel" data-bind="css: { active: $component.activeTab() == 'utilities' }" class="tab-pane">
<div class="paddedWrapper">
<ul class="nav nav-pills">
<li role="presentation" data-bind="css: {active: $component.expressionMode() == 'import' }, click: function() {$component.expressionMode('import') };"><a>Import</a></li>
<li role="presentation" data-bind="css: {active: $component.expressionMode() == 'export' }, click: function() {$component.expressionMode('export') };"><a>Export</a></li>
</ul>
<div role="tabpanel" data-bind="visible: $component.expressionMode() == 'import'" class="tab-pane">
<div class="paddedWrapper">
<textarea class="code" style="width: 100%; height: 300px" data-bind="textInput: $component.importJSON"></textarea>
<div style="text-align: right">
<button class="btn btn-sm btn-primary" data-bind="click: $component.import">Import</button>
</div>
</div>
</div>
<div role="tabpanel" data-bind="visible: $component.expressionMode() == 'export'" class="tab-pane">
<div class="paddedWrapper">
<textarea class="code" style="width: 100%; height: 300px" data-bind="textInput: $component.expressionJSON"></textarea>
</div>
</div>
</div>
</div>
</div>
</div>

<div data-bind="modal: showConceptSetBrowser" class="modal fade" tabindex="-1" role="dialog">
Expand Down
34 changes: 31 additions & 3 deletions js/components/ir-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ define(['knockout',
'webapi/SourceAPI',
'webapi/CohortDefinitionAPI',
'iranalysis/IRAnalysisDefinition',
'iranalysis/IRAnalysisExpression',
'ohdsi.util',
'iranalysis',
'databindings',
'conceptsetbuilder/components',
'circe'
], function (ko, template, iraAPI, sourceAPI, cohortAPI, IRAnalysisDefinition, ohdsiUtil) {
], function (ko, template, iraAPI, sourceAPI, cohortAPI, IRAnalysisDefinition, IRAnalysisExpression, ohdsiUtil) {
function IRAnalysisManager(params) {


Expand Down Expand Up @@ -64,6 +65,24 @@ define(['knockout',
data.selectedData.action();
}
};

self.modifiedJSON = "";
self.importJSON = ko.observable();
self.expressionJSON = ko.pureComputed({
read: function () {
return ko.toJSON(self.selectedAnalysis().expression(), function (key, value) {
if (value === 0 || value) {
return value;
} else {
return
}
}, 2);
},
write: function (value) {
self.modifiedJSON = value;
}
});
self.expressionMode = ko.observable('import');

// model behaviors

Expand Down Expand Up @@ -165,7 +184,16 @@ define(['knockout',
pollForInfo();
});
}


self.import = function () {
if (self.importJSON() && self.importJSON().length > 0) {
var updatedExpression = JSON.parse(self.importJSON());
self.selectedAnalysis().expression(new IRAnalysisExpression(updatedExpression));
self.importJSON("");
self.activeTab('definition');
}
};

self.init = function() {
self.refreshDefs();
if (self.selectedAnalysisId() == null && self.selectedAnalysis() == null) {
Expand Down Expand Up @@ -207,7 +235,7 @@ define(['knockout',
}

// startup actions
self.init();
self.init();

sourceAPI.getSources().then(function(sources) {
var sourceList = [];
Expand Down
2 changes: 1 addition & 1 deletion js/styles/atlas.css
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,7 @@ div.button-overlay {

textarea.code {
font-style='Courier New';
font-size: 8px;
/* font-size: 8px; */
}

.panel-default>.panel-heading {
Expand Down

0 comments on commit 6aaef25

Please sign in to comment.