11
11
* Controller of the oncokbStaticApp
12
12
*/
13
13
angular . module ( 'oncokbStaticApp' )
14
- . controller ( 'CancerGenesCtrl' , function ( $scope , _ , api , $q , apiLink ) {
15
- // DataTable initialization & options
16
- $scope . dt = { } ;
17
- $scope . dt . dtOptions = {
18
- paging : true ,
19
- hasBootstrap : true ,
20
- language : {
21
- loadingRecords : '<img src="resources/images/loader.gif">'
22
- } ,
23
- pageLength : 15 ,
24
- lengthMenu : [ [ 15 , 30 , 50 , 100 , - 1 ] , [ 15 , 30 , 50 , 100 , 'All' ] ] ,
25
- pagingType : 'numbers' ,
26
- aaSorting : [ [ 9 , 'desc' ] , [ 0 , 'asc' ] , [ 1 , 'desc' ] ] ,
27
- columns : [
28
- { type : 'html' , orderSequence : [ 'asc' , 'desc' ] } ,
29
- { type : 'html' , orderSequence : [ 'desc' , 'asc' ] } ,
30
- { type : 'string' , orderSequence : [ 'desc' , 'asc' ] } ,
31
- { type : 'string' , orderSequence : [ 'desc' , 'asc' ] } ,
32
- { type : 'string' , orderSequence : [ 'desc' , 'asc' ] } ,
33
- { type : 'string' , orderSequence : [ 'desc' , 'asc' ] } ,
34
- { type : 'string' , orderSequence : [ 'desc' , 'asc' ] } ,
35
- { type : 'string' , orderSequence : [ 'desc' , 'asc' ] } ,
36
- { type : 'string' , orderSequence : [ 'desc' , 'asc' ] } ,
37
- { type : 'number' , orderSequence : [ 'desc' , 'asc' ] }
38
- ] ,
39
- responsive : true
40
- } ;
14
+ . controller ( 'CancerGenesCtrl' , function ( $rootScope , $scope , _ , api , $q , apiLink , NgTableParams ) {
15
+
41
16
42
17
function displayConvert ( obj , keys ) {
43
18
_ . each ( keys , function ( key ) {
@@ -46,46 +21,59 @@ angular.module('oncokbStaticApp')
46
21
return obj ;
47
22
}
48
23
49
- $scope . fetchedDate = '05/30/2017' ;
50
- $scope . doneLoading = false ;
51
- $scope . columnOrder = [ 'mSKImpact' , 'mSKHeme' , 'foundation' , 'foundationHeme' , 'vogelstein' , 'sangerCGC' ] ;
24
+ $scope . fetchedDate = '05/07/2019' ;
25
+ $scope . sources = [ 'oncokbAnnotated' , 'foundation' , 'foundationHeme' , 'mSKImpact' , 'mSKHeme' , 'vogelstein' , 'sangerCGC' ] ;
26
+ $scope . numOfGenes = _ . reduce ( $scope . sources , function ( acc , next ) {
27
+ acc [ next ] = 0 ;
28
+ return acc ;
29
+ } , { total : 0 } ) ;
52
30
53
- $q . all ( [ api . getGenes ( ) , api . getCancerGeneList ( ) ] ) . then ( function ( result ) {
54
- var geneTypeMapping = { } ;
55
- _ . each ( result [ 0 ] . data , function ( gene ) {
56
- if ( gene . oncogene ) {
57
- if ( gene . tsg ) {
58
- geneTypeMapping [ gene . hugoSymbol ] = 'Both' ;
31
+ $scope . doneLoading = true ;
32
+
33
+ $scope . data = {
34
+ searchTerm : '' ,
35
+ lastUpdate : $rootScope . data . lastUpdate
36
+ } ;
37
+
38
+ function getNgTable ( data ) {
39
+ return new NgTableParams ( {
40
+ sorting : { occurrenceCount : 'desc' , hugoSymbol : 'asc' , oncokbAnnotated : 'desc' } ,
41
+ count : 15
42
+ } , {
43
+ counts : [ 15 , 30 , 50 , 100 ] ,
44
+ dataset : data
45
+ } ) ;
46
+ }
47
+
48
+ $scope . updateSearchTerm = function ( ) {
49
+ $scope . tableParams . filter ( { $ : $scope . data . searchTerm } ) ;
50
+ } ;
51
+
52
+ api . getCancerGeneList ( ) . then ( function ( result ) {
53
+ var tempData = result . data ;
54
+ _ . each ( tempData , function ( item ) {
55
+ item = displayConvert ( item , $scope . sources ) ;
56
+ if ( item . oncogene ) {
57
+ if ( item . tsg ) {
58
+ item . geneType = 'Oncogene/TSG' ;
59
59
} else {
60
- geneTypeMapping [ gene . hugoSymbol ] = 'Oncogene' ;
60
+ item . geneType = 'Oncogene' ;
61
61
}
62
- } else if ( gene . tsg ) {
63
- geneTypeMapping [ gene . hugoSymbol ] = 'TSG' ;
62
+ } else if ( item . tsg ) {
63
+ item . geneType = 'TSG' ;
64
64
}
65
65
} ) ;
66
- var tempData = result [ 1 ] . data ;
67
- _ . each ( tempData , function ( item ) {
68
- item = displayConvert ( item , [ 'oncokbAnnotated' , 'foundation' , 'foundationHeme' , 'mSKImpact' , 'mSKHeme' , 'vogelstein' , 'sangerCGC' ] ) ;
69
- switch ( geneTypeMapping [ item . hugoSymbol ] ) {
70
- case 'Oncogene' :
71
- item . oncogene = 'Yes' ;
72
- break ;
73
- case 'TSG' :
74
- item . tsg = 'Yes' ;
75
- break ;
76
- case 'Both' :
77
- item . oncogene = 'Yes' ;
78
- item . tsg = 'Yes' ;
79
- break ;
80
- default :
81
- break ;
82
- }
66
+ _ . each ( $scope . sources , function ( key ) {
67
+ $scope . numOfGenes [ key ] = _ . filter ( tempData , function ( item ) {
68
+ return item [ key ] === 'Yes' ;
69
+ } ) . length ;
83
70
} ) ;
84
- $scope . cancerGeneList = tempData ;
85
- $scope . doneLoading = true ;
71
+ $scope . tableParams = getNgTable ( tempData ) ;
72
+ $scope . numOfGenes . total = tempData . length ;
73
+ $scope . doneLoading = false ;
86
74
} , function ( error ) {
87
- $scope . cancerGeneList = [ ] ;
88
- $scope . doneLoading = true ;
75
+ $scope . tableParams = getNgTable ( [ ] ) ;
76
+ $scope . doneLoading = false ;
89
77
} ) ;
90
78
$scope . apiLink = apiLink ;
91
79
} ) ;
0 commit comments