Skip to content

Commit ac4eef9

Browse files
committed
INTLV-22: Visualisation is initialised twice when there in another DOM updated event
1 parent eddf9c1 commit ac4eef9

File tree

3 files changed

+145
-94
lines changed

3 files changed

+145
-94
lines changed

application-interactive-link-visualizer-ui/src/main/resources/XWiki/InteractiveLinkVisualizer/Code/LinkVisualizerPanel.xml

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
1-
<?xml version='1.1' encoding='UTF-8'?>
1+
<?xml version="1.1" encoding="UTF-8"?>
2+
3+
<!--
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
-->
22+
223
<xwikidoc version="1.5" reference="XWiki.InteractiveLinkVisualizer.Code.LinkVisualizerPanel" locale="">
324
<web>XWiki.InteractiveLinkVisualizer.Code</web>
425
<name>LinkVisualizerPanel</name>
526
<language/>
6-
<defaultLanguage>en</defaultLanguage>
27+
<defaultLanguage/>
728
<translation>0</translation>
8-
<creator>XWiki.Admin</creator>
9-
<creationDate>1689193878000</creationDate>
29+
<creator>xwiki:XWiki.Admin</creator>
1030
<parent>WebHome</parent>
11-
<author>XWiki.Admin</author>
12-
<originalMetadataAuthor>XWiki.Admin</originalMetadataAuthor>
13-
<contentAuthor>XWiki.Admin</contentAuthor>
14-
<date>1691176537000</date>
15-
<contentUpdateDate>1691041061000</contentUpdateDate>
16-
<version>168.1</version>
31+
<author>xwiki:XWiki.Admin</author>
32+
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
33+
<version>1.1</version>
1734
<title>LinkVisualizerPanel</title>
1835
<comment/>
1936
<minorEdit>false</minorEdit>
@@ -167,8 +184,8 @@
167184
style=
168185
"width: 100%;
169186
height: 350px;
170-
">
171-
&lt;/div>
187+
"&gt;
188+
&lt;/div&gt;
172189
{{/html}}
173190
#panelfooter()
174191
{{/velocity}}</content>
@@ -313,7 +330,7 @@ height: 350px;
313330
if (firstResult.length == 1) {
314331
let extraDocuments = "";
315332
if (firstResult[0].links) {
316-
extraDocuments = ' OR ' + firstResult[0].links.map(link => 'reference:' + escapeQueryChars(link.replace(/^entity:/, ''))).join(' OR ');
333+
extraDocuments = ' OR ' + firstResult[0].links.map(link =&gt; 'reference:' + escapeQueryChars(link.replace(/^entity:/, ''))).join(' OR ');
317334
}
318335
$.post(solrServiceURL, {
319336
outputSyntax: 'plain',
@@ -341,7 +358,7 @@ height: 350px;
341358

342359
const edges = [];
343360
tempData.forEach(function(obj) {
344-
if (obj.links &amp;&amp; obj.links.length > 0) {
361+
if (obj.links &amp;&amp; obj.links.length &gt; 0) {
345362
obj.links.forEach(function(link) {
346363
var target = link.replace(/^entity:/, '');
347364
var isValid = tempData.some(function(item) {
@@ -378,4 +395,4 @@ height: 350px;
378395
<use>currentPage</use>
379396
</property>
380397
</object>
381-
</xwikidoc>
398+
</xwikidoc>

application-interactive-link-visualizer-ui/src/main/resources/XWiki/InteractiveLinkVisualizer/Code/MainVisualisation.xml

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
1-
<?xml version='1.1' encoding='UTF-8'?>
1+
<?xml version="1.1" encoding="UTF-8"?>
2+
3+
<!--
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
-->
22+
223
<xwikidoc version="1.5" reference="XWiki.InteractiveLinkVisualizer.Code.MainVisualisation" locale="">
324
<web>XWiki.InteractiveLinkVisualizer.Code</web>
425
<name>MainVisualisation</name>
526
<language/>
6-
<defaultLanguage>en</defaultLanguage>
27+
<defaultLanguage/>
728
<translation>0</translation>
8-
<creator>XWiki.Admin</creator>
9-
<creationDate>1691175193000</creationDate>
29+
<creator>xwiki:XWiki.Admin</creator>
1030
<parent>WebHome</parent>
11-
<author>XWiki.Admin</author>
12-
<originalMetadataAuthor>XWiki.Admin</originalMetadataAuthor>
13-
<contentAuthor>XWiki.Admin</contentAuthor>
14-
<date>1691233201000</date>
15-
<contentUpdateDate>1691176498000</contentUpdateDate>
16-
<version>30.1</version>
31+
<author>xwiki:XWiki.Admin</author>
32+
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
33+
<version>1.1</version>
1734
<title>MainVisualisation</title>
1835
<comment/>
1936
<minorEdit>false</minorEdit>
@@ -368,7 +385,7 @@ a.options-item.active, a.options-item.active:hover {
368385
<async_enabled>0</async_enabled>
369386
</property>
370387
<property>
371-
<content></content>
388+
<content/>
372389
</property>
373390
<property>
374391
<extensionPointId>org.xwiki.platform.panels.Applications</extensionPointId>
@@ -513,7 +530,7 @@ icon=icon:world</parameters>
513530
<async_enabled>0</async_enabled>
514531
</property>
515532
<property>
516-
<content></content>
533+
<content/>
517534
</property>
518535
<property>
519536
<extensionPointId>org.xwiki.platform.requirejs.module</extensionPointId>
@@ -530,4 +547,4 @@ path=$services.webjars.url('org.xwiki.contrib:application-interactive-link-visua
530547
<scope>wiki</scope>
531548
</property>
532549
</object>
533-
</xwikidoc>
550+
</xwikidoc>

application-interactive-link-visualizer-ui/src/main/resources/XWiki/InteractiveLinkVisualizer/WebHome.xml

Lines changed: 83 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
1-
<?xml version='1.1' encoding='UTF-8'?>
1+
<?xml version="1.1" encoding="UTF-8"?>
2+
3+
<!--
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
-->
22+
223
<xwikidoc version="1.5" reference="XWiki.InteractiveLinkVisualizer.WebHome" locale="">
324
<web>XWiki.InteractiveLinkVisualizer</web>
425
<name>WebHome</name>
526
<language/>
6-
<defaultLanguage>en</defaultLanguage>
27+
<defaultLanguage/>
728
<translation>0</translation>
8-
<creator>XWiki.Admin</creator>
9-
<creationDate>1691042382000</creationDate>
29+
<creator>xwiki:XWiki.Admin</creator>
1030
<parent>XWiki.WebHome</parent>
11-
<author>XWiki.Admin</author>
12-
<originalMetadataAuthor>XWiki.Admin</originalMetadataAuthor>
13-
<contentAuthor>XWiki.Admin</contentAuthor>
14-
<date>1691247580000</date>
15-
<contentUpdateDate>1691231537000</contentUpdateDate>
16-
<version>17.4</version>
31+
<author>xwiki:XWiki.Admin</author>
32+
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
33+
<version>1.1</version>
1734
<title>Interactive Link Visualizer</title>
1835
<comment/>
19-
<minorEdit>true</minorEdit>
36+
<minorEdit>false</minorEdit>
2037
<syntaxId>xwiki/2.1</syntaxId>
21-
<hidden>false</hidden>
38+
<hidden>true</hidden>
2239
<content>{{velocity output="false"}}
2340
#set ($discard = $xwiki.ssx.use('XWiki.InteractiveLinkVisualizer.Code.MainVisualisation'))
2441
{{/velocity}}{{include reference="Main.SolrSearchConfig" /}}{{include reference="Main.SolrSearchMacros" /}}{{velocity output="false"}}
@@ -30,33 +47,33 @@
3047
## To return visualisation as search results
3148
#macro (displaySearchResults)
3249
{{html}}
33-
&lt;div id="sigma-container" data-results="$escapetool.xml($jsontool.serialize($searchResponse.results))">
34-
&lt;div id="top-bar">
35-
&lt;div id="search">
36-
&lt;i class="fa fa-search">&lt;/i>
50+
&lt;div id="sigma-container" data-results="$escapetool.xml($jsontool.serialize($searchResponse.results))"&gt;
51+
&lt;div id="top-bar"&gt;
52+
&lt;div id="search"&gt;
53+
&lt;i class="fa fa-search"&gt;&lt;/i&gt;
3754
&lt;input
3855
type="search"
3956
id="search-input"
4057
list="suggestions"
4158
placeholder="Find pages in graph…"
42-
title="Find pages from the visualized graph">
43-
&lt;/input>
44-
&lt;datalist id="suggestions">&lt;/datalist>
45-
&lt;/div>
46-
&lt;div title="Displays information about graph" id="graph-info">
47-
&lt;span id="node-count">&lt;/span>
48-
&lt;span id="edge-count">&lt;/span>
49-
&lt;/div>
50-
&lt;/div>
51-
&lt;div class="buttonwrapper" id="graph-buttons">
52-
&lt;button class="icon-button" title="Zoom In" id="zoom-in">$services.icon.renderHTML('search-plus')&lt;/button>
53-
&lt;button class="icon-button" title="Zoom Out" id="zoom-out">$services.icon.renderHTML('search-minus')&lt;/button>
54-
&lt;button class="icon-button" title="Increase Graph Iterations: If graph is not layouted properly &amp; need more iterations" id="iteration-button">$services.icon.renderHTML('refresh')&lt;/button>
55-
&lt;button class="icon-button" title="Default Zoom" id="zoom-reset">$services.icon.renderHTML('world')&lt;/button>
56-
&lt;button class="icon-button" title="Fullscreen" id="view-fullscreen">$services.icon.renderHTML('arrows')&lt;/button>
57-
&lt;button class="icon-button hidden" title="Kill Graph" id="kill-graph-button">$services.icon.renderHTML('delete')&lt;/button>
58-
&lt;/div>
59-
&lt;/div>
59+
title="Find pages from the visualized graph"&gt;
60+
&lt;/input&gt;
61+
&lt;datalist id="suggestions"&gt;&lt;/datalist&gt;
62+
&lt;/div&gt;
63+
&lt;div title="Displays information about graph" id="graph-info"&gt;
64+
&lt;span id="node-count"&gt;&lt;/span&gt;
65+
&lt;span id="edge-count"&gt;&lt;/span&gt;
66+
&lt;/div&gt;
67+
&lt;/div&gt;
68+
&lt;div class="buttonwrapper" id="graph-buttons"&gt;
69+
&lt;button class="icon-button" title="Zoom In" id="zoom-in"&gt;$services.icon.renderHTML('search-plus')&lt;/button&gt;
70+
&lt;button class="icon-button" title="Zoom Out" id="zoom-out"&gt;$services.icon.renderHTML('search-minus')&lt;/button&gt;
71+
&lt;button class="icon-button" title="Increase Graph Iterations: If graph is not layouted properly &amp; need more iterations" id="iteration-button"&gt;$services.icon.renderHTML('refresh')&lt;/button&gt;
72+
&lt;button class="icon-button" title="Default Zoom" id="zoom-reset"&gt;$services.icon.renderHTML('world')&lt;/button&gt;
73+
&lt;button class="icon-button" title="Fullscreen" id="view-fullscreen"&gt;$services.icon.renderHTML('arrows')&lt;/button&gt;
74+
&lt;button class="icon-button hidden" title="Kill Graph" id="kill-graph-button"&gt;$services.icon.renderHTML('delete')&lt;/button&gt;
75+
&lt;/div&gt;
76+
&lt;/div&gt;
6077
{{/html}}
6178
#end
6279

@@ -78,48 +95,48 @@
7895
##
7996
#set($void = $services.progress.startStep('#displaySearchForm'))
8097
{{html clean="false"}}
81-
&lt;form class="search-form row" action="$doc.getURL()" role="search">
82-
&lt;div class="hidden">
83-
&lt;input type="hidden" name="sort" value="$!escapetool.xml($sort)"/>
84-
&lt;input type="hidden" name="sortOrder" value="$!escapetool.xml($sortOrder)"/>
85-
&lt;input type="hidden" name="highlight" value="$highlightEnabled"/>
86-
&lt;input type="hidden" name="facet" value="$facetEnabled"/>
98+
&lt;form class="search-form row" action="$doc.getURL()" role="search"&gt;
99+
&lt;div class="hidden"&gt;
100+
&lt;input type="hidden" name="sort" value="$!escapetool.xml($sort)"/&gt;
101+
&lt;input type="hidden" name="sortOrder" value="$!escapetool.xml($sortOrder)"/&gt;
102+
&lt;input type="hidden" name="highlight" value="$highlightEnabled"/&gt;
103+
&lt;input type="hidden" name="facet" value="$facetEnabled"/&gt;
87104
## The parameter used to determine if the request has been redirected with default search filters.
88-
&lt;input type="hidden" name="r" value="$!escapetool.xml($request.r)"/>
105+
&lt;input type="hidden" name="r" value="$!escapetool.xml($request.r)"/&gt;
89106
#if ("$!request.debug" != '')
90-
&lt;input type="hidden" name="debug" value="$escapetool.xml($request.debug)"/>
107+
&lt;input type="hidden" name="debug" value="$escapetool.xml($request.debug)"/&gt;
91108
#end
92109
## Preserve the current facet values when submitting a new search query.
93110
#foreach ($entry in $request.parameterMap.entrySet())
94111
#if ($entry.key.startsWith('f_') || $entry.key.startsWith('l_'))
95112
#foreach ($value in $entry.value)
96-
&lt;input type="hidden" name="$escapetool.xml($entry.key)" value="$escapetool.xml($value)"/>
113+
&lt;input type="hidden" name="$escapetool.xml($entry.key)" value="$escapetool.xml($value)"/&gt;
97114
#end
98115
#end
99116
#end
100-
&lt;/div>
101-
&lt;div class="col-xs-12 col-sm-6">
102-
&lt;div class="input-group">
117+
&lt;/div&gt;
118+
&lt;div class="col-xs-12 col-sm-6"&gt;
119+
&lt;div class="input-group"&gt;
103120
&lt;input type="search" name="text" class="form-control withTip useTitleAsTip"
104-
title="$services.localization.render('search.page.bar.query.title')" value="$escapetool.xml($text)"/>
105-
&lt;span class="input-group-btn">
106-
&lt;button type="submit" class="btn btn-primary">
121+
title="$services.localization.render('search.page.bar.query.title')" value="$escapetool.xml($text)"/&gt;
122+
&lt;span class="input-group-btn"&gt;
123+
&lt;button type="submit" class="btn btn-primary"&gt;
107124
$services.icon.renderHTML('search')
108-
&lt;span class="sr-only">$services.localization.render('search.page.bar.submit')&lt;/span>
109-
&lt;/button>
110-
&lt;/span>
111-
&lt;/div>
112-
&lt;div class="" id="nb-results">
125+
&lt;span class="sr-only"&gt;$services.localization.render('search.page.bar.submit')&lt;/span&gt;
126+
&lt;/button&gt;
127+
&lt;/span&gt;
128+
&lt;/div&gt;
129+
&lt;div class="" id="nb-results"&gt;
113130
&lt;input type="number" name="rows" title="Number of documents to display in graph"
114-
placeholder="Max no. of pages" value="$!escapetool.xml($request.rows)" id="rows"/>
115-
&lt;span id="nb-results">
116-
&lt;button type="submit" id="refresh-button" class="btn btn-primary">
131+
placeholder="Max no. of pages" value="$!escapetool.xml($request.rows)" id="rows"/&gt;
132+
&lt;span id="nb-results"&gt;
133+
&lt;button type="submit" id="refresh-button" class="btn btn-primary"&gt;
117134
$services.icon.renderHTML('refresh')
118-
&lt;/button>
119-
&lt;/span>
120-
&lt;/div>
121-
&lt;/div>
122-
&lt;/form>
135+
&lt;/button&gt;
136+
&lt;/span&gt;
137+
&lt;/div&gt;
138+
&lt;/div&gt;
139+
&lt;/form&gt;
123140
{{/html}}
124141
#if ($text == '')
125142
#set ($text = "*")
@@ -140,7 +157,7 @@
140157
(% class="search-options" %)
141158
* {{translation key="solr.options"/}}
142159
#if($facetEnabled)#extendQueryString($url {'facet': [false]})#else#extendQueryString($url {'facet': [true]})#end
143-
* [[{{translation key="solr.options.facet"/}}>>path:${url}||class="options-item#if($facetEnabled) active#end" title="$services.localization.render('solr.options.facet.title')"]]
160+
* [[{{translation key="solr.options.facet"/}}&gt;&gt;path:${url}||class="options-item#if($facetEnabled) active#end" title="$services.localization.render('solr.options.facet.title')"]]
144161

145162
(% class="search-results-sort" %)
146163
* {{translation key="solr.sortBy"/}}
@@ -155,7 +172,7 @@
155172
#set ($targetSortOrder = "#if ($sortOrder == 'asc')desc#{else}asc#end")
156173
#end
157174
#extendQueryString($url {'sort': [$entry.key], 'sortOrder': [$targetSortOrder]})
158-
* [[{{translation key="solr.sortBy.$entry.key"/}}$!sortOrderIndicator>>path:${url}||class="$class"]]
175+
* [[{{translation key="solr.sortBy.$entry.key"/}}$!sortOrderIndicator&gt;&gt;path:${url}||class="$class"]]
159176
#end
160177
#end
161178
{{/velocity}}{{velocity}}#handleSolrSearchRequest{{/velocity}}</content>
@@ -276,7 +293,7 @@
276293
});
277294
const edges = [];
278295
tempData.forEach(function(obj) {
279-
if (obj.links &amp;&amp; obj.links.length > 0) {
296+
if (obj.links &amp;&amp; obj.links.length &gt; 0) {
280297
obj.links.forEach(function(link) {
281298
var target = link.replace(/^entity:/, '');
282299
var isValid = tempData.some(function(item) {
@@ -345,4 +362,4 @@
345362
<use>currentPage</use>
346363
</property>
347364
</object>
348-
</xwikidoc>
365+
</xwikidoc>

0 commit comments

Comments
 (0)