This repository has been archived by the owner on Mar 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vm-logs): realtime logs (#1358)
* feat(vm-logs): VM logs plugin (#1330) * vm logs mock * vm logs * feat(vm-logs): show vm logs * vm logs * add tests * fix action name * fix selector name * fix monospace text in column header * feat(vm-logs): replace show logs icon button with text button * feat(vm-logs): keyword filtering * feat(vm-logs): save vm log keywords in query params * feat(vm-logs): filter by dates * feat(vm-logs): filter by dates * v1.10.1 * fix tests * fix version * fix package.json * sort by timestamp * fix timestamp * feat(vm-logs): filter vms by account * refactor date picker label * refactor labels * refactor labels * fix IE * feat(vm-logs): newest first (#1346) * vm logs mock * vm logs * feat(vm-logs): show vm logs * vm logs * add tests * fix action name * fix selector name * fix monospace text in column header * feat(vm-logs): replace show logs icon button with text button * feat(vm-logs): keyword filtering * feat(vm-logs): save vm log keywords in query params * feat(vm-logs): filter by dates * feat(vm-logs): filter by dates * v1.10.1 * fix tests * fix version * fix package.json * sort by timestamp * fix timestamp * feat(vm-logs): filter vms by account * refactor date picker label * refactor labels * refactor labels * fix IE * feat(vm-logs): newest first sorting * add types * add types * fix newest first * fix typings * fix typings * fix typings * feat(vm-logs): log files (#1351) * feat(vm-logs): log files * feat(vm-logs): log files * code style * feat(vm-logs): realtime logs * feat(vm-logs): disable auto update on show logs click * VM logs (#1362) * refactor(vm): get rid of BaseModel for VM model (#1180) PR close #1104 * build(code-coverage): enable source-maps by default (#1347) This is a workaround to fix code coverage mapping * Update README.md * Create version * Update README.md * Update README.md * feat(navigation): rework navigation menu (#1333) PR close #1235 * feat(config-validation): add config validators (#1309) * feat(config-validation): add config validators * revert security group template interface * add more validation * remove allowReorderingSidenav validation, use uniqueItems * Update vm-colors.scheme.json * style: update app code style (#1359) * Add prettier * Prettier formatted * Work in progress * Fix tsc errors and lint errors * Ann few more rules and changes to codebase * Add precommit hook * Run prettier on entire codebase * Run prettier * Fix lint error * fix bug about grouping * Fix bugs * Remove unused files * fix(misc): semantic errors * fix(lint) * Vm logs (#1363) * refactor(vm): get rid of BaseModel for VM model (#1180) PR close #1104 * build(code-coverage): enable source-maps by default (#1347) This is a workaround to fix code coverage mapping * Update README.md * Create version * Update README.md * Update README.md * feat(navigation): rework navigation menu (#1333) PR close #1235 * feat(config-validation): add config validators (#1309) * feat(config-validation): add config validators * revert security group template interface * add more validation * remove allowReorderingSidenav validation, use uniqueItems * Update vm-colors.scheme.json * style: update app code style (#1359) * Add prettier * Prettier formatted * Work in progress * Fix tsc errors and lint errors * Ann few more rules and changes to codebase * Add precommit hook * Run prettier on entire codebase * Run prettier * Fix lint error * fix bug about grouping * Fix bugs * Remove unused files * fix(misc): semantic errors * fix(lint) * update to master * vm logs * vm logs * simplify nav menu reducer * Update virtual-machines-subroutes.ts * Update accounts-subroutes.ts * nav menu * fix current route is not defined * remove view logs from context menu * fix event emitter names * feat(vm-logs): disable date and time pickers in autoupdate mode
- Loading branch information
Vladimir Shakhov
committed
Nov 2, 2018
1 parent
980adba
commit ff0f5aa
Showing
23 changed files
with
492 additions
and
35 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
6 changes: 5 additions & 1 deletion
6
src/app/shared/components/day-period/day-period.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
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
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,38 @@ | ||
import { Component } from '@angular/core'; | ||
import { select, Store } from '@ngrx/store'; | ||
import { State } from '../../reducers'; | ||
import * as fromVmLogsAutoUpdate from '../redux/vm-logs-auto-update.reducers'; | ||
import * as fromVmLogsVm from '../redux/vm-logs-vm.reducers'; | ||
import * as vmLogsActions from '../redux/vm-logs.actions'; | ||
import { debounceTime } from 'rxjs/internal/operators'; | ||
|
||
@Component({ | ||
selector: 'cs-vm-logs-container', | ||
template: ` | ||
<cs-vm-logs | ||
[isAutoUpdateEnabled]="isAutoUpdateEnabled$ | async" | ||
[selectedVmId]="selectedVmId$ | async" | ||
(autoUpdateStarted)="onAutoUpdate()" | ||
(autoUpdateStopped)="onAutoUpdateStop()" | ||
></cs-vm-logs> | ||
`, | ||
}) | ||
export class VmLogsContainerComponent { | ||
readonly isAutoUpdateEnabled$ = this.store.pipe( | ||
select(fromVmLogsAutoUpdate.selectIsAutoUpdateEnabled), | ||
); | ||
readonly selectedVmId$ = this.store.pipe( | ||
select(fromVmLogsVm.filterSelectedVmId), | ||
debounceTime(0), | ||
); | ||
|
||
constructor(private store: Store<State>) {} | ||
|
||
public onAutoUpdate() { | ||
this.store.dispatch(new vmLogsActions.EnableAutoUpdate()); | ||
} | ||
|
||
public onAutoUpdateStop() { | ||
this.store.dispatch(new vmLogsActions.DisableAutoUpdate()); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/app/vm-logs/redux/selectors/load-auto-update-vm-logs-request-params.selector.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,38 @@ | ||
import { createSelector } from '@ngrx/store'; | ||
import { filterSelectedVmId } from '../vm-logs-vm.reducers'; | ||
import { LoadVmLogsRequestParams } from '../../models/load-vm-logs-request-params'; | ||
import { filterKeywords, filterNewestFirst, filterSelectedLogFile } from '../vm-logs.reducers'; | ||
import * as pickBy from 'lodash/pickBy'; | ||
import { selectStartDate, selectEndDate } from '../vm-logs-auto-update.reducers'; | ||
import moment = require('moment'); | ||
|
||
export const loadAutoUpdateVmLogsRequestParams = createSelector( | ||
filterSelectedVmId, | ||
filterKeywords, | ||
selectStartDate, | ||
selectEndDate, | ||
filterSelectedLogFile, | ||
filterNewestFirst, | ||
(id, keywords, startDate, endDate, logFile, newestFirst): LoadVmLogsRequestParams => { | ||
const fields = { | ||
id, | ||
logFile, | ||
keywords: keywords.map(keyword => keyword.text).join(','), | ||
startDate: | ||
(startDate && | ||
moment(startDate) | ||
.toISOString() | ||
.slice(0, -1)) || | ||
null, | ||
endDate: | ||
(endDate && | ||
moment(endDate) | ||
.toISOString() | ||
.slice(0, -1)) || | ||
null, | ||
sort: newestFirst ? '-timestamp' : 'timestamp', | ||
}; | ||
|
||
return pickBy(fields, Boolean); | ||
}, | ||
); |
76 changes: 76 additions & 0 deletions
76
src/app/vm-logs/redux/vm-logs-auto-update-reducers.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,76 @@ | ||
import { VmLogsActionTypes } from './vm-logs.actions'; | ||
import { initialState, reducer } from './vm-logs-auto-update.reducers'; | ||
|
||
describe('VM logs auto update reducer', () => { | ||
it('should enable auto update', () => { | ||
const state = reducer( | ||
{ | ||
...initialState, | ||
isAutoUpdateEnabled: false, | ||
}, | ||
{ | ||
type: VmLogsActionTypes.ENABLE_AUTO_UPDATE, | ||
}, | ||
); | ||
|
||
expect(state).toEqual({ | ||
...initialState, | ||
isAutoUpdateEnabled: true, | ||
}); | ||
}); | ||
|
||
it('should disable auto update', () => { | ||
const state = reducer( | ||
{ | ||
...initialState, | ||
isAutoUpdateEnabled: true, | ||
}, | ||
{ | ||
type: VmLogsActionTypes.DISABLE_AUTO_UPDATE, | ||
}, | ||
); | ||
|
||
expect(state).toEqual({ | ||
...initialState, | ||
isAutoUpdateEnabled: false, | ||
}); | ||
}); | ||
|
||
const getDateObject = () => ({ | ||
years: 0, | ||
months: 0, | ||
date: 0, | ||
hours: 0, | ||
minutes: 0, | ||
seconds: 0, | ||
milliseconds: 0, | ||
}); | ||
|
||
it('should set start date', () => { | ||
const startDate = getDateObject(); | ||
|
||
const state = reducer(undefined, { | ||
type: VmLogsActionTypes.SET_AUTO_UPDATE_START_DATE, | ||
payload: startDate, | ||
}); | ||
|
||
expect(state).toEqual({ | ||
...initialState, | ||
startDate, | ||
}); | ||
}); | ||
|
||
it('should set end date', () => { | ||
const endDate = getDateObject(); | ||
|
||
const state = reducer(undefined, { | ||
type: VmLogsActionTypes.SET_AUTO_UPDATE_END_DATE, | ||
payload: endDate, | ||
}); | ||
|
||
expect(state).toEqual({ | ||
...initialState, | ||
endDate, | ||
}); | ||
}); | ||
}); |
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,73 @@ | ||
import { createFeatureSelector, createSelector } from '@ngrx/store'; | ||
import * as vmLogsActions from './vm-logs.actions'; | ||
import { DateObject } from '../models/date-object.model'; | ||
|
||
|
||
export interface State { | ||
isAutoUpdateEnabled: boolean, | ||
startDate: DateObject, | ||
endDate: DateObject, | ||
} | ||
|
||
export const initialState: State = { | ||
isAutoUpdateEnabled: false, | ||
startDate: null, | ||
endDate: null, | ||
}; | ||
|
||
export function reducer( | ||
state = initialState, | ||
action: vmLogsActions.Actions | ||
): State { | ||
switch (action.type) { | ||
case vmLogsActions.VmLogsActionTypes.ENABLE_AUTO_UPDATE: { | ||
return { | ||
...state, | ||
isAutoUpdateEnabled: true, | ||
}; | ||
} | ||
|
||
case vmLogsActions.VmLogsActionTypes.DISABLE_AUTO_UPDATE: { | ||
return { | ||
...state, | ||
isAutoUpdateEnabled: false, | ||
}; | ||
} | ||
|
||
case vmLogsActions.VmLogsActionTypes.SET_AUTO_UPDATE_START_DATE: { | ||
return { | ||
...state, | ||
startDate: action.payload, | ||
}; | ||
} | ||
|
||
case vmLogsActions.VmLogsActionTypes.SET_AUTO_UPDATE_END_DATE: { | ||
return { | ||
...state, | ||
endDate: action.payload, | ||
}; | ||
} | ||
|
||
default: { | ||
return state; | ||
} | ||
} | ||
} | ||
|
||
|
||
export const getVmLogsAutoUpdateState = createFeatureSelector<State>('vmLogsAutoUpdate'); | ||
|
||
export const selectIsAutoUpdateEnabled = createSelector( | ||
getVmLogsAutoUpdateState, | ||
state => state.isAutoUpdateEnabled | ||
); | ||
|
||
export const selectStartDate = createSelector( | ||
getVmLogsAutoUpdateState, | ||
state => state.startDate | ||
); | ||
|
||
export const selectEndDate = createSelector( | ||
getVmLogsAutoUpdateState, | ||
state => state.endDate | ||
); |
Oops, something went wrong.