Skip to content

Commit be8a3e6

Browse files
committed
hierarchical view of modules
1 parent 0885f78 commit be8a3e6

File tree

3 files changed

+161
-75
lines changed

3 files changed

+161
-75
lines changed

handlers/Main.cfc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ component extends="coldbox.system.RestHandler" {
6161
debugStartTime : getTickCount(),
6262
refreshFrequency : rc.frequency,
6363
urlBase : event.buildLink( "" ),
64-
loadedModules : variables.debuggerConfig.modules.enabled ? variables.controller
65-
.getModuleService()
66-
.getLoadedModules() : [],
6764
moduleSettings : variables.debuggerConfig.modules.enabled ? getSetting( "modules" ) : {},
6865
debuggerConfig : variables.debuggerConfig,
6966
debuggerService : variables.debuggerService,

views/main/panels/modulesPanel.cfm

Lines changed: 42 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
<cfscript>
2+
allModules = getSetting( "modules" );
3+
totalTimes = allModules.reduce( function( total, key, thisModuleConfig ){
4+
if( !isNull( arguments.thisModuleConfig.registrationTime ) ){
5+
arguments.total.registration += arguments.thisModuleConfig.registrationTime;
6+
}
7+
if( !isNull( arguments.thisModuleConfig.activationTime ) ){
8+
arguments.total.activation += arguments.thisModuleConfig.activationTime;
9+
}
10+
return arguments.total;
11+
}, {
12+
"registration" : 0,
13+
"activation" : 0
14+
} );
15+
rootModules = allModules.filter( function( module, config ){
16+
return arguments.config.parent.len() == 0;
17+
} );
18+
</cfscript>
119
<cfoutput>
220
<!--- Panel Header --->
321
<div class="cbd-titles" onClick="cbdToggle( 'cbdModules' )" >
422
&nbsp;
523
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
624
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z" />
725
</svg>
8-
ColdBox Modules (#arrayLen( args.loadedModules )#)
26+
ColdBox Modules (#structCount( allModules )#)
927
</div>
1028

1129
<!--- Panel Content --->
@@ -33,79 +51,31 @@
3351
Below you can see the registered and activated application modules.
3452
</p>
3553

36-
<!--- Module Charts --->
37-
<table border="0" cellpadding="0" cellspacing="1" class="cbd-tables">
38-
<tr >
39-
<th align="left">Module / Version</th>
40-
<th align="left" width="40%">Mapping</th>
41-
<th align="center" width="100" >CMDS</th>
42-
</tr>
54+
<!--- Info Bar --->
55+
<div class="mt10 mb10">
56+
<div>
57+
<strong>Total Registration Time:</strong>
58+
<div class="cbd-badge-light">
59+
#numberFormat( totalTimes.registration )# ms
60+
</div>
61+
</div>
4362

44-
<cfloop array="#args.loadedModules#" index="thisModule">
45-
<cfset thisModuleConfig = getModuleConfig( thisModule )>
46-
<tr id="cbd-modulerow-#thisModule#">
47-
<td title=" Invocation Path: #thisModuleConfig.invocationPath#">
48-
49-
<div>
50-
<cfif len( thisModuleConfig.entryPoint )>
51-
<a href="#event.buildLink( thisModuleConfig.entryPoint )#" title="Open Module Entry Point">
52-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
53-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
54-
</svg>
55-
</a>
56-
</cfif>
57-
58-
<!--- Title --->
59-
<strong>#thisModuleConfig.title#</strong>
60-
<!--- Version --->
61-
<cfif len( thisModuleConfig.version )>
62-
<span class="cbd-badge-light">
63-
#thisModuleConfig.version#
64-
</span>
65-
</cfif>
66-
</div>
67-
68-
<div class="mt5">
69-
#thisModuleConfig.description#
70-
</div>
71-
</td>
72-
73-
<!--- Mapping --->
74-
<td align="left" class="cbd-cellBreak">
75-
<div class="cbd-badge-light mt5 cbd-text-left">
76-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
77-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z" />
78-
</svg>
79-
#thisModuleConfig.mapping#
80-
</div>
81-
</td>
82-
83-
<!--- Actions --->
84-
<td align="center">
85-
<button
86-
type="button"
87-
title="Unloads This Module!"
88-
onClick="cbdUnloadModule( '#thisModule#', this )"
89-
>
90-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
91-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
92-
</svg>
93-
</button>
94-
95-
<button
96-
type="button"
97-
title="Reload This Module!"
98-
onClick="cbdReloadModule( '#thisModule#', this )"
99-
>
100-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
101-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
102-
</svg>
103-
</button>
104-
</td>
105-
</tr>
106-
</cfloop>
63+
<div class="mt5">
64+
<strong>Total Activation Time:</strong>
65+
<div class="cbd-badge-light">
66+
#numberFormat( totalTimes.activation )# ms
67+
</div>
68+
</div>
69+
</div>
10770

108-
</table>
71+
#renderView(
72+
view : "main/partials/modules",
73+
module : "cbdebugger",
74+
args : {
75+
modules : rootModules
76+
},
77+
prePostExempt : true
78+
)#
10979

11080
</div>
11181
</cfoutput>

views/main/partials/modules.cfm

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<cfscript>
2+
moduleKeys = args.modules.keyArray();
3+
arraySort( moduleKeys, "textnocase" );
4+
</cfscript>
5+
<cfoutput>
6+
<table border="0" cellpadding="0" cellspacing="1" class="cbd-tables">
7+
<tr >
8+
<th align="left">Module / Version</th>
9+
<th align="center" width="100">Registration Time</th>
10+
<th align="center" width="100">Activation Time</th>
11+
<th align="center" width="100">CMDS</th>
12+
</tr>
13+
14+
<cfloop array="#moduleKeys#" index="thisModule">
15+
<cfset moduleId = createUUID()>
16+
<cfset thisModuleConfig = args.modules[ thisModule ]>
17+
<tr id="cbd-modulerow-#thisModule#">
18+
<td title=" Invocation Path: #thisModuleConfig.invocationPath#">
19+
20+
<div>
21+
<cfif len( thisModuleConfig.entryPoint )>
22+
<a href="#event.buildLink( thisModuleConfig.entryPoint )#" title="Open Module Entry Point">
23+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
24+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
25+
</svg>
26+
</a>
27+
</cfif>
28+
29+
<!--- Title --->
30+
<strong>#thisModuleConfig.title#</strong>
31+
<!--- Version --->
32+
<cfif len( thisModuleConfig.version )>
33+
<span class="cbd-badge-light">
34+
#thisModuleConfig.version#
35+
</span>
36+
</cfif>
37+
</div>
38+
39+
<div class="mt5 mb10">
40+
#thisModuleConfig.description#
41+
</div>
42+
43+
<!--- Are we recursing down? --->
44+
<cfif thisModuleConfig.childModules.len()>
45+
<cfscript>
46+
childModules = getSetting( "modules" ).filter( function( moduleKey, config ){
47+
return arrayContainsNoCase( thisModuleConfig.childModules, moduleKey );
48+
} );
49+
</cfscript>
50+
<!--- Panel Header --->
51+
<div class="cbd-titles" onClick="cbdToggle( 'cbd-childmodules-#moduleId#' )" >
52+
&nbsp;
53+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
54+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />
55+
</svg>
56+
Child Modules (#structCount( childModules )#)
57+
</div>
58+
59+
<!--- Panel Content --->
60+
<div
61+
class="cbd-contentView cbd-hide"
62+
id="cbd-childmodules-#moduleId#"
63+
>
64+
#renderView(
65+
view : "main/partials/modules",
66+
module : "cbdebugger",
67+
args : {
68+
modules : childModules
69+
},
70+
prePostExempt : true
71+
)#
72+
</div>
73+
</cfif>
74+
75+
</td>
76+
77+
<td>
78+
<cfif !isNull( thisModuleConfig.registrationTime )>
79+
#numberFormat( thisModuleConfig.registrationTime )# ms
80+
<cfelse>
81+
<em>Upgrade to the latest ColdBox 6</em>
82+
</cfif>
83+
</td>
84+
85+
<td>
86+
<cfif !isNull( thisModuleConfig.activationTime )>
87+
#numberFormat( thisModuleConfig.activationTime )# ms
88+
<cfelse>
89+
<em>Upgrade to the latest ColdBox 6</em>
90+
</cfif>
91+
</td>
92+
93+
<!--- Actions --->
94+
<td align="center">
95+
<button
96+
type="button"
97+
title="Unloads This Module!"
98+
onClick="cbdUnloadModule( '#thisModule#', this )"
99+
>
100+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
101+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
102+
</svg>
103+
</button>
104+
105+
<button
106+
type="button"
107+
title="Reload This Module!"
108+
onClick="cbdReloadModule( '#thisModule#', this )"
109+
>
110+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
111+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
112+
</svg>
113+
</button>
114+
</td>
115+
</tr>
116+
</cfloop>
117+
118+
</table>
119+
</cfoutput>

0 commit comments

Comments
 (0)