Compare commits

..

2 commits

7 changed files with 207 additions and 109 deletions

View file

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="TsLint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

15
.idea/php.xml generated
View file

@ -9,9 +9,24 @@
<component name="PHPCodeSnifferOptionsConfiguration"> <component name="PHPCodeSnifferOptionsConfiguration">
<option name="transferred" value="true" /> <option name="transferred" value="true" />
</component> </component>
<component name="PhpCodeSniffer">
<phpcs_settings>
<phpcs_by_interpreter asDefaultInterpreter="true" interpreter_id="53f7f9d8-dddf-4d4f-ad7e-428c57c55670" timeout="30000" />
</phpcs_settings>
</component>
<component name="PhpStan">
<PhpStan_settings>
<phpstan_by_interpreter asDefaultInterpreter="true" interpreter_id="53f7f9d8-dddf-4d4f-ad7e-428c57c55670" timeout="60000" />
</PhpStan_settings>
</component>
<component name="PhpStanOptionsConfiguration"> <component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" /> <option name="transferred" value="true" />
</component> </component>
<component name="Psalm">
<Psalm_settings>
<psalm_fixer_by_interpreter asDefaultInterpreter="true" interpreter_id="53f7f9d8-dddf-4d4f-ad7e-428c57c55670" timeout="60000" />
</Psalm_settings>
</component>
<component name="PsalmOptionsConfiguration"> <component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" /> <option name="transferred" value="true" />
</component> </component>

1
.idea/prettier.xml generated
View file

@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="PrettierConfiguration"> <component name="PrettierConfiguration">
<option name="myConfigurationMode" value="AUTOMATIC" /> <option name="myConfigurationMode" value="AUTOMATIC" />
<option name="myRunOnSave" value="true" />
</component> </component>
</project> </project>

20
.idea/workspace.xml generated
View file

@ -5,8 +5,11 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="5e320804-68c9-4504-97d5-d421de3438b2" name="Changes" comment=""> <list default="true" id="5e320804-68c9-4504-97d5-d421de3438b2" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/php.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/php.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/prettier.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/prettier.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/lists/index.vue" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/lists/index.vue" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/pages/lists/[id].vue" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/lists/[id].vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/types/movielist.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/types/movielist.ts" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -44,9 +47,9 @@
<component name="ProblemsViewState"> <component name="ProblemsViewState">
<option name="selectedTabId" value="CurrentFile" /> <option name="selectedTabId" value="CurrentFile" />
</component> </component>
<component name="ProjectColorInfo"><![CDATA[{ <component name="ProjectColorInfo">{
"associatedIndex": 8 &quot;associatedIndex&quot;: 8
}]]></component> }</component>
<component name="ProjectId" id="2K1xoABBc3o8XBi4orGtOrB9Dxn" /> <component name="ProjectId" id="2K1xoABBc3o8XBi4orGtOrB9Dxn" />
<component name="ProjectLevelVcsManager"> <component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" /> <ConfirmationsSetting value="1" id="Add" />
@ -63,7 +66,7 @@
"WebServerToolWindowFactoryState": "false", "WebServerToolWindowFactoryState": "false",
"code.cleanup.on.save": "true", "code.cleanup.on.save": "true",
"git-widget-placeholder": "main", "git-widget-placeholder": "main",
"last_opened_file_path": "/home/tiradoe/Projects/movie-night/web", "last_opened_file_path": "/home/tiradoe/Projects/movie-night/web/src/types",
"list.type.of.created.stylesheet": "CSS", "list.type.of.created.stylesheet": "CSS",
"node.js.detected.package.eslint": "true", "node.js.detected.package.eslint": "true",
"node.js.detected.package.standard": "true", "node.js.detected.package.standard": "true",
@ -72,15 +75,17 @@
"node.js.selected.package.standard": "", "node.js.selected.package.standard": "",
"node.js.selected.package.tslint": "(autodetect)", "node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm", "nodejs_package_manager_path": "npm",
"npm.dev.executor": "Run",
"prettierjs.PrettierConfiguration.Package": "/home/tiradoe/Projects/movie-night/web/src/node_modules/prettier", "prettierjs.PrettierConfiguration.Package": "/home/tiradoe/Projects/movie-night/web/src/node_modules/prettier",
"rearrange.code.on.save": "true", "rearrange.code.on.save": "true",
"settings.editor.selected.configurable": "settings.javascript.prettier", "settings.editor.selected.configurable": "settings.vue",
"ts.external.directory.path": "/home/tiradoe/Projects/movie-night/web/src/node_modules/typescript/lib", "ts.external.directory.path": "/home/tiradoe/Projects/movie-night/web/src/node_modules/typescript/lib",
"vue.rearranger.settings.migration": "true" "vue.rearranger.settings.migration": "true"
} }
}]]></component> }]]></component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src/types" />
<recent name="$PROJECT_DIR$/components" /> <recent name="$PROJECT_DIR$/components" />
</key> </key>
<key name="MoveFile.RECENT_KEYS"> <key name="MoveFile.RECENT_KEYS">
@ -127,7 +132,8 @@
<workItem from="1673397538637" duration="47416000" /> <workItem from="1673397538637" duration="47416000" />
<workItem from="1673508732689" duration="1316000" /> <workItem from="1673508732689" duration="1316000" />
<workItem from="1673547794038" duration="2346000" /> <workItem from="1673547794038" duration="2346000" />
<workItem from="1743904898331" duration="11972000" /> <workItem from="1743904898331" duration="20256000" />
<workItem from="1743998844137" duration="23268000" />
</task> </task>
<servers /> <servers />
</component> </component>

View file

@ -10,12 +10,16 @@
<li> <li>
<label class="mr-2" for="hide_scheduled">Hide Scheduled</label> <label class="mr-2" for="hide_scheduled">Hide Scheduled</label>
<input <input
id="hide_scheduled"
v-model="hide_scheduled"
type="checkbox"
@change="hideScheduled" @change="hideScheduled"
v-model="hide_scheduled" id="hide_scheduled" type="checkbox"/> />
</li> </li>
</ul> </ul>
</div> </div>
<input v-model="movie_query" <input
v-model="movie_query"
class="p-1 rounded" class="p-1 rounded"
placeholder="Filter Movies" placeholder="Filter Movies"
type="text" type="text"
@ -24,8 +28,14 @@
</div> </div>
<!-- MOVIE LIST --> <!-- MOVIE LIST -->
<ul class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 mt-5"> <ul
<li v-for="movie in filtered_movies" :key="movie.id" class="rounded movie-card neon-border"> class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 mt-5"
>
<li
v-for="movie in filtered_movies"
:key="movie.id"
class="rounded movie-card neon-border"
>
<!-- POSTER --> <!-- POSTER -->
<img <img
:data-src="movie.poster" :data-src="movie.poster"
@ -36,7 +46,11 @@
<div class="p-5 flex flex-col"> <div class="p-5 flex flex-col">
<!-- TITLE --> <!-- TITLE -->
<span class="font-bold text-center mb-1">{{ movie.title }}</span> <span class="font-bold text-center mb-1">{{ movie.title }}</span>
<span v-if="logged_in" class="text-center hover-pointer" @click="removeMovie(movie.id)"> <span
v-if="logged_in"
class="text-center hover-pointer"
@click="removeMovie(movie.id)"
>
X X
</span> </span>
</div> </div>
@ -45,100 +59,139 @@
</div> </div>
</template> </template>
<script> <script lang="ts" setup>
import ShowMovie from "~/components/modal-content/ShowMovie.vue"; import ShowMovie from "~/components/modal-content/ShowMovie.vue";
import 'lazysizes'; import "lazysizes";
import type { MovieList } from "~/types/movielist";
import type { Movie } from "~/types/movie";
export default { const list_id = ref(0);
name: "list", const list = defineModel<MovieList>("movie_list", { default: [] });
components: {ShowMovie}, const modal_movie: Ref<Movie | null> = ref(null);
data: () => ({ const movies = defineModel<Movie[] | []>("movies", {
list_id: 0, default: [],
list: [], });
modal_movie: null, const filtered_movies = defineModel<Movie[]>("filtered_movies");
movies: [], const movie_query = ref("");
filtered_movies: [], const logged_in = ref(false);
movie_query: "", const hide_scheduled = ref(false);
logged_in: false,
hide_scheduled: false, const getList = async function (list_id: number) {
}), let config = useRuntimeConfig();
methods: { const { data, error } = await useFetch<MovieList>(
getList: function (list_id) { `${config.public.apiURL}/lists/${list_id}`,
let config = useRuntimeConfig() {
fetch(`${config.public.apiURL}/lists/${list_id}`, {
method: "GET", method: "GET",
headers: {"Content-type": "application/json"} headers: {
}) "Content-type": "application/json",
.then(response => response.json()) Authorization: `Token ${useCookie("token").value}`,
.then(json => {
this.list = json.list;
this.movies = json.movies;
this.filtered_movies = this.movies;
})
.catch(err => console.log(err))
}, },
hideScheduled: function() { },
if(this.hide_scheduled) { );
this.filtered_movies = this.movies.filter(movie => {
return movie.last_watched === null if (error.value) {
}); if (error.value.statusCode === 401) {
} else { navigateTo("/");
this.filtered_movies = this.movies;
} }
}, if (error.value.statusCode === 404) {
removeMovie: function (movie_id) { alert("List not found");
let config = useRuntimeConfig() navigateTo("/lists");
}
} else {
if (!data.value) {
alert("List not found");
navigateTo("/lists");
} else {
list.value = data.value;
movies.value = data.value?.movies || [];
filtered_movies.value = movies.value;
}
}
};
const hideScheduled = function () {
if (hide_scheduled && movies.value.length > 0) {
let filtered = movies.value.filter((movie) => {
return movie.last_watched === null;
});
if (typeof filtered != "undefined") {
filtered_movies.value = filtered;
}
} else {
filtered_movies.value = movies.value;
}
};
const removeMovie = async function (movie_id: number) {
let config = useRuntimeConfig();
let confirmed = confirm("Remove movie from list?"); let confirmed = confirm("Remove movie from list?");
if (!confirmed) { if (!confirmed) {
return false; return false;
} }
return fetch(`${config.public.apiURL}/movies/l/${this.list_id}/m/${movie_id}`, { const { data, error } = await useFetch<MovieList>(
credentials: "include", `${config.public.apiURL}/lists/${list_id.value}/movie/${movie_id}/`,
{
method: "DELETE", method: "DELETE",
headers: { headers: {
"Content-type": "application/json", "Content-type": "application/json",
"token": useCookie("token").value, Authorization: `Token ${useCookie("token").value}`,
}
})
.then(response => response.json())
.then(_json => {
this.filtered_movies = this.filtered_movies.filter((movie) => {
return movie.id !== movie_id
})
})
.catch(err => console.log(err));
}, },
filterMovies: function () { },
if (!this.movie_query) { );
this.filtered_movies = this.movies;
if (error.value) {
if (error.value.statusCode === 401) {
navigateTo("/");
}
if (error.value.statusCode === 404) {
alert("List not found");
navigateTo("/lists");
}
} else {
if (!data.value) {
alert("List not found");
navigateTo("/lists");
} else {
list.value = data.value;
movies.value = data.value?.movies || [];
filtered_movies.value = movies.value;
}
}
};
const filterMovies = function () {
if (!movie_query) {
filtered_movies.value = movies.value;
return; return;
} }
this.filtered_movies = this.movies.filter(movie => { filtered_movies.value = movies.value.filter((movie) => {
return movie.title.toLowerCase() return (
.search(this.movie_query.toLowerCase()) > -1 movie.title.toLowerCase().search(movie_query.value.toLowerCase()) > -1
);
}); });
}, };
showModal: function (movie) {
this.modal_movie = movie; const showModal = function (movie: Movie) {
document.getElementById("movie-modal").classList.remove("hidden"); modal_movie.value = movie;
}, document.getElementById("movie-modal")?.classList.remove("hidden");
}, };
mounted() {
onMounted(() => {
const route = useRoute(); const route = useRoute();
this.list_id = route.params.id if (typeof route.params.id === "string") {
this.getList(this.list_id) const list_param: string = route.params.id;
list_id.value = parseInt(list_param);
getList(list_id.value);
}
const token = useCookie("token").value; const token = useCookie("token").value;
if (token) { if (token) {
this.logged_in = true; logged_in.value = true;
} }
} });
}
</script> </script>
<style scoped> <style scoped></style>
</style>

14
src/types/movie.ts Normal file
View file

@ -0,0 +1,14 @@
export type Movie = {
id: number;
title: string;
added_by: number;
imdb_id: string;
year: number;
critic_score: string;
genre: string;
director: string;
actors: string;
plot: string;
poster: string;
last_watched: string;
};

View file

@ -1,7 +1,10 @@
import type { Movie } from "~/types/movie";
export type MovieList = { export type MovieList = {
id: number; id: number;
name: string; name: string;
public: boolean; public: boolean;
owner: number; owner: number;
movie_count: number; movie_count: number;
movies: Movie[];
}; };