mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:35:50 +00:00
LH :: Making the petclinic app data mockable for design views
This commit is contained in:
parent
7119ed8099
commit
f0ca57d2a3
8 changed files with 538 additions and 3 deletions
|
@ -5,7 +5,7 @@
|
|||
<div class="jumbotron-headline-cell">
|
||||
<h1>Pet care for the People who love them</h1>
|
||||
<p>PetClinic is here to enhance people's relationships with their pets</p>
|
||||
<p><a class="btn btn-primary btn-lg" data-scroll-to-target href="#contact-us" role="button">Learn more</a></p>
|
||||
<p><a class="btn btn-primary btn-lg" data-scroll-to-target href="#services" role="button">Learn more</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="container">
|
||||
<div id="services" class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<img class="img-thumbnail" src="images/services/service1.jpg" alt="Generic placeholder image">
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
<script src="js/lib/angular-ui-router-statehelper.js"></script>
|
||||
<script src="js/lib/angular-animate.js"></script>
|
||||
<script src="js/lib/angular-cookies.js"></script>
|
||||
<script src="js/lib/angular-mocks.js"></script>
|
||||
|
||||
<script src="services/services.js"></script>
|
||||
<script src="components/main/MainController.js"></script>
|
||||
<script src="components/veterinarians/VeterinarianController.js"></script>
|
|
@ -1,4 +1,10 @@
|
|||
var app = angular.module('spring-petclinic', ['ui.router','ui.router.stateHelper','ngAnimate','ngCookies','ngResource']);
|
||||
var app = angular.module('spring-petclinic', ['ui.router','ui.router.stateHelper','ngAnimate','ngCookies','ngResource','ngMockE2E']);
|
||||
|
||||
|
||||
/** Start of Configurable constants **/
|
||||
app.constant('useMockData', true);
|
||||
app.constant('context', '/petclinic');
|
||||
/** End of Configurable constants **/
|
||||
|
||||
app.config(['stateHelperProvider','$urlRouterProvider','$urlMatcherFactoryProvider',function(stateHelperProvider,$urlRouterProvider,$urlMatcherFactoryProvider) {
|
||||
|
||||
|
@ -53,6 +59,7 @@ app.factory('Owner', Owner);
|
|||
app.factory('Pet', Pet);
|
||||
app.factory('Vet', Vet);
|
||||
app.factory('Visit', Visit);
|
||||
app.factory('MockService', MockService);
|
||||
|
||||
/** Directives **/
|
||||
|
||||
|
@ -65,4 +72,8 @@ app.directive('scrollToTarget', function() {
|
|||
return false;
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
app.run(function(useMockData, MockService) {
|
||||
MockService.mock(useMockData);
|
||||
});
|
|
@ -18,3 +18,28 @@ var Visit = ['$resource', function($resource) {
|
|||
return $resource('/petclinic/api/pets/:petId/visits', {petId : '@id'});
|
||||
}];
|
||||
|
||||
var MockService = ['$httpBackend', '$http', 'context', function($httpBackend, $http, context) {
|
||||
return {
|
||||
mock : function(useMockData) {
|
||||
|
||||
if(useMockData) {
|
||||
$http.get(context + '/static/mock-data/pets.json').success(function(data) {
|
||||
console.log("Mocking /api/pets");
|
||||
$httpBackend.whenGET(context + '/api/pets').respond(data);
|
||||
});
|
||||
$http.get(context + '/static/mock-data/vets.json').success(function(data) {
|
||||
console.log("Mocking /api/vets");
|
||||
$httpBackend.whenGET(context + '/api/vets').respond(data);
|
||||
});
|
||||
$http.get(context + '/static/mock-data/owners.json').success(function(data) {
|
||||
console.log("Mocking /api/owners");
|
||||
$httpBackend.whenGET(context + '/api/owners').respond(data);
|
||||
});
|
||||
}
|
||||
|
||||
console.log("Setting up passthrough for other urls");
|
||||
var passThroughRegex = new RegExp('/');
|
||||
$httpBackend.whenGET(passThroughRegex).passThrough();
|
||||
}
|
||||
}
|
||||
}];
|
264
src/main/webapp/static/mock-data/owners.json
Normal file
264
src/main/webapp/static/mock-data/owners.json
Normal file
|
@ -0,0 +1,264 @@
|
|||
[ {
|
||||
"id" : 1,
|
||||
"firstName" : "George",
|
||||
"lastName" : "Franklin",
|
||||
"description" : null,
|
||||
"address" : "110 W. Liberty St.",
|
||||
"city" : "Madison",
|
||||
"telephone" : "6085551023",
|
||||
"pets" : [ {
|
||||
"id" : 1,
|
||||
"name" : "Leo",
|
||||
"birthDate" : "2010-09-07T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 1,
|
||||
"name" : "cat",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 2,
|
||||
"firstName" : "Betty",
|
||||
"lastName" : "Davis",
|
||||
"description" : null,
|
||||
"address" : "638 Cardinal Ave.",
|
||||
"city" : "Sun Prairie",
|
||||
"telephone" : "6085551749",
|
||||
"pets" : [ {
|
||||
"id" : 2,
|
||||
"name" : "Basil",
|
||||
"birthDate" : "2012-08-06T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 6,
|
||||
"name" : "hamster",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 3,
|
||||
"firstName" : "Eduardo",
|
||||
"lastName" : "Rodriquez",
|
||||
"description" : null,
|
||||
"address" : "2693 Commerce St.",
|
||||
"city" : "McFarland",
|
||||
"telephone" : "6085558763",
|
||||
"pets" : [ {
|
||||
"id" : 4,
|
||||
"name" : "Jewel",
|
||||
"birthDate" : "2010-03-07T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 2,
|
||||
"name" : "dog",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 3,
|
||||
"name" : "Rosy",
|
||||
"birthDate" : "2011-04-17T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 2,
|
||||
"name" : "dog",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 4,
|
||||
"firstName" : "Harold",
|
||||
"lastName" : "Davis",
|
||||
"description" : null,
|
||||
"address" : "563 Friendly St.",
|
||||
"city" : "Windsor",
|
||||
"telephone" : "6085553198",
|
||||
"pets" : [ {
|
||||
"id" : 5,
|
||||
"name" : "Iggy",
|
||||
"birthDate" : "2010-11-30T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 3,
|
||||
"name" : "lizard",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 5,
|
||||
"firstName" : "Peter",
|
||||
"lastName" : "McTavish",
|
||||
"description" : null,
|
||||
"address" : "2387 S. Fair Way",
|
||||
"city" : "Madison",
|
||||
"telephone" : "6085552765",
|
||||
"pets" : [ {
|
||||
"id" : 6,
|
||||
"name" : "George",
|
||||
"birthDate" : "2010-01-20T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 4,
|
||||
"name" : "snake",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 6,
|
||||
"firstName" : "Jean",
|
||||
"lastName" : "Coleman",
|
||||
"description" : null,
|
||||
"address" : "105 N. Lake St.",
|
||||
"city" : "Monona",
|
||||
"telephone" : "6085552654",
|
||||
"pets" : [ {
|
||||
"id" : 8,
|
||||
"name" : "Max",
|
||||
"birthDate" : "2012-09-04T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 1,
|
||||
"name" : "cat",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ {
|
||||
"id" : 3,
|
||||
"date" : "2013-01-03T00:00:00.000Z",
|
||||
"description" : "neutered",
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 2,
|
||||
"date" : "2013-01-02T00:00:00.000Z",
|
||||
"description" : "rabies shot",
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 7,
|
||||
"name" : "Samantha",
|
||||
"birthDate" : "2012-09-04T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 1,
|
||||
"name" : "cat",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ {
|
||||
"id" : 4,
|
||||
"date" : "2013-01-04T00:00:00.000Z",
|
||||
"description" : "spayed",
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 1,
|
||||
"date" : "2013-01-01T00:00:00.000Z",
|
||||
"description" : "rabies shot",
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 7,
|
||||
"firstName" : "Jeff",
|
||||
"lastName" : "Black",
|
||||
"description" : null,
|
||||
"address" : "1450 Oak Blvd.",
|
||||
"city" : "Monona",
|
||||
"telephone" : "6085555387",
|
||||
"pets" : [ {
|
||||
"id" : 9,
|
||||
"name" : "Lucky",
|
||||
"birthDate" : "2011-08-06T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 5,
|
||||
"name" : "bird",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 8,
|
||||
"firstName" : "Maria",
|
||||
"lastName" : "Escobito",
|
||||
"description" : null,
|
||||
"address" : "345 Maple St.",
|
||||
"city" : "Madison",
|
||||
"telephone" : "6085557683",
|
||||
"pets" : [ {
|
||||
"id" : 10,
|
||||
"name" : "Mulligan",
|
||||
"birthDate" : "2007-02-24T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 2,
|
||||
"name" : "dog",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 9,
|
||||
"firstName" : "David",
|
||||
"lastName" : "Schroeder",
|
||||
"description" : null,
|
||||
"address" : "2749 Blackhawk Trail",
|
||||
"city" : "Madison",
|
||||
"telephone" : "6085559435",
|
||||
"pets" : [ {
|
||||
"id" : 11,
|
||||
"name" : "Freddy",
|
||||
"birthDate" : "2010-03-09T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 5,
|
||||
"name" : "bird",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 10,
|
||||
"firstName" : "Carlos",
|
||||
"lastName" : "Estaban",
|
||||
"description" : null,
|
||||
"address" : "2335 Independence La.",
|
||||
"city" : "Waunakee",
|
||||
"telephone" : "6085555487",
|
||||
"pets" : [ {
|
||||
"id" : 12,
|
||||
"name" : "Lucky",
|
||||
"birthDate" : "2010-06-24T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 2,
|
||||
"name" : "dog",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 13,
|
||||
"name" : "Sly",
|
||||
"birthDate" : "2012-06-08T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 1,
|
||||
"name" : "cat",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
} ]
|
164
src/main/webapp/static/mock-data/pets.json
Normal file
164
src/main/webapp/static/mock-data/pets.json
Normal file
|
@ -0,0 +1,164 @@
|
|||
[ {
|
||||
"id" : 1,
|
||||
"name" : "Leo",
|
||||
"birthDate" : "2010-09-07T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 1,
|
||||
"name" : "cat",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 2,
|
||||
"name" : "Basil",
|
||||
"birthDate" : "2012-08-06T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 6,
|
||||
"name" : "hamster",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 3,
|
||||
"name" : "Rosy",
|
||||
"birthDate" : "2011-04-17T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 2,
|
||||
"name" : "dog",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 4,
|
||||
"name" : "Jewel",
|
||||
"birthDate" : "2010-03-07T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 2,
|
||||
"name" : "dog",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 5,
|
||||
"name" : "Iggy",
|
||||
"birthDate" : "2010-11-30T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 3,
|
||||
"name" : "lizard",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 6,
|
||||
"name" : "George",
|
||||
"birthDate" : "2010-01-20T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 4,
|
||||
"name" : "snake",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 7,
|
||||
"name" : "Samantha",
|
||||
"birthDate" : "2012-09-04T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 1,
|
||||
"name" : "cat",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ {
|
||||
"id" : 4,
|
||||
"date" : "2013-01-04T00:00:00.000Z",
|
||||
"description" : "spayed",
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 1,
|
||||
"date" : "2013-01-01T00:00:00.000Z",
|
||||
"description" : "rabies shot",
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 8,
|
||||
"name" : "Max",
|
||||
"birthDate" : "2012-09-04T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 1,
|
||||
"name" : "cat",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ {
|
||||
"id" : 3,
|
||||
"date" : "2013-01-03T00:00:00.000Z",
|
||||
"description" : "neutered",
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 2,
|
||||
"date" : "2013-01-02T00:00:00.000Z",
|
||||
"description" : "rabies shot",
|
||||
"new" : false
|
||||
} ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 9,
|
||||
"name" : "Lucky",
|
||||
"birthDate" : "2011-08-06T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 5,
|
||||
"name" : "bird",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 10,
|
||||
"name" : "Mulligan",
|
||||
"birthDate" : "2007-02-24T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 2,
|
||||
"name" : "dog",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 11,
|
||||
"name" : "Freddy",
|
||||
"birthDate" : "2010-03-09T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 5,
|
||||
"name" : "bird",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 12,
|
||||
"name" : "Lucky",
|
||||
"birthDate" : "2010-06-24T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 2,
|
||||
"name" : "dog",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 13,
|
||||
"name" : "Sly",
|
||||
"birthDate" : "2012-06-08T00:00:00.000Z",
|
||||
"type" : {
|
||||
"id" : 1,
|
||||
"name" : "cat",
|
||||
"new" : false
|
||||
},
|
||||
"visits" : [ ],
|
||||
"new" : false
|
||||
} ]
|
69
src/main/webapp/static/mock-data/vets.json
Normal file
69
src/main/webapp/static/mock-data/vets.json
Normal file
|
@ -0,0 +1,69 @@
|
|||
[ {
|
||||
"id" : 1,
|
||||
"firstName" : "James",
|
||||
"lastName" : "Carter",
|
||||
"description" : "Graduated from Oxford University in 2000 having \"gone the long way around\" picking up degrees in Agriculture & Applied Zoology and also in Animal Production along the way. He came down to work in Winchester in 2004 and set up PetClinic in 2005.",
|
||||
"specialties" : [ ],
|
||||
"nrOfSpecialties" : 0,
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 3,
|
||||
"firstName" : "Linda",
|
||||
"lastName" : "Douglas",
|
||||
"description" : "MA VetMB MRCVS Another Cambridge graduate, Linda joined our team in 2004. Linda has a hamster called Ash and a dog called Spotty.",
|
||||
"specialties" : [ {
|
||||
"id" : 3,
|
||||
"name" : "dentistry",
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 2,
|
||||
"name" : "surgery",
|
||||
"new" : false
|
||||
} ],
|
||||
"nrOfSpecialties" : 2,
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 6,
|
||||
"firstName" : "Sharon",
|
||||
"lastName" : "Jenkins",
|
||||
"description" : "MA VetMB MRCVS Sharon graduated from Oxford in 2006 and joined us in 2007. She joins international salsa competitions and consider herself an accomplished dancer.",
|
||||
"specialties" : [ ],
|
||||
"nrOfSpecialties" : 0,
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 2,
|
||||
"firstName" : "Helen",
|
||||
"lastName" : "Leary",
|
||||
"description" : "MA VetMB MRCVS A Cambridge graduate, Helen joined our expanding team of vets at the end of 2005. Helen has a cat called Checkers and a dog called Scoot.",
|
||||
"specialties" : [ {
|
||||
"id" : 1,
|
||||
"name" : "radiology",
|
||||
"new" : false
|
||||
} ],
|
||||
"nrOfSpecialties" : 1,
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 4,
|
||||
"firstName" : "Rafael",
|
||||
"lastName" : "Ortega",
|
||||
"description" : "MA VetMB MRCVS Rafael graduated from Cambridge in 2003 and joined PetClinit in October 2004. He has a particular interest in horseback archery and has competed in many international competitions.",
|
||||
"specialties" : [ {
|
||||
"id" : 2,
|
||||
"name" : "surgery",
|
||||
"new" : false
|
||||
} ],
|
||||
"nrOfSpecialties" : 1,
|
||||
"new" : false
|
||||
}, {
|
||||
"id" : 5,
|
||||
"firstName" : "Henry",
|
||||
"lastName" : "Stevens",
|
||||
"description" : "MA VetMB MRCVS Henry graduated from Oxford in 2008 and joined us in 2010. He is also a competitive chess player and has participated in many international competitions.",
|
||||
"specialties" : [ {
|
||||
"id" : 1,
|
||||
"name" : "radiology",
|
||||
"new" : false
|
||||
} ],
|
||||
"nrOfSpecialties" : 1,
|
||||
"new" : false
|
||||
} ]
|
Loading…
Reference in a new issue