@@ -51,6 +51,7 @@ function AssetConnectionWindow(props: { Name: string, ID: number, TypeID: number
5151 const [ selectedAssetID , setSelectedAssetID ] = React . useState < number > ( 0 ) ;
5252 const [ selectedTypeID , setSelectedtypeID ] = React . useState < number > ( 0 ) ;
5353 const [ localAssets , setLocalAssets ] = React . useState < Array < OpenXDA . Types . Asset > > ( [ ] ) ;
54+ const [ locations , setLocations ] = React . useState < number [ ] > ( [ ] ) ;
5455
5556 const [ sortKey , setSortKey ] = React . useState < string > ( 'AssetKey' ) ;
5657 const [ ascending , setAscending ] = React . useState < boolean > ( true ) ;
@@ -63,11 +64,6 @@ function AssetConnectionWindow(props: { Name: string, ID: number, TypeID: number
6364 const [ hover , setHover ] = React . useState < ( 'Update' | 'Reset' | 'None' ) > ( 'None' ) ;
6465 const roles = useAppSelector ( SelectRoles ) ;
6566
66- React . useEffect ( ( ) => {
67- let handle = getAssetConnections ( ) ;
68- return ( ) => { if ( handle != null || handle . abort != null ) handle . abort ( ) ; }
69- } , [ props . ID , trigger ] )
70-
7167 React . useEffect ( ( ) => {
7268 if ( props . ID > 0 ) {
7369 let sqlString = `(SELECT AssetRelationshipTypeID FROM AssetRelationshipTypeAssetType LEFT JOIN Asset ON `
@@ -106,7 +102,27 @@ function AssetConnectionWindow(props: { Name: string, ID: number, TypeID: number
106102 if ( index == - 1 && localAssets . length > 0 )
107103 setSelectedAssetID ( localAssets [ 0 ] . ID )
108104 } , [ localAssets ] )
109-
105+
106+ React . useEffect ( ( ) => {
107+ let handle = getAssetConnections ( ) ;
108+ return ( ) => { if ( handle != null || handle . abort != null ) handle . abort ( ) ; }
109+ } , [ props . ID , trigger ] )
110+
111+ React . useEffect ( ( ) => {
112+ getLocations ( ) ;
113+ } , [ assetConnections ] )
114+
115+ function getLocations ( ) : void {
116+ $ . ajax ( {
117+ type : "GET" ,
118+ url : `${ homePath } api/OpenXDA/Asset/${ props . ID } /Locations` ,
119+ contentType : "application/json; charset=utf-8" ,
120+ dataType : 'json' ,
121+ cache : true ,
122+ async : true
123+ } ) . done ( data => setLocations ( data ) ) ;
124+ }
125+
110126 function getAssetConnections ( ) : JQuery . jqXHR < OpenXDA . Types . AssetConnection > {
111127 setStatus ( 'loading' ) ;
112128 return $ . ajax ( {
@@ -176,7 +192,6 @@ function AssetConnectionWindow(props: { Name: string, ID: number, TypeID: number
176192 } ) ;
177193 }
178194
179-
180195 function handleSelect ( item ) {
181196 history . push ( { pathname : homePath + 'index.cshtml' , search : '?name=Asset&AssetID=' + item . row . AssetID } )
182197 }
@@ -232,7 +247,7 @@ function AssetConnectionWindow(props: { Name: string, ID: number, TypeID: number
232247 < h4 > Connections:</ h4 >
233248 </ div >
234249 < div className = "col-2" >
235- < LocationDrawings LocationID = { props . ID } />
250+ < LocationDrawings LocationID = { locations } LocationLabels = { } />
236251 </ div >
237252 </ div >
238253 </ div >
@@ -346,7 +361,6 @@ function AssetConnectionWindow(props: { Name: string, ID: number, TypeID: number
346361 </ div > }
347362 </ Modal >
348363 </ div >
349-
350364 ) ;
351365
352366}
0 commit comments