Commit 05ef6ab9 by Thomas Bosch

services

parent 44a42c9a
...@@ -5,7 +5,6 @@ angular.module('registry', [ ...@@ -5,7 +5,6 @@ angular.module('registry', [
'ngResource', 'ngResource',
'ngSanitize', 'ngSanitize',
'ngRoute', 'ngRoute',
'ngResource',
'registry.services' 'registry.services'
]) ])
.config(function ($routeProvider) { .config(function ($routeProvider) {
......
'use strict'; 'use strict';
angular.module('registry') angular.module('registry')
.controller('MainCtrl', function ($scope, Application, ApplicationInfo, $location) { .controller('MainCtrl', function ($scope, Application, ApplicationInfo, $location, $http) {
// Gets the service from /api/services // Gets the service from /api/services
$scope.applications = Application.query({}, function(applications) { $scope.applications = Application.query({}, function(applications) {
...@@ -9,7 +9,8 @@ angular.module('registry') ...@@ -9,7 +9,8 @@ angular.module('registry')
// Get details from applications // Get details from applications
for (var i = 0; i < applications.length; i++) { for (var i = 0; i < applications.length; i++) {
var app = applications[i]; var app = applications[i];
app.version = ApplicationInfo.query({url: app.url}).version; ApplicationInfo.setApp(app);
ApplicationInfo.getInfo();
} }
}); });
......
...@@ -8,11 +8,15 @@ angular.module('registry.services', ['ngResource']) ...@@ -8,11 +8,15 @@ angular.module('registry.services', ['ngResource'])
query: { method:'GET', isArray:true } query: { method:'GET', isArray:true }
}); });
}]) }])
.factory('ApplicationInfo', ['$resource', .service('ApplicationInfo', ['$http',
function($resource){ function($http){
return $resource( var _app;
decodeURIComponent(':url'), this.setApp = function(app) {
{}, { _app = app;
query: { method: 'GET' } , }
this.getInfo = function() {
return $http.get(_app.url + '/info').success(function(response) {
_app.version = response.version;
}); });
}
}]); }]);
\ No newline at end of file
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
<tbody> <tbody>
<tr ng-repeat="application in applications"> <tr ng-repeat="application in applications">
<td>{{ application.id }}</td> <td>{{ application.id }}</td>
<td>{{ application.url }}</td> <td>{{ application.version }}</td>
<td></td>
<td></td> <td></td>
<td></td> <td></td>
<td><!-- <button type="button" ng-click="editService(service.id)" class="btn btn-success">Edit</button> --></td> <td><!-- <button type="button" ng-click="editService(service.id)" class="btn btn-success">Edit</button> --></td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment