@@ -5,17 +5,34 @@ var testApp = angular.module('testApp');
5
5
6
6
testApp . controller ( 'HomeCtrl' , [ '$scope' , '$rootScope' , '$http' , '$location' , "ScientificModelRest" , "ValidationTestDefinitionRest" , 'CollabParameters' , 'IsCollabMemberRest' , 'Context' , 'ScientificModelInstanceRest' , 'ValidationTestCodeRest' , 'DataHandler' ,
7
7
function ( $scope , $rootScope , $http , $location , ScientificModelRest , ValidationTestDefinitionRest , CollabParameters , IsCollabMemberRest , Context , ScientificModelInstanceRest , ValidationTestCodeRest , DataHandler ) {
8
+ $scope . itemsPerPages = 20 ;
9
+ $scope . models = [ ] ;
10
+ $scope . tests = [ ] ;
11
+ $scope . total_models = 0 ;
8
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
+ }
9
26
Context . setService ( ) . then ( function ( ) {
10
27
console . log ( 'collab parameters setted' )
11
28
12
29
$scope . Context = Context ;
13
- var ctx = Context . getCtx ( ) ;
14
- var app_id = Context . getAppID ( ) ;
30
+ $scope . ctx = Context . getCtx ( ) ;
31
+ $scope . app_id = Context . getAppID ( ) ;
15
32
16
33
if ( Context . getStateType ( ) == "" || Context . getStateType ( ) == undefined ) {
17
34
18
- CollabParameters . setService ( ctx ) . then ( function ( ) {
35
+ CollabParameters . setService ( $scope . ctx ) . then ( function ( ) {
19
36
20
37
$scope . collab_species = CollabParameters . getParametersOrDefaultByType ( "species" ) ;
21
38
@@ -30,13 +47,19 @@ testApp.controller('HomeCtrl', ['$scope', '$rootScope', '$http', '$location', "S
30
47
//$scope.tests = ValidationTestDefinitionRest.get({ app_id: app_id }, function(data) {});
31
48
// //for test
32
49
// $scope.put_test1 = ValidationTestCodeRest.put({ app_id: app_id, test_definition_id: "53a7a2db-b18f-49ef-b1de-88bd48960c81", version: "1.1" });
33
- DataHandler . loadModels ( { app_id : app_id } ) . then ( function ( data ) {
34
- $scope . models = data
35
- $scope . $apply ( )
50
+ DataHandler . loadModels ( { app_id : $scope . app_id , page : 1 } ) . then ( function ( data ) {
51
+ $scope . total_models = data . total_models ;
52
+ $scope . nb_pages = data . total_nb_pages ;
53
+ $scope . maxSize = 5 ;
54
+ $scope . current_page = 1 ;
55
+ $scope . models = data ;
56
+ $scope . $apply ( ) ;
57
+
58
+ $scope . _load_other_models ( ) ;
36
59
} ) ;
37
60
38
- DataHandler . loadTests ( { app_id : app_id } ) . then ( function ( data ) {
39
- $scope . tests = data
61
+ DataHandler . loadTests ( { app_id : $scope . app_id } ) . then ( function ( data ) {
62
+ $scope . tests = data ;
40
63
$scope . $apply ( )
41
64
} ) ;
42
65
} ) ;
@@ -69,9 +92,9 @@ testApp.controller('ValTestCtrl', ['$scope', '$rootScope', '$http', '$location',
69
92
var ctx = Context . getCtx ( ) ;
70
93
var app_id = Context . getAppID ( ) ;
71
94
72
- DataHandler . loadModels ( { app_id : app_id } ) . then ( function ( data ) {
95
+ DataHandler . loadModels ( { app_id : $scope . app_id } ) . then ( function ( data ) {
73
96
$scope . models = data ;
74
- $scope . $apply ( )
97
+ $scope . $apply ( ) ;
75
98
} ) ;
76
99
77
100
DataHandler . loadTests ( { app_id : app_id } ) . then ( function ( data ) {
0 commit comments