Updated Sparky to add ECOMP functionality Browse, Specialized Search, BYOQ, and the...
[aai/sparky-fe.git] / src / app / model / testGallery.jsx
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2021 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *       http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 import React, {Component} from 'react';
22 import ModelGallery from 'app/modelSearch/components/ModelGallery.jsx';
23 import testData from 'app/CustomQueryMultiNode';
24
25 class testGallery extends Component {
26
27   state = {
28     nodes: [],
29     multipleNodes: '',
30     isLoading: 'show'
31   }
32
33   componentWillMount () {
34     this.processData(testData);
35   }
36
37
38
39   processData = (data) => {
40     console.log('Response data' + JSON.stringify(data));
41     if (data && data.results) {
42       //this.nodes = data.results;
43       this.setState({
44         nodes: data.results
45       });
46
47       this.multipleNodes = this.state.nodes.length > 1;
48     }
49     if (data && data.headers && data.headers.get('total-results')) {
50       this.modelService.setTotalResults(data.headers.get('total-results'));
51     }
52     this.setState({
53       isLoading: 'hidden'
54     });
55   }
56
57   render() {
58
59     let nodes = '';
60     if ( this.state.nodes.length > 0 ) {
61
62       console.log('nodes exist');
63
64       nodes =
65         (<div className='model-container'>
66           <ModelGallery
67             nodes={this.state.nodes}/>
68         </div>);
69     }
70
71     return(
72       <div className='multipleNodes'>
73         <div className={!this.state.isLoading}>
74           <div className='col align-self-cemter'>
75             <fa name='cog' className='fa-5x fa-spin'></fa>
76           </div>
77         </div>
78         <div className={!this.state.isLoading}>
79           <h2>{this.header}</h2>
80           <div className='nodes container-fluid'>
81             <div className='row-dsl'>
82               {nodes}
83             </div>
84           </div>
85         </div>
86       </div>
87     );
88   }
89 }
90
91 export default testGallery;