-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
150 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/app/core-ui/main/release-notification/release-notification.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<mat-card class="notification info" *ngIf="latestClientVersion && isNewUpdateAvailable()"> | ||
<mat-card-title class="title"> | ||
New update available <span class="tag">v{{ latestClientVersion }}</span> – please upgrade: | ||
<a href="{{releaseUrl}}" target="_blank" class="button" mat-button color="primary"> | ||
<mat-icon class="icon" fontSet="partIcon" fontIcon="part-lightning"></mat-icon> | ||
Upgrade now | ||
</a> | ||
</mat-card-title> | ||
</mat-card><!-- .notification --> | ||
|
||
<mat-card class="notification alert" *ngIf="false"> | ||
<mat-card-title class="title"> | ||
New security update available <span class="tag">1.1.2</span> – please upgrade: | ||
<button class="button" mat-button color="warn"> | ||
<mat-icon class="icon" fontSet="partIcon" fontIcon="part-lightning"></mat-icon> | ||
Upgrade now | ||
</button> | ||
</mat-card-title> | ||
</mat-card><!-- .notification --> |
41 changes: 41 additions & 0 deletions
41
src/app/core-ui/main/release-notification/release-notification.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@import "./src/assets/_config"; // import shared colors etc. | ||
|
||
// ------ ALERTS/NOTIFICATIONS ------ // | ||
|
||
mat-card.notification { | ||
@extend %disable-select; | ||
padding: 12px 28px; | ||
background: $bg; | ||
box-shadow: 0 1px $bg-shadow !important; | ||
border-left: 6px solid transparent; | ||
border-radius: 0; | ||
&.info { | ||
border-left: 6px solid $color; | ||
.title .tag { | ||
background: $color; | ||
} | ||
} | ||
&.alert { | ||
border-left: 6px solid $color-alert; | ||
.title .tag { | ||
background: $color-alert; | ||
} | ||
} | ||
.title { | ||
font-size: 13px; | ||
font-weight: 600; | ||
margin: 0; | ||
.tag { | ||
background: $text; | ||
color: white; | ||
border-radius: 99px; | ||
padding: 0px 6px; | ||
margin: 0 1px; | ||
font-size: 12px; | ||
font-weight: 700; | ||
} | ||
.button { | ||
margin-left: 8px; | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/app/core-ui/main/release-notification/release-notification.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ReleaseNotificationComponent } from './release-notification.component'; | ||
import { MainViewModule } from '../main-view.module'; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
|
||
describe('ReleaseNotificationComponent', () => { | ||
let component: ReleaseNotificationComponent; | ||
let fixture: ComponentFixture<ReleaseNotificationComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
MainViewModule, | ||
HttpClientModule | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ReleaseNotificationComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
src/app/core-ui/main/release-notification/release-notification.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
|
||
import { environment } from '../../../../environments/environment'; | ||
import { ReleaseNotification } from './release-notification.model'; | ||
|
||
@Component({ | ||
selector: 'app-release-notification', | ||
templateUrl: './release-notification.component.html', | ||
styleUrls: ['./release-notification.component.scss'] | ||
}) | ||
export class ReleaseNotificationComponent implements OnInit { | ||
|
||
public currentClientVersion: string = environment.version; | ||
public latestClientVersion: string; | ||
public releaseUrl: string; | ||
|
||
constructor(private http: HttpClient) { } | ||
|
||
ngOnInit() { | ||
// check new update in every 30 minute | ||
setTimeout(this.getCurrentClientVersion(), 1800000); | ||
} | ||
|
||
getCurrentClientVersion() { | ||
this.http.get('https://api.github.com/repos/particl/partgui/releases/latest').subscribe((response: ReleaseNotification) => { | ||
if (response.tag_name) { | ||
this.latestClientVersion = response.tag_name.substring(1); | ||
} | ||
|
||
this.releaseUrl = response.html_url; | ||
}); | ||
} | ||
|
||
isNewUpdateAvailable(): boolean { | ||
return (parseFloat(this.currentClientVersion) < parseFloat(this.latestClientVersion)); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/app/core-ui/main/release-notification/release-notification.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
export class ReleaseNotification { | ||
tag_name: string; | ||
prerelease: string; | ||
html_url: string; | ||
body: string; | ||
}; |