Form validation on login page

Using ngMessages, adds form validation to login page. Also creates a
directive, hasError, to be used to validate form field by passing
in a boolean. This is a proposed pattern to be used moving forward,
as form validation is added to additional pages.

Validation error messages are shown on $touched and on submit.
Unreachable Server and Invalid username and password error messages
remain until input is no longer $pristine after form submission.

In addition, this removes unneeded and unused css styling

Resolves openbmc/phosphor-webui#47

Change-Id: I7a067af67ac74d4cf2977d10f66445720ecae9eb
Signed-off-by: beccabroek <beccabroek@gmail.com>
diff --git a/app/common/styles/base/colors.scss b/app/common/styles/base/colors.scss
index 46285c8..405dad4 100644
--- a/app/common/styles/base/colors.scss
+++ b/app/common/styles/base/colors.scss
@@ -52,6 +52,7 @@
 $alert__error: rgb(230, 35, 37);
 $alert__warning: rgb(255, 127, 0);
 $alert__message: rgb(203, 221, 235);
+$alert__danger: #fad3D3;
 
 // Severity
 $critical-lightbg: #e62325;
diff --git a/app/common/styles/base/forms.scss b/app/common/styles/base/forms.scss
index 0957609..73c25c1 100644
--- a/app/common/styles/base/forms.scss
+++ b/app/common/styles/base/forms.scss
@@ -21,13 +21,13 @@
   border-radius: 0px;
   border: 1px solid $input-border;
   height: 3.1em;
-  margin: 0 0 1em 0;
+  margin: 0;
   background: $white;
   box-shadow: 0 0 0;
   transition: none !important;
   &:focus {
     border-color: $medgrey;
-    box-shadow: 0 -5px $field__focus inset;
+    box-shadow: 0 -3px $field__focus inset;
   }
   &:disabled,
   .disabled {
@@ -43,6 +43,33 @@
   }
 }
 
+//input validation
+.ng-invalid.ng-touched {
+  box-shadow: 0 -3px $error-color inset;
+  &:focus {
+    border-color: $medgrey;
+    box-shadow: 0 -3px $error-color inset;
+  }
+}
+.submitted .ng-invalid {
+  box-shadow: 0 -3px $error-color inset;
+  &:focus {
+    border-color: $medgrey;
+    box-shadow: 0 -3px $error-color inset;
+  }
+}
+
+.form-error {
+  margin-bottom: .7em;
+  font-size: 0.8rem;
+  color: #c60f13;
+  height:1rem;
+  display: block;
+  visibility: hidden;
+  .visible {
+    visibility: visible;
+  }
+}
 //Foundation overwrite
 [type=color], [type=date], [type=datetime-local], [type=datetime], [type=email], [type=month], [type=number], [type=password], [type=search], [type=tel], [type=text], [type=time], [type=url], [type=week], textarea {
   border-color: $input-border;
diff --git a/app/common/styles/base/foundation.scss b/app/common/styles/base/foundation.scss
index f1bcb2f..a422dec 100644
--- a/app/common/styles/base/foundation.scss
+++ b/app/common/styles/base/foundation.scss
@@ -705,31 +705,6 @@
   height: auto;
   background-image: none; }
 
-.is-invalid-input:not(:focus) {
-  border-color: #c60f13;
-  background-color: #f8e6e7; }
-.is-invalid-input:not(:focus)::-webkit-input-placeholder {
-  color: #c60f13; }
-.is-invalid-input:not(:focus)::-moz-placeholder {
-  color: #c60f13; }
-.is-invalid-input:not(:focus):-ms-input-placeholder {
-  color: #c60f13; }
-.is-invalid-input:not(:focus)::placeholder {
-  color: #c60f13; }
-
-.is-invalid-label {
-  color: #c60f13; }
-
-.form-error {
-  display: none;
-  margin-top: -0.5rem;
-  margin-bottom: 1rem;
-  font-size: 0.75rem;
-  font-weight: bold;
-  color: #c60f13; }
-.form-error.is-visible {
-  display: block; }
-
 .hide {
   display: none !important; }
 
diff --git a/app/common/styles/elements/alerts.scss b/app/common/styles/elements/alerts.scss
index 96f0a4c..6242257 100644
--- a/app/common/styles/elements/alerts.scss
+++ b/app/common/styles/elements/alerts.scss
@@ -1,67 +1,11 @@
 //Fixed alerts
 
-.alert__error,
-.alert__warning,
-.alert__message {
-  color: $darkbg__primary;
-  padding: 1em;
-  margin: .5em 0;
-  position: relative;
-  display: flex;
-  justify-content: center;
-  flex-direction: column;
-  .close {
-    color: $lightbg__primary;
-    position: absolute;
-    right: 0;
-    top: 50%;
-    transform: translateY(-50%);
-    font-size: 1.5em;
-    padding: 1em;
-    box-sizing: border-box;
-    line-height: 0;
-    display: flex;
-    justify-content: center;
-    flex-direction: column;
-    background: transparent;
-    border: 0;
-    margin: 0;
-    &:hover {
-      color: $lightbg__accent;
-    }
-  }
-}
-
-.alert__error {
-  background: $alert__error;
-
-}
-
-.alert__warning {
-  background: $alert__warning;
-
-}
-.alert__message {
-  background: $alert__message;
-}
-
-// Power confirmation buttons
-.power__confirm-buttons {
-  .btn-primary {
-    background: transparent;
-    border: 2px solid $white;
-    padding: 1em 2.2em;
-    margin: 0 10px;
-    border-radius: 4px;
-    &:focus,
-    &:hover {
-      background: $primebtn__bg;
-      border: 2px solid $primebtn__bg;
-    }
-  }
-  @include mediaQuery(large) {
-    float: right;
-  }
+.alert-danger{
+  background-color: $alert__danger;
+  border-color: $critical-lightbg;
+  border-radius: 0;
+  color: #333;
+  text-align: left;
 }
 
 
diff --git a/app/common/styles/elements/errors.scss b/app/common/styles/elements/errors.scss
deleted file mode 100644
index 3076a3d..0000000
--- a/app/common/styles/elements/errors.scss
+++ /dev/null
@@ -1,11 +0,0 @@
-.error-msg  {
-  background: lighten($error-color, 20%);
-  padding: 1em;
-  text-align: center;
-  font-size: 1em;
-  border: 1px solid $error-color;
-  color: $black;
-  font-family: "Courier New", Helvetica, Arial, sans-serif;
-  font-weight: 700;
-  max-width: 325px;
-}
diff --git a/app/common/styles/elements/index.scss b/app/common/styles/elements/index.scss
index 3c5754e..25162bb 100644
--- a/app/common/styles/elements/index.scss
+++ b/app/common/styles/elements/index.scss
@@ -11,5 +11,4 @@
 @import "export";
 @import "modals";
 @import "quicklinks";
-@import "errors";
 @import "toast";