Permalink
Browse files

Initialer Commit für finaler Version zum Kapitel 9.

  • Loading branch information...
1 parent 91bc4fd commit caf9e310eaa5a8fb8587292e3f3218f6afdf64c2 Stefan Scheidt committed Jun 21, 2012
Showing with 3,461 additions and 763 deletions.
  1. +1 −0 .gitignore
  2. +2 −11 jstd-unit.conf
  3. +151 −8 pom.xml
  4. +29 −0 src/main/webapp/app/AuthenticationController.js
  5. +76 −0 src/main/webapp/app/RentalController.js
  6. +32 −0 src/main/webapp/app/RentalHistoryController.js
  7. +2 −2 src/main/webapp/app/application.js
  8. +167 −0 src/main/webapp/app/backendService.js
  9. +7 −148 src/main/webapp/app/controllers.js
  10. +3 −2 src/main/webapp/app/markup.js
  11. +17 −0 src/main/webapp/app/rentalService.js
  12. +3 −284 src/main/webapp/app/services.js
  13. +121 −0 src/main/webapp/app/utilsService.js
  14. +23 −212 src/main/webapp/index.html
  15. +277 −0 src/main/webapp/lib/almond.js
  16. +189 −0 src/main/webapp/lib/order.js
  17. +2,053 −0 src/main/webapp/lib/require.js
  18. +2 −0 src/main/webapp/{rylc.css → main.css}
  19. +15 −0 src/main/webapp/main.js
  20. +33 −0 src/main/webapp/profilePage.html
  21. +37 −0 src/main/webapp/rental1Page.html
  22. +24 −0 src/main/webapp/rental2Page.html
  23. +37 −0 src/main/webapp/rental3Page.html
  24. +23 −0 src/main/webapp/rentalHistoryPage.html
  25. +14 −0 src/main/webapp/welcomePage.html
  26. +21 −30 src/test/webapp/UnitSpecRunner.html
  27. +42 −41 src/test/webapp/lib/testutils.js
  28. +1 −1 src/test/webapp/ui/loginUiSpec.js
  29. +1 −1 src/test/webapp/ui/profileUiSpec.js
  30. +4 −4 src/test/webapp/ui/rental1UiSpec.js
  31. +3 −3 src/test/webapp/ui/rental2UiSpec.js
  32. +3 −3 src/test/webapp/ui/rental3UiSpec.js
  33. +1 −1 src/test/webapp/ui/rentalHistoryUiSpec.js
  34. +7 −7 src/test/webapp/ui/welcomeUiSpec.js
  35. +1 −1 src/test/webapp/unit/AuthenticationControllerSpec.js
  36. +5 −0 src/test/webapp/unit/JSONParseDateSpec.js
  37. +25 −4 src/test/webapp/unit/backendServiceSpec.js
  38. +9 −0 src/test/webapp/unit/utilsServiceSpec.js
View
@@ -3,4 +3,5 @@
*.iml
# Maven
+build
target
View
@@ -1,23 +1,14 @@
server: http://localhost:9876
load:
- # Libraries
- - src/main/webapp/lib/JSONParseDate.js
- - src/main/webapp/lib/Base64.js
- - src/main/webapp/lib/jquery.js
- - src/main/webapp/lib/angular.js
+ # Libraries and Application
+ - target/html5/main.js
# Test-Libraries
- src/test/webapp/lib/jasmine.js
- src/test/webapp/lib/angular-mocks.js
- src/test/webapp/lib/JasmineAdapter.js
- # Application
- - src/main/webapp/app/application.js
- - src/main/webapp/app/controllers.js
- - src/main/webapp/app/markup.js
- - src/main/webapp/app/services.js
-
test:
# Tests
- src/test/webapp/unit/*.js
View
@@ -42,13 +42,109 @@
<webAppConfig>
<contextPath>${jetty.contextPath}</contextPath>
<defaultsDescriptor>${basedir}/misc/jetty-webapp/webdefault.xml</defaultsDescriptor>
- <resourceBases>
- <resourceBase>${basedir}/src/main/webapp</resourceBase>
- <resourceBase>${basedir}/src/test/webapp</resourceBase>
- </resourceBases>
</webAppConfig>
</configuration>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <id>package</id>
+ <phase>prepare-package</phase>
+ <configuration>
+ <target>
+ <property name="sourceDir" value="${project.basedir}/src/main/webapp"/>
+ <property name="outputDir" value="${project.build.directory}/html5"/>
+ <mkdir dir="${outputDir}"/>
+
+ <echo>-------- Building HTML ---------</echo>
+ <!-- Concat all html files into one file -->
+ <copy file="${sourceDir}/index.html" todir="${outputDir}" overwrite="true"/>
+ <loadresource property="pages">
+ <concat>
+ <fileset dir="${sourceDir}" includes="*.html" excludes="index.html"/>
+ <footer><![CDATA[</body>]]></footer>
+ </concat>
+ </loadresource>
+ <replace file="${outputDir}/index.html" value="${pages}">
+ <replacetoken><![CDATA[</body>]]></replacetoken>
+ </replace>
+ <!-- Minify html -->
+ <java classpathref="maven.compile.classpath" classname="com.googlecode.htmlcompressor.CmdLineCompressor">
+ <arg value="${outputDir}/index.html"/>
+ <arg value="-o"/>
+ <arg value="${outputDir}/index.html"/>
+ </java>
+
+ <echo>-------- Building JavaScript ---------</echo>
+ <!-- Concat all javascript files into one file -->
+ <java classpathref="maven.compile.classpath" classname="org.mozilla.javascript.tools.shell.Main">
+ <arg value="${project.basedir}/build/r.js"/>
+ <arg value="-o"/>
+ <arg value="baseUrl=src/main/webapp"/>
+ <arg value="name=lib/almond"/>
+ <arg value="include=main.js"/>
+ <arg value="out=${outputDir}/main.js"/>
+ <arg value="optimize=none"/>
+ </java>
+ <!-- Minify javascript -->
+ <java classpathref="maven.compile.classpath" classname="com.google.javascript.jscomp.CommandLineRunner">
+ <arg value="--js"/>
+ <arg value="${outputDir}/main.js"/>
+ <arg value="--compilation_level"/>
+ <arg value="SIMPLE_OPTIMIZATIONS"/>
+ <arg value="--language_in"/>
+ <arg value="ECMASCRIPT5"/>
+ <arg value="--js_output_file"/>
+ <arg value="${outputDir}/main.min.js"/>
+ </java>
+ <move file="${outputDir}/main.min.js" tofile="${outputDir}/main.js" overwrite="true"/>
+ <!-- include in index.html -->
+ <replace file="${outputDir}/index.html">
+ <replacetoken><![CDATA[src="lib/require.js"]]></replacetoken>
+ <replacevalue><![CDATA[src="main.js"]]></replacevalue>
+ </replace>
+
+ <echo>-------- Building CSS ---------</echo>
+ <!-- Concat all css includes into one file -->
+ <java classpathref="maven.compile.classpath" classname="org.mozilla.javascript.tools.shell.Main">
+ <arg value="${project.basedir}/build/r.js"/>
+ <arg value="-o"/>
+ <arg value="cssIn=src/main/webapp/main.css"/>
+ <arg value="out=${outputDir}/main.css"/>
+ </java>
+ <!-- Minify css -->
+ <java classpathref="maven.compile.classpath" classname="com.yahoo.platform.yui.compressor.YUICompressor">
+ <arg value="${outputDir}/main.css"/>
+ <arg value="-o"/>
+ <arg value="${outputDir}/main.css"/>
+ </java>
+
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.1.1</version>
+ <configuration>
+ <warSourceIncludes>**/*.xml, **/*.gif, **/*.png</warSourceIncludes>
+ <webResources>
+ <resource>
+ <directory>target/html5</directory>
+ </resource>
+ </webResources>
+ </configuration>
+ </plugin>
</plugins>
</build>
@@ -59,11 +155,35 @@
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>com.googlecode.jstd-maven-plugin</groupId>
- <artifactId>jstd-maven-plugin</artifactId>
- <version>1.3.2.5</version>
+ <groupId>com.google.jstestdriver</groupId>
+ <artifactId>jstestdriver</artifactId>
+ <version>1.3.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>rhino</groupId>
+ <artifactId>js</artifactId>
+ <version>1.7R2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.googlecode.htmlcompressor</groupId>
+ <artifactId>htmlcompressor</artifactId>
+ <version>1.5.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.javascript</groupId>
+ <artifactId>closure-compiler</artifactId>
+ <version>r1810</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.yahoo.platform.yui</groupId>
+ <artifactId>yuicompressor</artifactId>
+ <version>2.4.6</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<repositories>
@@ -83,6 +203,29 @@
<profiles>
<profile>
+ <id>development</id>
+ <activation>
+ <activeByDefault/>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <configuration>
+ <webAppConfig>
+ <resourceBases>
+ <resourceBase>${basedir}/src/main/webapp</resourceBase>
+ <resourceBase>${basedir}/src/test/webapp</resourceBase>
+ </resourceBases>
+ </webAppConfig>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
<id>integration</id>
<build>
<plugins>
@@ -129,7 +272,7 @@
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
- <goal>run</goal>
+ <goal>run-war</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
@@ -0,0 +1,29 @@
+define(function () {
+ function AuthenticationController($scope, backendService, $navigate) {
+
+ $scope.login = function () {
+ return backendService.login($scope.username, $scope.password).then(function () {
+ $navigate('welcomePage.html');
+ }, function (errorMessage) {
+ $scope.errorMessage = errorMessage;
+ });
+ };
+
+ $scope.loginPossible = function () {
+ return $scope.username && $scope.password;
+ };
+
+ $scope.logout = function () {
+ backendService.logout();
+ };
+
+ $scope.customer = function () {
+ return backendService.authenticatedCustomer();
+ };
+
+ }
+
+ AuthenticationController.$inject = ['$scope', 'backendService', '$navigate'];
+
+ return AuthenticationController;
+});
@@ -0,0 +1,76 @@
+define(function () {
+ function RentalController($scope, rentalService, backendService, $navigate) {
+ var SUCCESS_MESSAGE = "Bestellung erfolgreich entgegengenommen.";
+
+ $scope.clearMessages = function () {
+ $scope.successMessage = null;
+ $scope.errorMessage = null;
+ };
+
+ $scope.prefetchMasterData = function () {
+ backendService.carTypesBackground();
+ backendService.citiesBackground();
+ };
+
+ $scope.initRental = function () {
+ $scope.errorMessage = null;
+ $scope.successMessage = null;
+ $scope.startDate = new Date();
+ $scope.endDate = new Date();
+ $scope.maxPrice = 100;
+ $scope.endDate.setDate($scope.startDate.getDate() + 1);
+ backendService.cities().then(function (cities) {
+ $scope.cities = cities;
+ $scope.city = cities[0];
+ }, function (errorMessage) {
+ $scope.errorMessage = errorMessage;
+ });
+ backendService.carTypes().then(function (carTypes) {
+ $scope.carTypes = carTypes;
+ $scope.carType = carTypes[0];
+ }, function (errorMessage) {
+ $scope.errorMessage = errorMessage;
+ });
+ $navigate('rental1Page.html');
+ };
+
+ $scope.searchAvailableCars = function () {
+ return backendService.availableCars($scope.city.id, $scope.startDate, $scope.endDate, $scope.maxPrice).then(
+ function (cars) {
+ $scope.availableCars = cars;
+ $navigate("rental2Page.html");
+ }, function (errorMessage) {
+ $scope.errorMessage = errorMessage;
+ });
+ };
+
+ $scope.totalPrice = function () {
+ if ($scope.car) {
+ return rentalService.totalPrice($scope.car.price, $scope.startDate, $scope.endDate);
+ } else {
+ return 0;
+ }
+ };
+
+ $scope.selectCar = function (car) {
+ $scope.car = car;
+ $navigate('rental3Page.html');
+ };
+
+ $scope.rentCar = function () {
+ return backendService.rentCar($scope.car.id, $scope.startDate, $scope.endDate).then(
+ function (rental) {
+ $scope.rental = rental;
+ $scope.successMessage = SUCCESS_MESSAGE;
+ $navigate('back:welcomePage.html');
+ }, function (errorMessage) {
+ $scope.errorMessage = errorMessage;
+ $navigate('back:welcomePage.html');
+ });
+ };
+ }
+
+ RentalController.$inject = ['$scope', 'rentalService', 'backendService', '$navigate'];
+
+ return RentalController;
+});
@@ -0,0 +1,32 @@
+define(function () {
+ function RentalHistoryController($scope, rentalService, backendService) {
+
+ $scope.searchRentals = function () {
+ var res = backendService.rentalsByCustomerId(backendService.authenticatedCustomer().id);
+ res.then(function (data) {
+ $scope.rentals = data;
+ }, function (errorMessage) {
+ $scope.errorMessage = errorMessage;
+ });
+ return res;
+ };
+
+ $scope.totalPrice = function (rental) {
+ return rentalService.totalPrice(
+ rental.car.price, rental.hireStartDate, rental.hireEndDate);
+ };
+
+ $scope.infoMessage = function () {
+ if ($scope.rentals && $scope.rentals.length === 0) {
+ return "Keine Daten gefunden.";
+ } else {
+ return null;
+ }
+ };
+
+ }
+
+ RentalHistoryController.$inject = ['$scope', 'rentalService', 'backendService'];
+
+ return RentalHistoryController;
+});
@@ -1,5 +1,5 @@
-(function (angular) {
+define(function () {
angular.module("rylc", ["rylc-controllers", "rylc-markup", "rylc-services"]);
-})(angular);
+});
Oops, something went wrong.

0 comments on commit caf9e31

Please sign in to comment.