mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-21 22:07:48 +00:00
Initial implementation
This commit is contained in:
parent
0809759765
commit
fd6393acf7
@ -185,6 +185,7 @@ 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', {
|
||||||
@ -376,7 +377,8 @@ if (environment.production) {
|
|||||||
ServerManagementService,
|
ServerManagementService,
|
||||||
ConsoleService,
|
ConsoleService,
|
||||||
DefaultConsoleService,
|
DefaultConsoleService,
|
||||||
NodeCreatedLabelStylesFixer
|
NodeCreatedLabelStylesFixer,
|
||||||
|
NotificationSettingsService
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
AddServerDialogComponent,
|
AddServerDialogComponent,
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { timer, interval, Observable } from 'rxjs';
|
import { timer, interval, Observable, Subscription } from 'rxjs';
|
||||||
import { take } from 'rxjs/operators';
|
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',
|
||||||
@ -8,27 +10,38 @@ import { take } from 'rxjs/operators';
|
|||||||
styleUrls: ['./notification-box.component.scss']
|
styleUrls: ['./notification-box.component.scss']
|
||||||
})
|
})
|
||||||
export class NotificationBoxComponent implements OnInit {
|
export class NotificationBoxComponent implements OnInit {
|
||||||
|
notificationSettings: NotificationSettings;
|
||||||
timer: Observable<number>;
|
timer: Observable<number>;
|
||||||
|
timerSubscription: Subscription;
|
||||||
|
viewsCounter = 0;
|
||||||
ticks: number = 0;
|
ticks: number = 0;
|
||||||
|
progress: number = 0;
|
||||||
isVisible = true;
|
isVisible = false;
|
||||||
progress : number = 0;
|
|
||||||
|
|
||||||
initialTime = 1000;
|
|
||||||
showTime = 1000;
|
|
||||||
breakTime = 10;
|
|
||||||
interval = 10;
|
interval = 10;
|
||||||
|
|
||||||
constructor(){}
|
constructor(
|
||||||
|
private notifactionSettingsService: NotificationSettingsService
|
||||||
|
){}
|
||||||
|
|
||||||
ngOnInit(){
|
ngOnInit() {
|
||||||
this.timer = timer(this.initialTime, 1000);
|
this.notificationSettings = this.notifactionSettingsService.getConfiguration();
|
||||||
|
this.startTimer();
|
||||||
|
}
|
||||||
|
|
||||||
this.timer.subscribe(() => {
|
startTimer() {
|
||||||
|
this.timer = timer(this.notificationSettings.delayTime, 1000);
|
||||||
|
|
||||||
|
this.timerSubscription = this.timer.subscribe(() => {
|
||||||
this.ticks++;
|
this.ticks++;
|
||||||
if (this.ticks > this.breakTime) {
|
if (this.ticks > this.notificationSettings.breakTime) {
|
||||||
this.ticks = 0;
|
this.ticks = 0;
|
||||||
this.showNotification();
|
this.showNotification();
|
||||||
|
this.viewsCounter++;
|
||||||
|
if (!this.notificationSettings.isEndless){
|
||||||
|
if (this.viewsCounter === this.notificationSettings.numberOfViews) {
|
||||||
|
this.timerSubscription.unsubscribe();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -37,15 +50,15 @@ export class NotificationBoxComponent implements OnInit {
|
|||||||
this.isVisible = true;
|
this.isVisible = true;
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
|
|
||||||
interval(this.interval).pipe(take(this.showTime)).subscribe(() => {
|
interval(this.interval).pipe(take(this.notificationSettings.viewTime)).subscribe(() => {
|
||||||
this.progress += (1/this.interval);
|
this.progress += (1/this.interval);
|
||||||
if (this.progress > ((this.showTime/this.interval)-(1/this.interval))) {
|
if (this.progress > ((this.notificationSettings.viewTime/this.interval)-(1/this.interval))) {
|
||||||
this.isVisible = false;
|
this.isVisible = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
closeNotification(){
|
closeNotification() {
|
||||||
this.isVisible = false;
|
this.isVisible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
export class NotificationSettings {
|
||||||
|
delayTime: number;
|
||||||
|
viewTime: number;
|
||||||
|
breakTime: number;
|
||||||
|
numberOfViews?: number;
|
||||||
|
isEndless: boolean;
|
||||||
|
contentToShow?: string;
|
||||||
|
}
|
20
src/app/services/notification-settings.service.ts
Normal file
20
src/app/services/notification-settings.service.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
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: 1000,
|
||||||
|
viewTime: 1000,
|
||||||
|
breakTime: 10,
|
||||||
|
isEndless: true,
|
||||||
|
numberOfViews: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user