diff --git a/src/app/app.component.html b/src/app/app.component.html
index 258196c..c55026f 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -8,35 +8,7 @@
-
@@ -64,188 +36,3 @@
-
-
Resources
-
Here are some links to help you get started:
-
-
-
-
-
Next Steps
-
What do you want to do next with your app?
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Run and Watch Tests
-
-
-
-
-
-
Build for Production
-
-
-
-
-
-
ng generate component xyz
-
ng add @angular/material
-
ng add _____
-
ng test
-
ng build --prod
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 9ff817c..8337328 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -5,18 +5,22 @@ import { AppComponent } from './app.component';
import { GraphQLModule } from './graphql.module';
import { HttpClientModule } from '@angular/common/http';
import { ExchangeRatesComponent } from './exchange-rates/exchange-rates.component';
+import { PersonalityComponent } from './personality/personality.component';
@NgModule({
- declarations: [
- AppComponent,
- ExchangeRatesComponent
- ],
- imports: [
- BrowserModule,
- GraphQLModule,
- HttpClientModule
- ],
- providers: [],
- bootstrap: [AppComponent]
+ declarations: [
+ AppComponent,
+ ExchangeRatesComponent,
+ PersonalityComponent
+ ],
+ imports: [
+ BrowserModule,
+ GraphQLModule,
+ HttpClientModule
+ ],
+ providers: [],
+ bootstrap: [
+ AppComponent
+ ]
})
export class AppModule { }
diff --git a/src/app/exchange-rates/exchange-rates.component.html b/src/app/exchange-rates/exchange-rates.component.html
index af6b27d..ef1e9e3 100644
--- a/src/app/exchange-rates/exchange-rates.component.html
+++ b/src/app/exchange-rates/exchange-rates.component.html
@@ -1,4 +1,4 @@
-This component is made by me! The information below is queried from a GraphQL server that gave me exchange rates:
+
Loading...
@@ -6,8 +6,23 @@
Error :(
-
-
-
{{rate.currency}}: {{rate.rate}}
-
-
\ No newline at end of file
+
+
I like to do things last minuite
+
+
I have trouble managing my time
+
+
I like fire
+
+
I like water
+
+
I like grass for some reason
+
+
I really need help
+
+
I want to free myself of this pain
+
+
+
+
diff --git a/src/app/exchange-rates/exchange-rates.component.spec.ts b/src/app/exchange-rates/exchange-rates.component.spec.ts
index 08edf1d..ad10df7 100644
--- a/src/app/exchange-rates/exchange-rates.component.spec.ts
+++ b/src/app/exchange-rates/exchange-rates.component.spec.ts
@@ -2,6 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { GraphQLModule } from '../graphql.module';
import { ExchangeRatesComponent } from './exchange-rates.component';
import { HttpClientModule } from '@angular/common/http';
+import { FieldsOnCorrectTypeRule } from 'graphql';
describe('ExchangeRatesComponent', () => {
let component: ExchangeRatesComponent;
@@ -15,13 +16,36 @@ describe('ExchangeRatesComponent', () => {
.compileComponents();
}));
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+ it('should create', () => {
+ expect(component.pokemon).toBeFalsy();
+ });
+ it('should create', () => {
+ expect(component.pokemonid).toBeFalsy();
+ });
+ it('should create', () => {
+ expect(component.pokemonmoves).toBeFalsy();
+ });
+
beforeEach(() => {
fixture = TestBed.createComponent(ExchangeRatesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ spyOn(component, 'whatAmI');
+ expect(component.pokemon).toBeTruthy();
+ expect(component.pokemonid).toBeTruthy();
+ expect(component.pokemonmoves).toBeTruthy();
+
});
- it('should create', () => {
- expect(component).toBeTruthy();
+ beforeEach(() => {
+ fixture = TestBed.createComponent(ExchangeRatesComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ spyOn(component, 'getMoreInfo');
+ expect(window.alert).toHaveBeenCalledWith("You havent revealed your pokemon yet!!!");
});
+
});
diff --git a/src/app/exchange-rates/exchange-rates.component.ts b/src/app/exchange-rates/exchange-rates.component.ts
index c154c1a..af89bcd 100644
--- a/src/app/exchange-rates/exchange-rates.component.ts
+++ b/src/app/exchange-rates/exchange-rates.component.ts
@@ -1,36 +1,105 @@
-import { Component, OnInit } from '@angular/core';
-import {Apollo} from 'apollo-angular';
-import gql from 'graphql-tag';
-import { ApolloQueryResult } from 'apollo-client';
+import { Component, OnInit } from "@angular/core";
+import { Apollo } from "apollo-angular";
+import gql from "graphql-tag";
+import { ApolloQueryResult } from "apollo-client";
@Component({
- selector: 'app-exchange-rates',
- templateUrl: './exchange-rates.component.html',
- styleUrls: ['./exchange-rates.component.css']
+ selector: "app-exchange-rates",
+ templateUrl: "./exchange-rates.component.html",
+ styleUrls: ["./exchange-rates.component.css"]
})
export class ExchangeRatesComponent implements OnInit {
rates: any[];
+
loading = true;
error: any;
-
+ myCount: number = 0;
+ totalnum: number;
+ pokemon: string;
+ pokemonmoves: any[];
+ pokemonid: string;
constructor(private apollo: Apollo) {}
-
ngOnInit() {
this.apollo
.watchQuery({
+ // {
+ // rates(currency: "USD") {
+ // currency
+ // rate
+ // }
+ // }
+
query: gql`
{
- rates(currency: "USD") {
- currency
- rate
+ pokemons(first: 1000) {
+ name
}
}
- `,
+ `
})
.valueChanges.subscribe((result: ApolloQueryResult
) => {
- this.rates = result.data && result.data.rates;
+ this.rates = result.data.pokemons;
this.loading = result.loading;
this.error = result.errors;
+ this.totalnum = this.rates.length;
});
}
+ onNotify($event: any) {
+ console.log($event);
+ this.myCount += $event;
+ console.log(this.totalnum);
+ }
+ whatAmI() {
+ this.pokemon = this.rates[
+ (this.myCount * this.myCount) % this.totalnum
+ ].name;
+ window.alert(this.pokemon);
+ this.getInfo();
+ }
+ getInfo() {
+ const pokemoninfo = gql`
+ query pokemoninfo($name: String!) {
+ pokemon(name: $name) {
+ id
+ number
+ name
+ attacks {
+ special {
+ name
+ type
+ damage
+ }
+ }
+ }
+ }
+ `;
+
+ this.apollo
+ .watchQuery({
+ query: pokemoninfo,
+ variables: {
+ name: this.pokemon
+ }
+ })
+ .valueChanges.subscribe((result: ApolloQueryResult) => {
+ this.pokemonmoves = result.data.pokemon.attacks.special;
+ this.pokemonid = result.data.pokemon.id;
+ }); // do whatever
+
+ // 1, "string", false
+ }
+
+ getMoreInfo() {
+ if (!this.pokemon) {
+ // if a is negative,undefined,null,empty value then...
+ window.alert("You havent revealed your pokemon yet!!!"); // do whatever
+ } else {
+ window.alert("Your pokemon name is " + this.pokemon);
+
+ window.alert("Your pokemon id is " + this.pokemonid);
+ for (let move of this.pokemonmoves) {
+ window.alert("You can do " + move.name + " attack!");
+ }
+ }
+ }
}
diff --git a/src/app/graphql.module.ts b/src/app/graphql.module.ts
index c09af00..8e39ea3 100644
--- a/src/app/graphql.module.ts
+++ b/src/app/graphql.module.ts
@@ -3,7 +3,7 @@ import {ApolloModule, APOLLO_OPTIONS} from 'apollo-angular';
import {HttpLinkModule, HttpLink} from 'apollo-angular-link-http';
import {InMemoryCache} from 'apollo-cache-inmemory';
-const uri = 'https://o5x5jzoo7z.sse.codesandbox.io/graphql'; // <-- change the URL to point to Yelp GraphQL server, this is just a test server
+const uri = 'https://graphql-pokemon.now.sh/'; // <-- change the URL to point to Yelp GraphQL server, this is just a test server
export function createApollo(httpLink: HttpLink) {
return {
link: httpLink.create({uri}),
diff --git a/src/app/personality/personality.component.css b/src/app/personality/personality.component.css
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/personality/personality.component.html b/src/app/personality/personality.component.html
new file mode 100644
index 0000000..5935d6b
--- /dev/null
+++ b/src/app/personality/personality.component.html
@@ -0,0 +1,4 @@
+
+
+ {{item}}
+
diff --git a/src/app/personality/personality.component.spec.ts b/src/app/personality/personality.component.spec.ts
new file mode 100644
index 0000000..7830f36
--- /dev/null
+++ b/src/app/personality/personality.component.spec.ts
@@ -0,0 +1,30 @@
+/* tslint:disable:no-unused-variable */
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
+import { DebugElement } from '@angular/core';
+
+import { PersonalityComponent } from './personality.component';
+
+describe('PersonalityComponent', () => {
+ let component: PersonalityComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ PersonalityComponent ]
+ })
+ .compileComponents();
+ }));
+
+
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(PersonalityComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/personality/personality.component.ts b/src/app/personality/personality.component.ts
new file mode 100644
index 0000000..eeeee30
--- /dev/null
+++ b/src/app/personality/personality.component.ts
@@ -0,0 +1,23 @@
+import { Component, OnInit } from '@angular/core';
+import { Output, EventEmitter } from '@angular/core'
+@Component({
+ selector: 'app-personality',
+ templateUrl: './personality.component.html',
+ styleUrls: ['./personality.component.css']
+})
+export class PersonalityComponent implements OnInit {
+ @Output() notify = new EventEmitter();
+
+ submitNum($event: any) {
+ this.notify.emit($event);
+
+
+ }
+ constructor() { }
+
+ ngOnInit() {
+ }
+
+
+
+}