Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/webapp/WEB-INF/html/cars/layout.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

<div class="input-append">
<input style="width:358px;" class="span2" type="text" ng-model="carName" required min="1" />
<input style="width:358px; margin-left: 100px;" class="span2" type="text" ng-model="carName" required min="1" />
<button class="btn btn-primary" ng-disabled="!carName" ng-click="addNewCar(carName)">Add Car</button>
</div>

<h3>Car List</h3>
<div class="alert alert-info" style="width:400px;" ng-show="cars.length == 0">
<h3 style="margin-left:100px;">Car List</h3>
<div class="alert alert-info" style="width:400px;margin-left:100px;" ng-show="cars.length == 0">
No cars found
</div>
<table class="table table-bordered table-striped" style="width:450px;" ng-show="cars.length > 0">
<table class="table table-bordered table-striped" style="width:450px; margin-left: 100px;" ng-show="cars.length > 0">
<thead>
<tr>
<th style="text-align: center; width: 25px;">Action</th>
Expand All @@ -17,9 +17,9 @@ <h3>Car List</h3>
</thead>
<tbody>
<tr ng-repeat="car in cars">
<td style="width:70px;text-align: center;"><button class="btn btn-mini btn-danger" ng-click="removeCar(car)">Remove</button></td>
<td style="width:70px;text-align:center;"><button class="btn btn-mini btn-danger" ng-click="removeCar(car)">Remove</button></td>
<td>{{car}}</td>
</tr>
</tbody>
</table>
<button class="btn btn-danger" ng-show="cars.length > 1" ng-click="removeAllCars()">Remove All Cars</button>
<button style="margin-left:100px;" class="btn btn-danger" ng-show="cars.length > 1" ng-click="removeAllCars()">Remove All Cars</button>
8 changes: 2 additions & 6 deletions src/main/webapp/WEB-INF/html/railwaystations/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,18 @@ <h3>Railway Stations List</h3>
<tr>
<th style="text-align: center; width: 25px;">Id</th>
<th style="text-align: center;">Name</th>
<!--
<th style="text-align: center;">Speed</th>
<th style="text-align: center;">Diesel</th>
-->
<th style="text-align: center;">Action</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in railwaystations | orderBy:predicate">
<td style="text-align: center;">{{item.id}}</td>
<td>{{item.name}}</td>


<!-- <td>{{train.speed}}</td>
<td>{{item.train.speed}}</td>
<td style="text-align: center; width: 20px;"><span
ng-show="train.diesel" class="icon-ok"></span></td> -->
ng-show="item.train.diesel" class="icon-ok"></span></td>

<td style="width: 100px; text-align: center;">
<button class="btn btn-mini btn-danger"
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#wrapper {
margin: 0 auto;
width: 500px;
width: 650px;
margin-top: 50px;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/resources/js/controllers/CarController.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ var CarController = function($scope, $http) {
$http.get('cars/carlist.json').success(function(carList){
$scope.cars = carList;
});
}
};

$scope.addNewCar = function(newCar) {
$http.post('cars/addCar/' + newCar).success(function() {
$scope.fetchCarsList();
});
$scope.carName = '';
}
};

$scope.removeCar = function(car) {
$http.delete('cars/removeCar/' + car).success(function() {
$scope.fetchCarsList();
});
}
};

$scope.removeAllCars = function() {
$http.delete('cars/removeAllCars').success(function() {
Expand All @@ -32,4 +32,4 @@ var CarController = function($scope, $http) {
};

$scope.fetchCarsList();
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var RailwayStationController = function($scope, $http) {
$http.get('railwaystations/railwaystationlist.json').success(function(rsList){
$scope.railwaystations = rsList;
});
}
};

$scope.addNewRailwayStation = function(rs) {

Expand All @@ -27,7 +27,7 @@ var RailwayStationController = function($scope, $http) {
}).error(function() {
$scope.setError('Could not add a new station');
});
}
};

$scope.updateRailwayStation = function(rs) {
$scope.resetError();
Expand All @@ -42,13 +42,13 @@ var RailwayStationController = function($scope, $http) {
}).error(function() {
$scope.setError('Could not update the train');
});
}
};

$scope.editRailwayStation = function(rs) {
$scope.resetError();
$scope.rs = rs;
$scope.editMode = true;
}
};

$scope.removeRailwayStation = function(id) {
$scope.resetError();
Expand All @@ -58,7 +58,9 @@ var RailwayStationController = function($scope, $http) {
}).error(function() {
$scope.setError('Could not remove train');
});
}

$scope.rs = '';
};

$scope.removeAllRailwayStations = function() {
$scope.resetError();
Expand All @@ -75,19 +77,19 @@ var RailwayStationController = function($scope, $http) {
$scope.resetError();
$scope.rs = {};
$scope.editMode = false;
}
};

$scope.resetError = function() {
$scope.error = false;
$scope.errorMessage = '';
}
};

$scope.setError = function(message) {
$scope.error = true;
$scope.errorMessage = message;
}
};

$scope.fetchRailwayStationsList();

$scope.predicate = 'id';
}
};
20 changes: 11 additions & 9 deletions src/main/webapp/resources/js/controllers/TrainController.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var TrainController = function($scope, $http) {
$http.get('trains/trainslist.json').success(function(trainList){
$scope.trains = trainList;
});
}
};

$scope.addNewTrain = function(train) {
$scope.resetError();
Expand All @@ -25,7 +25,7 @@ var TrainController = function($scope, $http) {
}).error(function() {
$scope.setError('Could not add a new train');
});
}
};

$scope.updateTrain = function(train) {
$scope.resetError();
Expand All @@ -39,13 +39,13 @@ var TrainController = function($scope, $http) {
}).error(function() {
$scope.setError('Could not update the train');
});
}
};

$scope.editTrain = function(train) {
$scope.resetError();
$scope.train = train;
$scope.editMode = true;
}
};

$scope.removeTrain = function(id) {
$scope.resetError();
Expand All @@ -55,7 +55,9 @@ var TrainController = function($scope, $http) {
}).error(function() {
$scope.setError('Could not remove train');
});
}
$scope.train.name = '';
$scope.train.speed = '';
};

$scope.removeAllTrains = function() {
$scope.resetError();
Expand All @@ -72,19 +74,19 @@ var TrainController = function($scope, $http) {
$scope.resetError();
$scope.train = {};
$scope.editMode = false;
}
};

$scope.resetError = function() {
$scope.error = false;
$scope.errorMessage = '';
}
};

$scope.setError = function(message) {
$scope.error = true;
$scope.errorMessage = message;
}
};

$scope.fetchTrainsList();

$scope.predicate = 'id';
}
};