@@ -10,21 +10,12 @@ testApp.controller('HomeCtrl', ['$scope', '$rootScope', '$http', '$location', "S
10
10
$scope . tests = [ ] ;
11
11
$scope . total_models = 0 ;
12
12
13
- $scope . _load_other_models = function ( ) {
14
- var i = 2 ;
15
- for ( i ; i <= $scope . nb_pages ; i ++ ) {
16
- DataHandler . loadModelsByPage ( { app_id : $scope . app_id , page : i } ) . then ( function ( new_models ) {
17
- $scope . models . models = $scope . models . models . concat ( new_models . models ) ;
18
- $scope . models . models = $scope . models . models . sort ( _sort_array_by_timestamp_desc )
19
- $scope . $apply ( ) ;
20
- } )
21
- }
22
- }
23
- var _sort_array_by_timestamp_desc = function ( a , b ) {
24
- return new Date ( b . creation_date ) - new Date ( a . creation_date ) ;
25
- }
13
+ $scope . $on ( 'models_updated' , function ( event , models ) {
14
+ $scope . models = models ;
15
+ } ) ;
16
+
17
+
26
18
Context . setService ( ) . then ( function ( ) {
27
- console . log ( 'collab parameters setted' )
28
19
29
20
$scope . Context = Context ;
30
21
$scope . ctx = Context . getCtx ( ) ;
@@ -43,10 +34,7 @@ testApp.controller('HomeCtrl', ['$scope', '$rootScope', '$http', '$location', "S
43
34
$scope . collab_data_modalities = CollabParameters . getParametersOrDefaultByType ( "data_modalities" ) ;
44
35
$scope . collab_organization = CollabParameters . getParametersOrDefaultByType ( "organization" ) ;
45
36
46
- //$scope.models = ScientificModelRest.get({ app_id: app_id }, function(data) {});
47
- //$scope.tests = ValidationTestDefinitionRest.get({ app_id: app_id }, function(data) {});
48
- // //for test
49
- // $scope.put_test1 = ValidationTestCodeRest.put({ app_id: app_id, test_definition_id: "53a7a2db-b18f-49ef-b1de-88bd48960c81", version: "1.1" });
37
+
50
38
DataHandler . loadModels ( { app_id : $scope . app_id , page : 1 } ) . then ( function ( data ) {
51
39
$scope . total_models = data . total_models ;
52
40
$scope . nb_pages = data . total_nb_pages ;
@@ -59,7 +47,11 @@ testApp.controller('HomeCtrl', ['$scope', '$rootScope', '$http', '$location', "S
59
47
$ ( '#preloader-models' ) . delay ( 350 ) . fadeOut ( 'slow' ) ; // will fade out the white DIV that covers the website.
60
48
$ ( '#models-panel' ) . delay ( 350 ) . css ( { 'overflow' : 'visible' } ) ;
61
49
62
- $scope . _load_other_models ( ) ;
50
+
51
+ var status = DataHandler . getCurrentStatus ( ) ;
52
+ if ( status != "up_to_date" ) {
53
+ DataHandler . loadModelsByPage ( $scope . app_id , $scope . nb_pages ) ;
54
+ }
63
55
} ) ;
64
56
65
57
DataHandler . loadTests ( { app_id : $scope . app_id } ) . then ( function ( data ) {
@@ -1126,21 +1118,9 @@ ModelCatalogApp.controller('ModelCatalogCtrl', [
1126
1118
return models
1127
1119
}
1128
1120
1129
-
1130
- $scope . _load_other_models = function ( ) {
1131
- var i = 2 ;
1132
- for ( i ; i <= $scope . nb_pages ; i ++ ) {
1133
- DataHandler . loadModelsByPage ( { app_id : $scope . app_id , page : i } ) . then ( function ( new_models ) {
1134
- $scope . models . models = $scope . models . models . concat ( $scope . _change_empty_organization_string ( new_models ) . models ) ;
1135
- $scope . models . models = $scope . models . models . sort ( _sort_array_by_timestamp_desc )
1136
- $scope . $apply ( ) ;
1137
- } )
1138
- }
1139
- }
1140
-
1141
- var _sort_array_by_timestamp_desc = function ( a , b ) {
1142
- return new Date ( b . creation_date ) - new Date ( a . creation_date ) ;
1143
- }
1121
+ $scope . $on ( 'models_updated' , function ( event , models ) {
1122
+ $scope . models = $scope . _change_empty_organization_string ( models ) ;
1123
+ } ) ;
1144
1124
1145
1125
Context . setService ( ) . then ( function ( ) {
1146
1126
@@ -1166,11 +1146,12 @@ ModelCatalogApp.controller('ModelCatalogCtrl', [
1166
1146
$ ( '#preloader' ) . delay ( 350 ) . fadeOut ( 'slow' ) ; // will fade out the white DIV that covers the website.
1167
1147
$ ( 'body' ) . delay ( 350 ) . css ( { 'overflow' : 'visible' } ) ;
1168
1148
1169
-
1170
- $scope . _load_other_models ( ) ;
1171
-
1172
-
1149
+ var status = DataHandler . getCurrentStatus ( ) ;
1150
+ if ( status != "up_to_date" ) {
1151
+ DataHandler . loadModelsByPage ( $scope . app_id , $scope . nb_pages ) ;
1152
+ }
1173
1153
} ) ;
1154
+
1174
1155
Context . sendState ( "model" , "n" ) ;
1175
1156
1176
1157
0 commit comments