当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

angular-spotify

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 楚墨一
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Angular Spotify

A simple Spotify client built with Angular 12, Nx workspace, ngrx, TailwindCSS and ng-zorro.

I have recently shared about #angularspotify at AngularAir, you can watch the session here �� youtu.be/uPB0KHKlrU8

Working application

Check out the live application -> https://spotify.trungk18.com

Spotify premium is required for the Web Playback SDK to play music. If you are using a free account, you can still browse the app, but it couldn't play the music. Sorry about that ��

Support

If you like my work, feel free to:

  • this repository. And we will be happy together :)
  • about Angular Spotify
  • Buy Me A Coffee

Thanks a bunch for stopping by and supporting me!

Who is it for ��‍♀️

I still remember Window Media Player on windows has the visualization when you start to play the music, and I wanted to have the same experience when listening to Spotify. That is the reason I started this project.

I found that there weren't many resources on building a proper real-world scale application, and that's my focus for sharing. I made a Jira clone application as the first one for that purpose. Nx workspace is getting more and more attention from the Angular community, but people are always confused about how to architect and set up an Nx project. I hope Angular Spotify will give you more insight on that even though it is my first project using Nx ��


You know I am one of the moderators of Angular Vietnam. Recently, I also started Angular Singapore. This piece of work is my other long-term plan to bring Angular knowledge to more people. I desire to advocate and grow the Angular developer community in Singapore and Vietnam :)

Tech stack

I experimented with the ngrx/component store for AuthStore and UIStore. It might not be a best practice, and I will refactor it very soon. Just FYI ��

High-level design

See my original notes on Nx workspace structure for NestJS and Angular

Principles

All components are following:

  • OnPush Change Detection and async pipes: all components use observable and async pipe for rendering data without any single manual subscribe. Only some places are calling subscribe for dispatching an action, which I will have a refactor live stream session with my friend @nartc to use the component store for a fully subscribe-less application.
  • SCAMs (single component Angular modules) for tree-shakable components, meaning each component will have a respective module. For example, a RegisterComponent will have a corresponding RegisterModule. We won't declare RegisterComponent as part of AuthModule, for instance.
  • Mostly, everything will stay in the libs folder. New modules, new models, new configurations, new components etc... are in libs. libs should be separated into different directories based on existing apps. We won't put them inside the apps folder. For example in an Angular, contains the main.ts, app.component.ts and app.module.ts

Structure

I followed the structure recommended by my friend @nartc. Below is the simplified version of the application structure.

.
└── root
    ├── apps
    │   └── angular-spotify
    └── libs
        └── web (dir)
            ├── shell (dir)
            │   ├── feature (angular:lib) - for configure any forRoot modules
            │   └── ui
            │       └── layout (angular:lib)
            ├── settings (dir)
            │   ├── feature (angular:lib) - for configure and persist all settings
            │   └── data-access (workspace:lib) - store and services for settings module
            ├── playlist (dir)
            │   ├── data-access (angular:lib, service, state management)
            │   ├── features
            │   │   ├── list (angular:lib PlaylistsComponent)
            │   │   └── detail (angular:lib PlaylistDetailComopnent)
            │   └── ui (dir)
            │       └── playlist-track (angular:lib, SCAM for Component)
            ├── visualizer (dir)
            │   ├── data-access (angular:lib)
            │   ├── feature
            │   └── ui (angular:lib)
            ├── home (dir)
            │   ├── data-access (angular:lib)
            │   ├── feature (angular:lib)
            │   └── ui (dir)
            │       ├── featured-playlists (angular:lib, SCAM for Component)
            │       ├── greeting (angular:lib, SCAM for Component)
            │       └── recent-played (angular:lib, SCAM for Component)
            └── shared (dir)
                ├── app-config (injection token for environment)
                ├── data-access (angular:lib, API call, Service or State management to share across the Client app)
                ├── ui (dir)
                ├── pipes (dir)
                ├── directives (dir)
                └── utils (angular:lib, usually shared Guards, Interceptors, Validators...)

Authentication Flow

I follow Implicit Grant Flow that Spotify recommended for client-side only applications and did not involve secret keys. The issued access tokens are short-lived, and there are no refresh tokens to extend them when they expire.

View the Spotify Authorization Guide

  • Upon opening Angular Spotify, It will redirect you to Spotify to get access to your data. Angular Spotify only uses the data purely for displaying on the UI. We won't store your information anywhere else.
  • Angular Spotify only keeps the access token in the browser memory without even storing it into browser local storage. If you do a hard refresh on the browser, It will ask for a new access token from Spotify. One access token is only valid for one hour.
  • After having the token, I'll try to connect to the Web Playback SDK with a new player - Angular Spotify Web Player

Dependency Graph

Nx provides an dependency graph out of the box. To view it on your browser, clone my repository and run:

npm run dep-graph

A simplified graph looks like the following. It gives you insightful information for your mono repo and is especially helpful when multiple projects depend on each other.

Nx Computation Cache

Having Nx Cloud configured shortens the deployment time quite a lot.

Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times. Even teams that are new to Nx can connect to Nx Cloud and start saving time instantly. Visit Nx Cloud to learn more.

Features and Roadmap

I set a tentative deadline for motivating myself to finish the work on time. Otherwise, It will take forever to complete :)

1.0 - Simple Spotify client

March 01 - 28, 2021

  • Proven, scalable, and easy to understand the structure with Nx workspace
  • Play music using Spotify SDK
  • Load a maximum of 50 save playlists and top 100 songs per playlist.
  • Cool visualization

Live stream

Let work on it together!

I scheduled a few live stream sessions to show you how I continue developing Angular Spotify. Follow my twitter for the latest updates. See the scheduled events.

# Time Description/Link
1 Sat, 3rd April 2021, 10AM Structure your Angular application with Nx workspace
2 Sat, 10th April 2021, 10AM Build the album list page
3 Sat, 17th April 2021, 10AM Build the album detail page - part 1
4 Sat, 24th April 2021, 10AM Build the album detail page - part 2
5 Sat, 8th May 2021, 10AM Build the artist detail page - part 1
6 Sat, 15th May 2021, 10AM Build the artist detail page - part 2
7 Sat, 12th Jun 2021, 10AM Build the track list page - part 1
8 Sat, 19th Jun 2021, 10AM Build the track list page - part 2
9 Sun, 11th July 2021, 10AM NgRx Component Store Unit Testing
10 TBD Config Nx build:affected with Github action

I will also do some refactoring with @nartc for Angular Vietnam Office Hours. More detail is coming soon.

Community

I have received some invitations to talk about Angular Spotify from the community. You can watch my talks below ��

BLS033

AngularAir

# Time Description/Link
1 Wed, 21st April 2021 BLS SHOW & TELL - Angular Spotify
2 Fri, 08th May 2021 AngularAir - Another 1k stars repository

Time spending

It is a side project that I only spent time outside of the office hours to work on. I initially planned to complete the project within two weeks, but the first two weekends were not very productive, maybe because of the holiday mood from Lunar New Year :) But once the lego blocks are getting together, I feel the rhythm, and I know it has to be finished by the end of March.

I couldn't get the full-time report from waka time because it only shows me the latest two weeks. ��

I have spent approximately 50 hours working on this project, which is almost the same amount as the first version of jira.trungk18.com.

The visualizer was the most exciting feature, and I decided to start this project because of that single component.

Accessibility

Not all components have properly defined aria attributes, visual focus indicators, etc.

Setting up the development environment ��

  • git clone https://github.com/trungk18/angular-spotify.git
  • cd angular-spotify
  • npm start for starting Angular web application
  • The app should run on http://localhost:4200/

Unit/Integration tests ��

I skipped writing test for this project.

Compatibility

Web Playback SDK supports Chrome, Firefox, Edge, IE 11, or above running on Mac/Windows/Linux.

It doesn't support Safari or any mobile browser on Android or iOS

View completed list of supported browsers

Author: Trung Vo ✍️

  • A seasoned front-end engineer with seven years of passion in creating experience-driven products. I am proficient in Angular, React and TypeScript development.
  • Personal blog: https://trungk18.com/
  • Say hello: trungk18 [et] gmail [dot] com

Contributing

If you have any ideas, just open an issue and tell me what you think.

If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are warmly welcome.

Credits and reference

Special thanks to my friend @nartc, who helped me review the code early.

Resource Description
@koel/koel A cool player made by @phanan, I reused the visualizer code from this repo with my additional customization
beeman/component-store-playground A nice example of using Nx with ngrx/component-store, I refer to the project structure from this repo
Start using ngrx/effects for this An excellent write up by Tim Deschryver

License

Feel free to use my code on your project. Please put a reference to this repository.

MIT

  • 转载自 http://www.ngui.cc/news/show-128.html 在 Angular 中,我们可以使用 HostListener 属性装饰器,实现元素的事件绑定。 指令的作用 该指令用于演示如何利用 HostListener 装饰器,监听用户的点击事件。 指令的实现 import { Directive, HostBinding, HostListener, Input } fr

  • angular-hint可以帮助我们写出更好的angular代码,以及更容易定位angular中常见的错误。 使用方式: 1、使用chrome的插件 batarang 2、手动集成angular-hint,通过  npm install angular-hint --save <script type="/to/angular-hint/hint.js"></script> 启用ngHint指令:

  • Make sure install the latest Angular v6 with Angular CLI. Checkout ght Github for the code.   1. Create a new application: ng new elementApp   2. Install @angular/elements package: ng add @angular/ele

  • angular CLI 命令: ng new 项目名 ng generate component 组件名 ( 默认情况下,生成的组件会带有模板文件,你可以通过参数覆盖它: ng generate component 组件名 -it) ng generate class hero  【 hero.ts 】 ng generate service 服务名 ng generate module 路由模块

  • 使用Angular表达式: 语法: {{expression}} 操作的数据 基本类型数据: number/string/boolean undefined, Infinity(正无穷大的数值), NaN, null解析为空串: “”, 不显示任何效果 对象的属性或方法 数组

  • http://www.w3cschool.cc/angularjs/angularjs-tutorial.html AngularJS入门教程http://www.ituring.com.cn/minibook/303 AngularJS实战:http://www.imooc.com/learn/156 angularjs学习总结 详细教程 :http://blog.csdn.net/yy3748

  • angular.injector 创建一个injector对象, 调用injector对象的方法可用于获取服务以及依赖注入。 格式:angular.injector(modules); modules:  Array 注入的模块(一个或多个)。 使用代码: (function () {     angular.module("firstModule", [])     .service("firs

  • angular.uppercase 将指定的字符串转换成大写 格式:angular.uppercase(string); string:被转换成大写的字符串。 使用代码: var str = "ABCabc";  var upperCase = angular.uppercase(str);//ABCABC angular.lowercase 将指定的字符串转换成小写 格式:angular.low

  • Create an app with routing config: ng new mynewapp --routing   If you want to generate a new module with routing , you can also do: ng g m mynewModule --routing   Define env variable: You can create a

 相关资料
  • Angular 是一款十分流行且好用的 Web 前端框架,目前由 Google 维护。这个条目收录的是 Angular 2 及其后面的版本。由于官方已将 Angular 2 和之前的版本 Angular.js 分开维护(两者的 GitHub 地址和项目主页皆不相同),所以就有了这个页面。传送门:Angular.js 特性 跨平台 渐进式 Web 应用 借助现代化 Web 平台的力量,交付 app

  • 即将到来的Angular 2框架是使用TypeScript开发的。 因此Angular和TypeScript一起使用非常简单方便。 Angular团队也在其文档里把TypeScript视为一等公民。 正因为这样,你总是可以在Angular 2官网(或Angular 2官网中文版)里查看到最新的结合使用Angular和TypeScript的参考文档。 在这里查看快速上手指南,现在就开始学习吧!

  • 从头开始创建项目 lint你的代码 运行您的单元测试和端到端测试。 Angular 2 CLI目前只在TypeScript中生成框架,稍后还会有其他版本。

  • 这小节内容是译者加的,因为我认为对于新手而言,学习一个框架是有成本的,特别是对于一个不算简单的技术来说,我希望这篇教程是对新手友好的,所以我首先要让你放心的将时间和精力投入到Angular2 中。那我们先不谈技术细节,先用数据说话。 这里我多说一句,最近看一些文章中谷歌趋势截图,大都没有把范围限定在“编程”上。图中可以看出Vue2非常少,所以在下面比较中不再单独统计。 教程数量 这里我选取的主要是

  • 我们已经在Highcharts Configuration Syntax一章中看到了用于绘制图表的配置 。 下面给出角度计图表的示例。 配置 (Configurations) 现在让我们看一下所采取的其他配置/步骤。 chart.type 将图表类型配置为基于计量。 将类型设置为“规格”。 var chart = { type: 'guage' }; pane 此类型仅适用于极坐标图和角度

  • 角度计图表用于绘制仪表/仪表类型图表。 在本节中,我们将讨论不同类型的角度计图表。 Sr.No. 图表类型和描述 1 角度计 角度表。 2 实心仪​​表 实心图表。 3 Clock 时钟。 4 带双轴的仪表 带双轴的仪表图。 5 VU表 VU表图表。