import { Viewer } from "@toast-ui/vue-editor";
import RecentlyModified from "./RecentlyModified";
+import LoadingIndicator from "./LoadingIndicator.vue";
import api from "../api";
import * as constants from "../constants";
Viewer,
Editor,
RecentlyModified,
+ LoadingIndicator,
},
data: function() {
.catch(function(error) {
if (error.handled) {
return;
- } else if ([400, 422].includes(error.response.status)) {
+ } else if (
+ typeof error.response !== "undefined" &&
+ [400, 422].includes(error.response.status)
+ ) {
parent.$bvToast.toast("Incorrect Username or Password ✘", {
variant: "danger",
noCloseButton: true,
getSearchResults: function() {
let parent = this;
+ this.searchFailed = false;
api
.get("/api/search", { params: { term: this.searchTerm } })
.then(function(response) {
})
.catch(function(error) {
if (!error.handled) {
+ parent.searchFailed = true;
parent.unhandledServerErrorToast();
}
});
loadNote: function(filename) {
let parent = this;
+ this.noteLoadFailed = false;
api
.get(`/api/notes/${filename}.${constants.markdownExt}`)
.then(function(response) {
parent.updateDocumentTitle();
})
.catch(function(error) {
- if (!error.handled) {
+ if (error.handled) {
+ return;
+ } else if (
+ typeof error.response !== "undefined" &&
+ error.response.status == 404
+ ) {
+ parent.noteLoadFailedMessage = "Note not found 😞";
+ parent.noteLoadFailed = true;
+ } else {
parent.unhandledServerErrorToast();
+ parent.noteLoadFailed = true;
}
});
},
.catch(function(error) {
if (error.handled) {
return;
- } else if (error.response.status == 409) {
+ } else if (
+ typeof error.response !== "undefined" &&
+ error.response.status == 409
+ ) {
parent.existingFilenameToast();
} else {
parent.unhandledServerErrorToast();
.catch(function(error) {
if (error.handled) {
return;
- } else if (error.response.status == 409) {
+ } else if (
+ typeof error.response !== "undefined" &&
+ error.response.status == 409
+ ) {
parent.existingFilenameToast();
} else {
parent.unhandledServerErrorToast();
<div v-if="currentView == views.note">
<!-- Loading -->
<div v-if="currentNote == null">
- <p class="text-center">Loading...</p>
+ <loading-indicator
+ :failure-message="noteLoadFailedMessage"
+ :failed="noteLoadFailed"
+ />
</div>
<!-- Note Loaded -->
<div v-if="currentView == views.search">
<!-- Searching -->
<div v-if="searchResults == null">
- <p class="text-center">Searching...</p>
+ <loading-indicator
+ loading-message="Searching..."
+ failure-message="Search failed 😞"
+ :failed="searchFailed"
+ />
</div>
<!-- No Results -->
<!-- Loading -->
<div v-if="notes == null">
- <p class="text-center">Loading...</p>
+ <loading-indicator :failed="loadingFailed"/>
</div>
<!-- No Notes -->
import api from "../api";
import { Note } from "../classes";
import EventBus from "../eventBus";
+import LoadingIndicator from "./LoadingIndicator.vue";
export default {
+ components: {
+ LoadingIndicator,
+ },
+
data: function () {
return {
notes: null,
+ loadingFailed: false,
};
},
});
})
.catch(function (error) {
+ parent.loadingFailed = true;
if (!error.handled) {
EventBus.$emit("unhandledServerError");
}