Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
feat(indicator): Adds DtIndicator directive as its own package.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Moved to its own package. Import DtIndicatorModule and DtIndicatorThemePalette from @dynatrace/barista-components/indicator instead of */core
  • Loading branch information
rowa-audil authored and tomheller committed May 7, 2020
1 parent 257c49d commit ba28cda
Show file tree
Hide file tree
Showing 44 changed files with 546 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/libs/barista-components/formatters/** @ffriedl89 @rowa-audil
/libs/barista-components/highlight/** @lukasholzer @thomaspink
/libs/barista-components/icon/** @thomaspink
/libs/barista-components/indicator/** @ffriedl89 @rowa-audil
/libs/barista-components/info-group/** @ffriedl89 @NinaKammerlander
/libs/barista-components/inline-editor/** @thomaspink
/libs/barista-components/input/** @thomaspink
Expand Down Expand Up @@ -126,6 +127,7 @@
/apps/dev/src/formatters/** @ffriedl89 @rowa-audil
/apps/dev/src/highlight/** @lukasholzer @thomaspink
/apps/dev/src/icon/** @thomaspink
/apps/dev/src/indicator/** @ffriedl89 @rowa-audil
/apps/dev/src/info-group/** @ffriedl89 @NinaKammerlander
/apps/dev/src/inline-editor/** @thomaspink
/apps/dev/src/input/** @thomaspink
Expand Down Expand Up @@ -197,6 +199,7 @@
/libs/examples/src/formatters/** @ffriedl89 @rowa-audil
/libs/examples/src/highlight/** @lukasholzer @thomaspink
/libs/examples/src/icon/** @thomaspink
/libs/examples/src/indicator/** @ffriedl89 @rowa-audil
/libs/examples/src/info-group/** @ffriedl89 @NinaKammerlander
/libs/examples/src/inline-editor/** @thomaspink
/libs/examples/src/input/** @thomaspink
Expand Down
40 changes: 40 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,46 @@
},
"schematics": {}
},
"indicator": {
"projectType": "library",
"root": "libs/barista-components/indicator",
"sourceRoot": "libs/barista-components/indicator/src",
"prefix": "dt",
"architect": {
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"libs/barista-components/indicator/tsconfig.lib.json",
"libs/barista-components/indicator/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**",
"!libs/barista-components/indicator/**"
]
}
},
"lint-styles": {
"builder": "./dist/libs/workspace:stylelint",
"options": {
"stylelintConfig": ".stylelintrc",
"reportFile": "dist/stylelint/report.xml",
"exclude": ["**/node_modules/**"],
"files": ["libs/barista-components/indicator/**/*.scss"]
}
},
"test": {
"builder": "@nrwl/jest:jest",
"options": {
"jestConfig": "libs/barista-components/indicator/jest.config.js",
"tsConfig": "libs/barista-components/indicator/tsconfig.spec.json",
"setupFile": "libs/barista-components/indicator/src/test-setup.ts",
"passWithNoTests": true
}
}
},
"schematics": {}
},
"info-group": {
"projectType": "library",
"root": "libs/barista-components/info-group",
Expand Down
2 changes: 2 additions & 0 deletions apps/dev/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { FormFieldDemo } from './form-field/form-field-demo.component';
import { FormattersDemo } from './formatters/formatters-demo.component';
import { HighlightDemo } from './highlight/highlight-demo.component';
import { IconDemo } from './icon/icon-demo.component';
import { IndicatorDemo } from './indicator/indicator-demo.component';
import { InfoGroupDemo } from './info-group/info-group-demo.component';
import { InlineEditorDemo } from './inline-editor/inline-editor-demo.component';
import { InputDemo } from './input/input-demo.component';
Expand Down Expand Up @@ -156,6 +157,7 @@ export class NoopRouteComponent {}
BarIndicatorDemo,
TreeTableDemo,
ToggleButtonGroupDemo,
IndicatorDemo,
InfoGroupDemo,
HighlightDemo,
ConsumptionDemo,
Expand Down
2 changes: 2 additions & 0 deletions apps/dev/src/devapp-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { FormFieldDemo } from './form-field/form-field-demo.component';
import { FormattersDemo } from './formatters/formatters-demo.component';
import { HighlightDemo } from './highlight/highlight-demo.component';
import { IconDemo } from './icon/icon-demo.component';
import { IndicatorDemo } from './indicator/indicator-demo.component';
import { InfoGroupDemo } from './info-group/info-group-demo.component';
import { InlineEditorDemo } from './inline-editor/inline-editor-demo.component';
import { InputDemo } from './input/input-demo.component';
Expand Down Expand Up @@ -104,6 +105,7 @@ const routes: Routes = [
{ path: 'formatters', component: FormattersDemo },
{ path: 'highlight', component: HighlightDemo },
{ path: 'icon', component: IconDemo },
{ path: 'indicator', component: IndicatorDemo },
{ path: 'info-group', component: InfoGroupDemo },
{ path: 'inline-editor', component: InlineEditorDemo },
{ path: 'input', component: InputDemo },
Expand Down
1 change: 1 addition & 0 deletions apps/dev/src/devapp.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class DevApp implements AfterContentInit, OnDestroy {
{ name: 'Formatters', route: '/formatters' },
{ name: 'Highlight', route: '/highlight' },
{ name: 'Icon', route: '/icon' },
{ name: 'Indicator', route: '/indicator' },
{ name: 'Info-group', route: '/info-group' },
{ name: 'Inline-editor', route: '/inline-editor' },
{ name: 'Input', route: '/input' },
Expand Down
2 changes: 2 additions & 0 deletions apps/dev/src/dt-components.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { DtFormFieldModule } from '@dynatrace/barista-components/form-field';
import { DtFormattersModule } from '@dynatrace/barista-components/formatters';
import { DtHighlightModule } from '@dynatrace/barista-components/highlight';
import { DtIconModule } from '@dynatrace/barista-components/icon';
import { DtIndicatorModule } from '@dynatrace/barista-components/indicator';
import { DtInfoGroupModule } from '@dynatrace/barista-components/info-group';
import { DtInlineEditorModule } from '@dynatrace/barista-components/inline-editor';
import { DtInputModule } from '@dynatrace/barista-components/input';
Expand Down Expand Up @@ -102,6 +103,7 @@ import { DtTreeTableModule } from '@dynatrace/barista-components/tree-table';
DtFormattersModule,
DtHighlightModule,
DtIconModule,
DtIndicatorModule,
DtInfoGroupModule,
DtInlineEditorModule,
DtInputModule,
Expand Down
236 changes: 236 additions & 0 deletions apps/dev/src/indicator/indicator-demo.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
/**
* @license
* Copyright 2020 Dynatrace LLC
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Component } from '@angular/core';
import { ThreadNode, ThreadFlatNode } from './tree-table-example-types';
import {
DtTreeDataSource,
DtTreeControl,
DtTreeFlattener,
} from '@dynatrace/barista-components/core';
import { FlatTreeControl } from '@angular/cdk/tree';

const TESTDATA: ThreadNode[] = [
{
name: 'hz.hzInstance_1_cluster.thread',
icon: 'process',
threadlevel: 'S0',
totalTimeConsumption: 150,
waiting: 123,
running: 20,
blocked: 0,
children: [
{
name:
'hz.hzInstance_1_cluster.thread_1_hz.hzInstance_1_cluster.thread-1',
icon: 'process',
threadlevel: 'S1',
totalTimeConsumption: 150,
waiting: 123,
running: 20,
blocked: 0,
},
{
name: 'hz.hzInstance_1_cluster.thread-2',
icon: 'process',
threadlevel: 'S1',
totalTimeConsumption: 150,
waiting: 130,
running: 0,
blocked: 0,
},
],
},
{
name: 'jetty',
icon: 'process',
threadlevel: 'S0',
totalTimeConsumption: 150,
waiting: 123,
running: 20,
blocked: 10,
children: [
{
name: 'jetty-422',
icon: 'process',
threadlevel: 'S1',
totalTimeConsumption: 150,
waiting: 123,
running: 20,
blocked: 10,
},
{
name: 'jetty-423',
icon: 'process',
threadlevel: 'S1',
totalTimeConsumption: 150,
waiting: 130,
running: 0,
blocked: 0,
},
{
name: 'jetty-424',
icon: 'process',
threadlevel: 'S1',
totalTimeConsumption: 150,
waiting: 130,
running: 0,
blocked: 0,
},
],
},
{
name: 'Downtime timer',
icon: 'process',
threadlevel: 'S0',
totalTimeConsumption: 150,
waiting: 123,
running: 20,
blocked: 0,
},
];

@Component({
selector: 'demo-component',
template: `
<dt-tree-table [dataSource]="dataSource" [treeControl]="treeControl">
<ng-container dtColumnDef="name">
<dt-tree-table-header-cell *dtHeaderCellDef>
Name
</dt-tree-table-header-cell>
<dt-tree-table-toggle-cell *dtCellDef="let row">
<dt-info-group>
<dt-info-group-icon>
<dt-icon [name]="row.icon"></dt-icon>
</dt-info-group-icon>
<dt-info-group-title>{{ row.name }}</dt-info-group-title>
{{ row.threadlevel }}
</dt-info-group>
</dt-tree-table-toggle-cell>
</ng-container>
<ng-container dtColumnDef="blocked" dtColumnAlign="right">
<dt-tree-table-header-cell *dtHeaderCellDef>
Blocked
</dt-tree-table-header-cell>
<dt-cell
*dtCellDef="let row"
[dtIndicator]="row.blocked > 0"
dtIndicatorColor="error"
>
{{ row.blocked }}ms
</dt-cell>
</ng-container>
<ng-container dtColumnDef="running" dtColumnAlign="center">
<dt-tree-table-header-cell *dtHeaderCellDef>
Running
</dt-tree-table-header-cell>
<dt-cell *dtCellDef="let row">{{ row.running }}ms</dt-cell>
</ng-container>
<ng-container dtColumnDef="waiting">
<dt-tree-table-header-cell *dtHeaderCellDef>
Waiting
</dt-tree-table-header-cell>
<dt-cell *dtCellDef="let row">{{ row.waiting }}ms</dt-cell>
</ng-container>
<ng-container dtColumnDef="actions">
<dt-tree-table-header-cell *dtHeaderCellDef>
Actions
</dt-tree-table-header-cell>
<dt-cell *dtCellDef="let row">
<button dt-icon-button variant="nested" aria-label="Filter results">
<dt-icon name="filter"></dt-icon>
</button>
<button
dt-icon-button
variant="nested"
[dtContextDialogTrigger]="dialog"
aria-label="Show more data"
>
<dt-icon name="more"></dt-icon>
</button>
<dt-context-dialog
#dialog
aria-label="Show more data"
ariaLabelClose="Close context dialog"
>
{{ row.name }} context dialog
</dt-context-dialog>
</dt-cell>
</ng-container>
<dt-header-row
*dtHeaderRowDef="['name', 'blocked', 'running', 'waiting', 'actions']"
></dt-header-row>
<dt-tree-table-row
*dtRowDef="
let row;
columns: ['name', 'blocked', 'running', 'waiting', 'actions']
"
[data]="row"
></dt-tree-table-row>
</dt-tree-table>
`,
})
export class IndicatorDemo {
treeControl: FlatTreeControl<ThreadFlatNode>;
treeFlattener: DtTreeFlattener<ThreadNode, ThreadFlatNode>;
dataSource: DtTreeDataSource<ThreadNode, ThreadFlatNode>;

constructor() {
this.treeControl = new DtTreeControl<ThreadFlatNode>(
this._getLevel,
this._isExpandable,
);
this.treeFlattener = new DtTreeFlattener(
this.transformer,
this._getLevel,
this._isExpandable,
this._getChildren,
);
this.dataSource = new DtTreeDataSource(
this.treeControl,
this.treeFlattener,
);
this.dataSource.data = TESTDATA;
}

hasChild = (_: number, _nodeData: ThreadFlatNode) => _nodeData.expandable;

transformer = (node: ThreadNode, level: number): ThreadFlatNode => {
const flatNode = new ThreadFlatNode();
flatNode.name = node.name;
flatNode.level = level;
flatNode.threadlevel = node.threadlevel;
flatNode.expandable = !!node.children;
flatNode.blocked = node.blocked;
flatNode.running = node.running;
flatNode.waiting = node.waiting;
flatNode.totalTimeConsumption = node.totalTimeConsumption;
flatNode.icon = node.icon;
return flatNode;
};

private _getLevel = (node: ThreadFlatNode) => node.level;

private _isExpandable = (node: ThreadFlatNode) => node.expandable;

private _getChildren = (node: ThreadNode): ThreadNode[] =>
node.children || [];
}
Loading

0 comments on commit ba28cda

Please sign in to comment.