modify imports of api module

This commit is contained in:
Axolotle 2020-10-12 17:36:47 +02:00
parent ee0a2a0020
commit 6a46132fd7
27 changed files with 40 additions and 28 deletions

View file

@ -7,6 +7,11 @@ import store from '@/store'
import { handleResponse, handleError } from './handlers'
import { objectToParams } from '@/helpers/commons'
/**
* A digested fetch response as an object, a string or an error.
* @typedef {(Object|string|Error)} DigestedResponse
*/
export default {
options: {
credentials: 'include',

View file

@ -4,9 +4,10 @@ import store from '@/store'
* Handler for API responses.
*
* @param {Response} response - A fetch `Response` object.
* @return {DigestedResponse} Parsed response's json, response's text or an error.
* @return {(Object|String)} Parsed response's json or response's text.
*/
async function handleResponse (response) {
store.dispatch('SERVER_RESPONDED')
if (!response.ok) return handleError(response)
// FIXME the api should always return json objects
const responseText = await response.text()

View file

@ -12,6 +12,7 @@
<!-- <b-spinner /> -->
<img class="pacman" src="@/assets/ajax-loader.gif">
</div>
<b-card-body class="pb-4">
<b-card-title class="text-center m-0" v-t="'api_waiting'" />
@ -27,7 +28,7 @@
</b-card-body>
<!-- MESSAGES -->
<b-list-group v-if="messages" flush>
<b-list-group v-if="messages" flush class="rounded-0">
<b-list-group-item
v-for="({ text, type }, i) in messages" :key="i"
:variant="type"

View file

@ -1,5 +1,5 @@
import Vue from 'vue'
import api from '@/helpers/api'
import api from '@/api'
export default {
state: () => ({

View file

@ -1,6 +1,7 @@
import Vue from 'vue'
import api, { timeout } from '@/helpers/api'
import api from '@/api'
import router from '@/router'
import { timeout } from '@/helpers/commons'
export default {
state: {

View file

@ -61,7 +61,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import { DomainForm, PasswordForm } from '@/components/reusableForms'
import LoginView from '@/views/Login'

View file

@ -42,8 +42,9 @@
</template>
<script>
import api, { objectToParams } from '@/helpers/api'
import api from '@/api'
import { formatI18nField, formatYunoHostArgument } from '@/helpers/yunohostArguments'
import { objectToParams } from '@/helpers/commons'
export default {
name: 'AppActions',

View file

@ -166,7 +166,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import InputHelper from '@/components/InputHelper'
export default {

View file

@ -46,8 +46,9 @@
<script>
// FIXME needs test and rework
import api, { objectToParams } from '@/helpers/api'
import api from '@/api'
import { formatI18nField, formatYunoHostArgument } from '@/helpers/yunohostArguments'
import { objectToParams } from '@/helpers/commons'
export default {
name: 'AppConfigPanel',

View file

@ -152,7 +152,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import { readableDate } from '@/filters/date'
export default {

View file

@ -64,8 +64,9 @@
</template>
<script>
import api, { objectToParams } from '@/helpers/api'
import api from '@/api'
import { formatYunoHostArgument } from '@/helpers/yunohostArguments'
import { objectToParams } from '@/helpers/commons'
export default {
name: 'AppInstall',

View file

@ -45,7 +45,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
export default {
name: 'AppList',

View file

@ -90,7 +90,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
export default {
name: 'BackupCreate',

View file

@ -141,7 +141,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import { readableDate } from '@/filters/date'
import { humanSize } from '@/filters/size'

View file

@ -32,7 +32,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import { distanceToNow, readableDate } from '@/filters/date'
import { humanSize } from '@/filters/size'

View file

@ -107,7 +107,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import { distanceToNow } from '@/filters/date'
export default {

View file

@ -78,7 +78,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
export default {
name: 'DomainCert',

View file

@ -13,7 +13,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
export default {
name: 'DomainDns',

View file

@ -86,7 +86,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import { distanceToNow } from '@/filters/date'
export default {

View file

@ -33,7 +33,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import { distanceToNow } from '@/filters/date'
export default {

View file

@ -18,7 +18,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import { PasswordForm } from '@/components/reusableForms'
import InputHelper from '@/components/InputHelper'

View file

@ -133,7 +133,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
export default {
name: 'ToolFirewall',

View file

@ -58,7 +58,8 @@
</template>
<script>
import api, { objectToParams } from '@/helpers/api'
import api from '@/api'
import { objectToParams } from '@/helpers/commons'
import { readableDate } from '@/filters/date'
export default {

View file

@ -29,7 +29,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import { distanceToNow, readableDate } from '@/filters/date'
export default {
@ -70,7 +70,7 @@ export default {
operation[index].class = 'success'
} else {
operation[index].icon = 'close'
operation[index].class = 'success'
operation[index].class = 'danger'
}
})
this.operations = operation

View file

@ -101,7 +101,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
// FIXME not tested with pending migrations (disclaimer and stuff)

View file

@ -51,7 +51,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
import LoginView from '@/views/Login'
export default {

View file

@ -92,7 +92,7 @@
</template>
<script>
import api from '@/helpers/api'
import api from '@/api'
export default {
name: 'SystemUpdate',
@ -135,9 +135,9 @@ export default {
},
created () {
this.fetchData()
// FIXME Do not perform directly the update ?
this.performUpdate()
this.fetchData()
}
}
</script>