From b943a45122518497c0a3c45a55fa3041032d3391 Mon Sep 17 00:00:00 2001 From: "filip.kranjec" Date: Sun, 17 Aug 2025 18:01:08 +0200 Subject: [PATCH] flake unutar projekta --- .forgejo/workflows/deploy.yaml | 7 + flake.nix | 25 +++ src/app/app.component.html | 346 +-------------------------------- src/app/app.component.ts | 43 +++- src/app/app.config.ts | 3 +- 5 files changed, 82 insertions(+), 342 deletions(-) create mode 100644 .forgejo/workflows/deploy.yaml create mode 100644 flake.nix diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml new file mode 100644 index 0000000..5c94492 --- /dev/null +++ b/.forgejo/workflows/deploy.yaml @@ -0,0 +1,7 @@ +on: [push] +jobs: + angular: + runs-on: angular + steps: + - uses: actions/checkout@v4 + - run: nix develop . diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..53cce7d --- /dev/null +++ b/flake.nix @@ -0,0 +1,25 @@ +{ + description = "Minimal Angular dev shell"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + outputs = { self, nixpkgs }: + let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + in { + devShells.${system}.default = pkgs.mkShell { + packages = with pkgs; [ nodejs typescript nodePackages.typescript-language-server nodePackages.eslint ]; + shellHook = '' + clear + echo "------------------" + echo "Deploying TFTStats" + echo "------------------" + npm install + npm run build + cp -R dist/tft_stats /var/www/ + ''; + }; + apps.${system}.ng-build = {}; + }; +} diff --git a/src/app/app.component.html b/src/app/app.component.html index 36093e1..658e413 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,336 +1,10 @@ - - - - - - - - - - - -
-
-
- -

Hello, {{ title }}

-

Congratulations! Your app is running. 🎉

-
- -
-
- @for (item of [ - { title: 'Explore the Docs', link: 'https://angular.dev' }, - { title: 'Learn with Tutorials', link: 'https://angular.dev/tutorials' }, - { title: 'CLI Docs', link: 'https://angular.dev/tools/cli' }, - { title: 'Angular Language Service', link: 'https://angular.dev/tools/language-service' }, - { title: 'Angular DevTools', link: 'https://angular.dev/tools/devtools' }, - ]; track item.title) { - - {{ item.title }} - - - - - } -
- -
-
-
- - - - - - - - - - - +@for (champ of champions(); track champ.id) { + + + +} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4c2bd61..0dd9f02 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,12 +1,45 @@ -import { Component } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Component, inject, signal } from '@angular/core'; import { RouterOutlet } from '@angular/router'; +export type Champion = { + id: string; + name: string; + sprite: string; + tier: 1 | 2 | 3 | 4 | 5; +}; + +export type RiotResponse = { + data: any; + type: string; + version: string; +}; + @Component({ - selector: 'app-root', - imports: [RouterOutlet], - templateUrl: './app.component.html', - styleUrl: './app.component.scss' + selector: 'app-root', + imports: [RouterOutlet], + templateUrl: './app.component.html', + styleUrl: './app.component.scss', }) export class AppComponent { title = 'tft_stats'; + http = inject(HttpClient); + public champions = signal([]); + + constructor() { + this.http + .get( + 'https://ddragon.leagueoflegends.com/cdn/15.16.1/data/en_US/tft-champion.json', + ) + .subscribe((res) => { + this.champions.update((champs) => { + return Object.values(res.data).map((val: any) => ({ + id: val.id, + name: val.name, + sprite: val.image.full, + tier: val.tier, + })); + }); + }); + } } diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 6c6ef60..8bc4d99 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -2,7 +2,8 @@ import { ApplicationConfig } from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; +import { provideHttpClient } from '@angular/common/http'; export const appConfig: ApplicationConfig = { - providers: [provideRouter(routes)] + providers: [provideRouter(routes), provideHttpClient()], };