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

View file

@ -4,9 +4,10 @@ import store from '@/store'
* Handler for API responses. * Handler for API responses.
* *
* @param {Response} response - A fetch `Response` object. * @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) { async function handleResponse (response) {
store.dispatch('SERVER_RESPONDED')
if (!response.ok) return handleError(response) if (!response.ok) return handleError(response)
// FIXME the api should always return json objects // FIXME the api should always return json objects
const responseText = await response.text() const responseText = await response.text()

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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