@@ -8,11 +8,11 @@ import customCSS from './style.css?inline';
8
8
9
9
const ATTRIBUTES : string [ ] = [ "base-url" ] ;
10
10
interface MappingItem {
11
- id : string ;
11
+ mappingId : string ;
12
12
title : string ;
13
13
description ?: string ;
14
- mappingType :string ;
15
- name :string ;
14
+ mappingType : string ;
15
+ name : string ;
16
16
}
17
17
class MappingInputProvider extends HTMLElement {
18
18
shadowRoot : ShadowRoot ;
@@ -21,7 +21,10 @@ class MappingInputProvider extends HTMLElement {
21
21
baseUrl : URL = new URL ( "http://localhost:8090/" ) ;
22
22
// ---
23
23
24
+ selectedMappingId : string | null = null ;
25
+ selectedMappingType : string | null = null ;
24
26
27
+ messageDisplayed : boolean | null = null ;
25
28
// --- Helper methods
26
29
addCssContent ( css : string ) : void {
27
30
let styleElem : HTMLStyleElement = document . createElement ( "style" ) ;
@@ -93,77 +96,106 @@ class MappingInputProvider extends HTMLElement {
93
96
options . maxFiles = 1 ;
94
97
this . testingFileChooser = FilePondLib . create ( filepondElement , options ) ;
95
98
}
96
- //plugin endpoint test
97
- let pluginContainer : HTMLElement = < HTMLInputElement > (
98
- this . shadowRoot . getElementById ( 'plugin-container' )
99
- ) ;
100
- const pluginEndpoints = this . baseUrl . toString ( ) + "api/v1/mappingAdministration/types"
101
- fetch ( pluginEndpoints ) . then ( response => response . json ( )
102
- )
103
- . then ( ( pluginData : MappingItem [ ] ) => {
104
- console . log ( pluginData ) ;
105
- const pluginType = pluginData . map ( ( item :MappingItem ) => ( {
106
- id :item . id ,
107
- name :item . name
108
- } ) ) ;
109
- pluginContainer . innerHTML = '' ;
110
- console . log ( pluginData ) ;
111
- pluginType . forEach ( plugin =>
112
- {
113
- const division = document . createElement ( "div" )
114
- division . classList . add ( "xyz" ) ;
115
-
116
- division . innerHTML = `
117
- <span >Type : ${ plugin . id } </span>
118
- <span class="home-price section-Heading">Title: ${ plugin . name } </span>
119
- `
120
- pluginContainer . appendChild ( division ) ;
121
- } )
122
99
123
- } ) . catch ( error => {
124
- console . log ( `Error fetching data from server` , error ) ;
125
- } )
126
100
//Box of detailed contents like title , description
127
101
const mappingIdsEndpoint = this . baseUrl . toString ( ) + "api/v1/mappingAdministration/" ;
128
- let optionsContainer : HTMLElement = < HTMLInputElement > (
102
+ let optionsContainer : HTMLElement = < HTMLInputElement > (
129
103
this . shadowRoot . getElementById ( 'options-container' )
130
104
) ;
105
+ optionsContainer . addEventListener ( "click" , ( event ) => {
106
+ const selectedButton = event . target as HTMLElement ;
107
+ console . log ( selectedButton ) ;
108
+ // Remove the "selected" class from all buttons
109
+ const buttons = optionsContainer . querySelectorAll ( ".selection-button" ) ;
110
+ // console.log(buttons);
111
+ buttons . forEach ( ( button ) => {
112
+ button . classList . remove ( "selected-id" ) ;
113
+
114
+ } ) ;
115
+ // Add the "selected" class to the clicked button
116
+ selectedButton . classList . add ( "selected-id" ) ;
117
+
118
+ // Get the selected mapping ID from the button's ID
119
+ const selectedMappingId = selectedButton . id . replace ( "mapping-button-" , "" ) ;
120
+ this . selectedMappingId = selectedMappingId ;
121
+
122
+ // const selectedType=selectedButton
123
+ console . log ( selectedButton ) ;
124
+ } ) ;
125
+
131
126
fetch ( mappingIdsEndpoint ) . then ( response => response . json ( ) )
132
127
. then ( ( mappingIdsData : MappingItem [ ] ) => {
133
- const mappingIds = mappingIdsData . map ( ( item :MappingItem ) => ( {
134
- id :item . id ,
135
- title :item . title ,
136
- description :item . description ,
128
+ const mappingIds = mappingIdsData . map ( ( item : MappingItem ) => ( {
129
+
130
+ id : item . mappingId ,
131
+ title : item . title ,
132
+ description : item . description ,
137
133
type : item . mappingType
138
134
} ) ) ;
139
- optionsContainer . innerHTML = '' ;
140
- mappingIds . forEach ( mapping => {
135
+ optionsContainer . innerHTML = '' ;
136
+ mappingIds . forEach ( mapping => {
141
137
const division = document . createElement ( "div" )
142
- const button = document . createElement ( "button" ) ;
143
- button . classList . add ( "xyz" ) ;
138
+ // const button = document.createElement("button");
139
+ // button.classList.add("xyz");
144
140
division . classList . add ( "xyz" ) ;
145
- button . setAttribute ( "data-test" , "start-basics" ) ;
141
+ // button.setAttribute("data-test", "start-basics");
142
+ // button.id = `${mapping.id}`;
143
+ // button.innerText = "Select";
144
+
145
+ //<span class="selected-type section-type">Type : ${mapping.type}</span>
146
+ // <span class="home-price section-heading"> ${mapping.title}</span>
146
147
division . innerHTML = `
147
- <span >Type : ${ mapping . type } </span >
148
- <span class="home-price section-Heading">Title: ${ mapping . title } </span>
149
- </div>
150
- <span class="home-text10">
148
+ <img class="mapping-image" src=" ${ this . getImageByType ( mapping . type ) } " alt="Mapping Image" / >
149
+
150
+
151
+ <span class="home-text10 section-description ">
151
152
<br>
152
153
<span style="display:inline-block; overflow: auto; height: 124px;">
153
- Description: ${ mapping . description }
154
+ ${ mapping . description }
154
155
</span>
155
- <br>
156
- <br>
157
156
<span></span>
158
157
</span>
159
- <button>select</button>
158
+ <button class ="selection-button " id="mapping-button-${ mapping . id } " >Select</button>
159
+
160
+
160
161
` ;
162
+
163
+ const button = division . querySelector ( `#mapping-button-${ mapping . id } ` ) ;
164
+
165
+ if ( button ) {
166
+ button . addEventListener ( "click" , ( ) => {
167
+ this . selectedMappingId = mapping . id ;
168
+
169
+ console . log ( this . selectedMappingId ) ;
170
+ if ( ! this . messageDisplayed ) {
171
+ const fileInput = this . shadowRoot . querySelector ( "#fileUpload" ) ;
172
+
173
+ const messageElement = document . createElement ( "div" ) ;
174
+ // messageElement.style.display = "none";
175
+ messageElement . innerText = "Please upload file and then click on map document to extract metadata" ;
176
+ messageElement . style . marginBottom = "10px" ; // Add some bottom margin for spacing
177
+ messageElement . classList . add ( "message" ) ;
178
+ if ( fileInput != null && fileInput . parentNode != null ) {
179
+ fileInput . parentNode . insertBefore ( messageElement , fileInput ) ;
180
+ }
181
+ this . messageDisplayed = true ;
182
+
183
+ }
184
+
185
+ // this.displayMessage("Please upload file and then click on map document to extract metadata");
186
+ // this.executeMapping(selectedMappingId);
187
+ const selectedMappingType = mapping . type ;
188
+ console . log ( selectedMappingType ) ;
189
+
190
+
191
+ } ) ;
192
+ }
161
193
optionsContainer . appendChild ( division ) ;
194
+
162
195
} )
163
- } ) . catch ( error =>
164
- {
165
- console . error ( 'Error while fetch Mapping Ids' + error )
166
- } )
196
+ } ) . catch ( error => {
197
+ console . error ( 'Error while fetch Mapping Ids' + error )
198
+ } )
167
199
168
200
}
169
201
@@ -205,13 +237,11 @@ class MappingInputProvider extends HTMLElement {
205
237
executeMapping ( ) : Promise < any > ;
206
238
async executeMapping ( download : boolean = false ) : Promise < any > {
207
239
document . body . style . cursor = 'wait' ;
208
- let inputElement : HTMLInputElement = < HTMLInputElement > (
209
- this . shadowRoot . getElementById ( "options-container" )
210
- ) ;
211
- const selectedValue = inputElement ?. value ;
212
- console . log ( 'Selected Value ' + selectedValue )
213
- const selectedMappingId = selectedValue ?. split ( "-" ) [ 0 ] . trim ( ) ;
214
- if ( this . testingFileChooser != null ) {
240
+ const selectedMappingId = this . selectedMappingId ;
241
+ // const selectedValue = inputElement?.value;
242
+ // console.log('Selected Value ' +selectedValue)
243
+ // const selectedMappingId = selectedValue?.split("-")[0].trim();
244
+ if ( selectedMappingId && this . testingFileChooser != null ) {
215
245
const uploadedFile = this . testingFileChooser . getFile ( ) ;
216
246
if ( uploadedFile != null ) {
217
247
const execUrl = this . baseUrl . toString ( ) + "api/v1/mappingExecution/" + selectedMappingId ;
@@ -260,6 +290,18 @@ class MappingInputProvider extends HTMLElement {
260
290
this . shadowRoot . removeChild ( element ) ;
261
291
URL . revokeObjectURL ( element . href ) ;
262
292
}
293
+
294
+ getImageByType ( mappingType : string ) : string {
295
+ if ( mappingType . includes ( "GEMMA" ) ) {
296
+ return "https://th.bing.com/th/id/R.13af2c708c50701c5c418f39f1032c4a?rik=Bhi%2fy8GZ%2fC%2b1%2bg&riu=http%3a%2f%2flogos.textgiraffe.com%2flogos%2flogo-name%2fGemma-designstyle-pastel-m.png&ehk=oiRKyC5Jg2VKEybuGyH%2f8q4l73rWTBZpvXw7hP69AOk%3d&risl=&pid=ImgRaw&r=0" ;
297
+ } else if ( mappingType . includes ( "SEM" ) ) {
298
+ return "https://th.bing.com/th/id/R.aaebd43a8dc60519d02c93699d67fa33?rik=c9P%2bsFde%2bGc8gg&riu=http%3a%2f%2fwww.benspaintsupply.com%2fwp-content%2fuploads%2f2011%2f10%2fSEM-Logo.jpg&ehk=n3cCc0XCRDKt0XFslLWIafoPO6zFEMc91UZQJA6hxuA%3d&risl=&pid=ImgRaw&r=0" ;
299
+ } else if ( mappingType . includes ( "TEM" ) ) {
300
+ return "https://en.tem.ch/wp-content/uploads/sites/2/2019/08/TEM_Logo_Ohne_Claim.jpg" ;
301
+ } else {
302
+ return "https://th.bing.com/th/id/OIP.dDFaFWAAhofP-4yOMUOsCwHaD5?pid=ImgDet&rs=1" ;
303
+ }
304
+ }
263
305
}
264
306
265
307
// Custom Elements:
0 commit comments