This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git

commit 03a5ee7b8a5d139e7157ff5ca8938dfcd8c9a1fd
Author: longchun <[email protected]>
AuthorDate: Tue May 29 18:02:23 2018 +0800

    SCB-568 Provide web page for pack Demo, fixed the cros-site issue.
---
 .../saga/demo/pack/booking/MyConfiguration.java    | 36 ++++++++++++++++++++++
 .../booking/src/main/resources/static/index.html   |  8 +++--
 .../saga/demo/pack/car/CarBookingController.java   |  2 ++
 .../demo/pack/hotel/HotelBookingController.java    |  2 ++
 4 files changed, 46 insertions(+), 2 deletions(-)

diff --git 
a/saga-demo/booking/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/MyConfiguration.java
 
b/saga-demo/booking/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/MyConfiguration.java
new file mode 100644
index 0000000..0fc5e09
--- /dev/null
+++ 
b/saga-demo/booking/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/MyConfiguration.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.saga.demo.pack.booking;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import 
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+@Configuration
+public class MyConfiguration {
+  @Bean
+  public WebMvcConfigurer corsConfigurer() {
+    return new WebMvcConfigurerAdapter() {
+      @Override
+      public void addCorsMappings(CorsRegistry registry) {
+        registry.addMapping("/**");
+      }
+    };
+  }
+}
diff --git a/saga-demo/booking/booking/src/main/resources/static/index.html 
b/saga-demo/booking/booking/src/main/resources/static/index.html
index 417f5bd..2c92b69 100644
--- a/saga-demo/booking/booking/src/main/resources/static/index.html
+++ b/saga-demo/booking/booking/src/main/resources/static/index.html
@@ -34,19 +34,23 @@
             $.post("http://127.0.0.1:8083/booking/test/3/2";, function(data) {
                 var msg = data;
                 $("#booking_result_2").html(msg);
+            })
+            .fail(function(data) {
+                alert("The transaction is failed");
+                $("#booking_result_2").html("<li>" + JSON.stringify(data) + 
"</li>");
             });
         }
 
         function room_booking_result() {
             $.get("http://127.0.0.1:8081/bookings";, function(data) {
-                var msg = "<li>" + data + "</li>";
+                var msg = "<li>" + JSON.stringify(data) + "</li>";
                 $("#room_list").html(msg);
             });
         }
 
         function car_booking_result() {
             $.get("http://127.0.0.1:8082/bookings";, function(data) {
-                var msg = "<li>" + data + "</li>";
+                var msg = "<li>" + JSON.stringify(data) + "</li>";
                 $("#car_list").html(msg);
             });
         }
diff --git 
a/saga-demo/booking/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBookingController.java
 
b/saga-demo/booking/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBookingController.java
index 4528c22..9db37b3 100644
--- 
a/saga-demo/booking/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBookingController.java
+++ 
b/saga-demo/booking/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBookingController.java
@@ -18,6 +18,7 @@
 package org.apache.servicecomb.saga.demo.pack.car;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -35,6 +36,7 @@ public class CarBookingController {
 
   private final AtomicInteger id = new AtomicInteger(0);
 
+  @CrossOrigin
   @GetMapping("/bookings") List<CarBooking> getAll() {
     return new ArrayList<>(service.getAllBookings());
   }
diff --git 
a/saga-demo/booking/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBookingController.java
 
b/saga-demo/booking/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBookingController.java
index 22f9b2c..6582819 100644
--- 
a/saga-demo/booking/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBookingController.java
+++ 
b/saga-demo/booking/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBookingController.java
@@ -18,6 +18,7 @@
 package org.apache.servicecomb.saga.demo.pack.hotel;
 
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
@@ -35,6 +36,7 @@ public class HotelBookingController {
 
   private final AtomicInteger id = new AtomicInteger(0);
 
+  @CrossOrigin
   @GetMapping("/bookings")
   List<HotelBooking> getAll() {
     return new ArrayList<>(service.getAllBookings());

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to