Commit ab1b612e authored by Boris A. Burkov's avatar Boris A. Burkov
Browse files

Preparing to remove go-modal and move its logic to sequence.html/sequence.module.js for simplicity.

parent d7d97bc8
......@@ -3,6 +3,7 @@ var goAnnotations = {
upi: '=',
taxid: '=',
showGoAnnotations: '&',
onToggleGoModal: '&'
},
controller: ['$http', 'routes', function($http, routes) {
......@@ -42,7 +43,6 @@ var goAnnotations = {
};
ctrl.$onInit = function() {
ctrl.chart_data = '';
ctrl.fetchGoTerms().then(
function(response) {
ctrl.go_annotations = response.data;
......@@ -74,24 +74,12 @@ var goAnnotations = {
ctrl.fetchGoTerms = function() {
return $http.get(
routes.apiGoTermsView({ upi: ctrl.upi, taxid: ctrl.taxid }),
{ timeout: 5000 }
{ timeout: 20000 }
);
};
ctrl.openGoChartModal = function(term_id) {
var ontology = term_id.split(':')[0].toLowerCase();
var png = routes.quickGoChart({ ontology: ontology, term_ids: term_id });
ctrl.modal_status = 'loading';
$('#go-annotation-chart-modal').modal();
$http.get(png, { timeout: 5000 }).then(
function(response) {
ctrl.modal_status = 'loaded';
ctrl.chart_data = 'data:image/png;charset=utf-8;base64,' + response.data;
},
function(error) {
ctrl.modal_status = 'failed';
});
ctrl.openGoModal = function(termId) {
ctrl.onToggleGoModal({termId: termId});
};
}],
......
......@@ -14,12 +14,12 @@
<tr ng-if="!$ctrl.error" ng-repeat="annotation in $ctrl.go_annotations">
<td>{{ annotation.qualifier }}</td>
<td>
<a class="btn btn-circle btn-default btn-sm" ng-click="$ctrl.openGoChartModal(annotation.go_term_id)" type="button"><i class="fa fa-sitemap" uib-tooltip="View {{annotation.go_term_id}} ancestor chart"></i></button>
<a class="btn btn-circle btn-default btn-sm" ng-click="$ctrl.openGoModal(annotation.go_term_id)" type="button"><i class="fa fa-sitemap" uib-tooltip="View {{annotation.go_term_id}} ancestor chart"></i></button>
<a class="btn btn-sm" href='/search?q={{ annotation.qualifier }}:"{{ annotation.go_term_id }}"'><i class="fa fa-search" uib-tooltip="Search for sequences annotated with {{annotation.go_term_id}}"></i></a>
<a href="http://www.ebi.ac.uk/QuickGO/term/{{ annotation.go_term_id }}" class="no-icon">{{ annotation.go_term_name }}</a>
</td>
<td>
<a class="btn btn-circle btn-default btn-sm" ng-click="$ctrl.openGoChartModal(annotation.evidence_code_id)" type="button"><i class="fa fa-sitemap" uib-tooltip="View {{annotation.evidence_code_id}} ancestor chart"></i></a>
<a class="btn btn-circle btn-default btn-sm" ng-click="$ctrl.openGoModal(annotation.evidence_code_id)" type="button"><i class="fa fa-sitemap" uib-tooltip="View {{annotation.evidence_code_id}} ancestor chart"></i></a>
<a href="https://www.ebi.ac.uk/QuickGO/term/{{ annotation.evidence_code_id }}" class="no-icon">{{ annotation.evidence_code_name }}</a>
<small ng-if="annotation.needs_explanation">(<a href="{{ annotation.explanation_url }}">About this annotation</a>)</small>
</td>
......
......@@ -2,27 +2,39 @@ var goModal = {
bindings: {
upi: '=',
taxid: '=',
termId: '<'
termId: '<',
onToggleGoModal: '<'
},
controller: ['$http', 'routes', function($http, routes) {
var ctrl = this;
ctrl.openGoChartModal = function(term_id) {
var ontology = termId.split(':')[0].toLowerCase();
var png = routes.quickGoChart({ ontology: ontology, term_ids: termId });
ctrl.modal_status = 'loading';
$('#go-annotation-chart-modal').modal();
ctrl.$onInit = function() {
ctrl.chartData = '';
};
ctrl.$onChanges = function(changes) {
if (changes.termId.currentValue != null) {
var ontology = changes.termId.currentValue.split(':')[0].toLowerCase();
var png = routes.quickGoChart({ ontology: ontology, term_ids: changes.termId.currentValue });
ctrl.modalStatus = 'loading';
$('#go-annotation-chart-modal').modal();
$http.get(png, { timeout: 10000 }).then(
function(response) {
ctrl.modalStatus = 'loaded';
ctrl.chartData = 'data:image/png;charset=utf-8;base64,' + response.data;
},
function(error) {
ctrl.modalStatus = 'failed';
}
);
}
};
$http.get(png, { timeout: 5000 }).then(
function(response) {
ctrl.modalStatus = 'loaded';
ctrl.chartData = 'data:image/png;charset=utf-8;base64,' + response.data;
},
function(error) {
ctrl.modalStatus = 'failed';
}
);
ctrl.closeModal = function() {
ctrl.onToggleGoModal({termId : null});
$('#go-annotation-chart-modal').modal('toggle');
};
}],
......
......@@ -6,22 +6,22 @@
</div>
<div class="modal-body">
<span ng-if="$ctrl.modal_status === 'loading'">
<span ng-if="$ctrl.modalStatus === 'loading'">
<i class="fa fa-spinner fa-spin fa-2x"></i>
Loading ontology ancestors...
</span>
<span ng-if="$ctrl.modal_status === 'failed'">
<span ng-if="$ctrl.modalStatus === 'failed'">
Failed to load QuickGO Ancestor chart
</span>
<span ng-if="$ctrl.modal_status === 'loaded'">
<img ng-src="{{ $ctrl.chart_data }}" />
<span ng-if="$ctrl.modalStatus === 'loaded'">
<img ng-src="{{ $ctrl.chartData }}" />
</span>
</div>
<div class="modal-footer">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<button ng-click="$ctrl.toggleGoModal({termId: null})" type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>
</div>
</div>
</div>
......
......@@ -52,6 +52,11 @@ var rnaSequenceController = function($scope, $location, $window, $rootScope, $co
$scope.hideGoAnnotations = false;
};
// Pass non-null termId to open Go modal and null to close
$scope.toggleGoModal = function(termId) {
$scope.goTermId = termId;
};
// Hopscotch tour
// --------------
......
......@@ -198,6 +198,7 @@ limitations under the License.
<script src="{% static "js/components/sequence/xrefs/xref-publications/xref-publications.component.js" %}"></script>
<script src="{% static "js/components/sequence/2d/2d.component.js" %}"></script>
<script src="{% static "js/components/sequence/go-annotations/go-annotations.component.js" %}"></script>
<script src="{% static "js/components/sequence/go-modal/go-modal.component.js" %}"></script>
<script src="{% static "js/components/sequence-search/nhmmer.sequence.search.js" %}"></script>
......
......@@ -191,7 +191,8 @@ limitations under the License.
</a>
</small>
</h2>
<go-annotations upi="upi" taxid="taxid" show-go-annotations="showGOAnnotations()"></go-annotations>
<go-annotations upi="upi" taxid="taxid" show-go-annotations="showGOAnnotations()" on-toggle-go-modal="toggleGoModal(termId)"></go-annotations>
<go-modal upi="upi" taxid="taxid" term-id="goTermId" on-toggle-go-modal="toggleGoModal(termId)"></go-modal>
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment