|
11 | 11 | <meta charset="utf-8" /> |
12 | 12 | <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> |
13 | 13 | <title data-i18n="resources.title_knowledgeGraphMap"></title> |
14 | | - <script type="text/javascript" include="jquery" src="../js/include-web.js"></script> |
| 14 | + <script type="text/javascript" include="jquery,bootstrap,widgets" src="../js/include-web.js"></script> |
15 | 15 | <style> |
16 | 16 | body { |
17 | 17 | margin: 0; |
|
24 | 24 | width: 100%; |
25 | 25 | height: 100%; |
26 | 26 | } |
27 | | - .short-path-panel { |
28 | | - position: fixed; |
29 | | - top: 60px; |
30 | | - right: 30px; |
31 | | - display: flex; |
32 | | - flex-direction: column; |
33 | | - align-items: center; |
34 | | - justify-content: center; |
35 | | - width: 350px; |
36 | | - padding: 15px; |
37 | | - background-color: antiquewhite; |
38 | | - border: 1px solid gray; |
39 | | - } |
40 | 27 | .node-item { |
41 | 28 | display: inline-flex; |
42 | 29 | width: 100%; |
43 | 30 | margin-top: 15px; |
44 | 31 | } |
45 | | - .node-item input { |
| 32 | + .node-item .form-control { |
46 | 33 | width: 150px; |
| 34 | + border-radius: 0 4px 4px 0; |
47 | 35 | } |
48 | | - .node-item button { |
49 | | - margin: 0 5px; |
| 36 | + |
| 37 | + .node-item .btn { |
| 38 | + padding: 0 8px; |
| 39 | + margin-left: 10px; |
50 | 40 | } |
51 | 41 | .buttons { |
52 | 42 | display: inline-flex; |
|
56 | 46 | } |
57 | 47 | #analysis { |
58 | 48 | width: 80px; |
59 | | - margin-right: 10px; |
60 | 49 | } |
61 | 50 | #reset { |
62 | 51 | width: 80px; |
| 52 | + margin-right: 10px; |
| 53 | + } |
| 54 | + .panel-default { |
| 55 | + position: fixed; |
| 56 | + top: 60px; |
| 57 | + right: 30px; |
| 58 | + width: 380px; |
| 59 | + margin: 15px 15px 0 0; |
| 60 | + } |
| 61 | + |
| 62 | + .input-group { |
| 63 | + margin-bottom: 15px; |
| 64 | + } |
| 65 | + .node-title { |
| 66 | + width: 80px; |
| 67 | + line-height: unset; |
63 | 68 | } |
64 | 69 | </style> |
65 | 70 | </head> |
66 | 71 |
|
67 | 72 | <body> |
68 | 73 | <div id="knowledgeGraph"></div> |
69 | | - <div class="short-path-panel"> |
70 | | - <div class="title" data-i18n="resources.text_graphmap_shortest_analysis"></div> |
71 | | - <div class="node-item start-node"> |
72 | | - <span data-i18n="resources.text_startNode"></span> <input class="start" disabled /><button |
73 | | - id="select-start-node" |
74 | | - data-i18n="resources.text_selectStartNode" |
75 | | - ></button> |
| 74 | + <div class="panel panel-default"> |
| 75 | + <div class="panel-heading"> |
| 76 | + <h3 class="panel-title" data-i18n="resources.text_graphmap_shortest_analysis"></h3> |
76 | 77 | </div> |
77 | | - <div class="node-item end-node"> |
78 | | - <span data-i18n="resources.text_endeNode"></span><input class="end" disabled /><button |
79 | | - id="select-end-node" |
80 | | - data-i18n="resources.text_selectEndNode" |
81 | | - ></button> |
82 | | - </div> |
83 | | - <div class="buttons"> |
84 | | - <button id="analysis" data-i18n="resources.text_analysis"></button> |
85 | | - <button id="reset" data-i18n="resources.text_reset"></button> |
| 78 | + <div class="panel-body"> |
| 79 | + <div class="node-item start-node"> |
| 80 | + <span class="input-group-addon node-title" data-i18n="resources.text_startNode"></span> |
| 81 | + <input type="text" class="start form-control" disabled /> |
| 82 | + <input |
| 83 | + type="button" |
| 84 | + id="select-start-node" |
| 85 | + class="btn btn-primary" |
| 86 | + data-i18n="[value]resources.text_selectStartNode" |
| 87 | + /> |
| 88 | + </div> |
| 89 | + <div class="node-item end-node"> |
| 90 | + <span class="input-group-addon node-title" data-i18n="resources.text_endeNode"></span> |
| 91 | + <input type="text" class="end form-control" disabled /> |
| 92 | + <input |
| 93 | + type="button" |
| 94 | + id="select-end-node" |
| 95 | + class="btn btn-primary" |
| 96 | + data-i18n="[value]resources.text_selectEndNode" |
| 97 | + /> |
| 98 | + </div> |
| 99 | + <div class="buttons" align="center"> |
| 100 | + <input type="button" id="reset" class="btn" data-i18n="[value]resources.text_reset" /> |
| 101 | + <input type="button" id="analysis" class="btn btn-primary" data-i18n="[value]resources.text_analysis" /> |
| 102 | + </div> |
86 | 103 | </div> |
87 | 104 | </div> |
88 | 105 | <script type="text/javascript" include="g6" src="../../dist/leaflet/include-leaflet.js"></script> |
|
142 | 159 | } |
143 | 160 |
|
144 | 161 | function setShortestPath({ startID, endID }) { |
145 | | - graphmap.findShortestPath({ startID, endID }, () => { |
146 | | - graphmap.clearHighlight(); |
| 162 | + graphmap.findShortestPath({ startID, endID }, (res) => { |
| 163 | + if (res.type === 'processCompleted' && res.result.succeed) { |
| 164 | + const { nodeIDs, edgeIDs } = res.result; |
| 165 | + if (nodeIDs.length === 0 && edgeIDs.length === 0) { |
| 166 | + widgets.alert.showAlert(resources.text_no_shortestPath); |
| 167 | + } |
| 168 | + } |
147 | 169 | }); |
148 | 170 | } |
149 | 171 | </script> |
|
0 commit comments