1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < meta charset ="UTF-8 ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < title > Import Bazel project wizard</ title >
8+ </ head >
9+
10+ < body >
11+ < div >
12+ < input type ="text " id ="workspaceLocation " name ="workspaceLocation " style ="width: 50%; height: 1.5em; ">
13+ < button id ="browseWorkspace " name ="browseWorkspace " onclick ="onBrowseHandler('browseWorkspace') "
14+ style ="height: 1.5em; "> Browse...</ button >
15+ </ div >
16+
17+ < button id ="loadModulesBtn " onclick ="loadModules() " style ="height: 1.5em; "> Load modules</ button >
18+ < button id ="importProjectBtn " onclick ="importProject() " style ="height: 1.5em; " disabled > Start import</ button >
19+
20+ < div id ="moduleList " style ="width: 100%; height: 50%; overflow-y: scroll; ">
21+ </ div >
22+
23+ < script >
24+ const vscode = acquireVsCodeApi ( ) ;
25+ const moduleListDivId = 'moduleList' ;
26+
27+ window . addEventListener ( 'message' , event => {
28+
29+ const message = event . data ; // The JSON data our extension sent
30+
31+ switch ( message . command ) {
32+ case 'setworkspace' : {
33+ setLocation ( "workspaceLocation" , message ) ;
34+ break ;
35+ }
36+ case 'listModules' : {
37+ const modules = message . data ;
38+ if ( modules != null ) {
39+ if ( modules . length > 0 ) {
40+ document . getElementById ( 'importProjectBtn' ) . disabled = false ;
41+ }
42+ for ( i = 0 ; i < modules . length ; i ++ ) {
43+ const moduleName = modules [ i ] ;
44+ const moduleId = moduleListDivId + moduleName ;
45+ const divSection = document . getElementById ( moduleListDivId ) ;
46+ const cbNode = document . createElement ( 'input' ) ;
47+ cbNode . type = 'checkbox' ;
48+ cbNode . name = moduleId ;
49+ cbNode . value = moduleName ;
50+ cbNode . id = moduleId ;
51+ cbNode . setAttribute ( 'type' , 'checkbox' ) ;
52+
53+ const labelNode = document . createElement ( 'label' ) ;
54+ labelNode . htmlFor = moduleId ;
55+ labelNode . appendChild ( document . createTextNode ( moduleName ) ) ;
56+
57+ divSection . appendChild ( cbNode ) ;
58+ divSection . appendChild ( labelNode ) ;
59+ divSection . appendChild ( document . createElement ( 'br' ) ) ;
60+
61+ }
62+ }
63+ break ;
64+ }
65+ }
66+ } ) ;
67+
68+ function setLocation ( elementId , message ) {
69+ if ( message . data != null ) {
70+ document . getElementById ( elementId ) . value = message . data
71+ } else {
72+ document . getElementById ( elementId ) . value = ''
73+ }
74+ }
75+
76+ function onBrowseHandler ( cmd ) {
77+ vscode . postMessage ( {
78+ command : cmd
79+ } )
80+ }
81+
82+ function importProject ( ) {
83+ const sourceLocation = document . getElementById ( "workspaceLocation" ) . value ;
84+ let modules = [ ] ;
85+ const divNode = document . getElementById ( moduleListDivId ) ;
86+ const divModuleNodes = divNode . getElementsByTagName ( 'input' ) ;
87+ for ( i = 0 ; i < divModuleNodes . length ; i ++ ) {
88+ if ( divModuleNodes [ i ] . checked ) {
89+ const moduleName = divModuleNodes [ i ] . value ;
90+ modules . push ( moduleName ) ;
91+ }
92+ }
93+ vscode . postMessage ( {
94+ command : 'importProject' ,
95+ source : sourceLocation ,
96+ modules : modules
97+ } )
98+ }
99+
100+ function loadModules ( ) {
101+ const sourceLocation = document . getElementById ( "workspaceLocation" ) . value ;
102+ vscode . postMessage ( {
103+ command : 'loadModules' ,
104+ source : sourceLocation
105+ } )
106+ }
107+ </ script >
108+ </ body >
109+
110+ </ html >
0 commit comments