{"id":24018687,"url":"https://github.com/ryancoll/comp-3330-week11","last_synced_at":"2026-06-10T22:31:07.270Z","repository":{"id":139649180,"uuid":"429679445","full_name":"RyanColl/Comp-3330-week11","owner":"RyanColl","description":null,"archived":false,"fork":false,"pushed_at":"2021-11-29T00:56:52.000Z","size":660,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-18T22:16:16.097Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RyanColl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-19T05:24:44.000Z","updated_at":"2021-11-29T00:56:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb4240a5-4db6-4bfd-8979-8dbb9443b9b4","html_url":"https://github.com/RyanColl/Comp-3330-week11","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RyanColl/Comp-3330-week11","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanColl%2FComp-3330-week11","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanColl%2FComp-3330-week11/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanColl%2FComp-3330-week11/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanColl%2FComp-3330-week11/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RyanColl","download_url":"https://codeload.github.com/RyanColl/Comp-3330-week11/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanColl%2FComp-3330-week11/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34174148,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-08T10:17:38.244Z","updated_at":"2026-06-10T22:31:07.253Z","avatar_url":"https://github.com/RyanColl.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# COMP 3330 - Week 11 - Lab\n\nRyan Collicutt - A00888552 | https://complabs2.web.app\n\n# Week 11\n\nIn week 11 we explored workign with API's in Angular. Because we are experienced with web-apps, we jumped right into pulling movie data from the IMBD API. Today I am going to cover the details of the assignment and what it is I have done here. I used the comman ```ng g c componentName``` for all of my components. This gives me a brand new folder in the app directory that comes with its own css, html, model and component files. \n\n# ES6 usage Examples\n\n1. Class AppComponent from lines 10-12 of app.component.ts:\n```js\nexport class AppComponent {\n  title = 'hw6';\n}\n```\n\n2. Arrow Function from a modal transition animation property from lines 9-19 of movie-modal.component.ts\n```js\nanimations: [\n    trigger('dialog', [\n      transition('void =\u003e *', [\n        style({ transform: 'scale3d(.3, .3, .3)' }),\n        animate(100)\n      ]),\n      transition('* =\u003e void', [\n        animate(100, style({ transform: 'scale3d(.0, .0, .0)' }))\n      ])\n    ])\n  ]\n```\n\n3. Let from the declaration of a Page variable from lines 61-66 of home.component.ts\n```js\nlet page: Page = {\n      page: 1,\n      totalPages: 0,\n      totalResults: 0,\n      results: []\n    }\n```\n\n4. Const from the declaration of a Page array from line 60 of home.component.ts\n```js\nconst pages: Page[] = []\n```\n\n5. Template Literal String inside of a console.log from line 88 of home.component.ts\n```js\nconsole.log(`pagelength: ${this.displayedPages.length}, movielength: ${this.displayedMovies.length}`)\n```\n\n6. Spread syntax inserting page information into a page object, and also movies into a movie array for each page, from lines 73-78 of home.component.ts\n```js\npage = {...page, ...{\n        page: ((~~(i/20))+1),\n        totalPages: 0,\n        totalResults: 0,\n        results: [...page.results, movie]\n      }}\n```\n\n7. Modules from importing necessary modules from lines 1-3 of home.component.ts\n```js\nimport { Component, OnInit } from '@angular/core';\nimport { MovieServices } from '../app.movie.services';\nimport { Genre, Movie, Page } from '../app.types';\n```\n\n8. Destructuring in an import statement from line 3 of movie-modal.component.ts\n```js\nimport { Movie } from '../app.types';\n```\n\n# How It Works\n\nMy experience with Angular this time was much better. Angular is suprisingly... nice to work with. At first, I thought because it followed a more object oriented structure, that it would be less attractive, as I am more of a functional programmer. But there is something nice about the way it integrates into html.\n\nThe movie list is pulled from the imbd database using their api's. I used interfaces to create types for each of the data type coming in. The following interfaces are necessary to make dealing with the data in typescript easy. \napp.types.ts\n```js\nexport interface Movie {\n    id: number;\n    original_language: string;\n    title: string;\n    release_date: string;\n    backdrop_path: string;\n    overview: string;\n    poster_path: string;\n    genre_ids: number[];\n  }\n\nexport interface Genre {\n    id: number;\n    name: string;\n}\n\nexport interface Page {\n    page: number;\n    results: Movie[];\n    totalPages: number;\n    totalResults: number;\n}\n```\n\nThese types give us insight into the pages we will see, and the data they will contain, like each page has a movie array. Using fetch, I create a file called app.movie.services.ts, which calls the movie data inside of a for loop, inserting it into an array, then returning the array through a promise. This was then received in the home.component.ts and assigned to the proper variables to keep the data for the app. \napp.movie.services\n```js\nexport class MovieServices {\n  public api =\n    'https://api.themoviedb.org/3/discover/movie?api_key=yourapikeyhere\u0026language=en-US\u0026sort_by=popularity.desc\u0026include_video=true';\n  public error!: any;\n  private genreApi = 'https://api.themoviedb.org/3/genre/movie/list?api_key=yourapikeyhere\u0026language=en-US'\n  // private Pages: Page[] = [];\n  public awaitGenres(): Promise\u003cGenre[]\u003e {\n    return new Promise((res, rej) =\u003e {\n      fetch(this.genreApi)\n          .then((data) =\u003e data.json())\n          .then((result) =\u003e {\n            res(result.genres)\n          })\n          .catch((e) =\u003e (this.error = e));\n    })\n  }\n  public awaitPages() {\n    const fn = (i: number) =\u003e {\n      return new Promise((res, rej) =\u003e {\n        fetch(`${this.api}\u0026page=${i + 1}`).then((data) =\u003e data.json())\n        .then((result) =\u003e {\n          res(result)\n        })\n      })\n    }\n    return new Promise((res, rej) =\u003e {\n      let pages: Page[] = []\n      for(let i = 0; i\u003c10; i++) {\n         fn(i).then(r =\u003e {\n           // @ts-ignore\n          pages = [...pages, r] \n          if(i === 9) {\n            console.log(pages) \n            res(pages)\n          }         \n         }) \n      }       \n    }) \n  }\n}\n```\n\nOnce the data was in its correct variables in the home component, the movies would load into the web page. The movies were loaded in based on the Page array, and changing a page using the buttons would show the different movies on each page. Everything is dynamic, so when the imbd api fails to return us 10 pages, and only gives us 8, then our app does not fail or glitch out, it shows the correct number of pages. I also decided to use a modal that would popup on click with the selected movie and a more detailed description. \n\n\n# Genre \n\nThe Genre dropdown was fun to implement. It allows you to filter through all of the movies as to which genre you choose. Pages displayed after using the Genre dropdown use different variables than pages regularly displayed. First, it filters through the displayed movies. Each movie has an array of genre ids, so we use an include inside of the filter to pull any movies whos included id's match in the selected genre id. Then, we create a page object we can use for filling with movies. We use spread syntax tospread the object through a loop, adding a movie to the page every time. Using ```(~~(i/20))```, we can ensure after the 200th, 40th, 60th... movie we have a new page. This means only 20 movies displayed on the page. The following logic is how this is completed. \nLines 54-89 of home.component.ts\n```js\ndisplayGenre(genre: Genre) {\n    this.pageCount = 1;\n    this.currentGenre = genre\n    this.displayedMovies = this.Movies.filter((movie: Movie) =\u003e {\n      return movie.genre_ids.includes(genre.id)\n    })\n    const pages: Page[] = []\n    let page: Page = {\n      page: 1,\n      totalPages: 0,\n      totalResults: 0,\n      results: []\n    }\n    \n    this.displayedMovies.forEach((movie: Movie, i: number) =\u003e {\n      if(i%20===0 \u0026\u0026 i!==0) {\n        pages.push(page)\n        page = {...page, results: []}\n      }\n      page = {...page, ...{\n        page: ((~~(i/20))+1),\n        totalPages: 0,\n        totalResults: 0,\n        results: [...page.results, movie]\n      }}\n      if(i+1 === this.displayedMovies.length) {\n        console.log('here',page)\n        pages.push(page)\n        return;\n      }\n      \n    })  \n    this.displayedPages = pages\n    this.pageTotal = this.displayedPages.length\n    console.log(`pagelength: ${this.displayedPages.length}, movielength: ${this.displayedMovies.length}`)\n  }\n```\n\n# Design Architecture\n\nThis time, we are using routing with angular, so our app is very simple. I used the original navbar from the template that comes with a starter project, and I added routing underneath it. That way, my routing can be controlled from the nav bar.\n```html\n\u003cnav\u003e\u003c/nav\u003e\n\u003crouter-outlet\u003e\u003c/router-outlet\u003e\n```\n\nI have two routs inside my app. About and Home. Home is the movie list, and About is about me. In Home, My home component contains my movie modal component, and all of logic for the movie display. \nhome.component.ts\n```html\n    \u003cmovie-modal  [(visible)]=\"showCard\" [(currentMovie)]=\"currentMovie\"\u003e\n      \u003ch1\u003eHello World\u003c/h1\u003e\n      \u003cbutton (click)=\"showCard = !showCard\" class=\"btn\"\u003eClose\u003c/button\u003e\n    \u003c/movie-modal\u003e\n```\n\nMy app.movie.services.ts holds the logic in calling the api and returning the data in a promise. And my app.types.ts contains the type definitions for all of the object structure for the api data. \n\nOverall, I am proud of my app and would use angular again in the future.\n\n\n# Hosted \n# @\n# https://complabs2.web.app","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryancoll%2Fcomp-3330-week11","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryancoll%2Fcomp-3330-week11","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryancoll%2Fcomp-3330-week11/lists"}