Skip to content

Commit

Permalink
Merge ba63e41 into 0ad510c
Browse files Browse the repository at this point in the history
  • Loading branch information
AllienWorks committed Jan 5, 2018
2 parents 0ad510c + ba63e41 commit 11bd7ba
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 15 deletions.
13 changes: 5 additions & 8 deletions src/app/core-ui/main/main-view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<mat-content>
<mat-list class="sidebar-item-group">

<a class="sidebar-item-link" routerLinkActive="active" href="javascript:void(0)" (click)="createWallet()" >
<a class="sidebar-item-link" routerLinkActive="active" href="javascript:void(0)" (click)="createWallet()">
<mat-list-item class="sidebar-item">
<mat-icon class="icon" fontSet="partIcon" fontIcon="part-add-account"></mat-icon>
<span class="text">Add Account</span>
Expand All @@ -93,7 +93,6 @@
</mat-list>
</mat-content> --><!-- .sidebar-section -->


<footer class="pin-to-bottom">

<mat-content *ngIf="!daemonRunning || !walletInitialized">
Expand All @@ -118,7 +117,7 @@
</mat-list><!-- .error.sidebar-item-group -->
</mat-content>

<!-- Versions | TODO: move to separate component? -->
<!-- Versions -->
<mat-content class="client-version">
<div class="client item">
Client <span class="version">{{ clientVersion }}</span>
Expand All @@ -136,12 +135,12 @@

</footer><!-- .pin-to-bottom -->


</mat-sidenav><!-- .sidebar -->



<!-- Page header -->
<!-- info/warning notification -->
<app-release-notification></app-release-notification>

<mat-toolbar class="header-main">
<button fxLayout="row" fxLayoutAlign="center end" mat-button (click)="sidenav.toggle()" fxHide.gt-sm>
<mat-icon fontSet="partIcon" fontIcon="part-hamburger"></mat-icon>
Expand All @@ -158,6 +157,4 @@
<router-outlet></router-outlet>
</div>



</mat-sidenav-container>
3 changes: 1 addition & 2 deletions src/app/core-ui/main/main-view.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ a.sidebar-item-link {
}
}


/* ------------------------------- *\
LAYOUT
\* ------------------------------- */
Expand Down Expand Up @@ -170,4 +169,4 @@ a.sidebar-item-link {
text-transform: uppercase;
font-size: 15px;
font-weight: 700;
}
}
13 changes: 8 additions & 5 deletions src/app/core-ui/main/main-view.module.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { RouterModule } from '@angular/router';
import { MatIconModule } from '@angular/material';

import { MaterialModule } from '../material/material.module';
import { ModalsModule } from '../../modals/modals.module';
import { CoreModule } from '../../core/core.module';

import { MainViewComponent } from './main-view.component';
import { StatusComponent } from './status/status.component';
import { ConsoleModalComponent } from './status/modal/help-modal/console-modal.component';
import { PercentageBarComponent } from '../../modals/shared/percentage-bar/percentage-bar.component';

import { TransactionService } from '../../wallet/wallet/shared/transaction.service';
import { ReleaseNotificationComponent } from './release-notification/release-notification.component';


@NgModule({
imports: [
CommonModule,
RouterModule,
MaterialModule,
MatIconModule
],
exports: [
MainViewComponent,
Expand All @@ -28,10 +29,12 @@ import { TransactionService } from '../../wallet/wallet/shared/transaction.servi
MainViewComponent,
StatusComponent,
PercentageBarComponent,
ConsoleModalComponent
ConsoleModalComponent,
ReleaseNotificationComponent
],
entryComponents: [
ConsoleModalComponent
ConsoleModalComponent,
ReleaseNotificationComponent
],
providers: [
TransactionService
Expand Down
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> &ndash; 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> &ndash; 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 -->
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;
}
}
}
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();
});
});
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));
}

}
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;
};

0 comments on commit 11bd7ba

Please sign in to comment.