@@ -10,11 +10,11 @@ import { MetricHandler } from 'metric_handler';
1010import { $GF , GFTimer , GFLog , GFPlugin , GFCONSTANT } from 'globals_class' ;
1111import grafana from 'grafana_func' ;
1212import { defaults as _defaults , cloneDeep as _cloneDeep } from 'lodash' ;
13- import { InteractiveMap } from 'mapping_class' ;
13+ // import { InteractiveMap } from 'mapping_class';
1414import { GFDrawio } from 'drawio_base' ;
1515
1616// Debug
17- const DEBUG = false ;
17+ const DEBUG = true ;
1818const _log = ( ...args : any ) => {
1919 DEBUG && console . log ( ...args ) ;
2020} ;
@@ -40,7 +40,7 @@ class FlowchartCtrl extends MetricsPanelCtrl {
4040 rulesHandler : RulesHandler | undefined ;
4141 flowchartHandler : FlowchartHandler | undefined ;
4242 metricHandler : MetricHandler | undefined ;
43- onMapping : InteractiveMap ;
43+ onMapping = false ;
4444 uid : string = $GF . genUid ( this . constructor . name ) ;
4545 graphHoverTimer : GFTimer | undefined = undefined ;
4646 mouseIn = false ;
@@ -69,7 +69,7 @@ class FlowchartCtrl extends MetricsPanelCtrl {
6969 this . changedSource = true ;
7070 this . changedData = true ;
7171 this . changedOptions = true ;
72- this . onMapping = new InteractiveMap ( ) ;
72+ // this.onMapping = new InteractiveMap();
7373 this . parentDiv = document . createElement ( 'div' ) ;
7474 this . flowchartsDiv = document . createElement ( 'div' ) ;
7575 // this.uid = $GF.genUid();
@@ -129,11 +129,15 @@ class FlowchartCtrl extends MetricsPanelCtrl {
129129 this . $gf . events . connect ( 'debug_asked' , this , this . _on_global_debug_asked . bind ( this ) ) ;
130130 this . $gf . events . connect ( 'panel_closed' , this , this . _on_global_panel_closed . bind ( this ) ) ;
131131 this . $gf . events . connect ( 'editmode_closed' , this , this . _on_global_editmode_closed . bind ( this ) ) ;
132+ this . $gf . events . connect ( 'mapping_enabled' , this , this . _on_global_mapping_enabled . bind ( this ) ) ;
133+ this . $gf . events . connect ( 'mapping_disabled' , this , this . _on_global_mapping_disabled . bind ( this ) ) ;
132134 }
133135
134136 _eventsDisconnect ( ) {
135137 this . $gf . events . disconnect ( 'debug_asked' , this ) ;
136138 this . $gf . events . disconnect ( 'panel_closed' , this ) ;
139+ this . $gf . events . disconnect ( 'mapping_enabled' , this ) ;
140+ this . $gf . events . disconnect ( 'mapping_disabled' , this ) ;
137141 }
138142
139143 init_handlers ( ) {
@@ -218,6 +222,75 @@ class FlowchartCtrl extends MetricsPanelCtrl {
218222 return false ;
219223 }
220224
225+ link ( scope : any , elem : any , attrs : any , ctrl : any ) {
226+ this . $panelElem = elem ;
227+ const $section = this . $panelElem . find ( '#flowcharting-section' ) ;
228+ this . parentDiv = $section [ 0 ] ;
229+ const $flowchartsDiv = $section . find ( '#flowcharting-panel-content' ) ;
230+ this . flowchartsDiv = $flowchartsDiv [ 0 ] ;
231+ // this.onMapping.setContainer(this.flowchartsDiv);
232+ this . notify ( 'Initialisation MXGRAPH/DRAW.IO Libs' ) ;
233+
234+ // MxGraph Init
235+ this . notify ( 'Load configuration' ) ;
236+ if ( this . panel . gf_isEdited ) {
237+ delete this . panel . gf_isEdited ;
238+ }
239+ GFDrawio . init ( ) ;
240+ this . init_ctrl ( ) ;
241+ if ( this . panel . version !== GFPlugin . getVersion ( ) ) {
242+ //TODO : Reactive this
243+ // this.notify(
244+ // `The plugin version has changed, save the dashboard to optimize loading : ${
245+ // this.panel.version
246+ // } <> ${$GF.plugin.getVersion()}`
247+ // );
248+ }
249+ this . clearNotify ( ) ;
250+ this . panel . version = this . version ;
251+ // Open is edit mode
252+ if ( this . panel . isEditing === true ) {
253+ this . panel . gf_isEdited = true ;
254+ }
255+ }
256+
257+ isMouseInPanel ( ) : boolean {
258+ return this . mouseIn ;
259+ }
260+
261+ displayMultiCursor ( ) : boolean {
262+ if ( this . flowchartHandler ) {
263+ return this . flowchartHandler . isMultiFlowcharts ( ) ;
264+ }
265+ return false ;
266+ }
267+
268+ displayFirstCursor ( ) : boolean {
269+ if ( this . flowchartHandler ) {
270+ return ! this . flowchartHandler . isCurrentfirst ( ) ;
271+ }
272+ return false ;
273+ }
274+
275+ displayLastCursor ( ) : boolean {
276+ if ( this . flowchartHandler ) {
277+ return ! this . flowchartHandler . isCurrentLast ( ) ;
278+ }
279+ return false ;
280+ }
281+
282+ displayNextFlowchart ( ) {
283+ if ( this . flowchartHandler ) {
284+ this . flowchartHandler . setNextFlowchart ( ) ;
285+ }
286+ }
287+
288+ displayPreviousFlowchart ( ) {
289+ if ( this . flowchartHandler ) {
290+ this . flowchartHandler . setPreviousFlowchart ( ) ;
291+ }
292+ }
293+
221294 //###########################################################################
222295 //### EVENTS
223296 //###########################################################################
@@ -314,79 +387,20 @@ class FlowchartCtrl extends MetricsPanelCtrl {
314387 return ;
315388 }
316389
317- link ( scope : any , elem : any , attrs : any , ctrl : any ) {
318- this . $panelElem = elem ;
319- const $section = this . $panelElem . find ( '#flowcharting-section' ) ;
320- this . parentDiv = $section [ 0 ] ;
321- const $flowchartsDiv = $section . find ( '#flowcharting-panel-content' ) ;
322- this . flowchartsDiv = $flowchartsDiv [ 0 ] ;
323- this . onMapping . setContainer ( this . flowchartsDiv ) ;
324- this . notify ( 'Initialisation MXGRAPH/DRAW.IO Libs' ) ;
325-
326- // MxGraph Init
327- this . notify ( 'Load configuration' ) ;
328- if ( this . panel . gf_isEdited ) {
329- delete this . panel . gf_isEdited ;
330- }
331- GFDrawio . init ( ) ;
332- this . init_ctrl ( ) ;
333- if ( this . panel . version !== GFPlugin . getVersion ( ) ) {
334- //TODO : Reactive this
335- // this.notify(
336- // `The plugin version has changed, save the dashboard to optimize loading : ${
337- // this.panel.version
338- // } <> ${$GF.plugin.getVersion()}`
339- // );
340- }
341- this . clearNotify ( ) ;
342- this . panel . version = this . version ;
343- // Open is edit mode
344- if ( this . panel . isEditing === true ) {
345- this . panel . gf_isEdited = true ;
346- }
347- }
348-
349- isMouseInPanel ( ) : boolean {
350- return this . mouseIn ;
351- }
352-
353- displayMultiCursor ( ) : boolean {
354- if ( this . flowchartHandler ) {
355- return this . flowchartHandler . isMultiFlowcharts ( ) ;
356- }
357- return false ;
390+ private _on_global_mapping_enabled ( ) {
391+ _log ( '📬' , this . constructor . name , this . uid , '_on_global_mapping_enabled' ) ;
392+ this . onMapping = true ;
393+ this . flowchartsDiv . style . cursor = `url("${ GFPlugin . getStaticPath ( ) } cursor-marker.svg") 8 16, crosshair` ;
394+ this . flowchartsDiv . scrollIntoView ( ) ;
395+ this . flowchartsDiv . focus ( ) ;
358396 }
359397
360- displayFirstCursor ( ) : boolean {
361- if ( this . flowchartHandler ) {
362- return ! this . flowchartHandler . isCurrentfirst ( ) ;
363- }
364- return false ;
398+ private _on_global_mapping_disabled ( ) {
399+ _log ( '📬' , this . constructor . name , this . uid , '_on_global_mapping_disabled' ) ;
400+ this . onMapping = false ;
401+ this . flowchartsDiv . style . cursor = 'auto' ;
365402 }
366403
367- displayLastCursor ( ) : boolean {
368- if ( this . flowchartHandler ) {
369- return ! this . flowchartHandler . isCurrentLast ( ) ;
370- }
371- return false ;
372- }
373-
374- displayNextFlowchart ( ) {
375- if ( this . flowchartHandler ) {
376- this . flowchartHandler . setNextFlowchart ( ) ;
377- }
378- }
379-
380- displayPreviousFlowchart ( ) {
381- if ( this . flowchartHandler ) {
382- this . flowchartHandler . setPreviousFlowchart ( ) ;
383- }
384- }
385-
386- //
387- // EVENTS
388- //
389-
390404 $onDestroy ( ) {
391405 // $GF.destroy();
392406 GFTimer . stop ( ) ;
0 commit comments