From 5cf4f930bbc6b86ed9a83cd29a4cb17dc4eb7a22 Mon Sep 17 00:00:00 2001
From: gopi17701 <41270090+gopi17701@users.noreply.github.com>
Date: Sat, 29 Sep 2018 21:21:20 -0400
Subject: [PATCH] Add files via upload

---
 .../src/app/app-routing.module.spec.ts        | 26 ++---
 AstuteClient2/src/app/app-routing.module.ts   | 58 +++++------
 AstuteClient2/src/app/app.component.css       |  2 +-
 AstuteClient2/src/app/app.component.spec.ts   | 54 +++++------
 AstuteClient2/src/app/app.component.ts        | 20 ++--
 AstuteClient2/src/app/app.module.ts           | 96 ++++++++++---------
 .../src/app/homepage/homepage.component.html  | 10 --
 .../invoice-payment.component.html            |  4 +-
 .../src/app/login/login.component.html        |  7 +-
 .../src/app/login/login.component.ts          |  2 +-
 .../sales-order/sales-order.component.html    |  2 +-
 .../src/app/services/astute-client-service.ts | 37 +++++--
 12 files changed, 173 insertions(+), 145 deletions(-)

diff --git a/AstuteClient2/src/app/app-routing.module.spec.ts b/AstuteClient2/src/app/app-routing.module.spec.ts
index d68ef06..4e83b72 100644
--- a/AstuteClient2/src/app/app-routing.module.spec.ts
+++ b/AstuteClient2/src/app/app-routing.module.spec.ts
@@ -1,13 +1,13 @@
-import { AppRoutingModule } from './app-routing.module';
-
-describe('AppRoutingModule', () => {
-  let appRoutingModule: AppRoutingModule;
-
-  beforeEach(() => {
-    appRoutingModule = new AppRoutingModule();
-  });
-
-  it('should create an instance', () => {
-    expect(appRoutingModule).toBeTruthy();
-  });
-});
+import { AppRoutingModule } from './app-routing.module';
+
+describe('AppRoutingModule', () => {
+  let appRoutingModule: AppRoutingModule;
+
+  beforeEach(() => {
+    appRoutingModule = new AppRoutingModule();
+  });
+
+  it('should create an instance', () => {
+    expect(appRoutingModule).toBeTruthy();
+  });
+});
diff --git a/AstuteClient2/src/app/app-routing.module.ts b/AstuteClient2/src/app/app-routing.module.ts
index e1b1ecf..b24699f 100644
--- a/AstuteClient2/src/app/app-routing.module.ts
+++ b/AstuteClient2/src/app/app-routing.module.ts
@@ -1,27 +1,31 @@
-import { NgModule } from '@angular/core';
-import { CommonModule } from '@angular/common';
-import {RouterModule, Routes} from '@angular/router';
-import {CustomerComponent} from './customer/customer.component';
-import {SalesOrderComponent} from './sales-order/sales-order.component';
-import {InvoiceComponent} from './invoice/invoice.component';
-import {HomepageComponent} from './homepage/homepage.component';
-import {InvoiceGenComponent} from './invoice-gen/invoice-gen.component';
-
-const routes: Routes = [
-  { path: '', redirectTo: 'homepage', pathMatch: 'full'},
-  { path: 'homepage', component: HomepageComponent },
-  { path: 'customer', component: CustomerComponent },
-  { path: 'sales-order', component: SalesOrderComponent },
-  { path: 'invoice', component: InvoiceComponent },
-  { path: 'invoice-gen', component: InvoiceGenComponent }
-];
-
-@NgModule({
-  exports: [RouterModule],
-  imports: [
-    CommonModule,
-    RouterModule.forRoot(routes)
-  ],
-  declarations: []
-})
-export class AppRoutingModule { }
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import {RouterModule, Routes} from '@angular/router';
+import {CustomerComponent} from './customer/customer.component';
+import {SalesOrderComponent} from './sales-order/sales-order.component';
+import {InvoiceComponent} from './invoice/invoice.component';
+import {HomepageComponent} from './homepage/homepage.component';
+import {InvoiceGenComponent} from './invoice-gen/invoice-gen.component';
+import {InvoicePaymentComponent} from './invoice-payment/invoice-payment.component';
+import {LoginComponent} from './login/login.component';
+
+const routes: Routes = [
+  { path: '', redirectTo: 'login', pathMatch: 'full'},
+  { path: 'homepage', component: HomepageComponent },
+  { path: 'customer', component: CustomerComponent },
+  { path: 'sales-order', component: SalesOrderComponent },
+  { path: 'invoice', component: InvoiceComponent },
+  { path: 'invoice-gen', component: InvoiceGenComponent },
+  { path: 'invoice-payment', component: InvoicePaymentComponent },
+  { path: 'login', component: LoginComponent }
+];
+
+@NgModule({
+  exports: [RouterModule],
+  imports: [
+    CommonModule,
+    RouterModule.forRoot(routes)
+  ],
+  declarations: []
+})
+export class AppRoutingModule { }
diff --git a/AstuteClient2/src/app/app.component.css b/AstuteClient2/src/app/app.component.css
index 8b13789..d3f5a12 100644
--- a/AstuteClient2/src/app/app.component.css
+++ b/AstuteClient2/src/app/app.component.css
@@ -1 +1 @@
-
+
diff --git a/AstuteClient2/src/app/app.component.spec.ts b/AstuteClient2/src/app/app.component.spec.ts
index be3c0e8..6d27027 100644
--- a/AstuteClient2/src/app/app.component.spec.ts
+++ b/AstuteClient2/src/app/app.component.spec.ts
@@ -1,27 +1,27 @@
-import { TestBed, async } from '@angular/core/testing';
-import { AppComponent } from './app.component';
-describe('AppComponent', () => {
-  beforeEach(async(() => {
-    TestBed.configureTestingModule({
-      declarations: [
-        AppComponent
-      ],
-    }).compileComponents();
-  }));
-  it('should create the app', async(() => {
-    const fixture = TestBed.createComponent(AppComponent);
-    const app = fixture.debugElement.componentInstance;
-    expect(app).toBeTruthy();
-  }));
-  it(`should have as title 'app'`, async(() => {
-    const fixture = TestBed.createComponent(AppComponent);
-    const app = fixture.debugElement.componentInstance;
-    expect(app.title).toEqual('app');
-  }));
-  it('should render title in a h1 tag', async(() => {
-    const fixture = TestBed.createComponent(AppComponent);
-    fixture.detectChanges();
-    const compiled = fixture.debugElement.nativeElement;
-    expect(compiled.querySelector('h1').textContent).toContain('Welcome to AstuteClient2!');
-  }));
-});
+import { TestBed, async } from '@angular/core/testing';
+import { AppComponent } from './app.component';
+describe('AppComponent', () => {
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [
+        AppComponent
+      ],
+    }).compileComponents();
+  }));
+  it('should create the app', async(() => {
+    const fixture = TestBed.createComponent(AppComponent);
+    const app = fixture.debugElement.componentInstance;
+    expect(app).toBeTruthy();
+  }));
+  it(`should have as title 'app'`, async(() => {
+    const fixture = TestBed.createComponent(AppComponent);
+    const app = fixture.debugElement.componentInstance;
+    expect(app.title).toEqual('app');
+  }));
+  it('should render title in a h1 tag', async(() => {
+    const fixture = TestBed.createComponent(AppComponent);
+    fixture.detectChanges();
+    const compiled = fixture.debugElement.nativeElement;
+    expect(compiled.querySelector('h1').textContent).toContain('Welcome to AstuteClient2!');
+  }));
+});
diff --git a/AstuteClient2/src/app/app.component.ts b/AstuteClient2/src/app/app.component.ts
index 7b0f672..a5f44c2 100644
--- a/AstuteClient2/src/app/app.component.ts
+++ b/AstuteClient2/src/app/app.component.ts
@@ -1,10 +1,10 @@
-import { Component } from '@angular/core';
-
-@Component({
-  selector: 'app-root',
-  templateUrl: './app.component.html',
-  styleUrls: ['./app.component.css']
-})
-export class AppComponent {
-  title = 'app';
-}
+import { Component } from '@angular/core';
+
+@Component({
+  selector: 'app-root',
+  templateUrl: './app.component.html',
+  styleUrls: ['./app.component.css']
+})
+export class AppComponent {
+  title = 'app';
+}
diff --git a/AstuteClient2/src/app/app.module.ts b/AstuteClient2/src/app/app.module.ts
index 7bc50d6..f8bfeb3 100644
--- a/AstuteClient2/src/app/app.module.ts
+++ b/AstuteClient2/src/app/app.module.ts
@@ -1,43 +1,53 @@
-import { BrowserModule } from '@angular/platform-browser';
-import { NgModule } from '@angular/core';
-
-import { AppComponent } from './app.component';
-import { CustomerComponent } from './customer/customer.component';
-import { AstuteClientService } from './services/astute-client-service';
-import { AgGridModule } from 'ag-grid-angular';
-import { ModalFormComponent } from './modal-form/modal-form.component';
-import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
-import {HttpClientModule} from '@angular/common/http';
-import { AppRoutingModule } from './/app-routing.module';
-import { NavBarComponent } from './nav-bar/nav-bar.component';
-import { SalesOrderComponent } from './sales-order/sales-order.component';
-import { InvoiceComponent } from './invoice/invoice.component';
-import { HomepageComponent } from './homepage/homepage.component';
-import { AppBoxComponent } from './app-box/app-box.component';
-import { InvoiceGenComponent } from './invoice-gen/invoice-gen.component';
-import { TextMaskModule } from 'angular2-text-mask';
-
-@NgModule({
-  declarations: [
-    AppComponent,
-    CustomerComponent,
-    ModalFormComponent,
-    NavBarComponent,
-    SalesOrderComponent,
-    InvoiceComponent,
-    HomepageComponent,
-    AppBoxComponent,
-    InvoiceGenComponent
-  ],
-  imports: [
-    BrowserModule,
-    AgGridModule.withComponents([]),
-    NgbModule.forRoot(),
-    HttpClientModule,
-    AppRoutingModule,
-    TextMaskModule
-  ],
-  providers: [AstuteClientService],
-  bootstrap: [AppComponent]
-})
-export class AppModule { }
+import { BrowserModule } from '@angular/platform-browser';
+import { NgModule } from '@angular/core';
+
+import { AppComponent } from './app.component';
+import { CustomerComponent } from './customer/customer.component';
+import { AstuteClientService } from './services/astute-client-service';
+import { AgGridModule } from 'ag-grid-angular';
+import { ModalFormComponent } from './modal-form/modal-form.component';
+import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
+import {HttpClientModule} from '@angular/common/http';
+import { AppRoutingModule } from './/app-routing.module';
+import { NavBarComponent } from './nav-bar/nav-bar.component';
+import { SalesOrderComponent } from './sales-order/sales-order.component';
+import { InvoiceComponent } from './invoice/invoice.component';
+import { HomepageComponent } from './homepage/homepage.component';
+import { AppBoxComponent } from './app-box/app-box.component';
+import { InvoiceGenComponent } from './invoice-gen/invoice-gen.component';
+import { TextMaskModule } from 'angular2-text-mask';
+import { LoginComponent } from './login/login.component';
+import { InvoicePaymentComponent } from './invoice-payment/invoice-payment.component';
+import { CommonModule } from '@angular/common';
+import { FormsModule }   from '@angular/forms';
+import { ReactiveFormsModule } from '@angular/forms';
+
+@NgModule({
+  declarations: [
+    AppComponent,
+    CustomerComponent,
+    ModalFormComponent,
+    NavBarComponent,
+    SalesOrderComponent,
+    InvoiceComponent,
+    HomepageComponent,
+    AppBoxComponent,
+    InvoiceGenComponent,
+    LoginComponent,
+    InvoicePaymentComponent
+  ],
+  imports: [
+    BrowserModule,
+    AgGridModule.withComponents([]),
+    NgbModule.forRoot(),
+    HttpClientModule,
+    AppRoutingModule,
+    TextMaskModule,
+    CommonModule,
+    FormsModule,
+      ReactiveFormsModule
+  ],
+  providers: [AstuteClientService],
+  bootstrap: [AppComponent]
+})
+export class AppModule { }
diff --git a/AstuteClient2/src/app/homepage/homepage.component.html b/AstuteClient2/src/app/homepage/homepage.component.html
index 5a31e36..c726dcb 100644
--- a/AstuteClient2/src/app/homepage/homepage.component.html
+++ b/AstuteClient2/src/app/homepage/homepage.component.html
@@ -8,16 +8,6 @@
           Welcome to the Astute Internal System, {{currentUser}}!
         </h1>
       </div>
-      <div class="col-lg-4">
-        <div class="input-group mb-3 float-right">
-          <input type="text" class="form-control" placeholder="Search...">
-          <div class="input-group-prepend">
-            <button class="btn btn-sm btn-info btn-round">
-              <i class="material-icons">search</i>
-            </button>
-          </div>
-        </div>
-      </div>
     </div>
 
     <!--applications-->
diff --git a/AstuteClient2/src/app/invoice-payment/invoice-payment.component.html b/AstuteClient2/src/app/invoice-payment/invoice-payment.component.html
index 4d48099..0dfb3cc 100644
--- a/AstuteClient2/src/app/invoice-payment/invoice-payment.component.html
+++ b/AstuteClient2/src/app/invoice-payment/invoice-payment.component.html
@@ -73,7 +73,7 @@
           <span class="input-group-text">Payment Date*</span>
         </td>
         <td colspan="7">
-          <input type="text" class="form-control" #inDateReceived>
+          <input type="date" class="form-control" #inDateReceived>
         </td>
       </tr>
 
@@ -120,7 +120,7 @@
             <span class="input-group-text">Date Received*</span>
           </td>
           <td colspan="7">
-            <input type="text" class="form-control" #inDateReceived [value]="selected.paymentDate">
+            <input type="date" class="form-control" #inDateReceived [value]="selected.paymentDate">
           </td>
         </tr>
         </tbody>
diff --git a/AstuteClient2/src/app/login/login.component.html b/AstuteClient2/src/app/login/login.component.html
index 75191a4..56f01fa 100644
--- a/AstuteClient2/src/app/login/login.component.html
+++ b/AstuteClient2/src/app/login/login.component.html
@@ -1,6 +1,11 @@
 <div class="page" style="width: 35%; margin: 20px auto auto;">
   <form class="form-signin" (ngSubmit)="login(f)" #f="ngForm" style="margin-bottom: 10px">
-    <h2 class="form-signin-heading">Login</h2>
+    <div class="row">
+      <div class="col-12">
+      <img src="assets/img/AstuteLogo.gif" height="100" width="230">
+      <h1 class="form-signin-heading text-right">Login</h1>
+      </div>
+    </div>
 
     <label for="username" class="sr-only">Username</label>
     <input class="form-control" type="text" id="username" name="username" ngModel  placeholder="Username">
diff --git a/AstuteClient2/src/app/login/login.component.ts b/AstuteClient2/src/app/login/login.component.ts
index 31ac549..3978ca2 100644
--- a/AstuteClient2/src/app/login/login.component.ts
+++ b/AstuteClient2/src/app/login/login.component.ts
@@ -25,7 +25,7 @@ export class LoginComponent implements OnInit {
 
         this.astuteClientService.login(username, password).then((data) => {
             if (data) {
-                this.router.navigate(['/home']);
+                this.router.navigate(['/homepage']);
             } else {
                 alert('login failed, checked credentials');
             }
diff --git a/AstuteClient2/src/app/sales-order/sales-order.component.html b/AstuteClient2/src/app/sales-order/sales-order.component.html
index 4f313ef..4fb7de2 100644
--- a/AstuteClient2/src/app/sales-order/sales-order.component.html
+++ b/AstuteClient2/src/app/sales-order/sales-order.component.html
@@ -59,7 +59,7 @@
           <td style="width: 20%"><span class="input-group-text">Contract Number</span></td>
           <td style="width: 30%"><input type="text" class="form-control" placeholder="External Contract Number" #contractnum></td>
           <td style="width: 20%"><span class="input-group-text">Contract Amount</span></td>
-          <td style="width: 30%"><input type="number" class="form-control" placeholder="Derived From Details" [value]="newContractAmount" #contractamt disabled></td>
+          <td style="width: 30%"><input type="text" class="form-control" placeholder="Derived From Details" [value]="newContractAmount | currency" #contractamt disabled></td>
         </tr>
       </tbody>
     </table>
diff --git a/AstuteClient2/src/app/services/astute-client-service.ts b/AstuteClient2/src/app/services/astute-client-service.ts
index ba92b90..10251cf 100644
--- a/AstuteClient2/src/app/services/astute-client-service.ts
+++ b/AstuteClient2/src/app/services/astute-client-service.ts
@@ -15,7 +15,8 @@ export class AstuteClientService {
   private invoiceDetailUrl = 'http://localhost:8080/astutesystem/invoice/detail';
   private invoiceGenUrl = 'http://localhost:8080/astutesystem/invoice/generatedInvoice';
   private invoicePaymentUrl = 'http://localhost:8080/astutesystem/invoicePayment';
-  private sessionId;
+  private sessionId=localStorage.getItem('');
+  private sessionString = `?sessionId=${this.sessionId}`;
 
   constructor(private http: HttpClient) { }
 
@@ -28,13 +29,15 @@ export class AstuteClientService {
     };
 
     return this.http
-      .post(this.authUrl, data, this.headers)
+      .post(this.authUrl, data)
       .toPromise()
       .then(response => {
         console.log(response['entity']);
-        const sessionId = response['entity'];
+        const name = response['entity'].name;
+        const sessionId = response['entity'].sessionId;
         if (sessionId != null) {
           localStorage.setItem('SESSION_ID', sessionId);
+            localStorage.setItem('SESSION_USER', name);
           return sessionId;
         } else {
           return null;
@@ -42,22 +45,37 @@ export class AstuteClientService {
       });
   }
 
-  private getSessionId(): string {
-    console.log(localStorage.getItem('SESSION_ID'));
-    return localStorage.getItem('SESSION_ID');
-  }
+    public logout() {
+        localStorage.removeItem('SESSION_ID');
+        localStorage.removeItem('SESSION_USER');
+        console.log(localStorage.getItem('SESSION_ID'));
+    }
+
+    public getSessionId(): string {
+        console.log(localStorage.getItem('SESSION_ID'));
+        return localStorage.getItem('SESSION_ID');
+    }
+
+    public getSessionUser(): string {
+        console.log(localStorage.getItem('SESSION_USER'));
+        return localStorage.getItem('SESSION_USER');
+    }
+
 
   // **************************************** Customer Service methods
 
   public getCustomers(): Promise<any> {
     console.log("*** In getCustomers()");
-    const url = `${this.customerUrl}`;
+    const url = `${this.customerUrl}${this.sessionString}`;
     return this.http.get(url)
       .toPromise()
       .then(response => {
         console.log(response['entity']);
         return response['entity'];
-      });
+      })
+        .catch( error => {
+            alert(error);
+        });
   }
 
   public updateCustomer(customerId: number, data: any): Promise<any> {
@@ -137,6 +155,7 @@ export class AstuteClientService {
   // Date deliverBy;
   public updatePODetail(ponum, lineItemNo, data) {
     console.log("*** In updatePODetail()");
+    const sessionId = localStorage.getItem('sessionId');
     const url = `${this.POUrl}/detail/${ponum}/${lineItemNo}`; //TODO send sessionId
     return this.http.put(url, data)
       .toPromise()