File size: 1,490 Bytes
9d54b72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(function() {
	var app = angular.module('app.models');
	
	app.controller('ModelController', ["$scope","$rootScope","Session","AUTH_EVENTS","USER_ROLES","AuthService","$http", function($scope,$rootScope,Session,AUTH_EVENTS,USER_ROLES,AuthService,$http) {

		$scope.biomodels = [];
 		$scope.currBiomodel = {};
 		$scope.currSimulation = {};
		
		//
		// fetch the biomodels (first 10)
		//
		$scope.refreshBiomodel = function() {
			$http.get('/biomodel')
				.success(function(data){
    				$scope.biomodels = data;
   				})
  				.error(function(msg){
  					$scope.biomodels = [ {name: "bad"} ];
  				});
  		};
  			
   		$scope.refreshBiomodel();
  		
  		$scope.$on(AUTH_EVENTS.logoutSuccess, $scope.refreshBiomodel);
  		$scope.$on(AUTH_EVENTS.loginSuccess, $scope.refreshBiomodel);

  		$scope.back = function() {
			if ($scope.currSimulation.name){
				$scope.currSimulation = {};
			}else if ($scope.currBiomodel.name){
				$scope.currBiomodel = {};
			}
  		};
  			
  		$scope.showBiomodels = function() {
  			console.log("show list of biomodels");
  			$scope.currBiomodel = {};
  			$scope.currSimulation = {};
  		};
		
		$scope.clickBiomodelRow = function(bm) {
			console.log("clicked biomodel "+bm.name);
			$scope.currBiomodel = bm;
			$scope.currSimulation = {};
		};
		
		$scope.clickSimulationRow = function(sim) {
			console.log("clicked simulation "+sim.name);
			$scope.currSimulation = sim;
		};
	}]);

})();