Skip to content

Commit

Permalink
feat(demo): add new Example 33 to demo Realtime Trading
Browse files Browse the repository at this point in the history
- also make this new example the new default route
  • Loading branch information
ghiscoding committed Jan 5, 2022
1 parent b13411c commit 75987b4
Show file tree
Hide file tree
Showing 10 changed files with 532 additions and 4 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"@angular/platform-browser": "^13.1.1",
"@angular/platform-browser-dynamic": "^13.1.1",
"@angular/router": "^13.1.1",
"@fnando/sparkline": "^0.3.10",
"@ng-select/ng-select": "^8.1.1",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
Expand All @@ -117,7 +118,9 @@
"@slickgrid-universal/graphql": "^1.1.1",
"@slickgrid-universal/odata": "^1.1.1",
"@slickgrid-universal/text-export": "^1.1.1",
"@types/faker": "^5.5.9",
"@types/flatpickr": "^3.1.2",
"@types/fnando__sparkline": "^0.3.4",
"@types/jest": "^27.4.0",
"@types/moment": "^2.13.0",
"@types/node": "^17.0.8",
Expand All @@ -135,6 +138,7 @@
"del": "^6.0.0",
"del-cli": "^4.0.1",
"eslint": "^8.6.0",
"faker": "^5.5.3",
"jest": "^27.4.6",
"jest-extended": "^1.2.0",
"jest-preset-angular": "^11.0.1",
Expand All @@ -159,4 +163,4 @@
"node": ">=14.17.0",
"npm": ">=6.14.8"
}
}
}
6 changes: 4 additions & 2 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { GridRowMoveComponent } from './examples/grid-rowmove.component';
import { GridRowSelectionComponent } from './examples/grid-rowselection.component';
import { GridStateComponent } from './examples/grid-state.component';
import { GridTabsComponent } from './examples/grid-tabs.component';
import { GridTradingComponent } from './examples/grid-trading.component';
import { GridTreeDataHierarchicalComponent } from './examples/grid-tree-data-hierarchical.component';
import { GridTreeDataParentChildComponent } from './examples/grid-tree-data-parent-child.component';
import { SwtCommonGridTestComponent } from './examples/swt-common-grid-test.component';
Expand Down Expand Up @@ -67,11 +68,12 @@ const routes: Routes = [
{ path: 'rowdetail', component: GridRowDetailComponent },
{ path: 'rowmove', component: GridRowMoveComponent },
{ path: 'selection', component: GridRowSelectionComponent },
{ path: 'trading', component: GridTradingComponent },
{ path: 'tree-data-parent-child', component: GridTreeDataParentChildComponent },
{ path: 'tree-data-hierarchical', component: GridTreeDataHierarchicalComponent },
{ path: 'swt', component: SwtCommonGridTestComponent },
{ path: '', redirectTo: '/basic', pathMatch: 'full' },
{ path: '**', redirectTo: '/basic', pathMatch: 'full' }
{ path: '', redirectTo: '/trading', pathMatch: 'full' },
{ path: '**', redirectTo: '/trading', pathMatch: 'full' }
];

@NgModule({
Expand Down
5 changes: 5 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@
32- Regular & Custom Tooltip
</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLinkActive="active" [routerLink]="['/trading']">
33- Real-Time Trading Platform
</a>
</li>
</ul>
</section>

Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { GridRowMoveComponent } from './examples/grid-rowmove.component';
import { GridRowSelectionComponent } from './examples/grid-rowselection.component';
import { GridStateComponent } from './examples/grid-state.component';
import { GridTabsComponent } from './examples/grid-tabs.component';
import { GridTradingComponent } from './examples/grid-trading.component';
import { GridTreeDataHierarchicalComponent } from './examples/grid-tree-data-hierarchical.component';
import { GridTreeDataParentChildComponent } from './examples/grid-tree-data-parent-child.component';
import { HomeComponent } from './examples/home.component';
Expand Down Expand Up @@ -119,6 +120,7 @@ export function appInitializerFactory(translate: TranslateService, injector: Inj
GridRowSelectionComponent,
GridStateComponent,
GridTabsComponent,
GridTradingComponent,
GridTreeDataParentChildComponent,
GridTreeDataHierarchicalComponent,
RowDetailPreloadComponent,
Expand Down
58 changes: 58 additions & 0 deletions src/app/examples/grid-trading.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<div class="container-fluid">
<h2>
{{title}}
<span class="float-end">
<a style="font-size: 18px"
target="_blank"
href="https://github.com/ghiscoding/Angular-Slickgrid/blob/master/src/app/examples/grid-trading.component.ts">
<span class="fa fa-link"></span> code
</a>
</span>
</h2>
<div class="subtitle" [innerHTML]="subTitle"></div>

<div class="trading-platform">
<div class="row mb-4 simulation-form">
<div class="col-sm-12 d-flex align-items-center">
<div class="range">
<label for="refreshRateRange" class="form-label me-1">Changes Rate(ms)</label>
<input type="range" class="form-range" id="refreshRateRange" min="0" max="250" [(ngModel)]="refreshRate">
<span class="refresh-rate">
<input type="number" [(ngModel)]="refreshRate">
</span>
</div>
<span class="ms-3 me-1">
<button class="btn btn-outline-secondary btn-sm" data-test="start-btn" (click)="startSimulation()">
<li class="fa fa-play"></li> Start Simulation
</button>
</span>
<span class="me-3">
<button class="btn btn-outline-secondary btn-sm" data-test="stop-btn" (click)="stopSimulation()">
<li class="fa fa-stop"></li> Stop Simulation
</button>
</span>
<span class="mx-1">
<label for="change-per-cycle-input">Changes p/Cycle</label>
<input type="number" id="change-per-cycle-input" [(ngModel)]="minChangePerCycle" [max]="maxChangePerCycle">
to
<input type="number" [(ngModel)]="maxChangePerCycle" [min]="minChangePerCycle">
</span>
<span class="ms-2">
<label for="highlight-input">Highlight Duration(ms)</label>
<input type="number" id="highlight-input" data-test="highlight-input" [(ngModel)]="highlightDuration">
</span>
<div class="ms-auto">
<button class="btn btn-outline-secondary btn-sm" (click)="toggleFullScreen()">
<li [class]="isFullScreen ? 'fa fa-compress' : 'fa fa-arrows-alt'"></li> Toggle Full-Screen
</button>
</div>
</div>
</div>

<angular-slickgrid gridId="grid33"
[columnDefinitions]="columnDefinitions"
[gridOptions]="gridOptions"
[dataset]="dataset"
(onAngularGridCreated)="angularGridReady($event.detail)">
</angular-slickgrid>
</div>
49 changes: 49 additions & 0 deletions src/app/examples/grid-trading.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// @import '@slickgrid-universal/common/dist/styles/sass/slickgrid-theme-salesforce.lite.scss';

$sparkline-color: #00b78d;
// $sparkline-color: #573585;

.trading-platform.full-screen {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding: 10px 12px 0 10px;
background-color: white;
z-index: 8000;
position: fixed;
}
.changed-gain {
background-color: #eafae8 !important;
}
.changed-loss {
background-color: #ffeae8 !important;
}
.simulation-form {
input[type=number] {
height: 32px;
width: 50px;
border: 1px solid #c0c0c0;
border-radius: 3px;
}
div.range {
display: contents;
width: 200px;
label.form-label {
margin: 0;
}
input.form-range {
width: 120px;
}
}
.refresh-rate input {
height: 30px;
width: 46px;
}
}
.sparkline {
stroke: $sparkline-color;
// fill: none;
fill: rgba($sparkline-color, 0.03);
}
Loading

0 comments on commit 75987b4

Please sign in to comment.