From cfee6ac8fdcedc9db6e43e2007927427a7e0fa17 Mon Sep 17 00:00:00 2001 From: AdamFraley Date: Tue, 24 May 2022 14:31:35 -0700 Subject: [PATCH 1/3] lab07 progress save --- code/adam/javascript/lab07/index.html | 53 ++++++++++++++++ code/adam/javascript/lab07/script.js | 91 +++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 code/adam/javascript/lab07/index.html create mode 100644 code/adam/javascript/lab07/script.js diff --git a/code/adam/javascript/lab07/index.html b/code/adam/javascript/lab07/index.html new file mode 100644 index 00000000..05013be8 --- /dev/null +++ b/code/adam/javascript/lab07/index.html @@ -0,0 +1,53 @@ + + + + + + + Lab07 + + + + + + +
+

MiniCapstone API

+ +
+ + + + + +
+ + + +
+ +
    +
  • {{ craft.name }}
  • +
  • {{ craft.description }}
  • +
  • {{ craft.status.name }}
  • +
+
+
+
+ + + +
+
+ + + +
+ + + + \ No newline at end of file diff --git a/code/adam/javascript/lab07/script.js b/code/adam/javascript/lab07/script.js new file mode 100644 index 00000000..59a126dd --- /dev/null +++ b/code/adam/javascript/lab07/script.js @@ -0,0 +1,91 @@ +axios({ + url: 'https://lldev.thespacedevs.com/2.2.0/spacecraft', + method: 'get', + headers: { + Accept: 'application/json' + } +}).then(res => { + console.log(res.data.next) +}) + +const App = { + data () { + return { + searchTerm: '', + baseUrl: 'https://lldev.thespacedevs.com/2.2.0/', + imageUrl: '', + spacecraft: [], + searchCraft: '', + nextUrl:'', + previousUrl: '', + url: 'https://lldev.thespacedevs.com/2.2.0/spacecraft/', + limit: 10, + offset: 0 // methods that do this.offset += 10 or this.offset -= 10 + } + }, + + methods: { + getCraft () { + //console.log(res.data.results[0]) + axios({ + url: this.baseUrl + 'spacecraft/', // url: this.url, + headers: { Accept: 'application/json' }, + method: 'get', + // params: { limit: 10, offset: 0 } + }).then(res=> { + console.log(res.data) + this.spacecraft = res.data.results + console.log(this.spacecraft) + this.imageUrl = res.data.results[0].spacecraft_config.image_url + this.nextUrl = res.data.next + console.log(res.data.next) + // this.url = res.data.next + }) + }, + nextPage() { + axios({ + url: this.nextUrl, + headers: { Accept: 'application/json' }, + method: 'get', + }).then(res=> { + this.spacecraft = res.data.results + this.nextUrl = res.data.next + this.previousUrl = res.data.previous + console.log(res.data) + console.log('nextUrl '+this.nextUrl) + console.log('previousUrl '+this.previousUrl) + }) + }, + previousPage() { + axios({ + url: this.previousUrl, + method: 'get', + headers: { Accept: 'application/json' }, + }).then(res=> { + this.spacecraft = res.data.results + this.nextUrl = res.data.next + this.previousUrl = res.data.previous + console.log(res.data) + console.log(res.data.next) + }) + }, + searchKeyword() { + axios({ + url: this.baseUrl + 'spacecraft/', + headers: { Accept: 'application/json' }, + params: { search: this.searchTerm }, + method: 'get', + }).then(res=> { + console.log(res.data) + console.log(res.data.results[0].name) + this.spacecraft = res.data.results + this.nextUrl = res.data.next + this.previousUrl = res.data.previous + }) + } + + } +} + +const app = Vue.createApp(App) +app.mount('#app') \ No newline at end of file From a07b4b4725bd13ea4078537afeadb8f1e60f5212 Mon Sep 17 00:00:00 2001 From: AdamFraley Date: Tue, 24 May 2022 16:32:11 -0700 Subject: [PATCH 2/3] progress save lab07 --- code/adam/javascript/lab07/index.html | 41 +++++++++++++++------------ code/adam/javascript/lab07/script.js | 27 ++++++++++++------ 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/code/adam/javascript/lab07/index.html b/code/adam/javascript/lab07/index.html index 05013be8..8678e4e1 100644 --- a/code/adam/javascript/lab07/index.html +++ b/code/adam/javascript/lab07/index.html @@ -8,24 +8,37 @@ +
-

MiniCapstone API

- -
+

Exploring Space Craft

+

MiniCapstone API

+ + +
+ + + + +
+ +
- + - -
- + -
- + +
+
  • {{ craft.name }}
  • {{ craft.description }}
  • @@ -33,15 +46,7 @@

    MiniCapstone API

-
- - - -
+
diff --git a/code/adam/javascript/lab07/script.js b/code/adam/javascript/lab07/script.js index 59a126dd..e0761159 100644 --- a/code/adam/javascript/lab07/script.js +++ b/code/adam/javascript/lab07/script.js @@ -1,19 +1,19 @@ axios({ - url: 'https://lldev.thespacedevs.com/2.2.0/spacecraft', + url: 'https://lldev.thespacedevs.com/2.2.0/launch', method: 'get', headers: { Accept: 'application/json' } }).then(res => { - console.log(res.data.next) + console.log(res.data.results) }) const App = { data () { return { + searchType: '', searchTerm: '', baseUrl: 'https://lldev.thespacedevs.com/2.2.0/', - imageUrl: '', spacecraft: [], searchCraft: '', nextUrl:'', @@ -26,17 +26,17 @@ const App = { methods: { getCraft () { - //console.log(res.data.results[0]) + //console.log(res.data) axios({ url: this.baseUrl + 'spacecraft/', // url: this.url, headers: { Accept: 'application/json' }, method: 'get', - // params: { limit: 10, offset: 0 } + params: { status: this.searchType,} //limit: 10, offset: 0 }).then(res=> { console.log(res.data) + console.log(this.searchType) this.spacecraft = res.data.results - console.log(this.spacecraft) - this.imageUrl = res.data.results[0].spacecraft_config.image_url + console.log(this.spacecraft[0].spacecraft_config.in_use) this.nextUrl = res.data.next console.log(res.data.next) // this.url = res.data.next @@ -73,15 +73,26 @@ const App = { axios({ url: this.baseUrl + 'spacecraft/', headers: { Accept: 'application/json' }, - params: { search: this.searchTerm }, + params: { search: this.searchTerm, status: this.searchType }, method: 'get', }).then(res=> { console.log(res.data) console.log(res.data.results[0].name) + console.log(res.data.results[0].spacecraft_config.in_use) this.spacecraft = res.data.results this.nextUrl = res.data.next this.previousUrl = res.data.previous }) + }, + + getLaunch() { + axois({ + url: this.baseUrl + 'launch/', + headers: { Accept: 'application/json'}, + method: 'get', + }).then(res=> { + console.log(res.data) + }) } } From 476aae560e6184bf7ab5cd879d6ab990f2d67c0b Mon Sep 17 00:00:00 2001 From: AdamFraley Date: Thu, 26 May 2022 15:15:18 -0700 Subject: [PATCH 3/3] lab07 Vue mini-Capstone complete --- code/adam/javascript/lab07/index.html | 63 ++++++++++++--- code/adam/javascript/lab07/script.js | 106 ++++++++++++++++++++++---- 2 files changed, 145 insertions(+), 24 deletions(-) diff --git a/code/adam/javascript/lab07/index.html b/code/adam/javascript/lab07/index.html index 8678e4e1..3ed3ec21 100644 --- a/code/adam/javascript/lab07/index.html +++ b/code/adam/javascript/lab07/index.html @@ -11,13 +11,13 @@ - +
-

Exploring Space Craft

-

MiniCapstone API

+

Exploring Space Craft & Launches

+

MiniCapstone API

- -
+ + +
+

Space Craft 🌌

- - + +
@@ -45,12 +47,51 @@

MiniCapstone API

  • {{ craft.status.name }}
  • + +
    +
    +

    Upcoming Launches 🚀

    +
    +
    +
    + + +
    + +
      +
    • {{ launch.name }}
    • +
    • {{ launch.launch_service_provider.name }}
    • +
    • {{ launch.launch_service_provider.type }}
    • +
    • {{ launch.mission.description }}
    • +
    • {{ launch.status.name }}
    • +
    +
    +
    - +
    +

    Search Launches 🚀

    +
    + + + +
    + + +
    - -
    diff --git a/code/adam/javascript/lab07/script.js b/code/adam/javascript/lab07/script.js index e0761159..7d7fd816 100644 --- a/code/adam/javascript/lab07/script.js +++ b/code/adam/javascript/lab07/script.js @@ -1,11 +1,11 @@ axios({ - url: 'https://lldev.thespacedevs.com/2.2.0/launch', + url: 'https://lldev.thespacedevs.com/2.2.0/launch/?mode=list&search=SpaceX', method: 'get', headers: { Accept: 'application/json' } }).then(res => { - console.log(res.data.results) + console.log(res.data) }) const App = { @@ -15,12 +15,21 @@ const App = { searchTerm: '', baseUrl: 'https://lldev.thespacedevs.com/2.2.0/', spacecraft: [], + allSpacecraft: [], searchCraft: '', nextUrl:'', previousUrl: '', url: 'https://lldev.thespacedevs.com/2.2.0/spacecraft/', limit: 10, - offset: 0 // methods that do this.offset += 10 or this.offset -= 10 + offset: 0, // methods that do this.offset += 10 or this.offset -= 10 + upcomingLaunches: [], + upcomingLaunchesAll: [], + previousUrlLaunch: '', + previousUrlLaunchSearch: '', + nextUrlLaunch: '', + nextUrlLaunchSearch: '', + searchLaunch: '', + launchesSearched: [], } }, @@ -31,12 +40,12 @@ const App = { url: this.baseUrl + 'spacecraft/', // url: this.url, headers: { Accept: 'application/json' }, method: 'get', - params: { status: this.searchType,} //limit: 10, offset: 0 + params: { status: this.searchType} //limit: 10, offset: 0 }).then(res=> { - console.log(res.data) + console.log(res.data.results) console.log(this.searchType) this.spacecraft = res.data.results - console.log(this.spacecraft[0].spacecraft_config.in_use) + // this.spacecraft = this.allSpacecraft[Math.floor(Math.random()*this.allspacecraft.length)] this.nextUrl = res.data.next console.log(res.data.next) // this.url = res.data.next @@ -51,6 +60,7 @@ const App = { this.spacecraft = res.data.results this.nextUrl = res.data.next this.previousUrl = res.data.previous + // this.nextUrlLaunch = res.data.next console.log(res.data) console.log('nextUrl '+this.nextUrl) console.log('previousUrl '+this.previousUrl) @@ -64,7 +74,7 @@ const App = { }).then(res=> { this.spacecraft = res.data.results this.nextUrl = res.data.next - this.previousUrl = res.data.previous + // this.previousUrl = res.data.previous console.log(res.data) console.log(res.data.next) }) @@ -77,24 +87,94 @@ const App = { method: 'get', }).then(res=> { console.log(res.data) - console.log(res.data.results[0].name) - console.log(res.data.results[0].spacecraft_config.in_use) this.spacecraft = res.data.results this.nextUrl = res.data.next this.previousUrl = res.data.previous }) }, + launchSearch() { + axios({ + url: 'https://lldev.thespacedevs.com/2.2.0/launch/?mode=list&search=' + this.launchSearch, + headers: { Accept: 'application/json' }, + params: { search: this.searchLaunch }, + method: 'get', + }).then(res=> { + console.log(this.searchLaunch) + console.log(res.data) + this.launchesSearched = res.data.results + this.nextUrlLaunchSearch = res.data.next + this.previousUrlLaunchSearch = res.data.previous + console.log(this.nextUrlLaunchSearch) + }) + }, + getLaunch() { - axois({ - url: this.baseUrl + 'launch/', + axios({ + url: 'https://lldev.thespacedevs.com/2.2.0/launch/upcoming', headers: { Accept: 'application/json'}, method: 'get', }).then(res=> { + this.nextUrlLaunch = res.data.next + this.previousUrlLaunch = res.data.previous + this.upcomingLaunches = res.data.results + }) + }, + + nextPageLaunch() { + axios({ + url: this.nextUrlLaunch, + headers: { Accept: 'application/json' }, + method: 'get', + }).then(res=> { + this.upcomingLaunches = res.data.results + this.nextUrlLaunch = res.data.next + this.previousUrlLaunch = res.data.previous console.log(res.data) }) - } - + }, + + previousPageLaunch() { + axios({ + url: this.previousUrlLaunch, + method: 'get', + headers: { Accept: 'application/json' }, + }).then(res=> { + this.upcomingLaunches = res.data.results + this.nextUrlLaunch = res.data.next + this.previousUrlLaunch = res.data.previous + console.log(res.data) + console.log(res.data.next) + }) + }, + + nextPageLaunchSearch() { + axios({ + url: this.nextUrlLaunchSearch, + headers: { Accept: 'application/json' }, + method: 'get', + }).then(res=> { + this.launchesSearched = res.data.results + this.nextUrlLaunchSearch = res.data.next + this.previousUrlLaunchSearch = res.data.previous + console.log(res.data) + }) + }, + + previousPageLaunchSearch() { + axios({ + url: this.previousUrlLaunchSearch, + method: 'get', + headers: { Accept: 'application/json' }, + }).then(res=> { + this.launchesSearched = res.data.results + this.nextUrlLaunchSearch = res.data.next + this.previousUrlLaunchSearch = res.data.previous + console.log(res.data) + console.log(res.data.next) + }) + }, + } }