Obtain and control VSP package upload status
[sdc.git] / openecomp-ui / src / sdc-app / onboarding / softwareProduct / landingPage / VspUploadStatus.js
1 /*
2  * -
3  *  ============LICENSE_START=======================================================
4  *  Copyright (C) 2022 Nordix Foundation.
5  *  ================================================================================
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *       http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21
22 import i18n from 'nfvo-utils/i18n/i18n';
23
24 export default class VspUploadStatus {
25     static UPLOADING = 'UPLOADING';
26     static VALIDATING = 'VALIDATING';
27     static PROCESSING = 'PROCESSING';
28     static SUCCESS = 'SUCCESS';
29     static ERROR = 'ERROR';
30
31     complete;
32     created;
33     lockId;
34     status;
35     updated;
36     vspId;
37     vspVersionId;
38
39     constructor(vspUploadStatusResponse) {
40         this.status = vspUploadStatusResponse.status;
41         this.complete = vspUploadStatusResponse.complete;
42         this.created = vspUploadStatusResponse.created;
43         this.lockId = vspUploadStatusResponse.lockId;
44         this.updated = vspUploadStatusResponse.updated;
45         this.vspId = vspUploadStatusResponse.vspId;
46         this.vspVersionId = vspUploadStatusResponse.vspVersionId;
47     }
48
49     statusToString() {
50         if (!this.status) {
51             return '';
52         }
53         switch (this.status) {
54             case VspUploadStatus.UPLOADING: {
55                 return i18n('upload.status.uploading');
56             }
57             case VspUploadStatus.VALIDATING: {
58                 return i18n('upload.status.validating');
59             }
60             case VspUploadStatus.PROCESSING: {
61                 return i18n('upload.status.processing');
62             }
63             case VspUploadStatus.SUCCESS: {
64                 return i18n('upload.status.success');
65             }
66             case VspUploadStatus.ERROR: {
67                 return i18n('upload.status.error');
68             }
69             default:
70                 return this.status;
71         }
72     }
73 }