Commit 89109a91 by Thomas Bosch

rename variable

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