Skip to content

Commit 5e2bdda

Browse files
committed
feat(arc): created demo component to demo all the gantt component
created demo component to demo all the gantt component GH-58
1 parent f1c79b0 commit 5e2bdda

File tree

12 files changed

+217
-23
lines changed

12 files changed

+217
-23
lines changed

projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ export class GanttBarsComponent {
1111
@Input() allocationTypes: any;
1212
@Input() allocationBase: number;
1313

14-
constructor() {
15-
console.log('hii tiny');
16-
}
1714
formatAllocation(value: number): string {
1815
return `${value} hours`;
1916
}

projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header.component.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
<div>
2-
<h1>{{ name }}</h1>
3-
<div *ngIf="showSearch">
4-
<input type="text" [placeholder]="searchPlaceholder" />
5-
</div>
1+
<div class="header-wrapper">
2+
<h2 class="project-title">{{ name }}</h2>
3+
<nb-card>
4+
<nb-card-body>
5+
<div class="search-wrapper" *ngIf="showSearch">
6+
<input
7+
nbInput
8+
fullWidth
9+
fieldSize="medium"
10+
type="text"
11+
status="basic"
12+
[placeholder]="searchPlaceholder"
13+
/>
14+
</div>
15+
</nb-card-body>
16+
</nb-card>
17+
618
<div *ngIf="desc">
719
<p>Description is enabled.</p>
820
</div>

projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header.component.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
bottom: 70.83%;
2929
}
3030
}
31+
3132
.title-bar {
3233
display: flex;
3334
align-items: center;
@@ -50,4 +51,15 @@
5051
nb-form-field nb-icon {
5152
color: map.get($color, icon);
5253
}
54+
55+
5356
}
57+
.header-wrapper {
58+
display: flex;
59+
align-items: center;
60+
gap: 20px;
61+
}
62+
63+
.project-title{
64+
font-size: x-large;
65+
}

projects/arc-lib/src/lib/components/gantt/components/gantt-tooltip/gantt-tooltip.component.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
<!-- gantt-tooltip.component.html -->
22
<div class="tooltip-wrapper">
3-
<div class="gantt-tooltip" *ngIf="item">
3+
<div class="gantt-tooltip" *ngIf="itemData">
44
<div class="key">
55
<div>Hours Per Day</div>
6-
<div>{{ formatAllocation(item.allocatedHours) }}</div>
6+
<div>{{ formatAllocation(itemData.allocatedHours) }}</div>
77
</div>
8-
<div class="key" *ngIf="item.billingRate">
8+
<div class="key" *ngIf="itemData.billingRate">
99
<div>Hourly Rate</div>
10-
<div>{{ formatter(item.billingRate) }}</div>
10+
<div>{{ formatter(itemData.billingRate) }}</div>
1111
</div>
12-
<div class="key" *ngIf="item.startDate">
12+
<div class="key" *ngIf="itemData.startDate">
1313
<div>Start Date</div>
14-
<div *ngIf="item.startDate">
15-
{{ formatDate(item.startDate) | date: 'dd/MM/yyyy' }}
14+
<div *ngIf="itemData.startDate">
15+
{{ formatDate(itemData.startDate) | date: 'dd/MM/yyyy' }}
1616
</div>
1717
</div>
18-
<div class="key" *ngIf="item.endDate">
18+
<div class="key" *ngIf="itemData.endDate">
1919
<div>End Date</div>
20-
<div *ngIf="item.endDate">
21-
{{ formatDate(item.endDate) | date: 'dd/MM/yyyy' }}
20+
<div *ngIf="itemData.endDate">
21+
{{ formatDate(itemData.endDate) | date: 'dd/MM/yyyy' }}
2222
</div>
2323
</div>
2424
<hr />
25-
<div class="key" *ngFor="let deal of item.allotedDeals">
25+
<div class="key" *ngFor="let deal of itemData.allotedDeals">
2626
<div class="deal-name">
2727
<span class="underline">{{ deal.name }}</span>
2828
<ng-container *ngIf="allocationMap.get(deal.name)">

projects/arc-lib/src/lib/components/gantt/components/gantt-tooltip/gantt-tooltip.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {Item} from '../../model/item.model';
99
})
1010
export class GanttTooltipComponent {
1111
@Input()
12-
item: Item;
12+
itemData: Item;
1313

1414
@Input()
1515
allocationMap = new Map<string, boolean>([]);

projects/arc-lib/src/lib/components/gantt/gantt.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ import {
1515
GanttLib,
1616
GanttScaleService,
1717
} from './types';
18-
import {DateOperationService} from './services/date-operation.service';
18+
1919
import {
2020
GanttBarsComponent,
2121
GanttColumnComponent,
2222
GanttHeaderComponent,
2323
GanttTooltipComponent,
2424
} from './components';
25+
import {NbInputModule} from '@nebular/theme/components/input/input.module';
2526

2627
@NgModule({
2728
declarations: [
@@ -38,7 +39,6 @@ import {
3839
GanttTooltipComponent,
3940
],
4041
providers: [
41-
DateOperationService,
4242
GanttService,
4343
{
4444
provide: GANTT,

projects/arc/src/app/app-routing.module.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {NgModule} from '@angular/core';
22
import {RouterModule, Routes} from '@angular/router';
33
import {environment} from '../environments/environment';
44
import {AuthGuard, LoggedInGuard} from '@project-lib/core/auth';
5+
import {GanttDemoComponent} from './components/gantt-demo/gantt-demo.component';
56

67
const routes: Routes = [
78
{
@@ -25,6 +26,12 @@ const routes: Routes = [
2526
),
2627
canActivate: [AuthGuard],
2728
},
29+
30+
{
31+
path: 'gantt-demo',
32+
component: GanttDemoComponent,
33+
},
34+
2835
{
2936
path: '',
3037
redirectTo: environment.homePath,

projects/arc/src/app/app.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ import {GanttModule} from '@project-lib/components/index';
2323
import {SelectModule} from '@project-lib/components/selector';
2424
import {HeaderComponent} from '@project-lib/components/header/header.component';
2525
import {SidebarComponent} from '@project-lib/components/sidebar/sidebar.component';
26+
import {GanttService} from '@project-lib/components/gantt';
27+
import {GanttDemoComponent} from './components/gantt-demo/gantt-demo.component';
2628

2729
@NgModule({
28-
declarations: [AppComponent],
30+
declarations: [AppComponent, GanttDemoComponent],
2931
schemas: [CUSTOM_ELEMENTS_SCHEMA],
3032
imports: [
3133
BrowserModule,
@@ -36,6 +38,7 @@ import {SidebarComponent} from '@project-lib/components/sidebar/sidebar.componen
3638
ThemeModule.forRoot('default'),
3739
OverlayModule,
3840
SelectModule,
41+
3942
GanttModule,
4043
BrowserAnimationsModule,
4144
HeaderComponent,
@@ -49,6 +52,7 @@ import {SidebarComponent} from '@project-lib/components/sidebar/sidebar.componen
4952
SystemStoreFacadeService,
5053
EnvAdapterService,
5154
ApiService,
55+
GanttService,
5256
{
5357
provide: APP_CONFIG,
5458
useValue: environment,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<nb-layout>
2+
<nb-layout-header fixed class="border-basic-bottom">
3+
<div class="header-wrapper">
4+
<div class="header">
5+
<arc-gantt-header
6+
[desc]="headerDesc"
7+
[name]="headerName"
8+
[searchPlaceholder]="headerSearchPlaceholder"
9+
[showSearch]="headerShowSearch"
10+
></arc-gantt-header>
11+
</div>
12+
</div>
13+
</nb-layout-header>
14+
<nb-sidebar>
15+
<div class="sidebar">
16+
<arc-gantt-column
17+
[items]="items"
18+
[showParentInitials]="showParentInitials"
19+
[showChildInitials]="showChildInitials"
20+
[showOverallocatedIcon]="showOverallocatedIcon"
21+
></arc-gantt-column>
22+
</div>
23+
</nb-sidebar>
24+
<nb-layout-column>
25+
<nb-card>
26+
<nb-card-header> </nb-card-header>
27+
<nb-card-body>
28+
<arc-gantt-bars
29+
[item]="item"
30+
[allocationTypes]="allocationTypes"
31+
[allocationBase]="allocationBase"
32+
></arc-gantt-bars>
33+
</nb-card-body>
34+
</nb-card>
35+
</nb-layout-column>
36+
37+
<arc-gantt-tooltip [item]="selectedItem"></arc-gantt-tooltip>
38+
</nb-layout>

projects/arc/src/app/components/gantt-demo/gantt-demo.component.scss

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { GanttDemoComponent } from './gantt-demo.component';
4+
5+
describe('GanttDemoComponent', () => {
6+
let component: GanttDemoComponent;
7+
let fixture: ComponentFixture<GanttDemoComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ GanttDemoComponent ]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(GanttDemoComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import {Component} from '@angular/core';
2+
import {NbSidebarService} from '@nebular/theme';
3+
import {Item, empData} from '@project-lib/components/gantt/model/item.model';
4+
5+
@Component({
6+
selector: 'arc-gantt-demo',
7+
templateUrl: './gantt-demo.component.html',
8+
styleUrls: ['./gantt-demo.component.scss'],
9+
})
10+
export class GanttDemoComponent {
11+
// data for tooltip component
12+
showTooltip = false;
13+
selectedItem: Item;
14+
15+
onBarHovered(itemData: Item) {
16+
this.selectedItem = itemData;
17+
this.showTooltip = true;
18+
}
19+
20+
onBarMouseLeave() {
21+
this.showTooltip = false;
22+
}
23+
24+
itemData: Item = {
25+
allocatedHours: 1600,
26+
billingRate: 100,
27+
startDate: new Date('2024-01-01'),
28+
endDate: new Date('2024-12-31'),
29+
allotedDeals: [
30+
{name: 'Deal 1', allocatedHours: 800, status: 'approved'},
31+
{name: 'Deal 2', allocatedHours: 900, status: 'pending'},
32+
],
33+
};
34+
35+
allocationMap = new Map<string, boolean>([
36+
['Deal 1', true],
37+
['Deal 2', false],
38+
]);
39+
40+
// Data for GanttColumnComponent
41+
items: empData[] = [
42+
{
43+
name: 'john Doe ',
44+
subtitle: 'Manager',
45+
hasChildren: false,
46+
isParent: false,
47+
$open: false,
48+
overallocated: false,
49+
},
50+
{
51+
name: 'kelly',
52+
subtitle: 'Assistant Manager',
53+
hasChildren: false,
54+
isParent: false,
55+
$open: false,
56+
overallocated: false,
57+
},
58+
{
59+
name: 'Clove',
60+
subtitle: 'Software Developer',
61+
hasChildren: false,
62+
isParent: false,
63+
$open: false,
64+
overallocated: false,
65+
},
66+
{
67+
name: 'Classy',
68+
subtitle: 'DevOps',
69+
hasChildren: false,
70+
isParent: false,
71+
$open: false,
72+
overallocated: false,
73+
},
74+
];
75+
showParentInitials = true;
76+
showChildInitials = true;
77+
showOverallocatedIcon = true;
78+
79+
allocationTypes = {
80+
PlaceholderResource: 'PlaceholderResource',
81+
};
82+
83+
allocationBase = 40;
84+
85+
item: Item = {
86+
type: 'ActualResource',
87+
allocation: 32,
88+
payload: {dealStage: 'closedwon', billingRate: 100},
89+
classes: ['example-class'],
90+
subAllocations: [
91+
{percent: 50, allocation: 16, allocatedHours: 16, classes: ['class1']},
92+
{percent: 50, allocation: 16, allocatedHours: 16, classes: ['class2']},
93+
],
94+
};
95+
96+
// Data for GanttHeaderComponent
97+
headerDesc = true;
98+
headerName = 'Dynamic Project Gantt';
99+
headerSearchPlaceholder = 'Search your tasks';
100+
headerShowSearch = true;
101+
}

0 commit comments

Comments
 (0)