Skip to content

Commit

Permalink
Merge pull request #467 from codeforsapporo/feature/migration-fetch-api
Browse files Browse the repository at this point in the history
Fetch API に変更
  • Loading branch information
NEKOYASAN authored Jun 2, 2021
2 parents d1d8bc1 + 8f344dc commit 76a321a
Show file tree
Hide file tree
Showing 13 changed files with 3,373 additions and 2,386 deletions.
450 changes: 222 additions & 228 deletions components/DesktopFlowSvg.vue

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions components/cards/ContactsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ export default {
},
methods: {
async getContactsGraphFromAPI() {
await this.$axios
.$get('/contacts.json')
.then(response => {
this.contactsGraph = formatGraph(response.data)
this.contacts.last_update = response.last_update
this.contacts.loaded = true
})
.catch(_ => {
this.$emit('failed', '新型コロナコールセンター相談件数データ ')
})
try {
const fetchurl = await fetch(
'https://codeforsapporo.github.io/covid19hokkaido_scraping/contacts.json'
)
const response = await fetchurl.json()
this.contactsGraph = formatGraph(response.data)
this.contacts.last_update = response.last_update
this.contacts.loaded = true
} catch (_) {
this.$emit('failed', '新型コロナコールセンター相談件数データ ')
}
}
}
}
Expand Down
22 changes: 12 additions & 10 deletions components/cards/CurrentPatientsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ export default {
},
methods: {
async getCurrentPatientsGraphFromAPI() {
await this.$axios
.$get('/current_patients.json')
.then(response => {
this.currentPatientsGraph = formatCurrentPatientsGraph(response.data)
this.current_patients.last_update = response.last_update
this.current_patients.loaded = true
})
.catch(_ => {
this.$emit('failed', '現在患者数データ ')
})
try {
const fetchurl = await fetch(
'https://codeforsapporo.github.io/covid19hokkaido_scraping/current_patients.json'
)
const response = await fetchurl.json()
this.currentPatientsGraph = formatCurrentPatientsGraph(response.data)
this.current_patients.last_update = response.last_update
this.current_patients.loaded = true
} catch (_) {
this.$emit('failed', '現在患者数データ ')
}
}
}
}
Expand Down
22 changes: 12 additions & 10 deletions components/cards/DischargesCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ export default {
methods: {
// 治療終了者数グラフ
async getDischargesSummaryGraphFromAPI() {
await this.$axios
.$get('/discharges_summary.json')
.then(response => {
this.dischargesGraph = formatDischargesSummaryGraph(response.data)
this.discharges_summary.last_update = response.last_update
this.discharges_summary.loaded = true
})
.catch(_ => {
this.$emit('failed', '治療終了者数データ ')
})
try {
const fetchurl = await fetch(
'https://codeforsapporo.github.io/covid19hokkaido_scraping/discharges_summary.json'
)
const response = await fetchurl.json()
this.dischargesGraph = formatDischargesSummaryGraph(response.data)
this.discharges_summary.last_update = response.last_update
this.discharges_summary.loaded = true
} catch (_) {
this.$emit('failed', '治療終了者数データ ')
}
}
}
}
Expand Down
23 changes: 12 additions & 11 deletions components/cards/InspectionsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,18 @@ export default {
},
methods: {
async getInscpectionsGraphFromAPI() {
await this.$axios
.$get('/inspections.json')
.then(response => {
this.inspectionsGraph = formatInspectionsGraph(response.data)
this.inspections.last_update = response.last_update
this.inspections.loaded = true
return true
})
.catch(_ => {
this.$emit('failed', '検査数データ ')
})
try {
const fetchurl = await fetch(
'https://codeforsapporo.github.io/covid19hokkaido_scraping/inspections.json'
)
const response = await fetchurl.json()
this.inspectionsGraph = formatInspectionsGraph(response.data)
this.inspections.last_update = response.last_update
this.inspections.loaded = true
} catch (_) {
this.$emit('failed', '検査数データ ')
}
}
}
}
Expand Down
98 changes: 51 additions & 47 deletions components/cards/PatientsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,57 +48,61 @@ export default {
},
methods: {
async getPatientsTableFromAPI() {
await this.$axios
.$get('/patients.json')
.then(response => {
this.patientsTable = formatTable(response.data)
// 陽性患者の属性 ヘッダー翻訳
for (const header of this.patientsTable.headers) {
header.text =
header.value === '退院' ? this.$t('退院※') : this.$t(header.value)
try {
const fetchurl = await fetch(
'https://codeforsapporo.github.io/covid19hokkaido_scraping/patients.json'
)
const response = await fetchurl.json()
this.patientsTable = formatTable(response.data)
// 陽性患者の属性 ヘッダー翻訳
for (const header of this.patientsTable.headers) {
header.text =
header.value === '退院' ? this.$t('退院※') : this.$t(header.value)
}
// 陽性患者の属性 中身の翻訳
for (const row of this.patientsTable.datasets) {
row['居住地'] = this.$t(row['居住地'])
row['性別'] = this.$t(row['性別'])
row['退院'] = this.$t(row['退院'])
if (row['性別'] === '非公表性') {
row['性別'] = this.$t('非公表')
}
// 陽性患者の属性 中身の翻訳
for (const row of this.patientsTable.datasets) {
row['居住地'] = this.$t(row['居住地'])
row['性別'] = this.$t(row['性別'])
row['退院'] = this.$t(row['退院'])
if (row['性別'] === '非公表性') {
row['性別'] = this.$t('非公表')
}
const match = row['年代'].match(/^([0-9]+)代$/)
if (match) {
row['年代'] = this.$t('{age}代', { age: match[1] })
} else {
row['年代'] = this.$t(row['年代'])
}
const match = row['年代'].match(/^([0-9]+)代$/)
if (match) {
row['年代'] = this.$t('{age}代', { age: match[1] })
} else {
row['年代'] = this.$t(row['年代'])
}
this.patients.last_update = response.last_update
this.patients.loaded = true
})
.catch(_ => {
this.$emit('failed', '陽性患者の属性データ ')
})
}
this.patients.last_update = response.last_update
this.patients.loaded = true
} catch (_) {
this.$emit('failed', '陽性患者の属性データ ')
}
},
async getPatientsSummaryGraphFromAPI() {
await this.$axios
.$get('/patients_summary.json')
.then(response => {
const patientsGraph = formatPatientsSummaryGraph(response.data)
this.sumInfoOfPatients = {
lText: patientsGraph[
patientsGraph.length - 1
].cumulative.toLocaleString(),
sText: this.$t('{date}の累計', {
date: this.$dayjs(
patientsGraph[patientsGraph.length - 1].label
).format('MM/DD')
}),
unit: this.$t('')
}
})
.catch(_ => {
this.$emit('failed2', '陽性患者数データ ')
})
try {
const fetchurl = await fetch(
'https://codeforsapporo.github.io/covid19hokkaido_scraping/patients_summary.json'
)
const response = await fetchurl.json()
const patientsGraph = formatPatientsSummaryGraph(response.data)
this.sumInfoOfPatients = {
lText: patientsGraph[
patientsGraph.length - 1
].cumulative.toLocaleString(),
sText: this.$t('{date}の累計', {
date: this.$dayjs(
patientsGraph[patientsGraph.length - 1].label
).format('MM/DD')
}),
unit: this.$t('')
}
} catch (_) {
this.$emit('failed2', '陽性患者数データ ')
}
}
}
}
Expand Down
22 changes: 12 additions & 10 deletions components/cards/PatientsSummaryCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@ export default {
methods: {
// 治療終了者数グラフ
async getPatientsSummaryGraphFromAPI() {
await this.$axios
.$get('/patients_summary.json')
.then(response => {
this.patientsGraph = formatPatientsSummaryGraph(response.data)
this.patients_summary.last_update = response.last_update
this.patients_summary.loaded = true
})
.catch(_ => {
this.$emit('failed', '陽性患者数データ ')
})
try {
const fetchurl = await fetch(
'https://codeforsapporo.github.io/covid19hokkaido_scraping/patients_summary.json'
)
const response = await fetchurl.json()
this.patientsGraph = formatPatientsSummaryGraph(response.data)
this.patients_summary.last_update = response.last_update
this.patients_summary.loaded = true
} catch (_) {
this.$emit('failed', '陽性患者数データ ')
}
}
}
}
Expand Down
22 changes: 12 additions & 10 deletions components/cards/QuerentsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ export default {
},
methods: {
async getQuerentsGraphFromAPI() {
await this.$axios
.$get('/querents.json')
.then(response => {
this.querentsGraph = formatGraph(response.data)
this.querents.last_update = response.last_update
this.querents.loaded = true
})
.catch(_ => {
this.$emit('failed', '帰国者・接触者電話相談センター相談件数データ ')
})
try {
const fetchurl = await fetch(
'https://codeforsapporo.github.io/covid19hokkaido_scraping/querents.json'
)
const response = await fetchurl.json()
this.querentsGraph = formatGraph(response.data)
this.querents.last_update = response.last_update
this.querents.loaded = true
} catch (_) {
this.$emit('failed', '帰国者・接触者電話相談センター相談件数データ ')
}
}
}
}
Expand Down
14 changes: 2 additions & 12 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable */
module.exports = {
mode: 'universal',
target: 'static',
telemetry: false,
/*
** Headers of the page
*/
Expand Down Expand Up @@ -82,11 +83,7 @@ module.exports = {
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/pwa',
// Doc: https://github.com/nuxt-community/dotenv-module
'@nuxtjs/dotenv',
'nuxt-webfontloader',
[
'nuxt-i18n',
Expand Down Expand Up @@ -159,13 +156,6 @@ module.exports = {
'nuxt-svg-loader',
'@nuxtjs/sitemap'
],
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {
baseURL: process.env.NODE_ENV === "production" ? "/api/" : "https://stopcovid19-dev.hokkaido.dev/api/"
},
webfontloader: {
google: {
families: ['Roboto&display=swap']
Expand Down
58 changes: 29 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,46 @@
}
},
"dependencies": {
"@mdi/font-build": "^1.8.4",
"@nuxt/typescript-runtime": "^0.4.2",
"@nuxtjs/axios": "^5.9.7",
"@nuxtjs/dotenv": "^1.4.1",
"@nuxtjs/pwa": "^3.0.0-0",
"@nuxtjs/sitemap": "^2.2.0",
"@mdi/font-build": "^1.8.6",
"@nuxt/typescript-runtime": "^2.0.0",
"@nuxtjs/pwa": "^3.1.0",
"@nuxtjs/sitemap": "^2.4.0",
"chart.js": "^2.9.3",
"cross-env": "^7.0.2",
"dayjs": "^1.8.25",
"express": "^4.16.4",
"nuxt": "^2.12.2",
"nuxt-i18n": "6.8.1",
"dayjs": "^1.9.1",
"express": "^4.17.1",
"nuxt": "^2.14.6",
"nuxt-i18n": "6.15.1",
"nuxt-webfontloader": "^1.1.0",
"vue-chartjs": "^3.5.0",
"vue-property-decorator": "^8.4.1",
"vue-spinner": "^1.0.3"
"vue-chartjs": "^3.5.1",
"vue-class-component": "^7.2.6",
"vue-property-decorator": "^9.0.2",
"vue-spinner": "^1.0.4"
},
"devDependencies": {
"@nuxt/typescript-build": "^0.6.2",
"@nuxtjs/eslint-config-typescript": "^1.0.2",
"@nuxtjs/google-analytics": "^2.2.3",
"@nuxtjs/stylelint-module": "^3.2.2",
"@nuxtjs/vuetify": "^1.11.0",
"@types/chart.js": "^2.9.18",
"@vue/test-utils": "^1.0.0-beta.32",
"babel-jest": "^25.2.6",
"@nuxt/types": "^2.14.6",
"@nuxt/typescript-build": "^2.0.3",
"@nuxtjs/eslint-config-typescript": "^3.0.0",
"@nuxtjs/google-analytics": "^2.4.0",
"@nuxtjs/stylelint-module": "^4.0.0",
"@nuxtjs/vuetify": "^1.11.2",
"@types/chart.js": "^2.9.25",
"@vue/test-utils": "^1.1.0",
"babel-jest": "^26.5.2",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-tsdoc": "^0.2.4",
"husky": "^4.2.3",
"jest": "^25.2.7",
"lint-staged": "^10.1.2",
"nodemon": "^2.0.2",
"husky": "^4.3.0",
"jest": "^26.5.2",
"lint-staged": "^10.4.0",
"nodemon": "^2.0.4",
"nuxt-svg-loader": "^1.2.0",
"prettier": "^1.19.1",
"stylelint": "^13.3.0",
"stylelint-config-prettier": "^8.0.1",
"stylelint": "^13.7.2",
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^20.0.0",
"stylelint-scss": "^3.16.0",
"vue-jest": "^4.0.0-beta.2"
"stylelint-scss": "^3.18.0",
"vue-jest": "^3.0.7"
}
}
Loading

0 comments on commit 76a321a

Please sign in to comment.