Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
# ej2-angular-scheduler-asynchronous-crud
# EJ2-Angular-Scheduler-Asychronous-CRUD

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.2.4.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
16 changes: 16 additions & 0 deletions ej2-angular-scheduler-asynchronous-crud/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
42 changes: 42 additions & 0 deletions ej2-angular-scheduler-asynchronous-crud/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db
101 changes: 101 additions & 0 deletions ej2-angular-scheduler-asynchronous-crud/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ng-scheduler": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ng-scheduler",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "ng-scheduler:build:production"
},
"development": {
"browserTarget": "ng-scheduler:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "ng-scheduler:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
}
}
}
}
},
"cli": {
"analytics": false
}
}
1 change: 1 addition & 0 deletions ej2-angular-scheduler-asynchronous-crud/debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[0414/210144.439:ERROR:registration_protocol_win.cc(106)] CreateFile: The system cannot find the file specified. (0x2)
40 changes: 40 additions & 0 deletions ej2-angular-scheduler-asynchronous-crud/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "ng-scheduler",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^15.2.0",
"@angular/common": "^15.2.0",
"@angular/compiler": "^15.2.0",
"@angular/core": "^15.2.0",
"@angular/forms": "^15.2.0",
"@angular/platform-browser": "^15.2.0",
"@angular/platform-browser-dynamic": "^15.2.0",
"@angular/router": "^15.2.0",
"@syncfusion/ej2-angular-schedule": "*",
"angular-in-memory-web-api": "^0.15.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.2.4",
"@angular/cli": "~15.2.4",
"@angular/compiler-cli": "^15.2.0",
"@types/jasmine": "~4.3.0",
"jasmine-core": "~4.5.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"typescript": "~4.9.4"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

const routes: Routes = [];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ejs-schedule #scheduleObj width='100%' height='600px' [selectedDate]="selectedDate" (dataBinding)="onDataBinding($event)" (actionBegin)="onActionBegin($event)" (navigating)="onNavigation()"></ejs-schedule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
});

it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});

it(`should have as title 'my-app'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('my-app');
});

it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('.content span')?.textContent).toContain('my-app app is running!');
});
});
80 changes: 80 additions & 0 deletions ej2-angular-scheduler-asynchronous-crud/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { DayService, WeekService, WorkWeekService, MonthService, AgendaService, ScheduleComponent, ActionEventArgs, EventSettingsModel, ReturnType } from '@syncfusion/ej2-angular-schedule';
import { forkJoin, Observable } from 'rxjs';
import { CrudService, EventData } from './crud.service';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['../styles.scss'],
providers: [DayService, WeekService, WorkWeekService, MonthService, AgendaService],
encapsulation: ViewEncapsulation.None
})
export class AppComponent implements OnInit {
@ViewChild('scheduleObj') scheduleObj: ScheduleComponent;

public selectedDate: Date = new Date(2023, 4, 1);
public eventSettings: EventSettingsModel = {
fields: {
id: 'id'
}
};
private $query = { skip: 0, take: 100 };
private isNavigation: boolean = false;

constructor(private crudService: CrudService) { }

ngOnInit(): void {
this.crudService.eventData.subscribe((response: Array<EventData>) => {
if (this.scheduleObj) {
this.scheduleObj.eventSettings.dataSource = response;
this.scheduleObj.hideSpinner();
}
});
}

onDataBinding(args: ReturnType): void {
if (!(this.scheduleObj?.eventSettings.dataSource as Array<Record<string, any>>).length || this.isNavigation) {
args.result = [];
this.scheduleObj.showSpinner();
this.crudService.execute(this.$query);
this.isNavigation = false;
}
}

onNavigation(): void {
this.isNavigation = true;
}

onActionBegin(args: ActionEventArgs): void {
if (['eventCreate', 'eventChange', 'eventRemove'].indexOf(args.requestType) > -1) {
args.cancel = true;
const requests: Array<Observable<EventData>> = [];
if (args.addedRecords.length) {
args.addedRecords.forEach((data: any) => {
requests.push(this.crudService.addEvent(data));
});
}
if (args.changedRecords.length) {
args.changedRecords.forEach((data: any) => {
requests.push(this.crudService.updateEvent(data));
});
}
if (args.deletedRecords.length) {
args.deletedRecords.forEach((data: any) => {
requests.push(this.crudService.deleteEvent(data));
});
}
this.scheduleObj.showSpinner();
forkJoin(requests).subscribe({
next: () => {
this.crudService.execute(this.$query);
},
error: (error) => {
this.scheduleObj.hideSpinner();
console.error(error);
}
});
}
}
}
26 changes: 26 additions & 0 deletions ej2-angular-scheduler-asynchronous-crud/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { HttpClientModule } from '@angular/common/http';
import { HttpClientInMemoryWebApiModule, InMemoryWebApiModule } from 'angular-in-memory-web-api';
import { CrudService } from './crud.service';
import { ScheduleAllModule } from '@syncfusion/ej2-angular-schedule';
import { AppComponent } from './app.component';
import { DataService } from './data.service';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
ScheduleAllModule,
HttpClientModule,
HttpClientInMemoryWebApiModule.forRoot(DataService),
InMemoryWebApiModule.forRoot(DataService, { delay: 1000 })
],
providers: [CrudService],
bootstrap: [AppComponent]
})
export class AppModule { }
Loading