Skip to content

Commit

Permalink
Added link to github issues and added experimental flag in storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Imolorhe committed Nov 13, 2017
1 parent a6bad43 commit f637204
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 17 deletions.
21 changes: 15 additions & 6 deletions src/app/effects/query.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -198,11 +198,19 @@ export class QueryEffects {
notifyExperimental$: Observable<Action> = this.actions$
.ofType(layoutActions.NOTIFY_EXPERIMENTAL)
.switchMap(() => {
this.notifyService.info(`
This feature is experimental, and still in beta.
Click <a href="https://github.com/imolorhe/altair/issues/new">here</a> 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();
});
Expand All @@ -213,6 +221,7 @@ export class QueryEffects {
private gqlService: GqlService,
private queryService: QueryService,
private notifyService: NotifyService,
private dbService: DbService,
private store: Store<any>
) {}

Expand Down
8 changes: 4 additions & 4 deletions src/app/services/db.service.ts
Expand Up @@ -22,7 +22,7 @@ export class DbService {
* Gets the item with the exact name specified
* @param key
*/
getItemByExactKey(key) {
getItemByExactKey(key): Observable<any> {
const dbValue = localStorage.getItem(key);

return Observable.create((observer) => {
Expand All @@ -44,7 +44,7 @@ export class DbService {
* The key is retrieved with the application-specific key
* @param key
*/
getItem(key) {
getItem(key): Observable<any> {
return this.getItemByExactKey(this.getItemName(key));
}

Expand All @@ -53,7 +53,7 @@ export class DbService {
* @param key
* @param value
*/
setItem(key, value) {
setItem(key, value): Observable<any> {
const dbValue = {
value: null
};
Expand All @@ -71,7 +71,7 @@ export class DbService {
* Removes an item with the specified exact key
* @param key
*/
removeItemByExactKey(key) {
removeItemByExactKey(key): Observable<any> {
localStorage.removeItem(key);

return Observable.create(obs => obs.next(null));
Expand Down
22 changes: 18 additions & 4 deletions src/app/services/notify/notify.service.ts
Expand Up @@ -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);
}
}
7 changes: 4 additions & 3 deletions src/app/services/window.service.ts
Expand Up @@ -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';
Expand All @@ -19,7 +20,7 @@ export class WindowService {
private store: Store<fromRoot.State>
) { }

loadWindows(): Observable<any> {
loadWindows(): Subscription {
return this.db.getItem('windows').subscribe(data => {
if (data && Object.keys(data).length) {
this.store.dispatch(new windowActions.SetWindowsAction(data));
Expand All @@ -29,7 +30,7 @@ export class WindowService {
});
}

newWindow(): Observable<any> {
newWindow(): Subscription {
return this.db.getItem('windows').subscribe(data => {
data = data || [];

Expand All @@ -46,7 +47,7 @@ export class WindowService {
});
}

removeWindow(windowId): Observable<any> {
removeWindow(windowId): Subscription {
return this.db.getItem('windows').subscribe(data => {
data = data || [];

Expand Down

0 comments on commit f637204

Please sign in to comment.