From f637204856307601e09a3ce3aa9732f6f6ce6cd1 Mon Sep 17 00:00:00 2001 From: Samuel Imolorhe Date: Mon, 13 Nov 2017 21:45:10 +0100 Subject: [PATCH] Added link to github issues and added experimental flag in storage. --- src/app/effects/query.ts | 21 +++++++++++++++------ src/app/services/db.service.ts | 8 ++++---- src/app/services/notify/notify.service.ts | 22 ++++++++++++++++++---- src/app/services/window.service.ts | 7 ++++--- 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/app/effects/query.ts b/src/app/effects/query.ts index 837526b5fb..b40a2cfb04 100644 --- a/src/app/effects/query.ts +++ b/src/app/effects/query.ts @@ -5,7 +5,7 @@ import { Observable } from 'rxjs/Observable'; import * as validUrl from 'valid-url'; -import { GqlService, QueryService, NotifyService } from '../services'; +import { GqlService, QueryService, NotifyService, DbService } from '../services'; import * as fromRoot from '../reducers'; import * as queryActions from '../actions/query/query'; @@ -198,11 +198,19 @@ export class QueryEffects { notifyExperimental$: Observable = this.actions$ .ofType(layoutActions.NOTIFY_EXPERIMENTAL) .switchMap(() => { - this.notifyService.info(` - This feature is experimental, and still in beta. - Click here to submit bugs, improvements, etc. - `, null, { - toastLife: 10000 + this.dbService.getItem('exp_add_query_seen').subscribe(val => { + if (!val) { + this.notifyService.info(` + This feature is experimental, and still in beta. + Click here to submit bugs, improvements, etc. + `, null, { + dismiss: 'click', + data: { + url: 'https://github.com/imolorhe/altair/issues/new' + } + }); + this.dbService.setItem('exp_add_query_seen', true); + } }); return Observable.empty(); }); @@ -213,6 +221,7 @@ export class QueryEffects { private gqlService: GqlService, private queryService: QueryService, private notifyService: NotifyService, + private dbService: DbService, private store: Store ) {} diff --git a/src/app/services/db.service.ts b/src/app/services/db.service.ts index f2fd7bdc6d..2d9dc0014f 100644 --- a/src/app/services/db.service.ts +++ b/src/app/services/db.service.ts @@ -22,7 +22,7 @@ export class DbService { * Gets the item with the exact name specified * @param key */ - getItemByExactKey(key) { + getItemByExactKey(key): Observable { const dbValue = localStorage.getItem(key); return Observable.create((observer) => { @@ -44,7 +44,7 @@ export class DbService { * The key is retrieved with the application-specific key * @param key */ - getItem(key) { + getItem(key): Observable { return this.getItemByExactKey(this.getItemName(key)); } @@ -53,7 +53,7 @@ export class DbService { * @param key * @param value */ - setItem(key, value) { + setItem(key, value): Observable { const dbValue = { value: null }; @@ -71,7 +71,7 @@ export class DbService { * Removes an item with the specified exact key * @param key */ - removeItemByExactKey(key) { + removeItemByExactKey(key): Observable { localStorage.removeItem(key); return Observable.create(obs => obs.next(null)); diff --git a/src/app/services/notify/notify.service.ts b/src/app/services/notify/notify.service.ts index 72671c58cd..ff2dfdb27a 100644 --- a/src/app/services/notify/notify.service.ts +++ b/src/app/services/notify/notify.service.ts @@ -7,18 +7,32 @@ export class NotifyService { constructor( private toastr: ToastsManager ) { + this.toastr.onClickToast().subscribe(toast => { + if (toast.data && toast.data['url']) { + // navigate to + window.open(toast.data['url'], '_blank'); + } + if (toast.timeoutId) { + clearTimeout(toast.timeoutId); + // do something before dismiss the toast + this.toastr.dismissToast(toast); + } + }); } success(message, title = 'Altair', opts = {}) { - this.toastr.success(message, title, opts); + return this.exec('success', message, title, opts); } error(message, title = 'Altair', opts = {}) { - this.toastr.error(message, title, opts); + return this.exec('error', message, title, opts); } warning(message, title = 'Altair', opts = {}) { - this.toastr.warning(message, title, opts); + return this.exec('warning', message, title, opts); } info(message, title = 'Altair', opts = {}) { - this.toastr.info(message, title, opts); + return this.exec('info', message, title, opts); + } + exec(type, message, title, opts) { + return this.toastr[type](message, title, opts); } } diff --git a/src/app/services/window.service.ts b/src/app/services/window.service.ts index 0000c021ac..0497716c17 100644 --- a/src/app/services/window.service.ts +++ b/src/app/services/window.service.ts @@ -3,6 +3,7 @@ import { Store } from '@ngrx/store'; import * as uuid from 'uuid/v4'; +import { Subscription } from 'rxjs/Subscription'; import { Observable } from 'rxjs/Observable'; import * as fromRoot from '../reducers'; @@ -19,7 +20,7 @@ export class WindowService { private store: Store ) { } - loadWindows(): Observable { + loadWindows(): Subscription { return this.db.getItem('windows').subscribe(data => { if (data && Object.keys(data).length) { this.store.dispatch(new windowActions.SetWindowsAction(data)); @@ -29,7 +30,7 @@ export class WindowService { }); } - newWindow(): Observable { + newWindow(): Subscription { return this.db.getItem('windows').subscribe(data => { data = data || []; @@ -46,7 +47,7 @@ export class WindowService { }); } - removeWindow(windowId): Observable { + removeWindow(windowId): Subscription { return this.db.getItem('windows').subscribe(data => { data = data || [];