From b6057f10de30d216b5ef53b938067df5ca6a671a Mon Sep 17 00:00:00 2001
From: Waldyr de Souza <waldyr.ar@gmail.com>
Date: Wed, 28 Sep 2016 10:23:43 -0300
Subject: [PATCH] FS-8976 [verto_communicator] Properly alert that the login
 has failed vs silently failing and sitting there.

---
 .../src/locales/locale-en.json                |  1 +
 .../src/locales/locale-pt.json                |  1 +
 .../src/partials/login.html                   | 14 +++++++----
 .../src/vertoService/services/vertoService.js | 24 +++++++++----------
 4 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/html5/verto/verto_communicator/src/locales/locale-en.json b/html5/verto/verto_communicator/src/locales/locale-en.json
index e7eddbe652..3eb1063817 100644
--- a/html5/verto/verto_communicator/src/locales/locale-en.json
+++ b/html5/verto/verto_communicator/src/locales/locale-en.json
@@ -92,6 +92,7 @@
   "LOGIN_INFORMATION": "Login Information",
   "SAVE_LOGIN_INFORMATION": "Save Login Information",
   "INVALID_LOGIN_FIELDS": "Verify the fields below and try again.",
+  "INVALID_SETTINGS_FIELDS": "Verify the settings below and try again.",
   "NAME": "Name",
   "YOUR_NAME": "Your name",
   "EMAIL": "Email",
diff --git a/html5/verto/verto_communicator/src/locales/locale-pt.json b/html5/verto/verto_communicator/src/locales/locale-pt.json
index c1d8cee9cc..0cf75ca880 100644
--- a/html5/verto/verto_communicator/src/locales/locale-pt.json
+++ b/html5/verto/verto_communicator/src/locales/locale-pt.json
@@ -92,6 +92,7 @@
   "LOGIN_INFORMATION": "Informações de login",
   "SAVE_LOGIN_INFORMATION": "Salvar informações de login",
   "INVALID_LOGIN_FIELDS": "Verifique os campos abaixo e tente novamente.",
+  "INVALID_SETTINGS_FIELDS": "Verifique as configurações abaixo e tente novamente.",
   "NAME": "Nome",
   "YOUR_NAME": "Seu nome",
   "EMAIL": "E-mail",
diff --git a/html5/verto/verto_communicator/src/partials/login.html b/html5/verto/verto_communicator/src/partials/login.html
index d8284c2163..032961fc9b 100644
--- a/html5/verto/verto_communicator/src/partials/login.html
+++ b/html5/verto/verto_communicator/src/partials/login.html
@@ -9,6 +9,10 @@
           <p>{{ 'INVALID_LOGIN_FIELDS' | translate }}</p>
         </div>
 
+        <div ng-show="loginFailed" class="alert alert-danger">
+          <p>{{ 'INVALID_SETTINGS_FIELDS' | translate }}</p>
+        </div>
+
         <form name="form" class="css-form" novalidate ng-init="advanced = false">
           <div class="form-group {{ (((!form.name.$pristine || form.$submitted) && !form.name.$valid) ? 'has-error': '') }}">
             <label class="control-label" for="login-name">{{ 'NAME' | translate}}</label>
@@ -19,25 +23,25 @@
             <input type="email" name="email" class="form-control" id="login-email" placeholder="{{ 'YOUR_EMAIL' | translate}}" required="" ng-model="verto.data.email" ng-model-options="{debounce: 250}">
           </div>
 
-          <div class="form-group" ng-hide="!advanced">
+          <div class="form-group" ng-show="advanced || loginFailed">
               <label class="control-label" for="login-user">{{ 'USER' | translate}}</label>
             <input type="text" class="form-control" id="login-user" placeholder="{{ 'USER' | translate}}" ng-model="verto.data.login">
           </div>
-          <div class="form-group" ng-hide="!advanced">
+          <div class="form-group" ng-show="advanced || loginFailed">
             <label class="control-label" for="login-password">{{ 'PASSWORD' | translate}}</label>
             <input type="password" class="form-control" id="login-password" placeholder={{ 'PASSWORD' | translate}} ng-model="verto.data.password">
           </div>
 
-          <div class="form-group" ng-hide="!advanced">
+          <div class="form-group" ng-show="advanced || loginFailed">
             <label class="control-label" for="login-callerid">{{ 'CALLER_ID' | translate}}</label>
             <input type="text" class="form-control" id="login-callerid" placeholder="{{ 'CALLER_ID' | translate}}" ng-model="verto.data.callerid">
           </div>
 
-          <div class="form-group" ng-hide="!advanced">
+          <div class="form-group" ng-show="advanced || loginFailed">
             <label class="control-label" for="login-hostname">{{ 'HOSTNAME' | translate}}</label>
             <input type="text" class="form-control" id="login-hostname" placeholder="{{ 'HOSTNAME' | translate}}" ng-model="verto.data.hostname">
           </div>
-          <div class="form-group" ng-hide="!advanced">
+          <div class="form-group" ng-show="advanced || loginFailed">
             <label class="control-label" for="login-wsurl">{{ 'WEBSOCKET_URL' | translate}}</label>
             <input type="text" class="form-control" id="login-wsurl" placeholder="{{ 'WEBSOCKET_URL' | translate}}" ng-model="verto.data.wsURL">
           </div>
diff --git a/html5/verto/verto_communicator/src/vertoService/services/vertoService.js b/html5/verto/verto_communicator/src/vertoService/services/vertoService.js
index c5c2fd9025..883cebf3b9 100644
--- a/html5/verto/verto_communicator/src/vertoService/services/vertoService.js
+++ b/html5/verto/verto_communicator/src/vertoService/services/vertoService.js
@@ -117,13 +117,13 @@ var updateReq;
 
 var updateVideoSize = function(ms) {
     if (!ms) ms = 500;
-    
+
     clearTimeout(updateReq);
     updateReq = setTimeout(function () {
         var videoElem = jQuery('#webcam');
         videoElem.width("");
         videoElem.height("");
-	
+
         var w = videoElem.width();
         var h = videoElem.height();
         var new_w, new_h;
@@ -577,6 +577,7 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
         var callbacks = {
           onWSLogin: function(v, success) {
             data.connected = success;
+            $rootScope.loginFailed = !success;
             $rootScope.$emit('ws.login', success);
             console.debug('Connected to verto server:', success);
 
@@ -679,7 +680,6 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
 
           onWSClose: function(v, success) {
             console.debug('onWSClose:', success);
-
             $rootScope.$emit('ws.close', success);
           },
 
@@ -825,9 +825,9 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
 
       screenshare: function(destination, callback) {
 
-	  
+
           var that = this;
-	  
+
 	  if (storage.data.selectedShare !== "screen") {
 
               console.log('share screen from device ' + storage.data.selectedShare);
@@ -856,9 +856,9 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
 		      StreamTrack.addEventListener('ended', stopSharing);
 		      // (stream.getVideoTracks()[0]).onended = stopSharing;
 		  }
-		  
+
 		  console.log("screenshare started");
-		  
+
 		  function stopSharing() {
 		      if(that.data.shareCall) {
 			  that.screenshareHangup();
@@ -866,16 +866,16 @@ vertoService.service('verto', ['$rootScope', '$cookieStore', '$location', 'stora
 		      }
 		  }
               };
-	      
+
               data.shareCall = call;
-	      
+
               console.log('shareCall', data);
-	      
+
               data.mutedMic = false;
               data.mutedVideo = false;
-	      
+
               that.refreshDevices();
-	      
+
 	      return;
 	  }