aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/nfvo-utils
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-01-25 19:38:32 +0000
committerMichael Morris <michael.morris@est.tech>2022-01-31 15:23:21 +0000
commit4594cba0c53461bc1a273458e0a7a314da6bfb68 (patch)
treec78010c789d726aa72ee8591ab12720b72d1c675 /openecomp-ui/src/nfvo-utils
parent99b7fb519806870b3c84e9e1ac0ac2f59320a6b0 (diff)
Obtain and control VSP package upload status
Obtain the upload status and control the upload from the frontend perspective. Change-Id: Idcc921cf592efea33df35c557afcfae827af3a39 Issue-ID: SDC-3862 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'openecomp-ui/src/nfvo-utils')
-rw-r--r--openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js2
-rw-r--r--openecomp-ui/src/nfvo-utils/RestAPIUtil.js74
-rw-r--r--openecomp-ui/src/nfvo-utils/i18n/en.json8
3 files changed, 51 insertions, 33 deletions
diff --git a/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js b/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js
index 5c55855027..e7d3f8a85c 100644
--- a/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js
+++ b/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js
@@ -64,7 +64,7 @@ function parseCatalogExceptionObject(responseJSON) {
return { title, msg };
}
-var errorResponseHandler = error => {
+const errorResponseHandler = error => {
let errorData;
if (error.data) {
errorData = parseCatalogExceptionObject(error.data);
diff --git a/openecomp-ui/src/nfvo-utils/RestAPIUtil.js b/openecomp-ui/src/nfvo-utils/RestAPIUtil.js
index 03908d8203..97d3847350 100644
--- a/openecomp-ui/src/nfvo-utils/RestAPIUtil.js
+++ b/openecomp-ui/src/nfvo-utils/RestAPIUtil.js
@@ -77,55 +77,69 @@ class RestAPIUtil {
handleRequest(url, type, options = {}, data = {}) {
applySecurity(options, data);
- let config = {
+ const config = {
method: type,
url: url,
headers: options.headers,
data: data
};
- store.dispatch({ type: LoaderConstants.SEND_REQUEST, url: url });
+ if (options.validateStatus) {
+ config.validateStatus = options.validateStatus;
+ }
+
+ if (options.onUploadProgress) {
+ config.onUploadProgress = options.onUploadProgress;
+ }
+
+ if (!options.noLoading) {
+ store.dispatch({ type: LoaderConstants.SEND_REQUEST, url: url });
+ }
if (options.dataType === BINARY) {
config.responseType = 'arraybuffer';
return axios(config)
.then(result => {
- store.dispatch({
- type: LoaderConstants.RECEIVE_RESPONSE,
- url: result.config.url
- });
+ if (!options.noLoading) {
+ store.dispatch({
+ type: LoaderConstants.RECEIVE_RESPONSE,
+ url: result.config.url
+ });
+ }
+
return {
blob: new Blob([result.data]),
headers: result.headers
};
})
.catch(error => {
- store.dispatch({
- type: LoaderConstants.RECEIVE_RESPONSE,
- url: error.config.url
- });
- errorResponseHandler(error.response);
- });
- } else {
- return axios(config)
- .then(result => {
- store.dispatch({
- type: LoaderConstants.RECEIVE_RESPONSE,
- url: result.config.url
- });
- handleSuccess(result.headers, result.config.headers);
- return result.data;
- })
- .catch(error => {
- store.dispatch({
- type: LoaderConstants.RECEIVE_RESPONSE,
- url: error.config.url
- });
+ if (!options.noLoading) {
+ store.dispatch({
+ type: LoaderConstants.RECEIVE_RESPONSE,
+ url: error.config.url
+ });
+ }
errorResponseHandler(error.response);
- return Promise.reject({
- responseJSON: error.response.data
- });
});
}
+ return axios(config)
+ .then(result => {
+ store.dispatch({
+ type: LoaderConstants.RECEIVE_RESPONSE,
+ url: result.config.url
+ });
+ handleSuccess(result.headers, result.config.headers);
+ return result.data;
+ })
+ .catch(error => {
+ store.dispatch({
+ type: LoaderConstants.RECEIVE_RESPONSE,
+ url: error.config.url
+ });
+ errorResponseHandler(error.response);
+ return Promise.reject({
+ responseJSON: error.response.data
+ });
+ });
}
fetch(url, options) {
diff --git a/openecomp-ui/src/nfvo-utils/i18n/en.json b/openecomp-ui/src/nfvo-utils/i18n/en.json
index 7a2e66a4b3..ada011f7c3 100644
--- a/openecomp-ui/src/nfvo-utils/i18n/en.json
+++ b/openecomp-ui/src/nfvo-utils/i18n/en.json
@@ -662,6 +662,10 @@
"Unknown": "Unknown",
"No Test Result Available": "No Test Result Available",
"Test is In-progress": "Test is In-progress",
- "has passed all checks": "has passed all checks"
-
+ "has passed all checks": "has passed all checks",
+ "upload.status.uploading": "Package upload is in progress",
+ "upload.status.validating": "Package is in validation",
+ "upload.status.processing": "Package is being processed",
+ "upload.status.success": "Package was successfully uploaded",
+ "upload.status.error": "Package upload resulted in error"
}