@@ -73,19 +73,17 @@ module.exports = {
7373 let modActions = getActions ( Module . notificationHandler [ mod . module ] ) ;
7474
7575 if ( modActions . length > 0 ) {
76- let pathGuess = mod . module . replace ( / M M M - / g, '' ) . replace ( / - / g, '' ) . toLowerCase ( ) ;
77-
7876 // Generate formatted actions object
7977 let actionsGuess = { } ;
8078
8179 modActions . forEach ( a => {
8280 actionsGuess [ a . replace ( / [ - _ ] / g, '' ) . toLowerCase ( ) ] = { notification : a , guessed : true } ;
8381 } ) ;
8482
85- if ( pathGuess in this . externalApiRoutes ) {
86- this . externalApiRoutes [ pathGuess ] . actions = Object . assign ( { } , actionsGuess , this . externalApiRoutes [ pathGuess ] . actions ) ;
83+ if ( mod . module in this . externalApiRoutes ) {
84+ this . externalApiRoutes [ mod . module ] . actions = Object . assign ( { } , actionsGuess , this . externalApiRoutes [ mod . module ] . actions ) ;
8785 } else {
88- this . externalApiRoutes [ pathGuess ] = {
86+ this . externalApiRoutes [ mod . module ] = {
8987 module : mod . module ,
9088 path : mod . module . replace ( / M M M - / g, '' ) . replace ( / - / g, '' ) . toLowerCase ( ) ,
9189 actions : actionsGuess
@@ -326,12 +324,12 @@ module.exports = {
326324 let extApiRoutes = this . externalApiRoutes ;
327325 let modules = this . configData . moduleData
328326 let query = { success : true , data : [ ] } ;
329-
327+
330328 modules . forEach ( ( mod ) => {
331329 if ( extApiRoutes [ mod . name ] === undefined ) {
332330 query . data . push ( mod ) ;
333331 } else {
334- query . data . push ( Object . assign ( { } , mod , { actions : extApiRoutes [ mod . name ] . actions } ) ) ;
332+ query . data . push ( Object . assign ( { } , mod , { actions : extApiRoutes [ mod . name ] . actions , urlpath : extApiRoutes [ mod . name ] . path } ) ) ;
335333 }
336334 } ) ;
337335
@@ -341,7 +339,7 @@ module.exports = {
341339 answerModuleApi ( req , res ) {
342340 if ( ! this . checkInitialized ( res ) ) { return ; }
343341 let dataMerged = this . mergeData ( ) . data
344-
342+
345343 if ( ! req . params . moduleName ) {
346344 res . json ( { success : true , data : dataMerged } ) ;
347345 return ;
@@ -350,7 +348,8 @@ module.exports = {
350348 let modData = [ ] ;
351349 if ( req . params . moduleName !== 'all' ) {
352350 modData = dataMerged . filter ( m => {
353- return ( req . params . moduleName . includes ( m . identifier ) ) ;
351+ const name = req . params . moduleName ;
352+ return name . includes ( m . identifier ) || name . includes ( m . name ) || name . includes ( m . urlpath ) ;
354353 } ) ;
355354 if ( ! modData . length ) {
356355 modData = dataMerged . filter ( m => {
@@ -493,26 +492,26 @@ module.exports = {
493492 icon : "window-restore" ,
494493 items : [ ]
495494 } ;
496- Object . keys ( this . externalApiRoutes ) . forEach ( r => {
495+ Object . values ( this . externalApiRoutes ) . forEach ( r => {
497496 let sub = {
498- id : "mc-" + r ,
497+ id : "mc-" + r . path ,
499498 type : "menu" ,
500499 icon : "bars" ,
501- text : this . formatName ( this . externalApiRoutes [ r ] . module ) ,
500+ text : this . formatName ( r . module ) ,
502501 items : [ ]
503502 } ;
504- Object . keys ( this . externalApiRoutes [ r ] . actions ) . forEach ( a => {
503+ Object . keys ( r . actions ) . forEach ( a => {
505504 let item = {
506- id : `mc-${ r } -${ a } ` ,
505+ id : `mc-${ r . path } -${ a } ` ,
507506 menu : "item" ,
508507 icon : "dot-circle-o" ,
509508 action : "NOTIFICATION" ,
510- content : this . externalApiRoutes [ r ] . actions [ a ]
509+ content : r . actions [ a ]
511510 } ;
512- if ( "prettyName" in this . externalApiRoutes [ r ] . actions [ a ] ) {
513- item . text = this . translate ( this . externalApiRoutes [ r ] . actions [ a ] . prettyName ) ;
511+ if ( "prettyName" in r . actions [ a ] ) {
512+ item . text = this . translate ( r . actions [ a ] . prettyName ) ;
514513 } else {
515- item . text = this . translate ( this . externalApiRoutes [ r ] . actions [ a ] . notification ) . toLowerCase ( ) . replace ( / ( ^ | _ ) ( \w ) / g, function ( $0 , $1 , $2 ) {
514+ item . text = this . translate ( r . actions [ a ] . notification ) . toLowerCase ( ) . replace ( / ( ^ | _ ) ( \w ) / g, function ( $0 , $1 , $2 ) {
516515 return ( $1 && ' ' ) + $2 . toUpperCase ( ) ;
517516 } ) ;
518517 }
0 commit comments