bioweb  0.09.92
C++/Python(django)/JavaScript(angularJS) framework
controllers.js
Go to the documentation of this file.
1 
4 angular.module('myAppControllers', [])
5  .controller('settingsController', //client static settings
6  ['$scope',
7  '$translate',
8  function($scope, $translate) {
9  $scope.langs = ['en', 'pl'];
10  $scope.changeLanguage = function (lang) {
11  $translate.use(lang);
12  };
13  }])
14  .controller('versionController', //versions of system modules
15  ['$scope',
16  'srvInfo',
17  function($scope, srvInfo) {
18  srvInfo.getVersion(
19  function(data) {
20  $scope.server_ver = data;
21  });
22  srvInfo.getCppNumber(
23  function(data) {
24  $scope.cpp_get = data;
25  });
26  $scope.client_ver = client_ver_major.toString() + '.' + client_ver_minor.toString() + '.' + client_ver_compilation.toString(); //from version.js file
27  }])
28  .controller('commandController', //cpp commands
29  ['$scope',
30  'srvCommands',
31  function($scope, srvCommands) {
32  $scope.getCppCommandsNo = function() {
33  srvCommands.getCppCommands(
34  function(data) {
35  $scope.cpp_commands_no = Object.keys(data).length;
36  });
37  };
38  $scope.clickNewCommand = function() {
39  srvCommands.startCommand(
40  function(data) {
41  $scope.getCppCommandsNo();
42  })
43  };
44  $scope.getCppCommandsNo();
45  }])
46  .controller('currentController', //current server params
47  ['$scope',
48  '$timeout',
49  'srvInfo',
50  'srvCommands',
51  function($scope, $timeout, srvInfo, srvCommands) {
52  var REFRESH_INTERVAL = 1000; //ms
53 
54  var call = function() { //function called periodically
55  $scope.getCppCommands = function() {
56  srvCommands.getCppCommands(
57  function(data) {
58  $scope.cpp_commands = data;
59  });
60  };
61 
62  srvInfo.getCurrent(
63  function(data) {
64  $scope.current = data;
65  $scope.getCppCommands();
66  $timeout(call, REFRESH_INTERVAL);
67  });
68  };
69  $timeout(call, 0); //start calling the service
70  }]);
71 
72