
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@2bitgmbh/planning-component
Advanced tools
[[TOC]]
2PLAN is a Angular Component Library developed for Angular 11, which is used to manage different types of schedules. E.g. project plan, shift schedules and deployment plan. The library uses material design from Angular Material. It contains a planning component which can visualize the planning on project or resource basis and a calendar component where the resources can look up their schedules.
To use this library you first need to install it with npm: npm install @2bitgmbh/planning-component
.
The library should now be in the node_modules
folder of your project. Next, we just need to set up the translation before the library is fully functional.
The translation in the library is implemented with ngx-translate and has its translation files in the following directory ./node_modules/@2Bitgmbh/planning-component/assets/i18n
.
These files are needed at runtime. To load the translations of the library, the angular.json
of your project must be modified as follows:
"architect": {
"build": {
"options": {
"assets": [
{
"input": "node_modules/@2bitgmbh/planning-component/assets/i18n",
"glob": "*.json",
"output": "assets/i18n/planning-component"
}
]
}
}
}
After that, you need to use the LibraryTranslationService
from 2PLAN and call this.libraryTranslationService.initTranslations(language);
when the language is initialized in your project.
The last step is to configure the locale for momentjs. Just add moment.locale(language);
where your project language is initialized.
The code to load the translation from the library could look like this.:
this.translateService.use(language).subscribe(() => {
moment.locale(language);
this.dateAdapter.setLocale(language);
this.libraryTranslationService.initTranslations(language);
});
Release | Updates |
---|---|
0.2.0 | Implemented Library for Angular 11 |
To build the library you have to be in the client directory of the workspace (./client) and it is required that the Angular CLI is installed. After that, you can enter the following command in the command line: ng build planning-component
.
The library has no unit tests, but there are some E2E tests with Protractor in the directory ./client/e2e
. The E2E tests can be run locally with the command npm run e2e-tests-local
. Enter this command on the command line in the client directory of the workspace and the tests will be executed. In order for the tests to work, you also need to start the web application with ng serve
and run the backend locally with Visual Studio. Make sure to run the web application on port 4200 and the backend on port 5000 or change the corresponding url of the web application and backend in the ./client/e2e/protractor.local.conf.js
file.
The lib-gantt-activity
component is used to plan the activities of a project. With this component, allocations for activities can be created and edited. In addition, the activities can be edited directly.
If desired, menu items with additional functions can also be inserted via Content Projection.
lib-gantt-activity
<lib-gantt-activity [activities$]="filteredActivities$"
[allocations$]="allocations$"
[planningStartDate]="planningStartDate"
(editActivity)="editActivity($event)"
(addAllocationWithPreselectedData)="addAllocationWithPreselectedData($event)"
(editAllocation)="editAllocation($event)">
<button mat-menu-item (click)="addActivity()">{{"ACTIVITY.CREATE" | translate}}</button>
</lib-gantt-activity>
Name | Required | Type | Default | Description |
---|---|---|---|---|
activities$ | true | Observable<IActivityDto[]> | undefined | Activities which should be displayed as sections. |
allocations$ | true | Observable<AllocationDto[]> | undefined | Allocations which should be displayed as items. |
planningStartDate | false | Moment | moment().startOf("day") | The start time of the scheduler as a moment object. |
lockPast | false | boolean | false | If the past is closed and only planning into the future should be allowed. |
Name | Type | Description |
---|---|---|
editActivity | EventEmitter<string> | Is called when an activity is clicked. The activity ID is returned. |
addAllocationWithPreselectedData | EventEmitter<{ sectionId: string, startDate: moment_.Moment }> | Is called when an allocation with preselected data should be added. The activity ID (sectionId ) and the start date for the allocation are passed. |
editAllocation | EventEmitter<string> | Is called when an allocation is clicked. The allocation ID is passed. |
saveAllocationAfterDragDrop | EventEmitter<{ id: string, sectionId: string }> | Is called when an allocation should be saved after drag and drop. Since the allocation can only be moved to another activity, only the allocation ID (id ) and the new activity id (sectionId ) are passed. |
The lib-gantt-resource
component is used for resource scheduling. With this component, allocations for resources can be created and edited. In addition, the resources can be edited directly.
If desired, menu items with additional functions can also be inserted via content projection.
lib-gantt-resource
<lib-gantt-resource
[resources$]="resources$"
[allocations$]="allocations$"
[planningStartDate]="planningStartDate"
(editResource)="editResource($event)"
(addAllocationWithPreselectedData)="addAllocationWithPreselectedData($event)"
(editAllocation)="editAllocation($event)">
</lib-gantt-resource>
Name | Required | Type | Default | Description |
---|---|---|---|---|
resources$ | true | Observable<IResourceDto[]> | undefined | Resources which should be displayed as sections. |
allocations$ | true | Observable<AllocationDto[]> | undefined | Allocations which should be displayed as items. |
planningStartDate | false | Moment | moment().startOf("day") | The start time of the scheduler as a moment object. |
lockPast | false | boolean | false | If the past is closed and only planning into the future should be allowed. |
Name | Type | Description |
---|---|---|
editResource | EventEmitter<string> | Is called when a resource is clicked. The resource ID is passed. |
addAllocationWithPreselectedData | EventEmitter<{ sectionId: string, startDate: moment_.Moment }> | Is called when an allocation with preselected data should be added. The resource ID (sectionId ) and the start date for the allocation are passed. |
editAllocation | EventEmitter<string> | Is called when an allocation is clicked. The allocation ID is passed. |
saveAllocationAfterDragDrop | EventEmitter<{ id: string, sectionId: string }> | Is called when an allocation should be saved after drag and drop. Since the allocation can only be moved to another resource, only the allocation ID (id ) and the new resource id (sectionId ) are passed. |
lib-gantt [items] [sections]
<lib-gantt [items]="items"
[sections]="sections"
[events]="events"
[periodStart]="planningStartDate">
<ng-content></ng-content>
</lib-gantt>
Name | Required | Type | Default | Description |
---|---|---|---|---|
items | true | Item[] | null | An array of Item to fill up the items of the scheduler. |
sections | true | Section[] | null | An array of Section to fill up the sections of the scheduler. |
events | false | Events | new Events() | The events that can be hooked into. |
periodStart | false | Moment | moment().startOf("day") | The start time of the scheduler as a moment object. |
lockPast | false | boolean | false | If the past is closed and only planning into the future should be allowed. |
locale | false | string | "" | Defines which locale for Moment.js should be loaded. By default, Moment.js uses English (United States) locale strings. |
showBusinessDayOnly | false | boolean | false | Whether only working days are displayed (Mon-Fri). |
Sections are displayed on the left side of the scheduler.
Name | Required | Type | Default | Description |
---|---|---|---|---|
id | true | string | null | A unique identifier for the section (e.q. activity or resource id). |
name | true | string | null | The name to display for the section. |
tooltip | false | string | null | It is used to display tooltip for the section. |
absences | false | `IAbsenceDto[] | undefined` | undefined |
hasConflicts | false | boolean | false | Whenever a conflict has arisen in the planning for the section. If it is true a red bar is displayed. |
Items are used to display the assignments of a section.
Name | Required | Type | Default | Description |
---|---|---|---|---|
id | true | number | null | The identifier for the allocation. |
name | true | string | null | The name to display for the item. |
start | true | any | null | A Moment object denoting where this object starts. |
end | true | any | null | A Moment object denoting where this object ends. |
sectionID | true | number | null | The id of the section that this item belongs to. |
tooltip | false | string | null | It is used to display tooltip for the section. |
color | false | string | "#ffce00" | The background color for the allocation. This is useful to visualize the affiliation to a project. |
hasConflicts | false | boolean | false | Whenever a conflict for this allocation exists. If it is true, the background color will be red. |
The events are executed on interactions with the items / sections and can be used to react to them.
Name | Parameters | Return type | Description |
---|---|---|---|
SectionClickEvent | section: Section | void | Triggered when a section is clicked. |
SectionContextMenuEvent | section: Section, event: MouseEvent | void | Triggered when a section is righted click. |
PeriodChange | start: moment.Moment, end: moment.Moment | void | Triggered when the period is changed. |
AddAllocationWithPreselectedData | sectionId: string, startDate: moment.Moment | void | Triggered when a cell in the scheduler is clicked. |
EditAllocation | id: string | void | Triggered when an item is clicked. |
SaveAllocationAfterDragDrop | id: string, sectionId: string | void | Triggered when an item is dropped to a new section. id is the id of the item and sectionId is the id of the target section. |
The lib-calendar
is used to display a calendar with monthly and weekly view. The calendar is filled with allocations on the corresponding date spans.
lib-calendar
<lib-calendar
[events]="events"
[monthViewSelected]="true"
(openAllocation)="openAllocation($event)">
</lib-calendar>
Name | Required | Type | Default | Description |
---|---|---|---|---|
events | true | IAllocationDto[] | null | Allocations which are displayed in the calendar. |
monthViewSelected | false | boolean | true | Sets the initial displayed calendar view. If true the month view is displayed otherwise the week view is displayed. |
Name | Type | Description |
---|---|---|
openAllocation | EventEmitter<string> | Is called when an allocation is clicked. The allocation ID is passed. |
The lib-calendar-month
displays a calendar monthly view. The calendar is filled with allocations on the corresponding time period. If desired, a navigation in the selection header can be added via content projection.
<lib-calendar-month
*ngIf="monthViewSelected"
[events]="events"
[(startDate)]="currentDate"
(openAllocation)="openAllocationHandler($event)">
<ng-container>
<button mat-icon-button [matMenuTriggerFor]="dropMenu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #dropMenu="matMenu">
<button mat-menu-item
(click)="changeView('month')"
[class.selected-view]="monthViewSelected">
{{ "CALENDAR.MONTH" | translate }}
</button>
<button mat-menu-item
(click)="changeView('week')"
[class.selected-view]="!monthViewSelected">
{{ "CALENDAR.WEEK" | translate }}
</button>
</mat-menu>
</ng-container>
</lib-calendar-month>
Name | Required | Type | Default | Description |
---|---|---|---|---|
events | true | IAllocationDto[] | null | Allocations which are displayed in the calendar. |
startDate | true | Date | new Date() | The calendar initially displays the month of the date passed starting with the previous Monday of the first day in that month. |
Name | Type | Description |
---|---|---|
startDateChange | EventEmitter<Date> | Is called when the month has been changed. The start date of the new month is passed. |
openAllocation | EventEmitter<string> | Is called when an allocation is clicked. The allocation ID is passed. |
The lib-calendar-week
displays a calendar weekly view. The calendar is filled with allocations on the corresponding time period. If desired, a navigation in the selection header can be added via content projection.
<lib-calendar-week
[events]="events"
[(startDate)]="currentDate"
(openAllocation)="openAllocationHandler($event)">
<ng-container>
<button mat-icon-button [matMenuTriggerFor]="dropMenu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #dropMenu="matMenu">
<button mat-menu-item
(click)="changeView('month')"
[class.selected-view]="monthViewSelected">
{{ "CALENDAR.MONTH" | translate }}
</button>
<button mat-menu-item
(click)="changeView('week')"
[class.selected-view]="!monthViewSelected">
{{ "CALENDAR.WEEK" | translate }}
</button>
</mat-menu>
</ng-container>
</lib-calendar-week>
Name | Required | Type | Default | Description |
---|---|---|---|---|
events | true | IAllocationDto[] | null | Allocations which are displayed in the calendar. |
startDate | true | Date | new Date() | The calendar initially displays the week of the date passed. Starting at the previous Monday. |
Name | Type | Description |
---|---|---|
startDateChange | EventEmitter<Date> | Is called when the week has been changed. The start date of the new week is passed. |
openAllocation | EventEmitter<string> | Is called when an allocation is clicked. The allocation ID is passed. |
The lib-message-overview
component displays an overview of all messages. They can be filtered by the names of the concerning projects, activities or resources. Furthermore, it provides a filter for the message type and for showing or hiding the accepted messages.
<lib-message-overview
[messages]="data.messages"
(acceptMessageEvent)="handleAcceptEvent($event)"
(solveConflictEvent)="handleSolveConflictEvent($event)">
</lib-message-overview>
Name | Required | Type | Default | Description |
---|---|---|---|---|
messages | true | IMessageDto[] | null | Messages that should be displayed in the overview. |
messageType | false | number | undefined | Preset for the message type filter. |
Name | Type | Description |
---|---|---|
acceptMessageEvent | EventEmitter<string> | Returns the message ID of the message that the user clicked to accept. |
solveConflictEvent | EventEmitter<IMessageDto> | Returns the message that the user wants to solve. |
The lib-gantt-resource
component can be used if a user should be able to to enter a date and time. If the times are not relevant, the switch "all day" can be activated.
The component ensures that the start must be before the end. In addition, further validations can be defined as input parameters (see startDateValidator
and endDateValidator
).
lib-datetime [formGroup] [start] [end]
<lib-datetime [formGroup]="activityForm"
[startParent]="activityProject.startDate"
[endParent]="activityProject.endDate"
[start]="activity.startDate"
[end]="activity.endDate"
[disabled]="!isEditable"
[startDateValidator]="isStartDateValid"
[endDateValidator]="isEndDateValid">
</lib-datetime>
Name | Required | Type | Default | Description |
---|---|---|---|---|
formGroup | true | FormGroup | null | The form group from the outer form element into which the component is integrated. For the input fields, form controls are added to the form group. |
start | true | Date | null | The start date to be displayed in the input field. |
end | true | Date | null | The end date to be displayed in the input field. |
startParent | false | `Date | undefined` | null |
endParent | false | `Date | undefined` | null |
startDateValidator | false | (selectedStart: moment_.Moment) => any | null | startDateValidator is executed when the start date changes. If there is no error the function should return undefined . Otherwise the function should return an object with a form error (e.g. {dateRangeProject: true} ). The form error is needed to display an error message below the input field. |
endDateValidator | false | (selectedEnd: moment_.Moment) => any | null | endDateValidator is executed when the end date changes. If there is no error the function should return undefined . Otherwise the function should return an object with a form error (e.g. {dateRangeProject: true} ). The form error is needed to display an error message below the input field. |
disabled | false | boolean | false | Whether all fields should be disabled. |
NOTE formGroup: The form controls are added to the form group with the following keys:
StartDate and endDate contains a Moment.js object which combines the entered date and time.
The lib-allocation-dialog
component can be used to create or edit an allocation via dialog. It should be used in project and resource planning when an allocation is to be created or edited.
lib-allocation-dialog
const dialogRef = this.dialog.open(AllocationDialogComponent, {
width: "80%",
data: {
allocation,
currentProjectId,
projects$,
projectActivities$,
resources$: this.resourcesClient.getResources(),
loadActivitiesForProjectFunction: this.loadActivitiesForProject,
lockPast$,
messages,
},
});
Name | Type | Description |
---|---|---|
allocation | IAllocationDto | The dto of the allocation to be displayed. If a new allocation is to be created, create a new dto. |
projects$ | `Observable<IProjectDto[]> | undefined` |
currentProjectId | `string | undefined` |
projectActivities$ | `Observable<IActivityDto[]> | undefined` |
resources$ | Observable<IResourceDto[]> | All resources which are available for selection for the event. |
loadActivitiesForProjectFunction | (projectId: string) => Observable<IActivityDto[]> | Function which is called when the project changes. The function should return all activities of the newly selected project. |
lockPast$ | `Observable | undefined` |
messages | IMessageDto[] | All messages which belong to the allocation or an empty array if no messages exists. |
Name | Type | Default | Description |
---|---|---|---|
acceptMessageEvent | EventEmitter<string> | new EventEmitter<string>() | Is called when a message is accepted. The message ID is passed. You have to subscribe to this event and forward the call to the server to save the message. |
solveConflictEvent | EventEmitter<IMessageDto> | new EventEmitter<IMessageDto>() | Is called when a message is to be resolved. You have to subscribe to this event and navigate to the route where the planner can solve the message. |
const dialogRef = this.dialog.open(AllocationDialogComponent, { ... });
const messageAcceptSubscription = dialogRef.componentInstance.acceptMessageEvent.subscribe(value => {
this.handleMessageAcceptEvent(value, dialogRef, allocation.id);
});
const solveConflictEvent = dialogRef.componentInstance.solveConflictEvent.subscribe(value => {
this.handleSolveConflictEvent(value);
});
dialogRef.afterClosed().subscribe(result => {
messageAcceptSubscription.unsubscribe();
solveConflictEvent.unsubscribe();
});
On Save:
{ event: "save", data: IAllocationDto }
On Cancel:
{ event: "cancel" }
On Delete
{event: "delete", data: IAllocationDto }
The lib-allocation-calendar-dialog
component can be used if details of an allocation from the calendar are to be displayed. The allocation is not editable in this dialog. Only the work can be set to done if this has been activated on the activity of the allocation.
lib-allocation-calendar-dialog
const dialogRef = this.dialog.open(AllocationCalendarDialogComponent, {
width: "80%",
data: {
allocation: dto,
isAcknowledgementActive: activityDto.acknowledgement,
},
});
Name | Type | Description |
---|---|---|
allocation | IAllocationDto | The dto of the allocation to be displayed. |
isAcknowledgementActive | boolean | Whether acknowledgment is active on the activity of the allocation. If true the allocation can be marked as done. |
On Save:
{ event: "save", data: IAllocationDto }
On Cancel:
{ event: "cancel" }
The following class diagram describes the view models and their connections. The properties that are used in the library are highlighted.
The IAllocationDto
is the most important class, which is needed in almost all components. When a resource is assigned to an operation to process it, a corresponding allocation is created.
The IAllocationDto
is needed to display an allocation in the gantt or in the calendar or to display the exact details of an allocation in the dialog.
Name | Type | Description |
---|---|---|
resourceId | string | The id of the resource to which the allocation was assigned. |
activityId | string | The id of the activity to which the allocation was assigned. |
resourceName | `string | undefined` |
activityName | `string | undefined` |
activityProjectName | `string | undefined` |
activityProjectColour | `string | undefined` |
workingHours | number | The number of hours a resource has available to complete the work. |
isAcknowledged | `boolean | undefined` |
messages | `MessageTypes | undefined` |
For each project, several activities can be defined. The IActivityDto
is used to perform the planning and to create IAllocationDto
.
Name | Type | Description |
---|---|---|
startDate | `Date | undefined` |
endDate | `Date | undefined` |
skills | `ISkillDto | undefined` |
messages | `MessageTypes | undefined` |
The IResourceDto
is used to assign an allocation to a resource.
Name | Type | Description |
---|---|---|
skills | `ISkillDto | undefined` |
workingDays | `IWorkingDayDto[] | undefined` |
absences | `IAbsenceDto[] | undefined` |
Messages are created, when errors occur during planning. These messages are displayed and can be accepted or resolved.
Name | Type | Description |
---|---|---|
startDate | `Date | undefined` |
endDate | `Date | undefined` |
validationCase | ValidationCase | Defines why a message exists. Based on the case, an appropriate message is displayed. |
projectName | `string | undefined ` |
activityName | `string | undefined ` |
allocations | `MessageAllocationSummaryDto[] | undefined` |
FAQs
[[_TOC_]]
We found that @2bitgmbh/planning-component demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.