Browse Source

Update Web UI REST API

dev
David Ludwig 4 years ago
parent
commit
544127a635
4 changed files with 14 additions and 15 deletions
  1. +2
    -3
      services/webui/src/app/components/modals/MovieModal.vue
  2. +7
    -6
      services/webui/src/app/store/actions.ts
  3. +1
    -2
      services/webui/src/app/views/Dashboard.vue
  4. +4
    -4
      services/webui/src/app/views/Search.vue

+ 2
- 3
services/webui/src/app/components/modals/MovieModal.vue View File

@ -164,7 +164,7 @@ export default defineComponent({
this.close();
return;
}
this.movie = response.data;
this.movie = response.result;
},
async request() {
if (this.isRequesting || this.movie == null || this.movie.tmdbId == null) {
@ -177,8 +177,7 @@ export default defineComponent({
console.log("Failed to add movie: quota has been met");
return;
}
console.log(response);
this.movie.ticketId = response.data.ticketId;
this.movie.ticketId = response.result.ticketId;
}
},
mounted() {


+ 7
- 6
services/webui/src/app/store/actions.ts View File

@ -162,12 +162,12 @@ export const actions: Actions<IState, GettersTypes, MutationsTypes, ActionsTypes
*/
async [Action.AuthRegister]({dispatch}, payload: IRegisterPayload) {
try {
let [status, body] = await dispatch(Action.Post, {
let [status, response] = await dispatch(Action.Post, {
path: `/auth/register`,
useAuth: false,
body: payload});
if (status !== 200) {
return body.errors ?? {};
return response.errors ?? {};
}
} catch(e) {
console.error("Error occurred during registration", e);
@ -181,17 +181,18 @@ export const actions: Actions<IState, GettersTypes, MutationsTypes, ActionsTypes
*/
async [Action.AuthLogin]({commit, dispatch}, {email, password, remember = false}) {
try {
let [status, body] = await dispatch(Action.Post, {
let [status, response] = await dispatch(Action.Post, {
path: `/auth/login?use_cookies=${navigator.cookieEnabled}`,
useAuth: false,
body: {email, password}});
if (status !== 200) {
if (status === 401) {
body.errors = { "email": ["Email or password is incorrect"] };
response.errors = { "email": ["Email or password is incorrect"] };
}
return body.errors || {};
return response.errors || {};
}
commit(Mutation.UserLoad, body.token);
console.log(response);
commit(Mutation.UserLoad, response.result.token);
commit(Mutation.UserStore, remember);
} catch(e) {
console.error("Error occurred during login:", e);


+ 1
- 2
services/webui/src/app/views/Dashboard.vue View File

@ -35,8 +35,7 @@ export default defineComponent({
if (status !== Status.Ok) {
throw new Error("Non-OK status returned: " + status);
}
console.log(response.data);
this.activeRequests = response.data;
this.activeRequests = response.result;
} catch(e) {
console.error("Failed to fetch active movie tickets", e);
};


+ 4
- 4
services/webui/src/app/views/Search.vue View File

@ -59,10 +59,10 @@ export default defineComponent({
try {
let [status, response] = await this.$store.dispatch(Action.SearchMovies, this.searchValue);
console.log(status, response);
this.movies = response.data.results;
this.page = response.data.page;
this.totalPages = response.data.totalPages;
this.totalResults = response.data.totalResults;
this.movies = response.result.results;
this.page = response.result.page;
this.totalPages = response.result.totalPages;
this.totalResults = response.result.totalResults;
console.log("Got results", this.totalResults);
} catch(e) {
console.log("Error fetching movies:", e);


Loading…
Cancel
Save