1+ <!--********************************************************************
2+ * Copyright© 2000 - 2020 SuperMap Software Co.Ltd. All rights reserved.
3+ *********************************************************************-->
4+ <!DOCTYPE html>
5+ < html lang ="en ">
6+ < head >
7+ < meta charset ="UTF-8 ">
8+ < title data-i18n ="resources.title_iPortalRegisterData "> </ title >
9+ </ head >
10+ < body style =" margin: 0;overflow: auto;background: #F2F2F2;width: 100%;height:100%;position: absolute;top: 0; ">
11+ < div class ="container ">
12+ < div class ="page-header ">
13+ < h4 data-i18n ="resources.title_iPortalRegisterData "> </ h4 >
14+ </ div >
15+ < div class ="col-md-10 ">
16+ < div class ="row ">
17+ < div class ="col-md-12 " style ="background: #FFF; ">
18+ <!--注册数据-->
19+ < div class ="row " style ="padding: 10px; ">
20+ < h5 data-i18n ="resources.text_data_type "> </ h5 >
21+ < select id ='typeSelect-type ' class ='form-control ' onchange ="onSelectDataType() ">
22+ < option value ="HDFS "> HDFS</ option >
23+ < option value ="HBASE "> HBASE</ option >
24+ </ select >
25+ < div class ="hdfs-container ">
26+ < h5 data-i18n ="resources.text_hdfs_directory "> </ h5 >
27+ < span style ="position: relative; ">
28+ < input id ="hdfs-address " class ='form-control ' type ="text " style ="width: 100%; " placeholder ="hdfs://<ip>:<port>/data/a.csv "> < i class ="fa fa-question-circle question " aria-hidden ="true "> </ i >
29+ </ span >
30+ < h5 data-i18n ="resources.detail_iPortal_name "> </ h5 >
31+ < input id ="hdfs-name " class ='form-control ' type ="text " style ="width: 100%; ">
32+ < h5 data-i18n ="resources.detail_iPortal_tags "> </ h5 >
33+ < input id ="hdfs-tags " class ='form-control ' type ="text " style ="width: 100%; ">
34+ </ div >
35+ < div class ="hbase-container ">
36+ < h5 data-i18n ="resources.text_hbase_address "> </ h5 >
37+ < span style ="position: relative; ">
38+ < input id ="hbase-address " class ='form-control ' type ="text " style ="width: 100%; " placeholder ="{ip}:{port} "> < i class ="fa fa-question-circle question " aria-hidden ="true "> </ i >
39+ </ span >
40+ < h5 data-i18n ="resources.text_dataBase_name "> </ h5 >
41+ < input id ="hbase-name " class ='form-control ' type ="text " style ="width: 100%; ">
42+ < h5 data-i18n ="resources.detail_iPortal_tags "> </ h5 >
43+ < input id ="hbase-tags " class ='form-control ' type ="text " style ="width: 100%; ">
44+ </ div >
45+ < div > < button class ="btn btn-primary col-md-offset-6 " style ="margin-top: 20px; " onclick ="registerDataClick() " data-i18n ="resources.btn_OK "> </ button > </ div >
46+ </ div >
47+ </ div >
48+ </ div >
49+ </ div >
50+ </ div >
51+ < script type ="text/javascript " include ="jquery,bootstrap,widgets " src ="../js/include-web.js "> </ script >
52+ < script type ="text/javascript " include ="iclient-leaflet-css,xlsx " src ="../../dist/leaflet/include-leaflet.js "> </ script >
53+ < script >
54+ //iportal的URL地址 或根据情况添加自己的本地iportal地址:http://localhost:8190/iportal
55+ var iPortalUrl = "https://iportal.supermap.io/iportal" ;
56+ var token = "MFEKl8kVmkvEDrDFcgnjoUF4o2VKXT1eZhKh7hU3tnJL1jPculOBmvCtA6Xfrw4KuAyxWj2OcUV1Aj3M41nSNQ.." ;
57+ //数据类型
58+ var dataType ;
59+
60+ $ ( document ) . ready ( function ( ) {
61+ generatePortalToken ( ) ;
62+ //初始化数据类型
63+ onSelectDataType ( ) ;
64+ } ) ;
65+
66+ //获取token
67+ function generatePortalToken ( ) {
68+ var serverInfo = new SuperMap . ServerInfo ( SuperMap . ServerType . IPORTAL , {
69+ server : iPortalUrl
70+ } ) ;
71+
72+ SuperMap . SecurityManager . registerServers ( [ serverInfo ] ) ;
73+ SuperMap . SecurityManager . destroyToken ( iPortalUrl ) ;
74+ SuperMap . SecurityManager . registerToken ( iPortalUrl , token ) ;
75+ }
76+
77+ //选中数据类型函数
78+ function onSelectDataType ( ) {
79+ dataType = $ ( "#typeSelect-type" ) . val ( ) ;
80+ if ( dataType === 'HDFS' ) {
81+ $ ( ".hdfs-container" ) . css ( "display" , "block" ) ;
82+ $ ( ".hbase-container" ) . css ( "display" , "none" ) ;
83+ } else {
84+ $ ( ".hbase-container" ) . css ( "display" , "block" ) ;
85+ $ ( ".hdfs-container" ) . css ( "display" , "none" ) ;
86+ }
87+ }
88+
89+ //注册数据函数
90+ function registerDataClick ( ) {
91+ var params ;
92+ switch ( dataType ) {
93+ case "HDFS" :
94+ var tags = $ ( "#hdfs-tags" ) . val ( ) ;
95+ var HDFSCatalog = $ ( "#hdfs-address" ) . val ( ) ;
96+ var dataStoreInfoParams = new SuperMap . iPortalDataStoreInfoParam ( {
97+ type :dataType ,
98+ url :HDFSCatalog
99+ } )
100+ var dataMetaParams = new SuperMap . iPortalDataMetaInfoParam ( {
101+ url :HDFSCatalog ,
102+ dataStoreInfo :dataStoreInfoParams
103+ } )
104+ params = new SuperMap . iPortalAddDataParam ( {
105+ type :dataType ,
106+ fileName :$ ( "#hdfs-name" ) . val ( ) ,
107+ tags :tags ? tags . replace ( ',' , ',' ) . split ( ',' ) : [ ] , // 将中文逗号替换为英文逗号并去重
108+ dataMetaInfo :dataMetaParams
109+ } )
110+ break ;
111+ case "HBASE" :
112+ var tags = $ ( "#hbase-tags" ) . val ( ) ;
113+ var serviceAddress = $ ( "#hbase-address" ) . val ( ) ;
114+ var connectionInfoParam = new SuperMap . iPortalDataConnectionInfoParam ( {
115+ dataBase :$ ( "#hbase-name" ) . val ( ) ,
116+ server :serviceAddress
117+ } )
118+ var dataStoreInfoParams = new SuperMap . iPortalDataStoreInfoParam ( {
119+ type :dataType ,
120+ connectionInfo :connectionInfoParam
121+ } )
122+ var dataMetaParams = new SuperMap . iPortalDataMetaInfoParam ( {
123+ dataStoreInfo :dataStoreInfoParams
124+ } )
125+ params = new SuperMap . iPortalAddDataParam ( {
126+ type :dataType ,
127+ fileName :$ ( "#hbase-name" ) . val ( ) ,
128+ tags :tags ? tags . replace ( ',' , ',' ) . split ( ',' ) : [ ] , // 将中文逗号替换为英文逗号并去重
129+ dataMetaInfo :dataMetaParams
130+ } ) ;
131+ break ;
132+ }
133+ new SuperMap . iPortalUser ( iPortalUrl ) . addData ( params ) . then ( res => {
134+ if ( res . childID ) {
135+ widgets . alert . showAlert ( resources . msg_register_success , true ) ;
136+ } else {
137+ widgets . alert . showAlert ( res . error . errorMsg , false ) ;
138+ }
139+ } )
140+ }
141+ </ script >
142+ </ body >
143+ </ html >
0 commit comments