Merge "update pom and change aaf config"
diff --git a/deliveries/local-dev-host-clone.sh b/deliveries/local-dev-host-clone.sh
index 1d7ae42..43153d3 100644
--- a/deliveries/local-dev-host-clone.sh
+++ b/deliveries/local-dev-host-clone.sh
@@ -2,6 +2,6 @@
# Sets up a new build area for Portal projects on on a dev/test host such as vm-ep-dev3
USER=org.UserId-goes-here
-git clone https://${USER}@gerrit.onap.org/r/a/portal
+git clone --depth 1 https://${USER}@gerrit.onap.org/r/a/portal
cd lf_portal
-git clone https://${USER}@gerrit.onap.org/r/a/portal/sdk
+git clone --depth 1 https://${USER}@gerrit.onap.org/r/a/portal/sdk
diff --git a/docs/conf.py b/docs/conf.py
index 8f40e8b..5371015 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -12,4 +12,4 @@
html_last_updated_fmt = '%d-%b-%y %H:%M'
def setup(app):
- app.add_stylesheet("css/ribbon_onap.css")
+ app.add_stylesheet("css/ribbon.css")
diff --git a/docs/tutorials/portal-BE/setting-up.rst b/docs/tutorials/portal-BE/setting-up.rst
index 22d7f47..3644899 100644
--- a/docs/tutorials/portal-BE/setting-up.rst
+++ b/docs/tutorials/portal-BE/setting-up.rst
@@ -18,7 +18,7 @@
::
- git clone "https://gerrit.onap.org/r/portal"
+ git clone --depth 1 "https://gerrit.onap.org/r/portal"
Building
-----------------
diff --git a/docs/tutorials/portal-sdk/setting-up.rst b/docs/tutorials/portal-sdk/setting-up.rst
index ce32dbb..ae03f1a 100644
--- a/docs/tutorials/portal-sdk/setting-up.rst
+++ b/docs/tutorials/portal-sdk/setting-up.rst
@@ -18,7 +18,7 @@
::
- git clone http://gerrit.onap.org/r/portal/sdk
+ git clone --depth 1 http://gerrit.onap.org/r/portal/sdk
Building the base
-----------------
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java
index 4b68a01..e2cd13c 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java
@@ -282,16 +282,7 @@
+ MS_WIDGET_URL + widgetId + "/framework.js", String.class,
WidgetServiceHeaders.getInstance());
}
-
- @GetMapping(value = "/portalApi/microservices/{widgetId}/controller.js")
- public String getWidgetController(@PathVariable("widgetId") long widgetId) throws Exception {
- return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://"
- + widgetMService.getServiceLocation(whatService,
- SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT))
- + MS_WIDGET_URL + widgetId + "/controller.js", String.class,
- WidgetServiceHeaders.getInstance());
- }
-
+
@GetMapping(value = "/portalApi/microservices/{widgetId}/style.css")
public String getWidgetCSS(@PathVariable("widgetId") long widgetId) throws Exception {
return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://"
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogUnRestrictedController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogUnRestrictedController.java
new file mode 100644
index 0000000..55cb08d
--- /dev/null
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogUnRestrictedController.java
@@ -0,0 +1,133 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.onap.portalapp.portal.controller;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.onap.portalapp.controller.EPUnRestrictedBaseController;
+import org.onap.portalapp.portal.domain.EPUser;
+import org.onap.portalapp.portal.domain.MicroserviceParameter;
+import org.onap.portalapp.portal.domain.WidgetCatalog;
+import org.onap.portalapp.portal.domain.WidgetCatalogParameter;
+import org.onap.portalapp.portal.domain.WidgetParameterResult;
+import org.onap.portalapp.portal.domain.WidgetServiceHeaders;
+import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
+import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
+import org.onap.portalapp.portal.logging.aop.EPAuditLog;
+import org.onap.portalapp.portal.service.WidgetMService;
+import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
+import org.onap.portalapp.portal.utils.EcompPortalUtils;
+import org.onap.portalapp.util.EPUserUtils;
+import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.multipart.commons.CommonsMultipartResolver;
+
+@SuppressWarnings("unchecked")
+@RestController
+@org.springframework.context.annotation.Configuration
+@EnableAspectJAutoProxy
+@EPAuditLog
+public class WidgetsCatalogUnRestrictedController extends EPUnRestrictedBaseController {
+
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetsCatalogUnRestrictedController.class);
+
+ private static final String MS_WIDGET_LOCAL_PORT = "microservices.widget.local.port";
+
+ private static final String MS_WIDGET_URL = "/widget/microservices/";
+
+ private RestTemplate template = new RestTemplate();
+
+ private String whatService = "widgets-service";
+
+ @Autowired
+ private WidgetMService widgetMService;
+
+
+ @Bean
+ public CommonsMultipartResolver multipartResolver() {
+ return new CommonsMultipartResolver();
+ }
+
+ static {
+ // for localhost testing only
+ javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() {
+ public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
+ if ("localhost".equals(hostname))
+ return true;
+ return false;
+ }
+ });
+ }
+ @GetMapping(value = "/portalApi/microservices/{widgetId}/controller.js")
+ public String getWidgetController(@PathVariable("widgetId") long widgetId) throws Exception {
+ return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://"
+ + widgetMService.getServiceLocation(whatService,
+ SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT))
+ + MS_WIDGET_URL + widgetId + "/controller.js", String.class,
+ WidgetServiceHeaders.getInstance());
+ }
+}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java
index 6a581c1..0f6f3ce 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerRestInterface.java
@@ -151,9 +151,6 @@
logger.debug(EELFLoggerDelegate.debugLogger, "Client Initialized");
-
-
-
}
@SuppressWarnings("unchecked")
@@ -178,7 +175,7 @@
if (cres.getEntity() != null) {
try {
String str = (cres).readEntity(String.class);
- if (t.getClass().getName().equals(String.class.getName())) {
+ if (t.getClass().isAssignableFrom(String.class)) {
t = (T) str;
} else {
@@ -233,7 +230,7 @@
try {
String str = (cres).readEntity(String.class);
- if (t.getClass().getName().equals(String.class.getName())) {
+ if (t.getClass().isAssignableFrom(String.class)) {
t = (T) str;
} else {
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerUtil.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerUtil.java
index c1ca873..675cfe1 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerUtil.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduler/SchedulerUtil.java
@@ -57,17 +57,17 @@
public static GetTimeSlotsWrapper getTimeSlotsWrapResponse (GetTimeSlotsRestObject<String> rs) {
- String resp_str = "";
+ String respStr = "";
int status = 0;
if ( rs != null ) {
- resp_str = rs.get();
+ respStr = rs.get();
status = rs.getStatusCode();
}
GetTimeSlotsWrapper w = new GetTimeSlotsWrapper();
- w.setEntity(resp_str);
+ w.setEntity(respStr);
w.setStatus (status);
return (w);
@@ -75,19 +75,19 @@
public static PostSubmitVnfChangeTimeSlotsWrapper postSubmitNewVnfWrapResponse (PostSubmitVnfChangeRestObject<String> rs) {
- String resp_str = "";
+ String respStr = "";
int status = 0;
String uuid = "";
if ( rs != null ) {
- resp_str = rs.get();
+ respStr = rs.get();
status = rs.getStatusCode();
uuid = rs.getUUID();
}
PostSubmitVnfChangeTimeSlotsWrapper w = new PostSubmitVnfChangeTimeSlotsWrapper();
- w.setEntity(resp_str);
+ w.setEntity(respStr);
w.setStatus (status);
w.setUuid(uuid);
@@ -96,19 +96,19 @@
public static PostCreateNewVnfWrapper postCreateNewVnfWrapResponse (PostCreateNewVnfRestObject<String> rs) {
- String resp_str = "";
+ String respStr = "";
int status = 0;
String uuid = "";
if ( rs != null ) {
- resp_str = rs.get();
+ respStr = rs.get();
status = rs.getStatusCode();
uuid = rs.getUUID();
}
PostCreateNewVnfWrapper w = new PostCreateNewVnfWrapper();
- w.setEntity(resp_str);
+ w.setEntity(respStr);
w.setStatus (status);
w.setUuid(uuid);
@@ -121,14 +121,14 @@
ObjectMapper mapper = new ObjectMapper();
String r_json_str = "";
if ( t != null ) {
- try {
- r_json_str = mapper.writeValueAsString(t);
- }
- catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
- logger.debug(EELFLoggerDelegate.debugLogger,
- DateUtil.getDateFormat().format(new Date()) + "<== " + methodName + " Unable " + "to "
- + "parse object as json");
- }
+ try {
+ r_json_str = mapper.writeValueAsString(t);
+ } catch (com.fasterxml.jackson.core.JsonProcessingException j) {
+ logger.debug(
+ EELFLoggerDelegate.debugLogger, DateUtil.getDateFormat().format(new Date())
+ + "<== " + methodName + " Unable " + "to " + "parse object as json",
+ j);
+ }
}
return (r_json_str);
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestInt.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestInt.java
index 75919ee..f120c4f 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestInt.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/scheduleraux/SchedulerAuxRestInt.java
@@ -63,24 +63,21 @@
*
* @param r the r
*/
- public void logRequest ( RequestDetails r ) {
- SimpleDateFormat dateFormat = DateUtil.getDateFormat();
- String methodName = "logRequest";
- ObjectMapper mapper = new ObjectMapper();
- String r_json_str = "";
- if ( r != null ) {
- r_json_str = r.toString();
- try {
- r_json_str = mapper.writeValueAsString(r);
- }
- catch ( com.fasterxml.jackson.core.JsonProcessingException j ) {
- logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== " + methodName + " "
- + "Unable to "
- + "parse request as json");
- }
- }
- logger.debug(EELFLoggerDelegate.debugLogger,dateFormat.format(new Date()) + "<== " + methodName + " Request="
- + "(" +
- r_json_str + ")");
+ public void logRequest(RequestDetails r) {
+ SimpleDateFormat dateFormat = DateUtil.getDateFormat();
+ String methodName = "logRequest";
+ ObjectMapper mapper = new ObjectMapper();
+ String rJsonStr = "";
+ if (r != null) {
+ rJsonStr = r.toString();
+ try {
+ rJsonStr = mapper.writeValueAsString(r);
+ } catch (com.fasterxml.jackson.core.JsonProcessingException j) {
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== "
+ + methodName + " " + "Unable to " + "parse request as json", j);
+ }
+ }
+ logger.debug(EELFLoggerDelegate.debugLogger, dateFormat.format(new Date()) + "<== "
+ + methodName + " Request=" + "(" + rJsonStr + ")");
}
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java
index 5d38317..4adf1fd 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java
@@ -62,6 +62,9 @@
public class EPRoleServiceImpl implements EPRoleService {
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(EPRoleServiceImpl.class);
+ private static final String GET_APP_ROLE_SQL_FORMAT =
+ "SELECT * FROM fn_role where APP_ID = %s AND APP_ROLE_ID = %s";
+
@Autowired
private DataAccessService dataAccessService;
@@ -123,10 +126,6 @@
return (EPRole) getDataAccessService().getDomainObject(EPRole.class, id, null);
}
- // TODO: refactor
- private static final String GET_APP_ROLE_SQL_FORMAT =
- "SELECT * FROM fn_role where APP_ID = %s AND APP_ROLE_ID = %s";
-
@SuppressWarnings("unchecked")
public EPRole getRole(Long appId, Long appRoleid) {
if (appId == null || appRoleid == null) {
@@ -185,7 +184,7 @@
if (roles != null) {
return roles.get(0);
}
- } else if (resultsCount == 1) {
+ } else if (roles!=null && resultsCount == 1) {
return roles.get(0);
}
return null;
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java
index 675e4f4..5daacbd 100644
--- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java
@@ -353,28 +353,6 @@
@SuppressWarnings("unchecked")
@Test
- public void getWidgetControllerTest() throws Exception {
- PowerMockito.mockStatic(EcompPortalUtils.class);
- PowerMockito.mockStatic(SystemProperties.class);
- PowerMockito.mockStatic(EPCommonSystemProperties.class);
- PowerMockito.mockStatic(CipherUtil.class);
- Mockito.when(EcompPortalUtils.widgetMsProtocol()).thenReturn("test1");
- Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.WIDGET_MS_PROTOCOL)).thenReturn("https");
- Mockito.when(SystemProperties.getProperty("microservices.widget.local.port")).thenReturn("test");
- Mockito.when(EcompPortalUtils.getPropertyOrDefault("microservices.widget.username", "widget_user"))
- .thenReturn("test");
- Mockito.when(CipherUtil
- .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
- .thenReturn("abc");
- Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
- Mockito.when(template.getForObject(Mockito.anyString(), Mockito.any(Class.class), Mockito.any(String.class)))
- .thenReturn("test123");
- String result = widgetsCatalogController.getWidgetController(1);
- assertNull(result);
- }
-
- @SuppressWarnings("unchecked")
- @Test
public void getWidgetCSSTest() throws Exception {
PowerMockito.mockStatic(EcompPortalUtils.class);
PowerMockito.mockStatic(SystemProperties.class);
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogUnRestrictedControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogUnRestrictedControllerTest.java
new file mode 100644
index 0000000..fbee764
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogUnRestrictedControllerTest.java
@@ -0,0 +1,143 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.onap.portalapp.portal.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.portalapp.portal.core.MockEPUser;
+import org.onap.portalapp.portal.domain.EPUser;
+import org.onap.portalapp.portal.domain.MicroserviceParameter;
+import org.onap.portalapp.portal.domain.WidgetCatalog;
+import org.onap.portalapp.portal.domain.WidgetCatalogParameter;
+import org.onap.portalapp.portal.domain.WidgetParameterResult;
+import org.onap.portalapp.portal.ecomp.model.PortalRestResponse;
+import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum;
+import org.onap.portalapp.portal.framework.MockitoTestSuite;
+import org.onap.portalapp.portal.service.MicroserviceServiceImpl;
+import org.onap.portalapp.portal.service.WidgetMService;
+import org.onap.portalapp.portal.service.WidgetMServiceImpl;
+import org.onap.portalapp.portal.service.WidgetParameterServiceImpl;
+import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
+import org.onap.portalapp.portal.utils.EcompPortalUtils;
+import org.onap.portalapp.util.EPUserUtils;
+import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.util.SystemProperties;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.mock.web.MockMultipartFile;
+import org.springframework.mock.web.MockMultipartHttpServletRequest;
+import org.springframework.web.client.RestClientException;
+import org.springframework.web.client.RestTemplate;
+
+@SuppressWarnings("rawtypes")
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ EPUserUtils.class, CipherUtil.class, EcompPortalUtils.class, SystemProperties.class,
+ EPCommonSystemProperties.class, EPUserUtils.class })
+public class WidgetsCatalogUnRestrictedControllerTest {
+
+ @Mock
+ WidgetMService widgetMService = new WidgetMServiceImpl();
+
+ @InjectMocks
+ WidgetsCatalogUnRestrictedController widgetsCatalogControllerTest = new WidgetsCatalogUnRestrictedController();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Mock
+ RestTemplate template = new RestTemplate();
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ MockEPUser mockUser = new MockEPUser();
+
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void getWidgetControllerTest() throws Exception {
+ PowerMockito.mockStatic(EcompPortalUtils.class);
+ PowerMockito.mockStatic(SystemProperties.class);
+ PowerMockito.mockStatic(EPCommonSystemProperties.class);
+ PowerMockito.mockStatic(CipherUtil.class);
+ Mockito.when(EcompPortalUtils.widgetMsProtocol()).thenReturn("test1");
+ Mockito.when(SystemProperties.getProperty(EPCommonSystemProperties.WIDGET_MS_PROTOCOL)).thenReturn("https");
+ Mockito.when(SystemProperties.getProperty("microservices.widget.local.port")).thenReturn("test");
+ Mockito.when(EcompPortalUtils.getPropertyOrDefault("microservices.widget.username", "widget_user"))
+ .thenReturn("test");
+ Mockito.when(CipherUtil
+ .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password")))
+ .thenReturn("abc");
+ Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com");
+ Mockito.when(template.getForObject(Mockito.anyString(), Mockito.any(Class.class), Mockito.any(String.class)))
+ .thenReturn("test123");
+ String result = widgetsCatalogControllerTest.getWidgetController(1);
+ assertNull(result);
+ }
+
+
+
+}
diff --git a/ecomp-portal-widget-ms/widget-ms/pom.xml b/ecomp-portal-widget-ms/widget-ms/pom.xml
index 50a285c..2cdf13f 100644
--- a/ecomp-portal-widget-ms/widget-ms/pom.xml
+++ b/ecomp-portal-widget-ms/widget-ms/pom.xml
@@ -91,7 +91,7 @@
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
- <!-- <version>1.5.8</version> -->
+ <version>1.5.8</version>
</dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java
index 1896a4f..e6c1c0a 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/controller/WidgetsCatalogController.java
@@ -163,13 +163,14 @@
try {
//check the zip file structure first
respond = storageService.checkZipFile(file);
+ logger.debug("Check file validity"+respond.isValid()+respond.getError());
if(respond.isValid()){
//update the widget catalog
WidgetCatalog newWidget = new ObjectMapper().readValue(widget, WidgetCatalog.class);
widgetCatalogService.updateWidgetCatalog(widgetId, newWidget);
logger.debug("WidgetsCatalogController.saveWidgetCatalog: updating widget with widgetId={}", widgetId);
//update the widget zip file
- storageService.update(file, newWidget, widgetId);
+ storageService.updateJsFile(file, newWidget, widgetId);
}
} catch (Exception e) {
logger.error("Exception occurred while performing WidgetsCatalogController.saveWidgetCatalog in widget microservices. Details:", e);
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/StorageService.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/StorageService.java
index fbd0f96..d8b5642 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/StorageService.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/StorageService.java
@@ -30,5 +30,7 @@
void update(MultipartFile file, WidgetCatalog newWidget, long widgetId);
+ void updateJsFile(MultipartFile file, WidgetCatalog newWidget, long widgetId);
+
byte[] getWidgetCatalogContent(long widgetId) throws Exception;
}
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/StorageServiceImpl.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/StorageServiceImpl.java
index 7a35ba4..3bb41b6 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/StorageServiceImpl.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/StorageServiceImpl.java
@@ -73,7 +73,7 @@
Criteria criteria = session.createCriteria(WidgetFile.class);
criteria.add(Restrictions.eq("widgetId", widgetId));
List<WidgetFile> widgetFiles = criteria.list();
- session.flush();
+ //session.flush();
session.close();
if (widgetFiles.size() > 0)
widgetFile = widgetFiles.get(0);
@@ -148,7 +148,7 @@
logger.error("StorageServiceImpl.save: Failed to store file " + file.getOriginalFilename(), e);
throw new StorageException("Failed to store file " + file.getOriginalFilename(), e);
}
- saveHelper(newWidget, widgetId, map);
+ saveJsHelper(newWidget, widgetId, map);
}
@Override
@@ -167,7 +167,7 @@
throw new StorageException("Failed to store file " + file.getName(), e);
}
- saveHelper(newWidget, widgetId, map);
+ saveJsHelper(newWidget, widgetId, map);
}
/**
@@ -259,6 +259,90 @@
widgetId);
}
+
+ /**
+ * Helper method to UnZip File
+ *
+ * @param file
+ */
+ private Map<String, byte[]> unZipFile(MultipartFile file) {
+ UnzipUtil unzipper = new UnzipUtil();
+ Map<String, byte[]> map;
+ File convFile;
+ try {
+ if (file.isEmpty()) {
+ logger.error("StorageServiceImpl.update: Failed to store empty file " + file.getOriginalFilename());
+ throw new StorageException("Failed to store empty file " + file.getOriginalFilename());
+ }
+ String fileLocation = file.getOriginalFilename();
+ logger.debug("StorageServiceImpl.update: store the widget to:" + fileLocation);
+ convFile = new File(fileLocation);
+ try(FileOutputStream fos = new FileOutputStream(convFile)){
+ fos.write(file.getBytes());
+ }
+ map = unzipper.unzip_db(fileLocation, ".", "tempWidgets");
+ convFile.delete();
+ return map;
+ } catch (IOException e) {
+ logger.error("StorageServiceImpl.update: Failed to store file " + file.getOriginalFilename(), e);
+ throw new StorageException("StorageServiceImpl.update: Failed to store file " + file.getOriginalFilename(),
+ e);
+ }
+ }
+
+ /**
+ * Helper method for saving widget file (controller.js) to ep_widget_catalog_files table in database
+ *
+ * @param newWidget
+ * @param widgetId
+ * @param map
+ */
+ private void saveJsHelper(WidgetCatalog newWidget, long widgetId, Map<String, byte[]> map) {
+
+ logger.debug("Going to save controller.js " + newWidget);
+ WidgetFile widgetFile = new WidgetFile();
+ widgetFile.setName(newWidget.getName());
+ widgetFile.setWidgetId(widgetId);
+ final byte[] controllerLoc = map.get(WidgetConstant.WIDGET_CONTROLLER_LOCATION);
+ if (controllerLoc == null || controllerLoc.length == 0)
+ throw new IllegalArgumentException(
+ "Map is missing required key " + WidgetConstant.WIDGET_CONTROLLER_LOCATION);
+ String javascript = new String(controllerLoc);
+
+ widgetFile.setController(javascript.getBytes());
+ Session session = sessionFactory.openSession();
+ session.save(widgetFile);
+ session.flush();
+ session.close();
+ logger.debug(
+ "StorageServiceImpl.save: saved controller.js file to the database for widget {}",
+ widgetId);
+
+ }
+
+ @Override
+ public void updateJsFile(MultipartFile file, WidgetCatalog newWidget, long widgetId) {
+ Map<String, byte[]> map;
+ map = unZipFile(file);
+ //Get existing widget file from DB
+ WidgetFile widgetFile = getWidgetFile(widgetId);
+
+ String javascript = new String(map.get(WidgetConstant.WIDGET_CONTROLLER_LOCATION));
+ widgetFile.setController(javascript.getBytes());
+ Session session = sessionFactory.openSession();
+ Transaction tx = session.beginTransaction();
+ session.update(widgetFile);
+ tx.commit();
+ session.flush();
+ session.close();
+ logger.debug(
+ "StorageServiceImpl.save: updated controller.js file to the database for widget {}",
+ widgetId);
+ }
+
+
+
+
@Override
public void update(MultipartFile file, WidgetCatalog newWidget, long widgetId) {
@@ -424,53 +508,14 @@
public byte[] getWidgetCatalogContent(long widgetId) throws Exception {
WidgetCatalog widget = widgetCatalogService.getWidgetCatalog(widgetId);
- String namespace = "Portal" + widgetId + "Widget";
- String controllerName = "Portal" + widgetId + "Ctrl";
- String cssName = "portal" + widgetId + "-css-ready";
-
- String styles = getWidgetCSS(widgetId).replaceAll(cssName, widget.getName() + "-css-ready");
File f = File.createTempFile("temp", ".zip");
try(ZipOutputStream out = new ZipOutputStream(new FileOutputStream(f))){
- ZipEntry e = new ZipEntry(widget.getName() + "/styles/styles.css");
- out.putNextEntry(new ZipEntry(widget.getName() + "/"));
- out.putNextEntry(new ZipEntry(widget.getName() + "/styles/"));
- out.putNextEntry(e);
- byte[] data = styles.getBytes();
- out.write(data, 0, data.length);
+ String javascript = getWidgetController(widgetId);
- String widgetData = namespace + "=" + namespace + "||{};" + "var res = " + namespace + ".widgetData;";
- String javascript = getWidgetController(widgetId).replace(widgetData, "").replace(namespace + ".controller =",
- "");
-
- String functionHeader = javascript.substring(javascript.indexOf("function"), javascript.indexOf(")") + 1);
- javascript = javascript.replaceFirst(controllerName, widget.getName() + "Ctrl");
- String functionParam = functionHeader.substring(functionHeader.indexOf("(") + 1, functionHeader.indexOf(")"));
- StringBuilder injectStr = new StringBuilder().append("[");
- List<String> paramList = Arrays.asList(functionParam.split(","));
- for (int i = 0; i < paramList.size(); i++) {
- if (i == paramList.size() - 1)
- injectStr.append("'" + paramList.get(i).trim() + "'];");
- else
- injectStr.append("'" + paramList.get(i).trim() + "',");
- }
- javascript = javascript.replace(";" + namespace + ".controller.$inject = " + injectStr.toString(), "");
-
- e = new ZipEntry(widget.getName() + "/js/controller.js");
+ ZipEntry e = new ZipEntry(widget.getName() + "/js/controller.js");
out.putNextEntry(new ZipEntry(widget.getName() + "/js/"));
out.putNextEntry(e);
- data = javascript.getBytes();
- out.write(data, 0, data.length);
-
- String html = getWidgetMarkup(widgetId).replaceFirst(controllerName, widget.getName() + "Ctrl");
-
- // new
- // String(map.get(WidgetConstant.WIDGET_MARKUP_LOCATION)).replaceFirst(functionName,
- // controllerName);;
-
- e = new ZipEntry(widget.getName() + "/markup/markup.html");
- out.putNextEntry(new ZipEntry(widget.getName() + "/markup/"));
- out.putNextEntry(e);
- data = html.getBytes();
+ byte[] data = javascript.getBytes();
out.write(data, 0, data.length);
out.closeEntry();
byte[] result = Files.readAllBytes(Paths.get(f.getPath()));
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java
index f5558e2..d71356f 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/service/impl/WidgetCatalogServiceImpl.java
@@ -148,14 +148,13 @@
@Override
public WidgetCatalog getWidgetCatalog(Long widgetCatalogId) {
Session session = sessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
WidgetCatalog widget = (WidgetCatalog) session.get(WidgetCatalog.class, widgetCatalogId);
- tx.commit();
logger.debug("WidgetCatalogServiceImpl.getWidgetCatalog: getting widget={}", widget);
return widget;
}
@Override
+ @Transactional
public void deleteWidgetCatalog(long widgetCatalogId) {
logger.debug("WidgetCatalogServiceImpl.deleteWidgetCatalog: deleting the widget with widgetId={}", widgetCatalogId);
WidgetCatalog widget = getWidgetCatalog(widgetCatalogId);
@@ -164,7 +163,7 @@
return;
}
Session session = sessionFactory.getCurrentSession();
- Transaction tx = session.beginTransaction();
+ //Transaction tx = session.beginTransaction();
Query query = session.createSQLQuery("delete from ep_pers_user_widget_sel where widget_id = :widgetId ").setParameter("widgetId", widgetCatalogId);
query.executeUpdate();
query = session.createSQLQuery("delete from ep_pers_user_widget_placement where widget_id = :widgetId ").setParameter("widgetId", widgetCatalogId);
@@ -174,7 +173,7 @@
query = session.createSQLQuery("delete from ep_widget_catalog_parameter where widget_id = :widgetId ").setParameter("widgetId", widgetCatalogId);
query.executeUpdate();
session.delete(widget);
- tx.commit();
+ //tx.commit();
}
@Override
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/utils/UnzipUtil.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/utils/UnzipUtil.java
index f20ed1b..164a698 100644
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/utils/UnzipUtil.java
+++ b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/onap/portalapp/widget/utils/UnzipUtil.java
@@ -51,8 +51,7 @@
ZipEntry entry = zipIn.getNextEntry();
Map<String, byte[]> map = new HashMap<>();
- String[] requiredKeys = { WidgetConstant.WIDGET_CONTROLLER_LOCATION, WidgetConstant.WIDGET_MARKUP_LOCATION,
- WidgetConstant.WIDGET_STYLE_LOCATION };
+ String[] requiredKeys = { WidgetConstant.WIDGET_CONTROLLER_LOCATION };
for (String k : requiredKeys)
map.put(k, null);
diff --git a/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.html b/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.html
index 65ccf1d..db0b6af 100644
--- a/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.html
+++ b/portal-FE-common/src/app/layout/components/tabbar/tabbar.component.html
@@ -35,6 +35,17 @@
-->
+ <style>
+ .apps-tab {
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ top: 100px;
+ left: 5px;
+ background-color: white;
+ }
+ </style>
+
<div style="display: flex; flex-direction:column">
<mat-tab-group [selectedIndex]="selected.value" (selectedIndexChange)="selected.setValue($event)"
@@ -79,19 +90,15 @@
</mat-tab-group>
-
-
-
-
- <div *ngFor="let tab of tabs; let index = index"
- [style.display]='tab.active? "inline" : "none"'
- [style.position]='tab.active? "static" : "absolute"'
- [style.height]='tab.active? "calc(100vh)" : "calc(0vh)"'>
-
- <iframe id="tabframe-{{tab.label.split(' ').join('-')}}-{{index}}" scrolling='yes' frameBorder='0' width='100%'
- scrolling='yes' frameBorder='0' width='100%' height='90%' [src]='tab.url'></iframe>
-
- </div>
-
-
- </div>
+ <div class="apps-tab" *ngFor="let tab of tabs; let index = index"
+ [style.display]='"inline"'
+ [style.position]='"absolute"'
+ [style.height]='"calc(100vh)"'
+ [style.z-index]="tab.active? 1 : 0"
+ [style.opacity]="tab.active? 1 : 0"
+ >
+ <iframe id="tabframe-{{tab.label.split(' ').join('-')}}-{{index}}" scrolling='yes' frameBorder='0'
+ scrolling='yes' frameBorder='0' width='100%' height='90%' [src]='tab.url'>
+ </iframe>
+ </div>
+</div>
diff --git a/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.html b/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.html
index d898563..54df2d1 100644
--- a/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.html
+++ b/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.html
@@ -40,7 +40,7 @@
<h1 class="heading-page">Edit Functional Menu</h1>
</div>
<div id="jqTree"></div>
- <div class="functional-admin-button-container">
+ <!-- <div class="functional-admin-button-container">
<button id="regenrate-functionalmenu-btn"
class="btn btn-alt btn-small"
(click)="regenerateFunctionalMenuAncestors()">Regenerate Menu
@@ -48,5 +48,5 @@
<div class="regenerate-functionalmenu-btn-txt">
<span class="n16r">Click when you are done with your changes.</span>
</div>
- </div>
+ </div> -->
</div>
diff --git a/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.ts b/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.ts
index d3b5a16..c231061 100644
--- a/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.ts
+++ b/portal-FE-common/src/app/pages/functional-menu/functional-menu.component.ts
@@ -151,43 +151,42 @@
* @param ngbModal
*/
buildTree(treedataarray,ngbModal: NgbModal , _self){
- //console.log("treedataarray>>>>",treedataarray);
- // $(function() {
- // $('#jqTree').tree('loadData', treedataarray);
- // $('#jqTree').tree({
- // data: treedataarray,
- // autoOpen: false,
- // dragAndDrop: true,
- // onCreateLi: function(node, $li) {
- // ////console.log("node >>",node);
- // }
- // }).on(
- // 'tree.contextmenu',
- // function(event:any) {
- // // The clicked node is 'event.node'
- // var node = event.node;
- // openMenuDetailsModal(node, "view");
- // }
- // );
+ console.log("treedataarray>>>>",treedataarray);
+ $(function() {
+ (<any>$('#jqTree')).tree('loadData', treedataarray);
+ (<any>$('#jqTree')).tree({
+ data: treedataarray,
+ autoOpen: false,
+ dragAndDrop: true,
+ onCreateLi: function(node, $li) {
+ ////console.log("node >>",node);
+ }
+ }).on(
+ 'tree.contextmenu',
+ function(event:any) {
+ // The clicked node is 'event.node'
+ var node = event.node;
+ openMenuDetailsModal(node, "view");
+ }
+ );
- // var openMenuDetailsModal = function(node: any, actionName: string ){
- // const modalRef = ngbModal.open(FunctionalMenuDialogComponent, { size: 'lg' });
- // modalRef.componentInstance.title = 'Functional Menu ',actionName;
- // if(node != 'undefined' && node){
- // modalRef.componentInstance.nodedata = node;
- // modalRef.componentInstance.operationName = actionName;
- // }else{
- // modalRef.componentInstance.nodedata = {};
- // }
- // modalRef.componentInstance.passEntry.subscribe((receivedEntry: any) => {
- // //console.log("receivedEntry>>>>",receivedEntry);
- // ngbModal.dismissAll();
- // if(receivedEntry.httpStatusCode===200){
- // _self.getFunctionalMenu();
- // }
- // });
- // }
- // });
- // }
+ var openMenuDetailsModal = function(node: any, actionName: string ){
+ const modalRef = ngbModal.open(FunctionalMenuDialogComponent, { size: 'lg' });
+ modalRef.componentInstance.title = 'Functional Menu ',actionName;
+ if(node != 'undefined' && node){
+ modalRef.componentInstance.nodedata = node;
+ modalRef.componentInstance.operationName = actionName;
+ }else{
+ modalRef.componentInstance.nodedata = {};
+ }
+ modalRef.componentInstance.passEntry.subscribe((receivedEntry: any) => {
+ //console.log("receivedEntry>>>>",receivedEntry);
+ ngbModal.dismissAll();
+ if(receivedEntry.httpStatusCode===200){
+ _self.getFunctionalMenu();
+ }
+ });
+ }
+ });
}
}
diff --git a/portal-FE-common/src/app/pages/web-analytics/web-analytics.component.scss b/portal-FE-common/src/app/pages/web-analytics/web-analytics.component.scss
index c72d11e..7e68e1a 100644
--- a/portal-FE-common/src/app/pages/web-analytics/web-analytics.component.scss
+++ b/portal-FE-common/src/app/pages/web-analytics/web-analytics.component.scss
@@ -44,6 +44,11 @@
padding-bottom: 15px;
padding-right: 40px;
font-weight: bold;
+ white-space: nowrap;
+}
+
+td.mat-cell, td.mat-footer-cell, th.mat-header-cell {
+ padding-right: 45px;
}
.ion-md-trash{
diff --git a/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.html b/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.html
index 6d0c544..f68d879 100644
--- a/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.html
+++ b/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.html
@@ -252,10 +252,10 @@
<span style="flex: 9">Upload
Image</span>
<app-information-tooltip style="flex: 1;"
- [textMessage]="'Image file must be smaller than 1MB'">
+ [textMessage]="'Image file(.png or.jpg or.jpeg with dimension 200X200 pixel) must be smaller than 1MB.'">
</app-information-tooltip>
</div>
- <input type="file" id="input-app-image-upload"
+ <input #inputAppImageUpload type="file" id="input-app-image-upload"
class="input-file-field input-app-image-upload-ht" accept="image/*"
[(ngModel)]="applicationObj.originalImage" name="appImage"
image-upload="applicationObj.originalImage" image-upload-resize-max-height="300"
@@ -284,7 +284,10 @@
<div class="property" *ngIf="!(applicationObj.applicationType == '3')">
<div class="property-label preview">
<span class="left-label">Preview</span>
- <span class="remove" (click)="removeImage()">Remove</span>
+ <span *ngIf="(applicationObj.imageLink && applicationObj.imageLink.indexOf('default_app_image.gif') == -1
+ ||applicationObj.thumbnail && applicationObj.thumbnail.indexOf('default_app_image.gif') == -1
+ ||emptyImgForPreview && emptyImgForPreview.indexOf('default_app_image.gif') == -1)"
+ class="remove" (click)="removeImage()">Remove</span>
</div>
<img id="image-app-preview" class="image-preview"
src="{{applicationObj.imageLink || applicationObj.thumbnail || emptyImgForPreview}}" />
diff --git a/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.ts b/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.ts
index 1b15f80..852e970 100644
--- a/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.ts
+++ b/portal-FE-os/src/app/pages/application-onboarding/application-details-dialog/application-details-dialog.component.ts
@@ -75,6 +75,7 @@
@Input() action: any;
@Output() passEntry: EventEmitter<any> = new EventEmitter();
@ViewChild('applicationName') applicationNameElement: ElementRef;
+ @ViewChild('inputAppImageUpload') inputAppImageUpload: ElementRef;
newAppModel = {
'id': null,
@@ -200,6 +201,7 @@
this.applicationObj.imageUrl = null;
this.applicationObj.imageLink = null;
this.emptyImgForPreview = '../../../assets/images/default_app_image.gif';
+ this.inputAppImageUpload.nativeElement.value = "";
}
}, (resut) => {
return;
diff --git a/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.html b/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.html
index 19f5d8a..4772247 100644
--- a/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.html
+++ b/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.html
@@ -51,6 +51,7 @@
</button>
<div class="apps-table">
+ <span class="ecomp-spinner" *ngIf="showEcompSpinner"></span>
<!-- Applications Table goes here-->
<table mat-table [dataSource]="dataSource" matSort>
<!-- Thumbnail Column -->
diff --git a/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.ts b/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.ts
index 5903d65..83cbfa0 100644
--- a/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.ts
+++ b/portal-FE-os/src/app/pages/application-onboarding/application-onboarding.component.ts
@@ -66,6 +66,7 @@
dataSource = new MatTableDataSource(this.appsList);
@ViewChild(MatSort) sort: MatSort;
@ViewChild(MatPaginator) paginator: MatPaginator;
+ showEcompSpinner:boolean = false;
constructor(public applicationsService: ApplicationsService, public ngbModal: NgbModal) { }
@@ -77,11 +78,13 @@
getOnboardingApps(){
//console.log("getOnboardingApps called");
+ this.showEcompSpinner = true;
this.applicationsService.getOnboardingApps()
.subscribe(_data => {
this.result = _data;
if (this.result == null || this.result == 'undefined') {
console.log('WidgetOnboardingService::getOnboardingWidgets Failed: Result or result.data is null');
+ this.showEcompSpinner = false;
}else {
this.appsList = _data;
for (var i = 0; i < this.appsList.length; i++) {
@@ -94,11 +97,14 @@
}
}
this.populateTableData(this.appsList);
+ this.showEcompSpinner = false;
}
}, error =>{
console.log(error);
+ this.showEcompSpinner = false;
this.openConfirmationModal('Error', error.message);
});
+ this.showEcompSpinner = false;
}
applyFilter(filterValue: string) {
@@ -143,13 +149,16 @@
console.log('ApplicationOnboardingCtrl::deleteApplication: No apllication or ID... cannot delete');
return;
}
+ this.showEcompSpinner = true;
this.appsList.splice(this.appsList.indexOf(application), 1);
this.applicationsService.deleteOnboardingApp(application.id)
.subscribe( data => {
this.result = data;
this.getOnboardingApps();
+ this.showEcompSpinner = false;
}, error => {
console.log(error);
+ this.showEcompSpinner = false;
if(error && error.status == 405){
this.openConfirmationModal('', 'Application : ' + application.appName+ ' can not be deleted as it is associsted with one of the Microservices.');
}else{