iPortalQueryResources.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 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_iPortalQueryResources"></title>
  9. <style>
  10. .gallery-item {
  11. margin-bottom: 30px;
  12. }
  13. .gallery-item-border {
  14. border: 1px solid #dadada;
  15. -webkit-box-shadow: 0px 2px 3px #dcdcdc;
  16. box-shadow: 0px 2px 3px #dcdcdc;
  17. background: white;
  18. }
  19. .thumbnail > img, .thumbnail a > img {
  20. margin-right: auto;
  21. margin-left: auto;
  22. }
  23. .gallery-item-img {
  24. height: 170px !important;
  25. width: 262px !important;
  26. }
  27. .resourcesDetails {
  28. margin: 0px 0 12px 16px;
  29. height: 21px;
  30. overflow: hidden;
  31. text-overflow: ellipsis;
  32. white-space: nowrap;
  33. font-size: 14px !important;
  34. color: #7c7c7c;
  35. }
  36. .resourcesUserDetails {
  37. width: 100%;
  38. border-top: 1px solid #E8E8E8;
  39. font-size: 13px;
  40. }
  41. .textEllipsis {
  42. display: inline-block;
  43. padding-left: 10px;
  44. padding-top: 12px;
  45. padding-bottom: 12px;
  46. vertical-align: top;
  47. overflow: hidden;
  48. text-overflow: ellipsis;
  49. white-space: nowrap;
  50. }
  51. .resourcesBottomList {
  52. padding-left: 10px;
  53. padding-top: 13px;
  54. padding-bottom: 12px;
  55. vertical-align: top;
  56. float: right;
  57. padding-right: 30px;
  58. border-left: 1px solid #ececec;
  59. }
  60. .ip-toolbar-footer {
  61. text-align: center
  62. }
  63. .pagination > li {
  64. display: inline;
  65. }
  66. .pagination > li > a {
  67. position: relative;
  68. float: left;
  69. padding: 8px 16px;
  70. margin-left: -1px;
  71. line-height: 1.42857143;
  72. color: #737373;
  73. text-decoration: none;
  74. background-color: #fff;
  75. border: 1px solid #ececec;
  76. }
  77. #resourcesListPaging > .pagination {
  78. margin: 10px 15px;
  79. }
  80. #resourcesListPaging > .pagination > li > .disable {
  81. pointer-events: none;
  82. background-color: rgba(0, 0, 0, 0.1);
  83. }
  84. #resourcesListPaging > .pagination > li > .active {
  85. background-color: #0083CB;
  86. color: white;
  87. }
  88. .disabled {
  89. cursor: not-allowed;
  90. background-color: #d9d9d9;
  91. }
  92. </style>
  93. </head>
  94. <body style=" margin: 0;overflow: auto;background: #F2F2F2;width: 100%;height:100%;position: absolute;top: 0;">
  95. <div class="container" style="margin-bottom: 100px">
  96. <div class="page-header">
  97. <h4 data-i18n=""></h4>
  98. </div>
  99. <div id="toolbar" class="panel panel-primary" style="position: absolute;top: 10px;right: 70px;text-align: center;z-index: 800;border-radius: 4px;">
  100. <div class='panel-heading' id="panelheading">
  101. <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryResourcesTitle"></h5>
  102. </div>
  103. <div class='panel-body content' id="panelbodycontent">
  104. <!-- 资源类型选择 -->
  105. <div class='input-group' style="width: 220px;margin-bottom: 15px;">
  106. <span class='input-group-addon' data-i18n="resources.title_iPortalQueryResourcesType"></span>
  107. <select class='form-control' id='typeSelect' onchange="onSelectResourcesType()">
  108. <option value="" data-i18n="resources.title_iPortalQueryResourcesAll"></option>
  109. <option value="MAP" data-i18n="resources.title_iPortalQueryResourcesMap"></option>
  110. <option value="SERVICE" data-i18n="resources.title_iPortalQueryResourcesService"></option>
  111. <option value="SCENE" data-i18n="resources.title_iPortalQueryResourcesScene"></option>
  112. <option value="DATA" data-i18n="resources.title_iPortalQueryResourcesData"></option>
  113. <option value="INSIGHTS_WORKSPACE" data-i18n="resources.title_iPortalQueryResourcesInsights"></option>
  114. <option value="MAP_DASHBOARD" data-i18n="resources.title_iPortalQueryResourcesDashboards"></option>
  115. </select>
  116. </div>
  117. <!-- 资源权限选择 -->
  118. <div class='input-group' style="width: 220px;margin-bottom: 15px;">
  119. <span class='input-group-addon' data-i18n="resources.title_iPortalQueryResourcesControl"></span>
  120. <select class='form-control' id='controlSelect'>
  121. <option value="PUBLIC" data-i18n="resources.title_iPortalQueryResourcesPublic"></option>
  122. <option value="SHARETOME_RES" disabled class="disabled" data-i18n="resources.title_iPortalQueryResourcesShareToMe"></option>
  123. <option value="MYDEPARTMENT_RES" disabled class="disabled" data-i18n="resources.title_iPortalQueryResourcesMyDepartment"></option>
  124. <option value="MYGROUP_RES" disabled class="disabled" data-i18n="resources.title_iPortalQueryResourcesMyGroup"></option>
  125. <option value="MY_RES" disabled class="disabled" data-i18n="resources.title_iPortalQueryResourcesMy"></option>
  126. </select>
  127. </div>
  128. <!-- 资源排序字段 -->
  129. <div class='input-group' style="width: 220px;margin-bottom: 15px;">
  130. <span class='input-group-addon' data-i18n="resources.title_iPortalQueryResourcesSortFiled"></span>
  131. <select class='form-control' id='filedSelect' onchange="onSelectResourcesOrderBy()">
  132. <option value="UPDATETIME" data-i18n="resources.title_iPortalQueryResourcesUpdateTime"></option>
  133. <option value="HEATLEVEL" data-i18n="resources.title_iPortalQueryResourcesHeatLevel"></option>
  134. </select>
  135. </div>
  136. <!-- 排序 -->
  137. <div class='input-group' style="width: 220px;margin-bottom: 15px;">
  138. <span class='input-group-addon' data-i18n="resources.title_iPortalQueryResourcesSort"></span>
  139. <select class='form-control' id='sortSelect' onchange="onSelectResourcesOrderType()">
  140. <option value="DESC" data-i18n="resources.title_iPortalQueryResourcesSortDown"></option>
  141. <option value="ASC" data-i18n="resources.title_iPortalQueryResourcesSortUp"></option>
  142. </select>
  143. </div>
  144. <!-- 搜索 -->
  145. <div class='input-group' style="width: 220px;margin-bottom: 15px;">
  146. <span class='input-group-addon' data-i18n="resources.title_iPortalQueryResourcesSearch"></span>
  147. <input type='text' class='form-control' id='searchText' />
  148. </div>
  149. <input type="button" class="btn btn-default" data-i18n="[value]nav.examples.query" onclick="onClickQuery(true)"/>
  150. </div>
  151. </div>
  152. <br />
  153. <div class="col-md-10">
  154. <div class="row">
  155. <div class="col-md-12">
  156. <!--所有资源的承载DIV-->
  157. <div class="row" id="resourcesList">
  158. <!--单个资源数据的可视化承载DIV 添加在此位置中-->
  159. </div>
  160. <!--分页切换列表-->、
  161. <div class="row">
  162. <div class="col-md-12">
  163. <div class="ip-toolbar-footer" id="resourcesListPaging">
  164. <ul class="pagination">
  165. <li><a href="javascript:void(0)"><i class="glyphicon glyphicon-chevron-left"></i></a>
  166. </li>
  167. <li><a href="javascript:void(0)"><i class="glyphicon glyphicon-chevron-right"></i></a>
  168. </li>
  169. </ul>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. <script type="text/javascript" include="jquery,bootstrap-css" src="../js/include-web.js"></script>
  178. <script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
  179. <script>
  180. //iportal的URL地址 或根据情况添加自己的本地iportal地址:http://localhost:8190/iportal
  181. var iPortalUrl = "https://iportal.supermap.io/iportal";
  182. //默认请求的参数
  183. var resourceCurrentPage = 1;//默认请求第一页
  184. var resourcePageSize = 12;//每一页显示9条资源信息
  185. var resourceType = ""; // 请求的资源类型
  186. var resourceOrderType = "DESC"; // 排序升序
  187. var resourceOrderBy = "UPDATETIME"; // 排序字段
  188. var searchText = ""; // 搜索字段
  189. //全局变量,承载请求后,一共有多少页数
  190. var totalPages;
  191. var queryParams = new SuperMap.iPortalQueryParam({
  192. resourceType: resourceType,
  193. pageSize: resourcePageSize,
  194. currentPage: resourceCurrentPage,
  195. orderBy: resourceOrderBy,
  196. orderType: resourceOrderType
  197. });
  198. //资源查询初始化工作
  199. var iPortal = new SuperMap.iPortal(iPortalUrl);
  200. $(document).ready(function () {
  201. //加载完DOM后,开始资源数据查询并添加
  202. queryResouces(queryParams);
  203. initClickEvent();
  204. });
  205. // 查询iPortal中的资源
  206. function queryResouces(queryParams) {
  207. iPortal.queryResources(queryParams).then(function (resourcesReslut) {
  208. //返回的结果集,需要查看可打开下行代码
  209. // console.log(resourcesReslut);
  210. $("#resourcesList").children().remove();
  211. //将结果集进行遍历,并添加到HTML中
  212. $.each(resourcesReslut.content, function (i) {
  213. var resourceItem = resourcesReslut.content[i];
  214. //解析时间戳,可根据需求自行处理
  215. var updateTime = new Date(parseInt(resourceItem.updateTime)).toLocaleString();
  216. var thumbnail = resourceItem.thumbnail;
  217. // 此判断获取部分相对路径的default图片
  218. if(thumbnail.indexOf("./") === 0){
  219. thumbnail = iPortalUrl + thumbnail.replace("./","/");
  220. }
  221. var resourcesDOM = $("<div class='col-md-4 gallery-item'>" +
  222. "<div class='gallery-item-border'>" +
  223. "<a class='thumbnail' style='margin-bottom: 10px'>" +
  224. "<img class='gallery-item-img' src='" + thumbnail + "' alt=''>" +
  225. "</a>" +
  226. "<div>" +
  227. "<p class='resourcesDetails'>" + resourceItem.name + "</p>" +
  228. "<p class='resourcesDetails'>" + resources.text_update + " "+updateTime + "</p>" +
  229. "<div class='resources'>" +
  230. "<div class='textEllipsis'>" +
  231. "<span class='glyphicon glyphicon-user'>" + "</span>" + "&nbsp;" + resourceItem.userName +
  232. "</div>" +
  233. "<div class='resourcesBottomList'>" +
  234. "<span class='glyphicon glyphicon-eye-open'>" + "</span>" +
  235. "<span style='text-align: center'>" + "&nbsp;" + resourceItem.heatLevel + "</span>" +
  236. "</div>" +
  237. "</div>" +
  238. "</div>" +
  239. "</div>" +
  240. "</div>")
  241. $("#resourcesList").append(resourcesDOM);
  242. });
  243. //初始化分页列表以及分页数目发生变化时执行一下
  244. if(!$("#resourcesListPaging > .pagination > .pagDom").length || resourceCurrentPage === 1){
  245. initPages(resourcesReslut.total);
  246. }
  247. })
  248. };
  249. // 初始化分页列表UI
  250. function initPages(total) {
  251. totalPages = Math.ceil(total/resourcePageSize);
  252. $(".glyphicon-chevron-right").parent().removeClass('disable');
  253. $(".glyphicon-chevron-left").parent().removeClass('disable');
  254. $("#resourcesListPaging > .pagination > .pagDom").remove();
  255. for (var i = 0; i < totalPages; i++) {
  256. if (i == (resourceCurrentPage - 1)) {
  257. var resourcesListPaging = $("<li class='pagDom' >" + "<a href='JavaScript:void(0)' class='resourcesListChang active' >" + (i + 1) + "</a>" + "</li>")
  258. } else {
  259. var resourcesListPaging = $("<li class='pagDom'>" + "<a href='JavaScript:void(0)' class='resourcesListChang ' >" + (i + 1) + "</a>" + "</li>")
  260. }
  261. resourcesListPaging.insertBefore($("#resourcesListPaging > .pagination > li:last-child"));
  262. }
  263. //根据初始页面的设置,判断向前/后 翻页按钮是否需要禁止点击
  264. if (resourceCurrentPage == 1) {
  265. $(".glyphicon-chevron-left").parent().addClass('disable');
  266. // 只有一页
  267. if(resourceCurrentPage == totalPages){
  268. $(".glyphicon-chevron-right").parent().addClass('disable');
  269. }
  270. } else if (resourceCurrentPage == totalPages) {
  271. $(".glyphicon-chevron-right").parent().addClass('disable');
  272. }
  273. };
  274. function initClickEvent() {
  275. //为分页列表项绑定事件
  276. $('#resourcesListPaging>.pagination').delegate('.resourcesListChang', 'click', function (e) {
  277. if (resourceCurrentPage != parseInt(e.currentTarget.text)) {
  278. resourceCurrentPage = parseInt(e.currentTarget.text)
  279. paginationClick(resourceCurrentPage);
  280. }
  281. });
  282. //切换到上一页
  283. $(".glyphicon-chevron-left").parent().click(function () {
  284. resourceCurrentPage--;
  285. paginationClick(resourceCurrentPage);
  286. });
  287. //切换到下一页
  288. $(".glyphicon-chevron-right").parent().click(function () {
  289. resourceCurrentPage++;
  290. paginationClick(resourceCurrentPage);
  291. });
  292. };
  293. //页面的点击事件,触发的function
  294. function paginationClick(resourceCurrentPage) {
  295. if (resourceCurrentPage == 1) {
  296. $(".glyphicon-chevron-left").parent().addClass('disable');
  297. $(".glyphicon-chevron-right").parent().removeClass('disable');
  298. } else if (resourceCurrentPage == totalPages) {
  299. $(".glyphicon-chevron-right").parent().addClass('disable');
  300. $(".glyphicon-chevron-left").parent().removeClass('disable');
  301. } else {
  302. $(".glyphicon-chevron-left").parent().removeClass('disable');
  303. $(".glyphicon-chevron-right").parent().removeClass('disable');
  304. }
  305. resourceCurrentPage = resourceCurrentPage;
  306. onClickQuery();
  307. $("#resourcesListPaging>.pagination>li").eq(resourceCurrentPage).children().addClass('active').parent().siblings().children().removeClass('active');
  308. }
  309. // 选择资源类型
  310. function onSelectResourcesType(){
  311. let type = $("#typeSelect").val();
  312. resourceType = type;
  313. }
  314. // 选择排序字段
  315. function onSelectResourcesOrderBy(){
  316. let orderBy = $("#filedSelect").val();
  317. resourceOrderBy = orderBy;
  318. }
  319. // 选择排序字段
  320. function onSelectResourcesOrderType(){
  321. let orderType = $("#sortSelect").val();
  322. resourceOrderType = orderType;
  323. }
  324. // 点击查询
  325. function onClickQuery(param){
  326. searchText = $("#searchText").val();
  327. // 重新查新 重置页数
  328. if(param){
  329. resourceCurrentPage =1;
  330. }
  331. queryParams = new SuperMap.iPortalQueryParam({
  332. resourceType: resourceType,
  333. pageSize: resourcePageSize,
  334. currentPage: resourceCurrentPage,
  335. orderBy: resourceOrderBy,
  336. orderType: resourceOrderType,
  337. text: searchText
  338. });
  339. queryResouces(queryParams);
  340. }
  341. </script>
  342. </body>
  343. </html>