mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 21:38:13 +00:00
cleanup http
This commit is contained in:
@@ -56,6 +56,7 @@ import { URLs } from '../../scripts/utils/apiURLs';
|
|||||||
import { useMainStore } from '../../store/mainStore';
|
import { useMainStore } from '../../store/mainStore';
|
||||||
import Loading from '../Global/Loading.vue';
|
import Loading from '../Global/Loading.vue';
|
||||||
import { API } from '../../typings/api';
|
import { API } from '../../typings/api';
|
||||||
|
import http from '../../http';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { Loading },
|
components: { Loading },
|
||||||
@@ -90,15 +91,11 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const statsData: API.DispatcherStats.Response = await (
|
const statsData: API.DispatcherStats.Response = await (
|
||||||
await axios.get(
|
await http.get('api/getDispatcherInfo?name=${this.store.dispatcherStatsName}')
|
||||||
`${URLs.stacjownikAPI}/api/getDispatcherInfo?name=${this.store.dispatcherStatsName}`
|
|
||||||
)
|
|
||||||
).data;
|
).data;
|
||||||
|
|
||||||
const timetables: API.TimetableHistory.Response = await (
|
const timetables: API.TimetableHistory.Response = await (
|
||||||
await axios.get(
|
await http.get('api/getTimetables?authorName=${this.store.dispatcherStatsName}')
|
||||||
`${URLs.stacjownikAPI}/api/getTimetables?authorName=${this.store.dispatcherStatsName}`
|
|
||||||
)
|
|
||||||
).data;
|
).data;
|
||||||
|
|
||||||
this.timetables = timetables;
|
this.timetables = timetables;
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ import dateMixin from '../../mixins/dateMixin';
|
|||||||
import { URLs } from '../../scripts/utils/apiURLs';
|
import { URLs } from '../../scripts/utils/apiURLs';
|
||||||
import { API } from '../../typings/api';
|
import { API } from '../../typings/api';
|
||||||
import { Status } from '../../typings/common';
|
import { Status } from '../../typings/common';
|
||||||
|
import http from '../../http';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'journal-daily-stats',
|
name: 'journal-daily-stats',
|
||||||
@@ -175,9 +176,7 @@ export default defineComponent({
|
|||||||
methods: {
|
methods: {
|
||||||
async fetchDailyTimetableStats() {
|
async fetchDailyTimetableStats() {
|
||||||
try {
|
try {
|
||||||
const res: API.DailyStats.Response = await (
|
const res: API.DailyStats.Response = await (await http.get('api/getDailyStats')).data;
|
||||||
await axios.get(`${URLs.stacjownikAPI}/api/getDailyStats`)
|
|
||||||
).data;
|
|
||||||
|
|
||||||
this.stats = res;
|
this.stats = res;
|
||||||
|
|
||||||
|
|||||||
@@ -110,14 +110,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import axios from 'axios';
|
|
||||||
import { defineComponent, inject, PropType } from 'vue';
|
import { defineComponent, inject, PropType } from 'vue';
|
||||||
import keyMixin from '../../mixins/keyMixin';
|
import keyMixin from '../../mixins/keyMixin';
|
||||||
import { URLs } from '../../scripts/utils/apiURLs';
|
|
||||||
import { useMainStore } from '../../store/mainStore';
|
import { useMainStore } from '../../store/mainStore';
|
||||||
import { Journal } from './typings';
|
import { Journal } from './typings';
|
||||||
import { API } from '../../typings/api';
|
import { API } from '../../typings/api';
|
||||||
import { Status } from '../../typings/common';
|
import { Status } from '../../typings/common';
|
||||||
|
import http from '../../http';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
emits: ['onSearchConfirm', 'onOptionsReset', 'onRefreshData'],
|
emits: ['onSearchConfirm', 'onOptionsReset', 'onRefreshData'],
|
||||||
@@ -216,9 +215,7 @@ export default defineComponent({
|
|||||||
this.store.driverStatsStatus = Status.Data.Loading;
|
this.store.driverStatsStatus = Status.Data.Loading;
|
||||||
|
|
||||||
const statsData: API.DriverStats.Response = await (
|
const statsData: API.DriverStats.Response = await (
|
||||||
await axios.get(
|
await http.get(`api/getDriverInfo?name=${this.store.driverStatsName}`)
|
||||||
`${URLs.stacjownikAPI}/api/getDriverInfo?name=${this.store.driverStatsName}`
|
|
||||||
)
|
|
||||||
).data;
|
).data;
|
||||||
|
|
||||||
this.store.driverStatsData = statsData;
|
this.store.driverStatsData = statsData;
|
||||||
@@ -241,7 +238,7 @@ export default defineComponent({
|
|||||||
this.searchTimeout = window.setTimeout(async () => {
|
this.searchTimeout = window.setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
const suggestions: string[] = await (
|
const suggestions: string[] = await (
|
||||||
await axios.get(`${URLs.stacjownikAPI}/api/get${type}Suggestions?name=${value}`)
|
await http.get(`api/get${type}Suggestions?name=${value}`)
|
||||||
).data;
|
).data;
|
||||||
|
|
||||||
this[`${type}Suggestions`] = suggestions;
|
this[`${type}Suggestions`] = suggestions;
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ import listObserverMixin from '../../mixins/listObserverMixin';
|
|||||||
import { OnlineScenery } from '../../store/typings';
|
import { OnlineScenery } from '../../store/typings';
|
||||||
import { API } from '../../typings/api';
|
import { API } from '../../typings/api';
|
||||||
import { Status } from '../../typings/common';
|
import { Status } from '../../typings/common';
|
||||||
|
import http from '../../http';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'SceneryDispatchersHistory',
|
name: 'SceneryDispatchersHistory',
|
||||||
@@ -121,11 +122,12 @@ export default defineComponent({
|
|||||||
try {
|
try {
|
||||||
this.dataStatus = Status.Data.Loading;
|
this.dataStatus = Status.Data.Loading;
|
||||||
|
|
||||||
const requestString = `${URLs.stacjownikAPI}/api/getDispatchers?stationName=${
|
const requestString = `api/getDispatchers?stationName=${
|
||||||
this.station?.name || this.onlineScenery?.name
|
this.station?.name || this.onlineScenery?.name
|
||||||
}&countFrom=${countFrom}&countLimit=${countLimit}`;
|
}&countFrom=${countFrom}&countLimit=${countLimit}`;
|
||||||
|
|
||||||
const historyAPIData: API.DispatcherHistory.Response = await (
|
const historyAPIData: API.DispatcherHistory.Response = await (
|
||||||
await axios.get(requestString)
|
await http.get(requestString)
|
||||||
).data;
|
).data;
|
||||||
|
|
||||||
this.dataStatus = Status.Data.Loaded;
|
this.dataStatus = Status.Data.Loaded;
|
||||||
|
|||||||
@@ -63,17 +63,16 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import axios from 'axios';
|
|
||||||
import { defineComponent, PropType } from 'vue';
|
import { defineComponent, PropType } from 'vue';
|
||||||
import dateMixin from '../../mixins/dateMixin';
|
import dateMixin from '../../mixins/dateMixin';
|
||||||
|
|
||||||
import Station from '../../scripts/interfaces/Station';
|
import Station from '../../scripts/interfaces/Station';
|
||||||
import { URLs } from '../../scripts/utils/apiURLs';
|
|
||||||
import Loading from '../Global/Loading.vue';
|
import Loading from '../Global/Loading.vue';
|
||||||
import listObserverMixin from '../../mixins/listObserverMixin';
|
import listObserverMixin from '../../mixins/listObserverMixin';
|
||||||
import { OnlineScenery } from '../../store/typings';
|
import { OnlineScenery } from '../../store/typings';
|
||||||
import { API } from '../../typings/api';
|
import { API } from '../../typings/api';
|
||||||
import { Status } from '../../typings/common';
|
import { Status } from '../../typings/common';
|
||||||
|
import http from '../../http';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'SceneryTimetablesHistory',
|
name: 'SceneryTimetablesHistory',
|
||||||
@@ -107,11 +106,11 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const requestString = `${URLs.stacjownikAPI}/api/getTimetables?issuedFrom=${
|
const requestString = `api/getTimetables?issuedFrom=${
|
||||||
this.station?.name || this.onlineScenery?.name
|
this.station?.name || this.onlineScenery?.name
|
||||||
}&countFrom=${countFrom}&countLimit=${countLimit}`;
|
}&countFrom=${countFrom}&countLimit=${countLimit}`;
|
||||||
|
|
||||||
const response: API.TimetableHistory.Response = await (await axios.get(requestString)).data;
|
const response: API.TimetableHistory.Response = await (await http.get(requestString)).data;
|
||||||
|
|
||||||
this.historyList = response;
|
this.historyList = response;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
export const URLs = {
|
|
||||||
stacjownikAPI:
|
|
||||||
import.meta.env.VITE_APP_API_DEV === '1' && !import.meta.env.PROD
|
|
||||||
? 'http://localhost:3001'
|
|
||||||
: 'https://stacjownik.spythere.eu',
|
|
||||||
stacjownikAPIDev: 'localhost:3000'
|
|
||||||
};
|
|
||||||
@@ -32,10 +32,8 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, provide, reactive, Ref, ref } from 'vue';
|
import { defineComponent, provide, reactive, Ref, ref } from 'vue';
|
||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
import JournalOptions from '../components/JournalView/JournalOptions.vue';
|
import JournalOptions from '../components/JournalView/JournalOptions.vue';
|
||||||
import { URLs } from '../scripts/utils/apiURLs';
|
|
||||||
import { useMainStore } from '../store/mainStore';
|
import { useMainStore } from '../store/mainStore';
|
||||||
import JournalDispatchersList from '../components/JournalView/JournalDispatchersList.vue';
|
import JournalDispatchersList from '../components/JournalView/JournalDispatchersList.vue';
|
||||||
|
|
||||||
@@ -44,8 +42,7 @@ import { LocationQuery } from 'vue-router';
|
|||||||
import { Journal } from '../components/JournalView/typings';
|
import { Journal } from '../components/JournalView/typings';
|
||||||
import { API } from '../typings/api';
|
import { API } from '../typings/api';
|
||||||
import { Status } from '../typings/common';
|
import { Status } from '../typings/common';
|
||||||
|
import http from '../http';
|
||||||
const DISPATCHERS_API_URL = `${URLs.stacjownikAPI}/api/getDispatchers`;
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@@ -183,9 +180,7 @@ export default defineComponent({
|
|||||||
this.countFromIndex = this.historyList.length;
|
this.countFromIndex = this.historyList.length;
|
||||||
|
|
||||||
const responseData: API.DispatcherHistory.Response = await (
|
const responseData: API.DispatcherHistory.Response = await (
|
||||||
await axios.get(
|
await http.get(`api/getDispatchers?${this.currentQuery}&countFrom=${this.countFromIndex}`)
|
||||||
`${DISPATCHERS_API_URL}?${this.currentQuery}&countFrom=${this.countFromIndex}`
|
|
||||||
)
|
|
||||||
).data;
|
).data;
|
||||||
|
|
||||||
if (!responseData) return;
|
if (!responseData) return;
|
||||||
@@ -232,7 +227,7 @@ export default defineComponent({
|
|||||||
if (reset) this.dataStatus = Status.Data.Loading;
|
if (reset) this.dataStatus = Status.Data.Loading;
|
||||||
|
|
||||||
const responseData: API.DispatcherHistory.Response = await (
|
const responseData: API.DispatcherHistory.Response = await (
|
||||||
await axios.get(`${DISPATCHERS_API_URL}?${this.currentQuery}`)
|
await http.get(`api/getDispatchers?${this.currentQuery}`)
|
||||||
).data;
|
).data;
|
||||||
|
|
||||||
if (!responseData) {
|
if (!responseData) {
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, provide, reactive, Ref, ref } from 'vue';
|
import { defineComponent, provide, reactive, Ref, ref } from 'vue';
|
||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
import dateMixin from '../mixins/dateMixin';
|
import dateMixin from '../mixins/dateMixin';
|
||||||
import routerMixin from '../mixins/routerMixin';
|
import routerMixin from '../mixins/routerMixin';
|
||||||
@@ -45,7 +44,6 @@ import JournalOptions from '../components/JournalView/JournalOptions.vue';
|
|||||||
import JournalStats from '../components/JournalView/JournalStats.vue';
|
import JournalStats from '../components/JournalView/JournalStats.vue';
|
||||||
import JournalHeader from '../components/JournalView/JournalHeader.vue';
|
import JournalHeader from '../components/JournalView/JournalHeader.vue';
|
||||||
|
|
||||||
import { URLs } from '../scripts/utils/apiURLs';
|
|
||||||
import { useMainStore } from '../store/mainStore';
|
import { useMainStore } from '../store/mainStore';
|
||||||
|
|
||||||
import { LocationQuery } from 'vue-router';
|
import { LocationQuery } from 'vue-router';
|
||||||
@@ -54,8 +52,7 @@ import JournalTimetablesList from '../components/JournalView/JournalTimetables/J
|
|||||||
import { Journal } from '../components/JournalView/typings';
|
import { Journal } from '../components/JournalView/typings';
|
||||||
import { Status } from '../typings/common';
|
import { Status } from '../typings/common';
|
||||||
import { API } from '../typings/api';
|
import { API } from '../typings/api';
|
||||||
|
import http from '../http';
|
||||||
const TIMETABLES_API_URL = `${URLs.stacjownikAPI}/api/getTimetables`;
|
|
||||||
|
|
||||||
export const journalTimetableFilters: Journal.TimetableFilter[] = [
|
export const journalTimetableFilters: Journal.TimetableFilter[] = [
|
||||||
{
|
{
|
||||||
@@ -272,7 +269,7 @@ export default defineComponent({
|
|||||||
this.currentQueryParams['countFrom'] = this.timetableHistory.length;
|
this.currentQueryParams['countFrom'] = this.timetableHistory.length;
|
||||||
|
|
||||||
const responseData: API.TimetableHistory.Response = await (
|
const responseData: API.TimetableHistory.Response = await (
|
||||||
await axios.get(`${TIMETABLES_API_URL}`, {
|
await http.get('api/getTimetables', {
|
||||||
params: { ...this.currentQueryParams }
|
params: { ...this.currentQueryParams }
|
||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
@@ -365,7 +362,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const responseData: API.TimetableHistory.Response = await (
|
const responseData: API.TimetableHistory.Response = await (
|
||||||
await axios.get(`${TIMETABLES_API_URL}`, {
|
await http.get('api/getTimetables', {
|
||||||
params: this.currentQueryParams
|
params: this.currentQueryParams
|
||||||
})
|
})
|
||||||
).data;
|
).data;
|
||||||
|
|||||||
Reference in New Issue
Block a user