Commit 89109a91 by Thomas Bosch

rename variable

parent c825a95c
......@@ -14,13 +14,13 @@ angular.module('service-registry', [
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/add-service', {
.when('/add-application', {
templateUrl: 'views/detail.html',
controller: 'ServiceCreationCtrl'
controller: 'ApplicationCreationCtrl'
})
.when('/services/:id', {
.when('/applications/:id', {
templateUrl: 'views/detail.html',
controller: 'ServiceDetailCtrl'
controller: 'ApplicationDetailCtrl'
})
.otherwise({
redirectTo: '/'
......
'use strict';
angular.module('service-registry')
.controller('MainCtrl', function ($scope, Service, ServiceDetail, $location) {
.controller('MainCtrl', function ($scope, Application, ApplicationDetail, $location) {
//Gets the service from /api/services
$scope.services = Service.query();
$scope.applications = Application.query();
$scope.addService = function () {
window.location = "/#add-service";
$scope.addApplication = function () {
window.location = "/#add-applications";
};
// callback for ng-click 'editService':
$scope.editService = function (id) {
$location.path('/services/' + id);
$scope.editApplication = function (id) {
$location.path('/applications/' + id);
};
// callback for ng-click 'deleteService':
$scope.deleteService = function (id) {
ServiceDetail.delete({ id: id });
$scope.services = Service.query();
$scope.deleteApplication = function (id) {
ApplicationDetail.delete({ id: id });
$scope.applications = Application.query();
};
})
.controller('ServiceCreationCtrl', function ($scope, Service, $location) {
.controller('ApplicationCreationCtrl', function ($scope, Application, $location) {
// callback for ng-click 'saveService':
$scope.saveService = function () {
$scope.saveApplication = function () {
Service.create($scope.service);
$location.path('/services');
$location.path('/applications');
}
// callback for ng-click 'cancel':
$scope.cancel = function () {
$location.path('/services');
$location.path('/applications');
};
})
.controller('ServiceDetailCtrl', function ($scope, $routeParams, Service, ServiceDetail, $location) {
.controller('ApplicationDetailCtrl', function ($scope, $routeParams, Application, ApplicationDetail, $location) {
// callback for ng-click 'updateService':
$scope.saveService = function () {
ServiceDetail.update($scope.service);
$location.path('/services');
$scope.saveApplication = function () {
ApplicationDetail.update($scope.service);
$location.path('/applications');
}
// callback for ng-click 'cancel':
$scope.cancel = function () {
$location.path('/services');
$location.path('/applications');
};
$scope.service = ServiceDetail.show({id: $routeParams.id});
$scope.service = ApplicationDetail.show({id: $routeParams.id});
});
\ No newline at end of file
'use strict';
angular.module('service-registry.services', ['ngResource'])
.factory('Service', ['$resource',
.factory('Application', ['$resource',
function($resource){
return $resource(
'/api/applications', {}, {
......@@ -9,7 +9,7 @@ angular.module('service-registry.services', ['ngResource'])
create: { method: 'POST' }
});
}])
.factory('ServiceDetail', ['$resource',
.factory('ApplicationDetail', ['$resource',
function($resource){
return $resource(
'/api/applications/:id',
......
......@@ -5,19 +5,19 @@
<tr>
<th>Service</th>
<th>Version</th>
<th>URL</th>
<th>Message</th>
<th>Active</th>
<th>Actions</th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="service in services">
<td>{{ service.name }}</td>
<td>{{ service.version }}</td>
<td>{{ service.url }}</td>
<td>{{ service.message }}</td>
<td>{{ service.active }}</td>
<tr ng-repeat="application in applications">
<td>{{ application.name }}</td>
<td>{{ application.version }}</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>
......
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