Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for issue with axios #1764

Merged
merged 4 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
[#1582](https://github.com/nextcloud/cookbook/pull/1582) @roliverio
- Make time input fields wider to view multiple digits in chrome
[#1687](https://github.com/nextcloud/cookbook/pull/1687) @christianlupus
- Prevent popup from falsely showing during loading of the app
[#1764](https://github.com/nextcloud/cookbook/pull/1764) @christianlupus

### Maintenance
- Fix URL of Transifex after upstream subdomain change
Expand Down
24 changes: 20 additions & 4 deletions src/components/SettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@
<fieldset>
<legend class="settings-info-blocks__legend">
{{
t(
"cookbook",
"Control which blocks of information are shown in the recipe view. If you do not use some features and find them distracting, you may hide them.",
)
// prettier-ignore
t("cookbook", "Control which blocks of information are shown in the recipe view. If you do not use some features and find them distracting, you may hide them.")
}}
</legend>
<ul>
Expand Down Expand Up @@ -159,6 +157,19 @@
</ul>
</fieldset>
</NcAppSettingsSection>
<NcAppSettingsSection
id="debug"
:title="t('cookbook', 'Frontend debug settings')"
class="app-settings-section"
>
<legend class="settings-info-blocks__legend">
{{
// prettier-ignore
t("cookbook", "This allows to temporarily enable logging in the browser console in case of problems. You will not need these settings by default.")
}}
</legend>
<NcButton @click="enableLogger">Enable debugging</NcButton>
</NcAppSettingsSection>
</NcAppSettingsDialog>
</template>

Expand All @@ -174,6 +185,8 @@
import api from "cookbook/js/api-interface"
import { showSimpleAlertModal } from "cookbook/js/modals"

import { enableLogging } from "cookbook/js/logging"

export const SHOW_SETTINGS_EVENT = "show-settings"

const INFO_BLOCK_KEYS = [
Expand Down Expand Up @@ -390,6 +403,9 @@
this.$log.error("Library reindexing failed!")
})
},
enableLogger() {
enableLogging()
},

beforeDestroy() {
unsubscribe(SHOW_SETTINGS_EVENT, this.handleShowSettings)
Expand All @@ -399,7 +415,7 @@
</script>

<style scoped>
/* TODO: Use @nextcloud/vue LoadingIcon once we update to 7.0.0 and we won't

Check warning on line 418 in src/components/SettingsDialog.vue

View workflow job for this annotation

GitHub Actions / Check for added todo messages

Found TODO: Use @nextcloud/vue LoadingIcon once we update to 7.0.0 and we won't
* have to do this */
.material-design-icon.loading-icon:deep(svg) {
animation: rotate var(--animation-duration, 0.8s) linear infinite;
Expand Down
7 changes: 5 additions & 2 deletions src/js/api-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ instance.interceptors.request.use((config) => {
`[axios] Making "${config.method}" request to "${config.url}"`,
config,
)
const contentType = config.headers[config.method]["Content-Type"]
if (!["application/json", "text/json"].includes(contentType)) {
const contentType = config.headers["Content-Type"]
if (
contentType &&
!["application/json", "text/json"].includes(contentType)
) {
Vue.$log.warn(
`[axios] Request to "${config.url}" is using Content-Type "${contentType}", not JSON`,
)
Expand Down
4 changes: 4 additions & 0 deletions src/js/logging.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// TODO: Switch to vuejs3-logger when we switch to Vue 3

Check warning on line 1 in src/js/logging.js

View workflow job for this annotation

GitHub Actions / Check for added todo messages

Found TODO: Switch to vuejs3-logger when we switch to Vue 3
import VueLogger from "vuejs-logger"
import moment from "@nextcloud/moment"

Expand Down Expand Up @@ -66,3 +66,7 @@

Vue.$log.info(`Setting up logging with log level ${logLevel}`)
}

export function enableLogging() {
localStorage.setItem(KEY_ENABLED, true)
}
Loading