Skip to content

Commit da6c105

Browse files
committed
download latest interpreter release
1 parent d79cde9 commit da6c105

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/app/app.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
<h3>Getting Started</h3>
2020
</mat-card-title>
2121
<mat-card-content class="download">
22-
<button mat-raised-button class="detected-os">Download <sup>{{ os }}</sup></button>
22+
<button mat-raised-button class="detected-os" (click)="download(os)">Download <sup>{{ os }}</sup></button>
2323
<div class="other-os">
2424
@for(item of oss; track item) {
2525
@if (item !== os) {
26-
<button mat-stroked-button>{{ item }}</button>
26+
<button mat-stroked-button (click)="download(item)">{{ item }}</button>
2727
}
2828
}
2929
</div>

src/app/app.component.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { MediaMatcher } from '@angular/cdk/layout';
22
import { isPlatformBrowser } from '@angular/common';
3+
import { HttpClient } from '@angular/common/http';
34
import { ChangeDetectorRef, Component, Inject, inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core';
45
import { MatButtonModule } from '@angular/material/button';
56
import { MatCardModule } from '@angular/material/card';
@@ -23,7 +24,10 @@ export class AppComponent implements OnInit, OnDestroy {
2324

2425
private _mobileQueryListener: () => void;
2526

26-
constructor(@Inject(PLATFORM_ID) private platformId: any) {
27+
constructor(
28+
@Inject(PLATFORM_ID) private platformId: any,
29+
private http: HttpClient
30+
) {
2731
const changeDetectorRef = inject(ChangeDetectorRef);
2832
const media = inject(MediaMatcher);
2933

@@ -47,6 +51,17 @@ export class AppComponent implements OnInit, OnDestroy {
4751
this.setTheme();
4852
}
4953

54+
download(os: string): void {
55+
const url = "https://api.github.com/repos/sQeeZ-scripting-language/interpreter/releases/latest";
56+
this.http.get(url).subscribe((data: any) => {
57+
data.assets.find((asset: any) => {
58+
if (asset.browser_download_url.includes(os.toLowerCase())) {
59+
window.location.href = asset.browser_download_url;
60+
}
61+
});
62+
});
63+
}
64+
5065
private getSystemTheme(): string {
5166
return (typeof window !== 'undefined' && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light';
5267
}

src/app/app.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { provideRouter } from '@angular/router';
33

44
import { routes } from './app.routes';
55
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
6+
import { provideHttpClient } from '@angular/common/http';
67

78
export const appConfig: ApplicationConfig = {
8-
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideAnimationsAsync()]
9+
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideAnimationsAsync(), provideHttpClient()]
910
};

0 commit comments

Comments
 (0)