Skip to content

Commit

Permalink
UI: all offers are under / uri, not /offers, simplified axios usage
Browse files Browse the repository at this point in the history
  • Loading branch information
lwitkowski committed Aug 1, 2024
1 parent f9ea7c1 commit d0b8de5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 21 deletions.
6 changes: 3 additions & 3 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
<div id="nav">
<div class="nav-element">
<router-link to="/offers"> All Offers </router-link>
<router-link to="/"> All Offers </router-link>
</div>
<div class="nav-element">
<router-link to="/gliders"> Gliders </router-link>
Expand Down Expand Up @@ -47,8 +47,8 @@
/*global __COMMIT_HASH__*/
/*global __BUILD_TIMESTAMP__*/
import axios from 'axios'
import Toast from 'primevue/toast'
import HTTP from './http-common'
export default {
components: {
Expand Down Expand Up @@ -77,7 +77,7 @@ export default {
fetchOptions(search, loading) {
loading(true)
this.options = []
HTTP.get(`/models?search=${search}`).then((response) => {
axios.get(`/models?search=${search}`).then((response) => {
const options = response.data
// add labels for displaying the data
for (let i = 0; i < options.length; i += 1) {
Expand Down
7 changes: 0 additions & 7 deletions ui/src/http-common.js

This file was deleted.

3 changes: 3 additions & 0 deletions ui/src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createApp, h } from 'vue'
import axios from 'axios'
import vSelect from 'vue-select'
import ToastService from 'primevue/toastservice'
import vueChartist from 'vue-chartist'
Expand All @@ -8,6 +9,8 @@ import 'primeicons/primeicons.css'
import App from './App.vue'
import router from './router'

axios.defaults.baseURL = import.meta.env.VITE_API_URI;

const app = createApp({
render: () => h(App)
})
Expand Down
8 changes: 2 additions & 6 deletions ui/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/offers',
name: 'Offers',
path: '/',
name: 'All Offers',
component: Offers,
meta: {
title: 'Aircraft Offers Overview',
Expand Down Expand Up @@ -68,10 +68,6 @@ const router = createRouter({
filter: 'aircraft_type=airplane'
}
},
{
path: '/',
redirect: '/offers'
},
{
path: '/model/:manufacturer/:model',
name: 'ModelInformation',
Expand Down
6 changes: 3 additions & 3 deletions ui/src/views/ModelInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
</template>

<script>
import ChartistTooltip from 'chartist-plugin-tooltips-updated'
import axios from 'axios'
import moment from 'moment'
import HTTP from '../http-common'
import ChartistTooltip from 'chartist-plugin-tooltips-updated'
export default {
name: 'ModelInformation',
Expand Down Expand Up @@ -97,7 +97,7 @@ export default {
fetchData() {
this.chartData.series = [[]]
HTTP.get(`/model/${this.manufacturer}/${this.model}`).then((response) => {
axios.get(`/model/${this.manufacturer}/${this.model}`).then((response) => {
this.manufacturer_website = response.data.manufacturer_website
this.offers = response.data.offers
if (this.offers.length === 0) {
Expand Down
4 changes: 2 additions & 2 deletions ui/src/views/Offers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</template>

<script>
import HTTP from '../http-common'
import axios from 'axios'
import OfferComponent from '../components/OfferComponent.vue'
export default {
Expand Down Expand Up @@ -40,7 +40,7 @@ export default {
methods: {
fetchData() {
HTTP.get(`/offers?${this.filter}&limit=${this.limit}&orderBy=creation_datetime&offset=${this.offset}`).then(
axios.get(`/offers?${this.filter}&limit=${this.limit}&orderBy=creation_datetime&offset=${this.offset}`).then(
(response) => {
this.offers = this.offers.concat(response.data)
}
Expand Down

0 comments on commit d0b8de5

Please sign in to comment.