refactor(demo): move the demo app

This commit is contained in:
Ken Sodemann
2017-12-05 16:38:12 -06:00
parent 05a6f17379
commit 303cd75aaa
58 changed files with 9 additions and 6 deletions

View File

@ -0,0 +1,58 @@
import { Component } from '@angular/core';
import { AlertController } from '@ionic/angular';
@Component({
selector: 'app-alert-page',
template: `
<ion-app>
<ion-page class="show-page">
<ion-header>
<ion-toolbar>
<ion-title>Test</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-button (click)="clickMe()">Open Basic Alert</ion-button>
</ion-content>
</ion-page>
</ion-app>
`
})
export class AlertPageComponent {
constructor(private alertController: AlertController) {
}
clickMe() {
const alert = this.alertController.create({
title: 'ohhhh snap',
message: 'Ive been injected via Angular keeping the old api',
buttons: [
{
text: 'Cancel',
role: 'Cancel',
handler: () => {
// console.log('cancel');
}
},
{
text: 'Okay',
role: 'Okay',
handler: () => {
// console.log('okay');
}
}
]
});
alert.present().then(() => {
return alert.dismiss();
}).then(() => {
console.log('dismissed');
});
}
}

View File

@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AlertPageComponent } from './alert-page.component';
const routes: Routes = [
{ path: '', component: AlertPageComponent }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class AlertRoutingModule { }

View File

@ -0,0 +1,15 @@
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AlertPageComponent } from './alert-page.component';
import { AlertRoutingModule } from './alert-routing.module';
@NgModule({
imports: [
CommonModule,
AlertRoutingModule
],
declarations: [AlertPageComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AlertModule { }

View File

@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'basic-inputs', loadChildren: 'app/basic-inputs-page/basic-inputs-page.module#BasicInputsPageModule' },
{ path: 'group-inputs', loadChildren: 'app/group-inputs-page/group-inputs-page.module#GroupInputsPageModule' },
{ path: 'home', loadChildren: 'app/home-page/home-page.module#HomePageModule' },
{ path: 'alert', loadChildren: 'app/alert/alert.module#AlertModule' }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }

View File

@ -0,0 +1,2 @@
<router-outlet></router-outlet>

View File

@ -0,0 +1,20 @@
import { TestBed, async } from '@angular/core/testing';
import { RouterOutletStubComponent } from '../../testing/router-stubs';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach( async(() => {
TestBed.configureTestingModule({
declarations: [AppComponent, RouterOutletStubComponent]
}).compileComponents();
})
);
it('should create the app', async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
})
);
});

View File

@ -0,0 +1,10 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
}

View File

@ -0,0 +1,21 @@
import { BrowserModule } from '@angular/platform-browser';
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { AlertController } from '@ionic/angular';
@NgModule({
declarations: [AppComponent],
imports: [
AppRoutingModule,
BrowserModule,
],
providers: [
AlertController
],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule {}

View File

@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { BasicInputsPageComponent } from './basic-inputs-page.component';
const routes: Routes = [
{ path: '', component: BasicInputsPageComponent }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class BasicInputsPageRoutingModule { }

View File

@ -0,0 +1,138 @@
<div class="title">
Ionic Core Basic Inputs Demo
</div>
<ion-grid>
<ion-row>
<ion-col>
<h2>Text Input</h2>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label for="stdTextInput">Standard Input</label>
<input id="stdTextInput" name="stdTextInput" [(ngModel)]="textValue" minlength="10" />
</ion-col>
<ion-col>
Value:
<span id="textOutput">{{textValue}}</span>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-item>
<ion-label>Ionic Text Input</ion-label>
<ion-input id="ionTextInput" name="ionTextInput" [(ngModel)]="textValue" minlength="10" (ionBlur)="onBlur($event)"></ion-input>
</ion-item>
</ion-col>
<ion-col>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h2>Textarea Input</h2>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label for="stdTextareaInput">Standard Textarea Input</label>
<textarea id="stdTextareaInput" name="stdTextareaInput" [(ngModel)]="textareaValue" minlength="10"></textarea>
</ion-col>
<ion-col>
Value:
<span id="textareaOutput">{{textareaValue}}</span>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-item>
<ion-label>Ionic Textarea Input</ion-label>
<ion-textarea id="ionTextareaInput" name="ionTextareaInput" [(ngModel)]="textareaValue" minlength="10" (ionBlur)="onBlur($event)"></ion-textarea>
</ion-item>
</ion-col>
<ion-col>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h2>Checkbox</h2>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label for="stdCheckbox">Standard Checkbox</label>
<input type="checkbox" id="stdCheckbox" name="stdCheckbox" [(ngModel)]="checkboxValue" (blur)="onBlur($event)" />
</ion-col>
<ion-col>
Value:
<span id="checkboxOutput">{{checkboxValue}}</span>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-item>
<ion-label>Ionic Checkbox</ion-label>
<ion-checkbox id="ionCheckbox" name="ionCheckbox" [(ngModel)]="checkboxValue" (ionBlur)="onBlur($event)"></ion-checkbox>
</ion-item>
</ion-col>
<ion-col>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h2>Toggle</h2>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label for="stdToggle">Standard Toggle</label>
<input type="checkbox" id="stdToggle" name="stdToggle" [(ngModel)]="toggleValue" (blur)="onBlur($event)" />
</ion-col>
<ion-col>
Value:
<span id="toggleOutput">{{toggleValue}}</span>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-item>
<ion-label>Ionic Toggle</ion-label>
<ion-toggle id="ionToggle" name="ionToggle" [(ngModel)]="toggleValue" (ionBlur)="onBlur($event)"></ion-toggle>
</ion-item>
</ion-col>
<ion-col>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h2>Date Time Picker</h2>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label for="stdToggle">ISO Formatted Date</label>
<input id="stdDatetimeInput" name="stdDatetimeInput" [(ngModel)]="datetimeValue" placeholder="YYYY-MM-DDTHH:mm:ssZ" />
</ion-col>
<ion-col>
Value:
<span id="datetimeOutput">{{datetimeValue}}</span>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-item>
<ion-label>Ionic Date</ion-label>
<ion-datetime id="ionDatetimeInput" pickerFormat="YYYY-MM-DD HH:mm:ss" displayFormat="MM/DD/YYYY HH:mm:ss" name="ionDatetimeInput" [(ngModel)]="datetimeValue"></ion-datetime>
</ion-item>
</ion-col>
<ion-col>
</ion-col>
</ion-row>
</ion-grid>
<a href='home'>Home</a>

View File

@ -0,0 +1,55 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { SharedModule } from '../shared/shared.module';
import { BasicInputsPageComponent } from './basic-inputs-page.component';
describe('InputsTestPageComponent', () => {
let component: BasicInputsPageComponent;
let fixture: ComponentFixture<BasicInputsPageComponent>;
beforeEach(
async(() => {
TestBed.configureTestingModule({
declarations: [BasicInputsPageComponent],
imports: [FormsModule, SharedModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
})
);
beforeEach(() => {
fixture = TestBed.createComponent(BasicInputsPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
describe('testInputOne binding', () => {
let input;
beforeEach(
fakeAsync(() => {
component.ngOnInit();
fixture.detectChanges();
tick();
input = fixture.debugElement.query(By.css('#stdTextInput')).nativeElement;
// This is what I ultimtely want to test...
//
// const ionInput = fixture.debugElement.query(By.css('#ionTextInput'));
// input = ionInput.query(By.css('input')).nativeElement;
})
);
it('should reflect changes to the input', () => {
expect(input).toBeTruthy();
input.value = 'Frank';
input.dispatchEvent(new Event('input'));
expect(component.textValue).toEqual('Frank');
});
});
});

View File

@ -0,0 +1,28 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-basic-inputs-page',
templateUrl: './basic-inputs-page.component.html',
styleUrls: ['./basic-inputs-page.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class BasicInputsPageComponent implements OnInit {
datetimeValue = '2017-11-18T14:17:45-06:00';
textareaValue = 'This is the Textarea Input';
textValue = 'This is the Text Input';
checkboxValue = true;
toggleValue = false;
constructor() {}
ngOnInit() {}
onBlur(evt) {
console.log('blur: ', evt);
}
change(evt) {
console.log('change: ', evt);
}
}

View File

@ -0,0 +1,19 @@
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { IonicAngularModule } from '@ionic/angular';
import { BasicInputsPageComponent } from './basic-inputs-page.component';
import { BasicInputsPageRoutingModule } from './basic-inputs-page-routing.module';
@NgModule({
imports: [
BasicInputsPageRoutingModule,
CommonModule,
FormsModule,
IonicAngularModule
],
declarations: [BasicInputsPageComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class BasicInputsPageModule {}

View File

@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { GroupInputsPageComponent } from './group-inputs-page.component';
const routes: Routes = [
{ path: '', component: GroupInputsPageComponent }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class GroupInputsPageRoutingModule { }

View File

@ -0,0 +1,158 @@
<div class="title">
Ionic Core Group Inputs Demo
</div>
<ion-grid>
<ion-row>
<ion-col>
<h2>Radio Buttons</h2>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h3>Angular</h3>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<input id="stdBeef" type="radio" value="beef" [(ngModel)]="radioValue" />
<label for="stdBeef">Carne Asada</label>
<input id="stdTongue" type="radio" value="tongue" [(ngModel)]="radioValue" />
<label for="stdTongue">Lengua</label>
<input id="stdBrains" type="radio" value="brains" [(ngModel)]="radioValue" />
<label for="stdBrains">Sesos</label>
<input id="stdTripe" type="radio" value="tripe" [(ngModel)]="radioValue" />
<label for="stdTripe">Tripa</label>
<input id="stdChicken" type="radio" value="chicken" [(ngModel)]="radioValue" />
<label for="stdChicken">Pollo</label>
</ion-col>
<ion-col>
Value:
<span id="radioOutput">{{radioValue}}</span>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h3>Ionic With Radio Group</h3>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-list>
<ion-radio-group id="radio-group" [(ngModel)]="radioValue">
<ion-item>
<ion-label>Crarne Asada</ion-label>
<ion-radio id="ion-grp-beef" value="beef"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Lengua</ion-label>
<ion-radio id="ion-grp-tongue" value="tongue"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Sesos</ion-label>
<ion-radio id="ion-grp-brains" value="brains"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Tripa</ion-label>
<ion-radio id="ion-grp-tripe" value="tripe"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Pollo</ion-label>
<ion-radio id="ion-grp-chicken" value="chicken"></ion-radio>
</ion-item>
</ion-radio-group>
</ion-list>
</ion-col>
<ion-col></ion-col>
</ion-row>
<ion-row>
<ion-col>
<h3>Ionic Without Radio Group</h3>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-list>
<ion-item>
<ion-label>Crarne Asada</ion-label>
<ion-radio value="beef" id="ion-beef" name="tacos" [(ngModel)]="radioValue"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Lengua</ion-label>
<ion-radio value="tongue" id="ion-tongue" name="tacos" [(ngModel)]="radioValue"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Sesos</ion-label>
<ion-radio value="brains" id="ion-brains" name="tacos" [(ngModel)]="radioValue"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Tripa</ion-label>
<ion-radio value="tripe" id="ion-tripe" name="tacos" [(ngModel)]="radioValue"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Pollo</ion-label>
<ion-radio value="chicken" id="ion-chicken" name="tacos" [(ngModel)]="radioValue"></ion-radio>
</ion-item>
</ion-list>
</ion-col>
<ion-col></ion-col>
</ion-row>
<ion-row>
<ion-col>
<h2>Ionic Segment</h2>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-segment id="segment" color="primary" [(ngModel)]="radioValue">
<ion-segment-button value="beef" id="ion-seg-beef">Carne Asada</ion-segment-button>
<ion-segment-button value="tongue" id="ion-seg-tongue">Lengua</ion-segment-button>
<ion-segment-button value="brains" id="ion-seg-brains">Sesos</ion-segment-button>
<ion-segment-button value="tripe" id="ion-seg-tripe">Tripa</ion-segment-button>
<ion-segment-button value="chicken" id="ion-seg-chicken">Pollo</ion-segment-button>
</ion-segment>
</ion-col>
<ion-col></ion-col>
</ion-row>
<ion-row>
<ion-col>
<h2>Select</h2>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<label for="stdSelect">Standard Select (for tacos)</label>
<select id="stdSelect" name="stdSelect" [(ngModel)]="selectValue">
<option value="beef">Carne Asada</option>
<option value="tongue">Lengua</option>
<option value="brains">Sesos</option>
<option value="tripe">Tripa</option>
<option value="chicken">Pollo</option>
</select>
</ion-col>
<ion-col>
Value:
<span id="selectOutput">{{selectValue}}</span>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-item>
<ion-label>Ionic Select (for tacos)</ion-label>
<ion-select id="ionSelect" name="ionSelect" [(ngModel)]="selectValue">
<ion-select-option value="beef">Carne Asada</ion-select-option>
<ion-select-option value="tongue">Lengua</ion-select-option>
<ion-select-option value="brains">Sesos</ion-select-option>
<ion-select-option value="tripe">Tripa</ion-select-option>
<ion-select-option value="chicken">Pollo</ion-select-option>
</ion-select>
</ion-item>
</ion-col>
<ion-col>
</ion-col>
</ion-row>
</ion-grid>
<a href='home'>Home</a>

View File

@ -0,0 +1,31 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { GroupInputsPageComponent } from './group-inputs-page.component';
import { SharedModule } from '../shared/shared.module';
describe('GroupInputsPageComponent', () => {
let component: GroupInputsPageComponent;
let fixture: ComponentFixture<GroupInputsPageComponent>;
beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [FormsModule, SharedModule],
declarations: [GroupInputsPageComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
}).compileComponents();
})
);
beforeEach(() => {
fixture = TestBed.createComponent(GroupInputsPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,16 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-group-inputs-page',
templateUrl: './group-inputs-page.component.html',
styleUrls: ['./group-inputs-page.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class GroupInputsPageComponent implements OnInit {
radioValue = 'tripe';
selectValue = 'brains';
constructor() {}
ngOnInit() {}
}

View File

@ -0,0 +1,19 @@
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicAngularModule } from '@ionic/angular';
import { GroupInputsPageComponent } from './group-inputs-page.component';
import { GroupInputsPageRoutingModule } from './group-inputs-page-routing.module';
@NgModule({
imports: [
CommonModule,
FormsModule,
GroupInputsPageRoutingModule,
IonicAngularModule
],
declarations: [GroupInputsPageComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class GroupInputsPageModule {}

View File

@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomePageComponent } from './home-page.component';
const routes: Routes = [
{ path: '', component: HomePageComponent }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class HomePageRoutingModule { }

View File

@ -0,0 +1,15 @@
<div class='title'>
Ionic Core Angular Demo Application
</div>
<ul>
<li>
<a href='basic-inputs'>Basic Inputs Test Page</a>
</li>
<li>
<a href='group-inputs'>Group Inputs Test Page</a>
</li>
<li>
<a href='alert'>Alert Page</a>
</li>
</ul>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HomePageComponent } from './home-page.component';
describe('HomePageComponent', () => {
let component: HomePageComponent;
let fixture: ComponentFixture<HomePageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomePageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HomePageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,15 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'app-home-page',
templateUrl: './home-page.component.html',
styleUrls: ['./home-page.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class HomePageComponent implements OnInit {
constructor() { }
ngOnInit() { }
}

View File

@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HomePageComponent } from './home-page.component';
import { HomePageRoutingModule } from './home-page-routing.module';
@NgModule({
imports: [
CommonModule,
HomePageRoutingModule
],
declarations: [HomePageComponent]
})
export class HomePageModule { }