Commit e0519d7c by Thomas Bosch

get details from app

parent 8c45b1df
......@@ -14,14 +14,6 @@ angular.module('registry', [
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/add-application', {
templateUrl: 'views/detail.html',
controller: 'ApplicationCreationCtrl'
})
.when('/applications/:id', {
templateUrl: 'views/detail.html',
controller: 'ApplicationDetailCtrl'
})
.otherwise({
redirectTo: '/'
});
......
'use strict';
angular.module('registry')
.controller('MainCtrl', function ($scope, Application, ApplicationDetail, $location) {
.controller('MainCtrl', function ($scope, Application, ApplicationInfo, $location) {
//Gets the service from /api/services
$scope.applications = Application.query();
$scope.addApplication = function () {
window.location = "/#add-applications";
};
// callback for ng-click 'editService':
$scope.editApplication = function (id) {
$location.path('/applications/' + id);
};
// Gets the service from /api/services
$scope.applications = Application.query({}, function(applications) {
// callback for ng-click 'deleteService':
$scope.deleteApplication = function (id) {
ApplicationDetail.delete({ id: id });
$scope.applications = Application.query();
};
})
.controller('ApplicationCreationCtrl', function ($scope, Application, $location) {
// callback for ng-click 'saveService':
$scope.saveApplication = function () {
Service.create($scope.service);
$location.path('/applications');
}
// callback for ng-click 'cancel':
$scope.cancel = function () {
$location.path('/applications');
};
})
.controller('ApplicationDetailCtrl', function ($scope, $routeParams, Application, ApplicationDetail, $location) {
// callback for ng-click 'updateService':
$scope.saveApplication = function () {
ApplicationDetail.update($scope.service);
$location.path('/applications');
}
// callback for ng-click 'cancel':
$scope.cancel = function () {
$location.path('/applications');
};
$scope.service = ApplicationDetail.show({id: $routeParams.id});
// Get details from applications
for (var i = 0; i < applications.length; i++) {
var app = applications[i];
app.version = ApplicationInfo.query({url: app.url}).version;
}
});
});
\ No newline at end of file
......@@ -9,13 +9,12 @@ angular.module('registry.services', ['ngResource'])
create: { method: 'POST' }
});
}])
.factory('ApplicationDetail', ['$resource',
.factory('ApplicationInfo', ['$resource',
function($resource){
return $resource(
'/api/applications/:id',
{id:'@id'}, {
show: { method: 'GET' },
':url',
{url:'@url'}, {
query: { method: 'GET' },
update: {method: 'PUT', params: {id: '@id'} },
delete: {method:'DELETE', params: {id: '@id'} }
});
}]);
\ No newline at end of file
<div class="container">
<form role="form">
<h2 class="form-signin-heading">Service Details</h2>
<div class="form-group">
<label for="inputName">Name</label>
<input type="text" id="inputName" ng-model="service.name" class="form-control" placeholder="Name of the Service" required autofocus>
</div>
<div class="form-group">
<label for="inputVersion">Version</label>
<input type="text" id="inputVersion" ng-model="service.version" class="form-control" placeholder="Version of the Service" required>
</div>
<div class="form-group">
<label for="inputUrl">URL</label>
<input type="text" id="inputUrl" ng-model="service.url" class="form-control" placeholder="URL of the Service" required>
</div>
<div class="form-group">
<label for="inputMessage">Message</label>
<input type="text" id="inputMessage" ng-model="service.message" class="form-control" placeholder="Message">
</div>
<div class="form-group">
<label for="inputActive">Active</label>
<input type="checkbox" id="inputActive" ng-model="service.active" class="form-control">
</div>
<button ng-click="saveService()" class="btn btn-lg btn-primary" type="submit">Save</button>
<button ng-click="cancel()" class="btn btn-lg btn-primary" type="submit">Cancel</button>
</form>
</div><!-- /.container -->
\ No newline at end of file
......@@ -13,16 +13,14 @@
</thead>
<tbody>
<tr ng-repeat="application in applications">
<td>{{ application.name }}</td>
<td>{{ application.version }}</td>
<td>{{ application.id }}</td>
<td>{{ application.url }}</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="deleteService(service.id)" class="btn btn-danger">Delete</button></td>
</tr>
</tbody>
</table>
<!-- <button type="button" ng-click="addService()" class="btn btn-primary">Add Service</button> -->
</div>
</div><!-- /.container -->
\ No newline at end of file
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