Allow browser refresh on known Angular routes 95/695/4
authorLott, Christopher (cl778h) <cl778h@att.com>
Tue, 13 Aug 2019 14:31:08 +0000 (10:31 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Tue, 13 Aug 2019 19:46:37 +0000 (15:46 -0400)
Stop the frustrating "404 page not found" behavior
Also add documentation of configuration parameters.

Change-Id: I189f1c8b579da6c5ddce4838760f947c5959cb69
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
docs/.gitignore [new file with mode: 0644]
docs/config.rst [new file with mode: 0644]
docs/index.rst
docs/release-notes.rst
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AnrXappController.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java [new file with mode: 0644]

diff --git a/docs/.gitignore b/docs/.gitignore
new file mode 100644 (file)
index 0000000..651cf82
--- /dev/null
@@ -0,0 +1,2 @@
+/conf.py
+/out
diff --git a/docs/config.rst b/docs/config.rst
new file mode 100644 (file)
index 0000000..988543c
--- /dev/null
@@ -0,0 +1,145 @@
+.. ===============LICENSE_START=======================================================
+.. O-RAN SC CC-BY-4.0
+.. %%
+.. Copyright (C) 2019 AT&T Intellectual Property and Nokia
+.. %%
+.. Licensed 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.
+.. ===============LICENSE_END=========================================================
+
+===========================
+RIC Dashboard Configuration
+===========================
+
+This documents the configuration parameters for the O-RAN SC RIC
+Dashboard web application.
+
+Application Properties
+----------------------
+
+This Spring-Boot project reads parameters from file
+``application.properties`` in the current working directory when
+launched, or from the same file in a ``config`` subdirectory. The
+application properties are listed in alphabetical order. Most have
+default values, but not all.
+
+``a1med.url.prefix``
+
+A1 Mediator URL prefix.  Usually a service name like
+"http://ricplt-entry/a1mediator"
+
+``a1med.url.suffix``
+
+A1 Mediator URL suffix; default is empty.
+
+``anrxapp.url.prefix``
+
+ANR Application URL prefix.  Usually a service name like
+"http://ricxapp-entry/anr"
+
+``anrxapp.url.suffix``
+
+ANR Application URL suffix; default is empty.
+
+``appmgr.url.prefix``
+
+Application Manager URL prefix. Usually a service name like
+"http://ricplt-entry/appmgr"
+
+``appmgr.url.suffix``
+
+Application Manager URL suffix. Default is "/ric/v1".
+
+``e2mgr.url.prefix``
+
+E2 Manager URL prefix. Usually a service name like
+"http://ricplt-entry/e2mgr". 
+
+``e2mgr.url.suffix``
+
+E2 Manager URL prefix. Default is "/v1".
+
+``mock.config.delay``
+
+Sleep period for mock methods in milliseconds.  This mimics slow
+endpoints. Default is 0.
+
+
+``portalapi.appname``
+
+Application name expected at ONAP portal; default "RIC Dashboard"
+
+``portalapi.decryptor``
+
+Java class that decrypts ciphertext from Portal; default
+"org.oransc.ric.portal.dashboard.portalapi.PortalSdkDecryptorAes"
+
+``portalapi.password``
+
+Application password expected at ONAP portal; no default.
+
+``portalapi.usercookie``
+
+Name of request cookie with user ID; default "UserId"
+
+``portalapi.username``
+
+Application user name expected at ONAP portal; no default.
+
+``server.port``
+
+Tomcat server port, default 8080
+
+``userfile``
+
+Path to file that stores user details; default "users.json"
+
+
+Key Properties
+--------------
+
+The file ``key.properties`` must be found on the Java classpath.  It
+must contain the following entries.
+
+``cipher.enc.key``
+
+Encryption key used by the EPSDK-FW library.
+      
+
+Portal Properties
+-----------------
+
+The file ``portal.properties`` must be found on the Java classpath.
+It must contain the following entries.
+
+``ecomp_redirect_url``
+
+URL of ONAP Portal.  Usually a value like
+"https://portal.api.simpledemo.onap.org:30225/ONAPPORTAL/login.htm"
+
+``ecomp_rest_url``
+
+URL of ONAP Portal REST endpoint.  Usually a value like
+"http://portal-app.onap:8989/ONAPPORTAL/auxapi"
+
+``portal.api.impl.class``
+
+Java class name.  Default is "org.oransc.ric.portal.dashboard.portalapi.PortalRestCentralServiceImpl"
+
+``role_access_centralized``
+
+Default value is "remote".
+
+``ueb_app_key``
+
+Unique key assigned by ONAP Portal to the RIC Dashboard application.
+No default.
index f3a7116..470d1b6 100644 (file)
@@ -28,6 +28,7 @@ RIC Dashboard
    :caption: Contents:
 
    overview.rst
+   config.rst
    release-notes.rst
 
 * :ref:`search`
index 5e89d6e..6ab767d 100644 (file)
@@ -36,6 +36,7 @@ Version 1.2.0, 13 Aug 2019
 * Update A1 mediator client to spec version 0.10.0
 * Update App manager client to spec version 0.1.7
 * Update E2 manager client to spec version 20190813
+* Add controller for page refresh of Angular routes
 
 Version 1.0.5, 5 July 2019
 --------------------------
index 55b4212..a05c25e 100644 (file)
@@ -72,10 +72,6 @@ public class AnrXappController {
        // Path parameters
        public static final String PP_SERVING = "servingcells";
        public static final String PP_NEIGHBOR = "neighborcells";
-       // Query parameters
-       public static final String QP_NODEB = "ggnodeb";
-       public static final String QP_SERVING = "servingCellNrcgi";
-       public static final String QP_NEIGHBOR = "neighborCellNrpci";
 
        // Populated by the autowired constructor
        private final HealthApi healthApi;
@@ -129,12 +125,12 @@ public class AnrXappController {
        @GetMapping(NCRT_METHOD)
        @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD })
        public NeighborCellRelationTable getNcrt( //
-                       @RequestParam(name = QP_NODEB, required = false) String ggnbId, //
-                       @RequestParam(name = QP_SERVING, required = false) String servingCellNrcgi, //
-                       @RequestParam(name = QP_NEIGHBOR, required = false) String neighborCellNrpci) {
-               logger.debug("getNcrt: ggnbid {}, servingCellNrpci {}, neighborCellNrcgi {}", ggnbId, servingCellNrcgi,
+                       @RequestParam(required = false) String ggnodeb, //
+                       @RequestParam(required = false) String servingCellNrcgi, //
+                       @RequestParam(required = false) String neighborCellNrpci) {
+               logger.debug("getNcrt: ggnbid {}, servingCellNrpci {}, neighborCellNrcgi {}", ggnodeb, servingCellNrcgi,
                                neighborCellNrpci);
-               return ncrtApi.getNcrt(ggnbId, servingCellNrcgi, neighborCellNrpci);
+               return ncrtApi.getNcrt(ggnodeb, servingCellNrcgi, neighborCellNrpci);
        }
 
        // /ncrt/servingcells/{servCellNrcgi}/neighborcells/{neighCellNrpci} :
diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/Html5PathsController.java
new file mode 100644 (file)
index 0000000..abe3b16
--- /dev/null
@@ -0,0 +1,59 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2019 AT&T Intellectual Property and Nokia
+ * %%
+ * Licensed 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.
+ * ========================LICENSE_END===================================
+ */
+package org.oransc.ric.portal.dashboard.controller;
+
+import java.lang.invoke.MethodHandles;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+/**
+ * Listens for requests to known Angular routes.
+ */
+@Controller
+public class Html5PathsController {
+
+       private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+       /**
+        * Forwards the browser to the index (main) page upon request of a known route.
+        * This unfortunately requires duplication of the Angular route strings in the
+        * path mappings on this method. Could switch to a regex pattern instead someday
+        * if the routes change too often.
+        * 
+        * https://stackoverflow.com/questions/44692781/configure-spring-boot-to-redirect-404-to-a-single-page-app
+        * 
+        * @param request
+        *                    HttpServletRequest
+        * @return Forward directive to index.html
+        */
+       @RequestMapping(method = { RequestMethod.OPTIONS, RequestMethod.GET }, //
+                       path = { "/catalog", "/control", "/stats", "/user" })
+       public String forwardAngularRoutes(HttpServletRequest request) {
+               logger.debug("forwardAngularRoutes: {}", request.getRequestURI());
+               return "forward:/index.html";
+       }
+
+}