@@ -13,6 +13,7 @@ var connection = null;
1313var storeFunc = null ;
1414var isConnected = false ;
1515var isAdvanceView = false ;
16+ var isTokenRequired = false ;
1617
1718export function Init ( ) {
1819 //Connect Button Events
@@ -46,7 +47,18 @@ export function Init() {
4647 }
4748
4849 NotConnected ( ) ;
49- Test ( ) ;
50+ RigisterNavigationTabEvent ( ) ;
51+
52+ document . getElementById ( 'chk-req-token' )
53+ . addEventListener ( 'change' , ( event ) => {
54+ if ( event . target . checked ) {
55+ document . getElementById ( 'authHeader' ) . disabled = false ;
56+ isTokenRequired = true ;
57+ } else {
58+ isTokenRequired = false ;
59+ document . getElementById ( 'authHeader' ) . disabled = true ;
60+ }
61+ } ) ;
5062
5163}
5264
@@ -70,7 +82,7 @@ eventEmitter.on('OnDisconnected', () => {
7082} ) ;
7183//#endregion
7284
73- export function Test ( ) {
85+ export function RigisterNavigationTabEvent ( ) {
7486
7587 var navLinkClass = document . getElementsByClassName ( 'nav-link' ) ;
7688 for ( var i = 0 ; i < navLinkClass . length ; i ++ ) {
@@ -85,25 +97,30 @@ export function Test() {
8597
8698export function OnTabChange ( tabName ) {
8799 if ( tabName == 'basic' ) {
88- //document.getElementById('protocol-support').style = 'display:none';
89100 isAdvanceView = false ;
90101 AdvanceViewElements ( isAdvanceView ) ;
91102 }
92103 else {
93104 isAdvanceView = true ;
94105 AdvanceViewElements ( isAdvanceView ) ;
95- // if (isConnected) {
96- // isAdvanceView = true;
97- // //document.getElementById('protocol-support').style = 'display:block';
98- // AdvanceViewElements(isAdvanceView);
99- // }
100106 }
101107}
102108
109+
103110export function AdvanceViewElements ( enable ) {
104111 if ( enable === true ) {
105112 document . getElementById ( 'protocol-support' ) . style = 'display:block' ;
106113 document . getElementById ( 'auth-container' ) . style = 'display:block' ;
114+ if ( isConnected === true ) {
115+ document . getElementById ( 'chk-req-token' ) . disabled = true ;
116+ document . getElementById ( 'authHeader' ) . disabled = true ;
117+ } else {
118+ document . getElementById ( 'chk-req-token' ) . disabled = false ;
119+ if ( isTokenRequired === true ) {
120+ document . getElementById ( 'authHeader' ) . disabled = false ;
121+ }
122+
123+ }
107124 }
108125 else {
109126 document . getElementById ( 'protocol-support' ) . style = 'display:none' ;
@@ -262,13 +279,13 @@ export function buildConnection(url) {
262279// accessTokenFactory: getToken
263280// };
264281
265- var option = {
266-
267- } ;
282+ var option = { } ;
268283
269- if ( isAdvanceView ) {
284+ if ( isAdvanceView ) {
285+ if ( isTokenRequired === true ) {
270286 option . accessTokenFactory = ( ) => document . getElementById ( 'authHeader' ) . value ;
271- }
287+ }
288+ }
272289
273290 connection = new signalR . HubConnectionBuilder ( )
274291 . withUrl ( url , option )
@@ -303,9 +320,8 @@ export function OnConnect() {
303320 SetConnectionProtocol ( ) ;
304321 }
305322
306- var url = document . getElementById ( "inputUrl" ) . value ;
307- debugger ;
308- connectToServer ( url ) ;
323+ var urlElement = document . getElementById ( "inputUrl" ) ;
324+ connectToServer ( urlElement . value ) ;
309325 console . log ( "OnConnect" ) ;
310326 isConnected = true ;
311327 var onConnectClass = document . getElementsByClassName ( 'onconnect' ) ;
@@ -330,6 +346,9 @@ export function OnConnect() {
330346
331347 eventEmitter . emit ( 'OnConnected' ) ;
332348 AddArguments ( ) ;
349+
350+ //Disable Url
351+ urlElement . disabled = true ;
333352}
334353
335354export function SetConnectionProtocol ( ) {
@@ -391,6 +410,8 @@ export function OnDisConnect() {
391410 EnableElementByClassName ( 'connectbtn' ) ;
392411 NotConnected ( ) ;
393412 AdvanceViewElements ( isAdvanceView ) ;
413+ //Enable URL textBix
414+ document . getElementById ( "inputUrl" ) . disabled = false ;
394415}
395416
396417export function Reset ( ) {
0 commit comments