mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-05-31 06:20:59 +00:00
Fixes after review
This commit is contained in:
parent
8eafbf66c9
commit
230aaf31fd
@ -185,7 +185,6 @@ import { ConsoleService } from './services/settings/console.service';
|
|||||||
import { DefaultConsoleService } from './services/settings/default-console.service';
|
import { DefaultConsoleService } from './services/settings/default-console.service';
|
||||||
import { NodeCreatedLabelStylesFixer } from './components/project-map/helpers/node-created-label-styles-fixer';
|
import { NodeCreatedLabelStylesFixer } from './components/project-map/helpers/node-created-label-styles-fixer';
|
||||||
import { NotificationBoxComponent } from './components/notification-box/notification-box.component';
|
import { NotificationBoxComponent } from './components/notification-box/notification-box.component';
|
||||||
import { NotificationSettingsService } from './services/notification-settings.service';
|
|
||||||
|
|
||||||
if (environment.production) {
|
if (environment.production) {
|
||||||
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
Raven.config('https://b2b1cfd9b043491eb6b566fd8acee358@sentry.io/842726', {
|
||||||
@ -377,8 +376,7 @@ if (environment.production) {
|
|||||||
ServerManagementService,
|
ServerManagementService,
|
||||||
ConsoleService,
|
ConsoleService,
|
||||||
DefaultConsoleService,
|
DefaultConsoleService,
|
||||||
NodeCreatedLabelStylesFixer,
|
NodeCreatedLabelStylesFixer
|
||||||
NotificationSettingsService
|
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
AddServerDialogComponent,
|
AddServerDialogComponent,
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { timer, interval, Observable, Subscription } from 'rxjs';
|
import { timer, Observable, Subscription } from 'rxjs';
|
||||||
import { take } from 'rxjs/operators';
|
|
||||||
import { NotificationSettingsService } from '../../services/notification-settings.service';
|
|
||||||
import { NotificationSettings } from '../../models/notification-settings-models/notification-settings';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-notification-box',
|
selector: 'app-notification-box',
|
||||||
@ -10,36 +7,38 @@ import { NotificationSettings } from '../../models/notification-settings-models/
|
|||||||
styleUrls: ['./notification-box.component.scss']
|
styleUrls: ['./notification-box.component.scss']
|
||||||
})
|
})
|
||||||
export class NotificationBoxComponent implements OnInit, OnDestroy {
|
export class NotificationBoxComponent implements OnInit, OnDestroy {
|
||||||
notificationSettings: NotificationSettings;
|
|
||||||
timer: Observable<number>;
|
timer: Observable<number>;
|
||||||
|
viewTimer: Observable<number>;
|
||||||
timerSubscription: Subscription;
|
timerSubscription: Subscription;
|
||||||
intervalSubscription: Subscription;
|
viewTimerSubscription: Subscription;
|
||||||
viewsCounter = 0;
|
viewsCounter = 0;
|
||||||
ticks: number = 1000;
|
ticks: number = 1000;
|
||||||
progress: number = 0;
|
progress: number = 0;
|
||||||
isVisible = false;
|
isVisible = false;
|
||||||
interval = 10;
|
interval = 10;
|
||||||
|
|
||||||
constructor(
|
delayTime: number = 0;
|
||||||
private notifactionSettingsService: NotificationSettingsService
|
breakTime: number = 1000;
|
||||||
){}
|
isEndless: boolean = true;
|
||||||
|
numberOfViews: number = 1;
|
||||||
|
|
||||||
|
constructor(){}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.notificationSettings = this.notifactionSettingsService.getConfiguration();
|
|
||||||
this.startTimer();
|
this.startTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
startTimer() {
|
startTimer() {
|
||||||
this.timer = timer(this.notificationSettings.delayTime, 1000);
|
this.timer = timer(this.delayTime, 1000);
|
||||||
|
|
||||||
this.timerSubscription = this.timer.subscribe(() => {
|
this.timerSubscription = this.timer.subscribe(() => {
|
||||||
this.ticks++;
|
this.ticks++;
|
||||||
if (this.ticks > this.notificationSettings.breakTime && navigator.onLine) {
|
if (this.ticks > this.breakTime && !this.isVisible && navigator.onLine) {
|
||||||
this.ticks = 0;
|
this.ticks = 0;
|
||||||
this.showNotification();
|
this.showNotification();
|
||||||
this.viewsCounter++;
|
this.viewsCounter++;
|
||||||
if (!this.notificationSettings.isEndless){
|
if (!this.isEndless){
|
||||||
if (this.viewsCounter === this.notificationSettings.numberOfViews) {
|
if (this.viewsCounter === this.numberOfViews) {
|
||||||
this.timerSubscription.unsubscribe();
|
this.timerSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,14 +47,15 @@ export class NotificationBoxComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showNotification() {
|
showNotification() {
|
||||||
|
this.viewTimer = timer(0, 100);
|
||||||
this.isVisible = true;
|
this.isVisible = true;
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
|
|
||||||
this.intervalSubscription = interval(this.interval).pipe(take(this.notificationSettings.viewTime)).subscribe(() => {
|
this.viewTimerSubscription = this.viewTimer.subscribe(() => {
|
||||||
this.progress += (1/this.interval);
|
this.progress += 1;
|
||||||
if (this.progress > ((this.notificationSettings.viewTime/this.interval)-(1/this.interval))) {
|
if (this.progress > 100) {
|
||||||
this.isVisible = false;
|
this.isVisible = false;
|
||||||
this.intervalSubscription.unsubscribe();
|
this.viewTimerSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -66,5 +66,6 @@ export class NotificationBoxComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.timerSubscription.unsubscribe();
|
this.timerSubscription.unsubscribe();
|
||||||
|
this.viewTimerSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
export class NotificationSettings {
|
|
||||||
delayTime: number;
|
|
||||||
viewTime: number;
|
|
||||||
breakTime: number;
|
|
||||||
numberOfViews?: number;
|
|
||||||
isEndless: boolean;
|
|
||||||
contentToShow?: string;
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { NotificationSettings } from '../models/notification-settings-models/notification-settings';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class NotificationSettingsService {
|
|
||||||
|
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
getConfiguration(): NotificationSettings {
|
|
||||||
let configuration: NotificationSettings = {
|
|
||||||
delayTime: 0,
|
|
||||||
viewTime: 1000,
|
|
||||||
breakTime: 1000,
|
|
||||||
isEndless: true,
|
|
||||||
numberOfViews: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user