-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #166.
- Loading branch information
Showing
20 changed files
with
256 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Action } from '@ngrx/store'; | ||
|
||
export const ADD_HISTORY = 'ADD_HISTORY'; | ||
|
||
export class AddHistoryAction implements Action { | ||
readonly type = ADD_HISTORY; | ||
|
||
constructor(public windowId: string, public payload: { query: string }) { } | ||
} | ||
|
||
export type Action = AddHistoryAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/app/components/history-dialog/history-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<clr-modal [clrModalOpen]="showDialog" (clrModalOpenChange)="toggleDialogChange.next()"> | ||
<h3 class="modal-title"> | ||
<div class="app-dialog-header"> | ||
<div class="app-dialog-title">{{ 'HISTORY_TEXT' | translate }}</div> | ||
{{ 'HISTORY_SUB_TEXT' | translate }} | ||
</div> | ||
</h3> | ||
<div class="modal-body"> | ||
<div class="app-dialog-body"> | ||
<div class="history-container"> | ||
<div class="history-item _track_me" *ngFor="let item of historyList; let index = index;" (click)="restoreHistory(index)"> | ||
{{item.query}} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<div class="app-dialog-footer"> | ||
<button class="app-button active-primary right" (click)="toggleDialogChange.next()">{{ 'DONE_BUTTON' | translate }}</button> | ||
</div> | ||
</div> | ||
</clr-modal> |
35 changes: 35 additions & 0 deletions
35
src/app/components/history-dialog/history-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { FormsModule } from '@angular/forms'; | ||
import { ClarityModule } from 'clarity-angular'; | ||
import { CodemirrorModule } from 'ng2-codemirror'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { HistoryDialogComponent } from './history-dialog.component'; | ||
|
||
describe('HistoryDialogComponent', () => { | ||
let component: HistoryDialogComponent; | ||
let fixture: ComponentFixture<HistoryDialogComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ HistoryDialogComponent ], | ||
imports: [ | ||
FormsModule, | ||
CodemirrorModule, | ||
ClarityModule.forRoot(), | ||
TranslateModule.forRoot() | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(HistoryDialogComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
src/app/components/history-dialog/history-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-history-dialog', | ||
templateUrl: './history-dialog.component.html' | ||
}) | ||
export class HistoryDialogComponent implements OnInit { | ||
|
||
@Input() historyList = []; | ||
@Input() showDialog = false; | ||
@Output() toggleDialogChange = new EventEmitter(); | ||
@Output() restoreHistoryChange = new EventEmitter(); | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
restoreHistory(index) { | ||
this.restoreHistoryChange.next(index); | ||
this.toggleDialogChange.next(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import isElectron from './utils/is_electron'; | ||
|
||
export default { | ||
ga: 'UA-41432833-6', | ||
add_query_depth_limit: 3, | ||
max_windows: 10, | ||
default_language: 'en', | ||
languages: ['en'] | ||
languages: ['en'], | ||
query_history_depth: isElectron ? 25 : 7 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Action } from '@ngrx/store'; | ||
|
||
import * as history from '../../actions/history/history'; | ||
|
||
import config from '../../config'; | ||
|
||
export interface History { | ||
query: string; | ||
} | ||
|
||
export interface HistoryList extends Array<History> { | ||
[index: number]: History; | ||
} | ||
|
||
export interface State { | ||
list: HistoryList; | ||
} | ||
|
||
const initialState: State = { | ||
list: [] | ||
}; | ||
|
||
export function historyReducer(state = initialState, action: history.Action): State { | ||
switch (action.type) { | ||
case history.ADD_HISTORY: | ||
const _state = { ...state }; | ||
|
||
// If the items in the list is more than the allowed limit, remove the last item | ||
if (state.list.length >= config.query_history_depth) { | ||
// Remove the last item in the list | ||
_state.list.pop(); | ||
} | ||
|
||
return { | ||
..._state, | ||
list: [ | ||
{ query: action.payload.query }, // Add the new item to the top of the list | ||
..._state.list | ||
] | ||
}; | ||
default: | ||
return state; | ||
} | ||
} |
Oops, something went wrong.