Skip to content

Commit

Permalink
Add navbar skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
marvac committed Jan 8, 2019
1 parent 4f2ae4f commit e72545c
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 10 deletions.
5 changes: 2 additions & 3 deletions Client/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<!--The content below is only a placeholder and can be replaced.-->
<div>
<nav-menu></nav-menu>
<h1>
Welcome to {{ title }}!
</h1>
<app-value></app-value>
</div>



8 changes: 6 additions & 2 deletions Client/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule } from '@angular/forms';

import { AppComponent } from './app.component';
import { ValueComponent } from './value/value.component';
import { NavMenuComponent } from './components/nav-menu/nav-menu.component';

@NgModule({
declarations: [
AppComponent,
ValueComponent
ValueComponent,
NavMenuComponent
],
imports: [
BrowserModule,
HttpClientModule
HttpClientModule,
FormsModule
],
providers: [],
bootstrap: [AppComponent]
Expand Down
Empty file.
22 changes: 22 additions & 0 deletions Client/src/app/components/nav-menu/nav-menu.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<a class="navbar-brand" href="#">Friendster</a>

<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Friends</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Lists</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Messages</a>
</li>
</ul>

<form #loginForm="ngForm" class="form-inline my-2 my-lg-0" (ngSubmit)="login()">
<input class="form-control mr-sm-2" type="text" name="username" placeholder="Username" required [(ngModel)]="model.username">
<input class="form-control mr-sm-2" type="password" name="password" placeholder="Password" required [(ngModel)]="model.password">
<button [disabled]="!loginForm.valid" class="btn btn-primary my-2 my-sm-0" type="submit">Login</button>
</form>

</nav>
25 changes: 25 additions & 0 deletions Client/src/app/components/nav-menu/nav-menu.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { NavMenuComponent } from './nav-menu.component';

describe('NavMenuComponent', () => {
let component: NavMenuComponent;
let fixture: ComponentFixture<NavMenuComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NavMenuComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(NavMenuComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
19 changes: 19 additions & 0 deletions Client/src/app/components/nav-menu/nav-menu.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'nav-menu',
templateUrl: './nav-menu.component.html',
styleUrls: ['./nav-menu.component.css']
})
export class NavMenuComponent implements OnInit {
model: any = {};

constructor() { }

ngOnInit() {
}

login() {
console.log(this.model);
}
}
1 change: 0 additions & 1 deletion Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public async Task<ActionResult<IEnumerable<Value>>> Get()
return Ok(values);
}


[AllowAnonymous]
[HttpGet("{id}")]
public async Task<ActionResult<Value>> Get(int id)
Expand Down
2 changes: 0 additions & 2 deletions Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Friendster": {
"commandName": "Project",
"launchBrowser": false,
"launchUrl": "api/values",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
13 changes: 11 additions & 2 deletions Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SpaServices.AngularCli;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -26,7 +27,6 @@ public Startup(IConfiguration configuration)

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<DataContext>(options =>
Expand All @@ -53,7 +53,6 @@ public void ConfigureServices(IServiceCollection services)
services.AddCors();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
Expand All @@ -70,6 +69,16 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseAuthentication();
app.UseMvc();

app.UseSpa(spa =>
{
spa.Options.SourcePath = "Client";

if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start");
}
});
}
}
}

0 comments on commit e72545c

Please sign in to comment.