Commit 05ef6ab9 by Thomas Bosch

services

parent 44a42c9a
......@@ -5,7 +5,6 @@ angular.module('registry', [
'ngResource',
'ngSanitize',
'ngRoute',
'ngResource',
'registry.services'
])
.config(function ($routeProvider) {
......
'use strict';
angular.module('registry')
.controller('MainCtrl', function ($scope, Application, ApplicationInfo, $location) {
.controller('MainCtrl', function ($scope, Application, ApplicationInfo, $location, $http) {
// Gets the service from /api/services
$scope.applications = Application.query({}, function(applications) {
......@@ -9,7 +9,8 @@ angular.module('registry')
// Get details from applications
for (var i = 0; i < applications.length; 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'])
query: { method:'GET', isArray:true }
});
}])
.factory('ApplicationInfo', ['$resource',
function($resource){
return $resource(
decodeURIComponent(':url'),
{}, {
query: { method: 'GET' } ,
.service('ApplicationInfo', ['$http',
function($http){
var _app;
this.setApp = function(app) {
_app = app;
}
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 @@
<tbody>
<tr ng-repeat="application in applications">
<td>{{ application.id }}</td>
<td>{{ application.url }}</td>
<td></td>
<td>{{ application.version }}</td>
<td></td>
<td></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