diff --git a/src/app/system/external-services/amazon-s3/amazon-s3.component.html b/src/app/system/external-services/amazon-s3/amazon-s3.component.html new file mode 100644 index 000000000..f786b459d --- /dev/null +++ b/src/app/system/external-services/amazon-s3/amazon-s3.component.html @@ -0,0 +1,27 @@ +
+ +
+ +
+ + + + + + + + + + + + + + + + +
Name {{ configuration.name }} Value {{ configuration.value }}
+ +
diff --git a/src/app/system/external-services/amazon-s3/amazon-s3.component.scss b/src/app/system/external-services/amazon-s3/amazon-s3.component.scss new file mode 100644 index 000000000..bdadd8bb1 --- /dev/null +++ b/src/app/system/external-services/amazon-s3/amazon-s3.component.scss @@ -0,0 +1,3 @@ +table { + width: 100%; +} diff --git a/src/app/system/external-services/amazon-s3/amazon-s3.component.spec.ts b/src/app/system/external-services/amazon-s3/amazon-s3.component.spec.ts new file mode 100644 index 000000000..a3c5d8091 --- /dev/null +++ b/src/app/system/external-services/amazon-s3/amazon-s3.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AmazonS3Component } from './amazon-s3.component'; + +describe('AmazonS3Component', () => { + let component: AmazonS3Component; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AmazonS3Component ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AmazonS3Component); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/system/external-services/amazon-s3/amazon-s3.component.ts b/src/app/system/external-services/amazon-s3/amazon-s3.component.ts new file mode 100644 index 000000000..fbbb16ab3 --- /dev/null +++ b/src/app/system/external-services/amazon-s3/amazon-s3.component.ts @@ -0,0 +1,51 @@ +/** Angular Imports */ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { MatTableDataSource, MatSort } from '@angular/material'; +import { ActivatedRoute } from '@angular/router'; + +/** + * Amazon S3 Component. + */ +@Component({ + selector: 'mifosx-amazon-s3', + templateUrl: './amazon-s3.component.html', + styleUrls: ['./amazon-s3.component.scss'] +}) +export class AmazonS3Component implements OnInit { + + /** Amazon S3 configuration data. */ + amazonS3ConfigurationData: any; + /** Columns to be displayed in Amazon S3 configuration table. */ + displayedColumns: string[] = ['name', 'value']; + /** Data source for Amazon S3 configuration table. */ + dataSource: MatTableDataSource; + + /** Sorter for Amazon S3 configuration table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the Amazon S3 configuration data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe((data: { amazonS3Configuration: any }) => { + this.amazonS3ConfigurationData = data.amazonS3Configuration; + }); + } + + /** + * Sets the Amazon S3 Configuration table. + */ + ngOnInit() { + this.setAmazonS3Configuration(); + } + + /** + * Initializes the data source and sorter for Amazon S3 configuration table. + */ + setAmazonS3Configuration() { + this.dataSource = new MatTableDataSource(this.amazonS3ConfigurationData); + this.dataSource.sort = this.sort; + } + +} diff --git a/src/app/system/external-services/amazon-s3/amazon-s3.resolver.ts b/src/app/system/external-services/amazon-s3/amazon-s3.resolver.ts new file mode 100644 index 000000000..1a62d1362 --- /dev/null +++ b/src/app/system/external-services/amazon-s3/amazon-s3.resolver.ts @@ -0,0 +1,30 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { SystemService } from '../../system.service'; + +/** + * Amazon S3 Configuration data resolver. + */ +@Injectable() +export class AmazonS3ConfigurationResolver implements Resolve { + + /** + * @param {SystemService} systemService System service. + */ + constructor(private systemService: SystemService) {} + + /** + * Returns the Amazon S3 Configuration data. + * @returns {Observable} + */ + resolve(): Observable { + return this.systemService.getExternalConfiguration('S3'); + } + +} diff --git a/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.html b/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.html new file mode 100644 index 000000000..12eb392bf --- /dev/null +++ b/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.html @@ -0,0 +1,48 @@ +
+ + + +
+ + + +
+ + + S3 Access Key + + + S3 Access Key is required + + + + + S3 Bucket Name + + + S3 Bucket Name is required + + + + + S3 Secret Key + + + S3 Secret Key is required + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.scss b/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.scss new file mode 100644 index 000000000..1915ad6d3 --- /dev/null +++ b/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.spec.ts b/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.spec.ts new file mode 100644 index 000000000..bf3a02b71 --- /dev/null +++ b/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EditAmazonS3Component } from './edit-amazon-s3.component'; + +describe('EditAmazonS3Component', () => { + let component: EditAmazonS3Component; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditAmazonS3Component ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditAmazonS3Component); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.ts b/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.ts new file mode 100644 index 000000000..e57147035 --- /dev/null +++ b/src/app/system/external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component.ts @@ -0,0 +1,70 @@ +/** Angular Imports */ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; + +/** Custom Services */ +import { SystemService } from 'app/system/system.service'; + +/** + * Edit Amazon S3 Component. + */ +@Component({ + selector: 'mifosx-edit-amazon-s3', + templateUrl: './edit-amazon-s3.component.html', + styleUrls: ['./edit-amazon-s3.component.scss'] +}) +export class EditAmazonS3Component implements OnInit { + + /** Amazon S3 Configuration data */ + amazonS3ConfigurationData: any; + /** Amazon S3 Configuration Form */ + amazonS3ConfigurationForm: FormGroup; + + /** + * Retrieves the Amazon S3 configuration data from `resolve`. + * @param {FormBuilder} formBuilder Form Builder. + * @param {SystemService} systemService Accounting Service. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + */ + constructor(private formBuilder: FormBuilder, + private systemService: SystemService, + private route: ActivatedRoute, + private router: Router) { + this.route.data.subscribe((data: { amazonS3Configuration: any }) => { + this.amazonS3ConfigurationData = data.amazonS3Configuration; + }); + } + + /** + * Creates Amazon S3 configuration form. + */ + ngOnInit() { + this.createAmazonS3ConfigurationForm(); + } + + /** + * Creates Amazon S3 configuration form. + */ + createAmazonS3ConfigurationForm() { + this.amazonS3ConfigurationForm = this.formBuilder.group({ + 's3_access_key': [this.amazonS3ConfigurationData[0].value, Validators.required], + 's3_bucket_name': [this.amazonS3ConfigurationData[1].value, Validators.required], + 's3_secret_key': [this.amazonS3ConfigurationData[2].value, Validators.required] + }); + } + + /** + * Submits the Amazon S3 configuration and updates the Amazon S3 configuration, + * if successful redirects to view Amazon S3 configuration. + */ + submit() { + this.systemService + .updateExternalConfiguration('S3', this.amazonS3ConfigurationForm.value) + .subscribe((response: any) => { + this.router.navigate(['../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/system/external-services/email/edit-email/edit-email.component.html b/src/app/system/external-services/email/edit-email/edit-email.component.html new file mode 100644 index 000000000..addd5c3d4 --- /dev/null +++ b/src/app/system/external-services/email/edit-email/edit-email.component.html @@ -0,0 +1,64 @@ +
+ + + +
+ + + +
+ + + Username + + + Username is required + + + + + Password + + + Password is required + + + + + Host + + + Host is required + + + + + Port + + + Port is required + + + + + Use TLS + + + Use TLS is required + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/system/external-services/email/edit-email/edit-email.component.scss b/src/app/system/external-services/email/edit-email/edit-email.component.scss new file mode 100644 index 000000000..1915ad6d3 --- /dev/null +++ b/src/app/system/external-services/email/edit-email/edit-email.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/system/external-services/email/edit-email/edit-email.component.spec.ts b/src/app/system/external-services/email/edit-email/edit-email.component.spec.ts new file mode 100644 index 000000000..162cf7566 --- /dev/null +++ b/src/app/system/external-services/email/edit-email/edit-email.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EditEmailComponent } from './edit-email.component'; + +describe('EditEmailComponent', () => { + let component: EditEmailComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditEmailComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditEmailComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/system/external-services/email/edit-email/edit-email.component.ts b/src/app/system/external-services/email/edit-email/edit-email.component.ts new file mode 100644 index 000000000..8097bf670 --- /dev/null +++ b/src/app/system/external-services/email/edit-email/edit-email.component.ts @@ -0,0 +1,72 @@ +/** Angular Imports */ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; + +/** Custom Services */ +import { SystemService } from 'app/system/system.service'; + +/** + * Edit Email Configuration Component. + */ +@Component({ + selector: 'mifosx-edit-email', + templateUrl: './edit-email.component.html', + styleUrls: ['./edit-email.component.scss'] +}) +export class EditEmailComponent implements OnInit { + + /** Email Configuration data */ + emailConfigurationData: any; + /** Email Configuration Form */ + emailConfigurationForm: FormGroup; + + /** + * Retrieves the Email configuration data from `resolve`. + * @param {FormBuilder} formBuilder Form Builder. + * @param {SystemService} systemService Accounting Service. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + */ + constructor(private formBuilder: FormBuilder, + private systemService: SystemService, + private route: ActivatedRoute, + private router: Router) { + this.route.data.subscribe((data: { emailConfiguration: any }) => { + this.emailConfigurationData = data.emailConfiguration; + }); + } + + /** + * Creates Email configuration form. + */ + ngOnInit() { + this.setEmailConfigurationForm(); + } + + /** + * Creates Email configuration form. + */ + setEmailConfigurationForm() { + this.emailConfigurationForm = this.formBuilder.group({ + 'username': [this.emailConfigurationData[0].value, Validators.required], + 'password': [this.emailConfigurationData[1].value, Validators.required], + 'host': [this.emailConfigurationData[2].value, Validators.required], + 'port': [this.emailConfigurationData[3].value, Validators.required], + 'useTLS': [this.emailConfigurationData[4].value, Validators.required] + }); + } + + /** + * Submits the Email configuration and updates the Email configuration, + * if successful redirects to view Email configuration. + */ + submit() { + this.systemService + .updateExternalConfiguration('SMTP', this.emailConfigurationForm.value) + .subscribe((response: any) => { + this.router.navigate(['../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/system/external-services/email/email.component.html b/src/app/system/external-services/email/email.component.html new file mode 100644 index 000000000..f786b459d --- /dev/null +++ b/src/app/system/external-services/email/email.component.html @@ -0,0 +1,27 @@ +
+ +
+ +
+ + + + + + + + + + + + + + + + +
Name {{ configuration.name }} Value {{ configuration.value }}
+ +
diff --git a/src/app/system/external-services/email/email.component.scss b/src/app/system/external-services/email/email.component.scss new file mode 100644 index 000000000..bdadd8bb1 --- /dev/null +++ b/src/app/system/external-services/email/email.component.scss @@ -0,0 +1,3 @@ +table { + width: 100%; +} diff --git a/src/app/system/external-services/email/email.component.spec.ts b/src/app/system/external-services/email/email.component.spec.ts new file mode 100644 index 000000000..f435ad93b --- /dev/null +++ b/src/app/system/external-services/email/email.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EmailComponent } from './email.component'; + +describe('EmailComponent', () => { + let component: EmailComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EmailComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EmailComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/system/external-services/email/email.component.ts b/src/app/system/external-services/email/email.component.ts new file mode 100644 index 000000000..5ee6ae9be --- /dev/null +++ b/src/app/system/external-services/email/email.component.ts @@ -0,0 +1,51 @@ +/** Angular Imports */ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { MatTableDataSource, MatSort } from '@angular/material'; + +/** + * Email Configuration Component. + */ +@Component({ + selector: 'mifosx-email', + templateUrl: './email.component.html', + styleUrls: ['./email.component.scss'] +}) +export class EmailComponent implements OnInit { + + /** Email configuration data. */ + emailConfigurationData: any; + /** Columns to be displayed in Email configuration table. */ + displayedColumns: string[] = ['name', 'value']; + /** Data source for Email configuration table. */ + dataSource: MatTableDataSource; + + /** Sorter for Email configuration table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the Email configuration data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe((data: { emailConfiguration: any }) => { + this.emailConfigurationData = data.emailConfiguration; + }); + } + + /** + * Sets the Email Configuration table. + */ + ngOnInit() { + this.setEmailConfiguration(); + } + + /** + * Initializes the data source and sorter for Email configuration table. + */ + setEmailConfiguration() { + this.dataSource = new MatTableDataSource(this.emailConfigurationData); + this.dataSource.sort = this.sort; + } + +} diff --git a/src/app/system/external-services/email/email.resolver.ts b/src/app/system/external-services/email/email.resolver.ts new file mode 100644 index 000000000..cb50b0ac1 --- /dev/null +++ b/src/app/system/external-services/email/email.resolver.ts @@ -0,0 +1,30 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { SystemService } from '../../system.service'; + +/** + * Email Configuration data resolver. + */ +@Injectable() +export class EmailConfigurationResolver implements Resolve { + + /** + * @param {SystemService} systemService System service. + */ + constructor(private systemService: SystemService) {} + + /** + * Returns the Email Configuration data. + * @returns {Observable} + */ + resolve(): Observable { + return this.systemService.getExternalConfiguration('SMTP'); + } + +} diff --git a/src/app/system/external-services/external-services.component.html b/src/app/system/external-services/external-services.component.html index 329cfdc5e..f706e7ba1 100644 --- a/src/app/system/external-services/external-services.component.html +++ b/src/app/system/external-services/external-services.component.html @@ -8,7 +8,7 @@ - + @@ -16,7 +16,7 @@

S3 Amazon Service Configuration

- + @@ -32,7 +32,7 @@ - + @@ -40,7 +40,7 @@

Email Service Configuration

- + diff --git a/src/app/system/external-services/notification/edit-notification/edit-notification.component.html b/src/app/system/external-services/notification/edit-notification/edit-notification.component.html new file mode 100644 index 000000000..a9e9b8a7e --- /dev/null +++ b/src/app/system/external-services/notification/edit-notification/edit-notification.component.html @@ -0,0 +1,48 @@ +
+ + + +
+ + + +
+ + + Server Key + + + Server Key is required + + + + + GCM End Point + + + GCM End Point is required + + + + + FCM End Point + + + FCM End Point is required + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/system/external-services/notification/edit-notification/edit-notification.component.scss b/src/app/system/external-services/notification/edit-notification/edit-notification.component.scss new file mode 100644 index 000000000..1915ad6d3 --- /dev/null +++ b/src/app/system/external-services/notification/edit-notification/edit-notification.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/system/external-services/notification/edit-notification/edit-notification.component.spec.ts b/src/app/system/external-services/notification/edit-notification/edit-notification.component.spec.ts new file mode 100644 index 000000000..14114b085 --- /dev/null +++ b/src/app/system/external-services/notification/edit-notification/edit-notification.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EditNotificationComponent } from './edit-notification.component'; + +describe('EditNotificationComponent', () => { + let component: EditNotificationComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditNotificationComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditNotificationComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/system/external-services/notification/edit-notification/edit-notification.component.ts b/src/app/system/external-services/notification/edit-notification/edit-notification.component.ts new file mode 100644 index 000000000..f3999ac9d --- /dev/null +++ b/src/app/system/external-services/notification/edit-notification/edit-notification.component.ts @@ -0,0 +1,70 @@ +/** Angular Imports */ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; + +/** Custom Services */ +import { SystemService } from 'app/system/system.service'; + +/** + * Edit Notification Configuration Component. + */ +@Component({ + selector: 'mifosx-edit-notification', + templateUrl: './edit-notification.component.html', + styleUrls: ['./edit-notification.component.scss'] +}) +export class EditNotificationComponent implements OnInit { + + /** Notification Configuration data */ + notificationConfigurationData: any; + /** Notification Configuration Form */ + notificationConfigurationForm: FormGroup; + + /** + * Retrieves the Notification configuration data from `resolve`. + * @param {FormBuilder} formBuilder Form Builder. + * @param {SystemService} systemService Accounting Service. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + */ + constructor(private formBuilder: FormBuilder, + private systemService: SystemService, + private route: ActivatedRoute, + private router: Router) { + this.route.data.subscribe((data: { notificationConfiguration: any }) => { + this.notificationConfigurationData = data.notificationConfiguration; + }); + } + + /** + * Creates Notification configuration form. + */ + ngOnInit() { + this.setNotificationConfigurationForm(); + } + + /** + * Creates Notification configuration form. + */ + setNotificationConfigurationForm() { + this.notificationConfigurationForm = this.formBuilder.group({ + 'server_key': [this.notificationConfigurationData[0].value, Validators.required], + 'gcm_end_point': [this.notificationConfigurationData[1].value, Validators.required], + 'fcm_end_point': [this.notificationConfigurationData[2].value, Validators.required] + }); + } + + /** + * Submits the Notification configuration and updates the Notification configuration, + * if successful redirects to view Notification configuration. + */ + submit() { + this.systemService + .updateExternalConfiguration('NOTIFICATION', this.notificationConfigurationForm.value) + .subscribe((response: any) => { + this.router.navigate(['../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/system/external-services/notification/notification.component.html b/src/app/system/external-services/notification/notification.component.html new file mode 100644 index 000000000..f786b459d --- /dev/null +++ b/src/app/system/external-services/notification/notification.component.html @@ -0,0 +1,27 @@ +
+ +
+ +
+ + + + + + + + + + + + + + + + +
Name {{ configuration.name }} Value {{ configuration.value }}
+ +
diff --git a/src/app/system/external-services/notification/notification.component.scss b/src/app/system/external-services/notification/notification.component.scss new file mode 100644 index 000000000..bdadd8bb1 --- /dev/null +++ b/src/app/system/external-services/notification/notification.component.scss @@ -0,0 +1,3 @@ +table { + width: 100%; +} diff --git a/src/app/system/external-services/notification/notification.component.spec.ts b/src/app/system/external-services/notification/notification.component.spec.ts new file mode 100644 index 000000000..69192c5e3 --- /dev/null +++ b/src/app/system/external-services/notification/notification.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { NotificationComponent } from './notification.component'; + +describe('NotificationComponent', () => { + let component: NotificationComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ NotificationComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(NotificationComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/system/external-services/notification/notification.component.ts b/src/app/system/external-services/notification/notification.component.ts new file mode 100644 index 000000000..9abc66805 --- /dev/null +++ b/src/app/system/external-services/notification/notification.component.ts @@ -0,0 +1,51 @@ +/** Angular Imports */ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { MatTableDataSource, MatSort } from '@angular/material'; + +/** + * Notification Configuration Component. + */ +@Component({ + selector: 'mifosx-notification', + templateUrl: './notification.component.html', + styleUrls: ['./notification.component.scss'] +}) +export class NotificationComponent implements OnInit { + + /** Notification configuration data. */ + notificationConfigurationData: any; + /** Columns to be displayed in Notification configuration table. */ + displayedColumns: string[] = ['name', 'value']; + /** Data source for Notification configuration table. */ + dataSource: MatTableDataSource; + + /** Sorter for Notification configuration table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the Notification configuration data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe((data: { notificationConfiguration: any }) => { + this.notificationConfigurationData = data.notificationConfiguration; + }); + } + + /** + * Sets the Notification Configuration table. + */ + ngOnInit() { + this.setNotificationConfiguration(); + } + + /** + * Initializes the data source and sorter for Notification configuration table. + */ + setNotificationConfiguration() { + this.dataSource = new MatTableDataSource(this.notificationConfigurationData); + this.dataSource.sort = this.sort; + } + +} diff --git a/src/app/system/external-services/notification/notification.resolver.ts b/src/app/system/external-services/notification/notification.resolver.ts new file mode 100644 index 000000000..74d3bd889 --- /dev/null +++ b/src/app/system/external-services/notification/notification.resolver.ts @@ -0,0 +1,30 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { SystemService } from '../../system.service'; + +/** + * Notification Configuration data resolver. + */ +@Injectable() +export class NotificationConfigurationResolver implements Resolve { + + /** + * @param {SystemService} systemService System service. + */ + constructor(private systemService: SystemService) {} + + /** + * Returns the Notification Configuration data. + * @returns {Observable} + */ + resolve(): Observable { + return this.systemService.getExternalConfiguration('NOTIFICATION'); + } + +} diff --git a/src/app/system/external-services/sms/edit-sms/edit-sms.component.html b/src/app/system/external-services/sms/edit-sms/edit-sms.component.html new file mode 100644 index 000000000..dc6e23eae --- /dev/null +++ b/src/app/system/external-services/sms/edit-sms/edit-sms.component.html @@ -0,0 +1,56 @@ +
+ + + +
+ + + +
+ + + Host Name + + + Host Name is required + + + + + Port Number + + + Port Number is required + + + + + End Point + + + End Point is required + + + + + Tenant App Key + + + Tenant App Key is required + + + +
+ +
+ + + + + + +
+ +
+ +
diff --git a/src/app/system/external-services/sms/edit-sms/edit-sms.component.scss b/src/app/system/external-services/sms/edit-sms/edit-sms.component.scss new file mode 100644 index 000000000..1915ad6d3 --- /dev/null +++ b/src/app/system/external-services/sms/edit-sms/edit-sms.component.scss @@ -0,0 +1,3 @@ +.container { + max-width: 37rem; +} diff --git a/src/app/system/external-services/sms/edit-sms/edit-sms.component.spec.ts b/src/app/system/external-services/sms/edit-sms/edit-sms.component.spec.ts new file mode 100644 index 000000000..407fe3a95 --- /dev/null +++ b/src/app/system/external-services/sms/edit-sms/edit-sms.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { EditSmsComponent } from './edit-sms.component'; + +describe('EditSmsComponent', () => { + let component: EditSmsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ EditSmsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(EditSmsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/system/external-services/sms/edit-sms/edit-sms.component.ts b/src/app/system/external-services/sms/edit-sms/edit-sms.component.ts new file mode 100644 index 000000000..9133ffeff --- /dev/null +++ b/src/app/system/external-services/sms/edit-sms/edit-sms.component.ts @@ -0,0 +1,71 @@ +/** Angular Imports */ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; + +/** Custom Services */ +import { SystemService } from 'app/system/system.service'; + +/** + * Edit SMS Configuration Component. + */ +@Component({ + selector: 'mifosx-edit-sms', + templateUrl: './edit-sms.component.html', + styleUrls: ['./edit-sms.component.scss'] +}) +export class EditSMSComponent implements OnInit { + + /** SMS Configuration data */ + smsConfigurationData: any; + /** SMS Configuration Form */ + smsConfigurationForm: FormGroup; + + /** + * Retrieves the SMS configuration data from `resolve`. + * @param {FormBuilder} formBuilder Form Builder. + * @param {SystemService} systemService Accounting Service. + * @param {ActivatedRoute} route Activated Route. + * @param {Router} router Router for navigation. + */ + constructor(private formBuilder: FormBuilder, + private systemService: SystemService, + private route: ActivatedRoute, + private router: Router) { + this.route.data.subscribe((data: { smsConfiguration: any }) => { + this.smsConfigurationData = data.smsConfiguration; + }); + } + + /** + * Creates SMS configuration form. + */ + ngOnInit() { + this.setSMSConfigurationForm(); + } + + /** + * Creates SMS configuration form. + */ + setSMSConfigurationForm() { + this.smsConfigurationForm = this.formBuilder.group({ + 'host_name': [this.smsConfigurationData[0].value, Validators.required], + 'port_number': [this.smsConfigurationData[1].value, Validators.required], + 'end_point': [this.smsConfigurationData[2].value, Validators.required], + 'tenant_app_key': [this.smsConfigurationData[3].value, Validators.required] + }); + } + + /** + * Submits the SMS configuration and updates the SMS configuration, + * if successful redirects to view SMS configuration. + */ + submit() { + this.systemService + .updateExternalConfiguration('SMS', this.smsConfigurationForm.value) + .subscribe((response: any) => { + this.router.navigate(['../'], { relativeTo: this.route }); + }); + } + +} diff --git a/src/app/system/external-services/sms/sms.component.html b/src/app/system/external-services/sms/sms.component.html new file mode 100644 index 000000000..f786b459d --- /dev/null +++ b/src/app/system/external-services/sms/sms.component.html @@ -0,0 +1,27 @@ +
+ +
+ +
+ + + + + + + + + + + + + + + + +
Name {{ configuration.name }} Value {{ configuration.value }}
+ +
diff --git a/src/app/system/external-services/sms/sms.component.scss b/src/app/system/external-services/sms/sms.component.scss new file mode 100644 index 000000000..bdadd8bb1 --- /dev/null +++ b/src/app/system/external-services/sms/sms.component.scss @@ -0,0 +1,3 @@ +table { + width: 100%; +} diff --git a/src/app/system/external-services/sms/sms.component.spec.ts b/src/app/system/external-services/sms/sms.component.spec.ts new file mode 100644 index 000000000..40911f3e5 --- /dev/null +++ b/src/app/system/external-services/sms/sms.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SMSComponent } from './sms.component'; + +describe('SmsComponent', () => { + let component: SMSComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ SMSComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SMSComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/system/external-services/sms/sms.component.ts b/src/app/system/external-services/sms/sms.component.ts new file mode 100644 index 000000000..6d38700dd --- /dev/null +++ b/src/app/system/external-services/sms/sms.component.ts @@ -0,0 +1,51 @@ +/** Angular Imports */ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import { MatTableDataSource, MatSort } from '@angular/material'; + +/** + * SMS Configuration Component. + */ +@Component({ + selector: 'mifosx-sms', + templateUrl: './sms.component.html', + styleUrls: ['./sms.component.scss'] +}) +export class SMSComponent implements OnInit { + + /** SMS configuration data. */ + smsConfigurationData: any; + /** Columns to be displayed in SMS configuration table. */ + displayedColumns: string[] = ['name', 'value']; + /** Data source for SMS configuration table. */ + dataSource: MatTableDataSource; + + /** Sorter for SMS configuration table. */ + @ViewChild(MatSort) sort: MatSort; + + /** + * Retrieves the SMS configuration data from `resolve`. + * @param {ActivatedRoute} route Activated Route. + */ + constructor(private route: ActivatedRoute) { + this.route.data.subscribe((data: {smsConfiguration: any}) => { + this.smsConfigurationData = data.smsConfiguration; + }); + } + + /** + * Sets the SMS Configuration table. + */ + ngOnInit() { + this.setSMSConfiguration(); + } + + /** + * Initializes the data source and sorter for SMS configuration table. + */ + setSMSConfiguration() { + this.dataSource = new MatTableDataSource(this.smsConfigurationData); + this.dataSource.sort = this.sort; + } + +} diff --git a/src/app/system/external-services/sms/sms.resolver.ts b/src/app/system/external-services/sms/sms.resolver.ts new file mode 100644 index 000000000..0f74485ef --- /dev/null +++ b/src/app/system/external-services/sms/sms.resolver.ts @@ -0,0 +1,30 @@ +/** Angular Imports */ +import { Injectable } from '@angular/core'; +import { Resolve } from '@angular/router'; + +/** rxjs Imports */ +import { Observable } from 'rxjs'; + +/** Custom Services */ +import { SystemService } from '../../system.service'; + +/** + * SMS Configuration data resolver. + */ +@Injectable() +export class SMSConfigurationResolver implements Resolve { + + /** + * @param {SystemService} systemService System service. + */ + constructor(private systemService: SystemService) {} + + /** + * Returns the SMS Configuration data. + * @returns {Observable} + */ + resolve(): Observable { + return this.systemService.getExternalConfiguration('SMS'); + } + +} diff --git a/src/app/system/system-routing.module.ts b/src/app/system/system-routing.module.ts index 672b91337..03803f226 100644 --- a/src/app/system/system-routing.module.ts +++ b/src/app/system/system-routing.module.ts @@ -17,6 +17,14 @@ import { ManageSurveysComponent } from './manage-surveys/manage-surveys.componen import { ManageSchedulerJobsComponent } from './manage-scheduler-jobs/manage-scheduler-jobs.component'; import { GlobalConfigurationsComponent } from './global-configurations/global-configurations.component'; import { EditConfigurationComponent } from './global-configurations/edit-configuration/edit-configuration.component'; +import { AmazonS3Component } from './external-services/amazon-s3/amazon-s3.component'; +import { EmailComponent } from './external-services/email/email.component'; +import { SMSComponent } from './external-services/sms/sms.component'; +import { NotificationComponent } from './external-services/notification/notification.component'; +import { EditAmazonS3Component } from './external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component'; +import { EditEmailComponent } from './external-services/email/edit-email/edit-email.component'; +import { EditNotificationComponent } from './external-services/notification/edit-notification/edit-notification.component'; +import { EditSMSComponent } from './external-services/sms/edit-sms/edit-sms.component'; /** Custom Resolvers */ import { CodesResolver } from './codes/codes.resolver'; @@ -27,6 +35,10 @@ import { ManageSurveysResolver } from './manage-surveys/manage-surveys.resolver' import { ManageSchedulerJobsResolver } from './manage-scheduler-jobs/manage-scheduler-jobs.resolver'; import { GlobalConfigurationsResolver } from './global-configurations/global-configurations.resolver'; import { GlobalConfigurationResolver } from './global-configurations/global-configuration.resolver'; +import { AmazonS3ConfigurationResolver } from './external-services/amazon-s3/amazon-s3.resolver'; +import { EmailConfigurationResolver } from './external-services/email/email.resolver'; +import { SMSConfigurationResolver } from './external-services/sms/sms.resolver'; +import { NotificationConfigurationResolver } from './external-services/notification/notification.resolver'; const routes: Routes = [ Route.withShell([ @@ -59,10 +71,99 @@ const routes: Routes = [ }, { path: 'external-services', - component: ExternalServicesComponent, - data: { title: extract('External Services'), breadcrumb: 'External Services' }, - }, - { + data: { title: extract('External Services'), breadcrumb: 'External Services' }, + children: [ + { + path: '', + component: ExternalServicesComponent + }, + { + path: 'amazon-s3', + data: { title: extract('View Amazon S3 Configuration'), breadcrumb: 'Amazon S3' }, + children: [ + { + path: '', + component: AmazonS3Component, + resolve: { + amazonS3Configuration: AmazonS3ConfigurationResolver + } + }, + { + path: 'edit', + component: EditAmazonS3Component, + data: {title: extract('Edit Amazon S3 Configuration'), breadcrumb: 'Edit'}, + resolve: { + amazonS3Configuration: AmazonS3ConfigurationResolver + } + } + ] + }, + { + path: 'email', + data: { title: extract('View Email Configuration'), breadcrumb: 'Email' }, + children: [ + { + path: '', + component: EmailComponent, + resolve: { + emailConfiguration: EmailConfigurationResolver + } + }, + { + path: 'edit', + component: EditEmailComponent, + data: { title: extract('Edit Email Configuration'), breadcrumb: 'Edit' }, + resolve: { + emailConfiguration: EmailConfigurationResolver + } + } + ] + }, + { + path: 'sms', + data: { title: extract('View SMS Configuration'), breadcrumb: 'SMS' }, + children: [ + { + path: '', + component: SMSComponent, + resolve: { + smsConfiguration: SMSConfigurationResolver + } + }, + { + path: 'edit', + data: { title: extract('Edit SMS Configuration'), breadcrumb: 'Edit' }, + component: EditSMSComponent, + resolve: { + smsConfiguration: SMSConfigurationResolver + } + } + ] + }, + { + path: 'notification', + data: { title: extract('View Notification Configuration'), breadcrumb: 'Notification' }, + children: [ + { + path: '', + component: NotificationComponent, + resolve: { + notificationConfiguration: NotificationConfigurationResolver + } + }, + { + path: 'edit', + component: EditNotificationComponent, + data: { title: extract('Edit Notification Configuration'), breadcrumb: 'Edit' }, + resolve: { + notificationConfiguration: NotificationConfigurationResolver + } + } + ] + } + ] + }, + { path: 'data-tables', component: ManageDataTablesComponent, resolve: { @@ -140,7 +241,11 @@ const routes: Routes = [ ManageSurveysResolver, ManageSchedulerJobsResolver, GlobalConfigurationsResolver, - GlobalConfigurationResolver + GlobalConfigurationResolver, + AmazonS3ConfigurationResolver, + EmailConfigurationResolver, + SMSConfigurationResolver, + NotificationConfigurationResolver ] }) export class SystemRoutingModule { } diff --git a/src/app/system/system.module.ts b/src/app/system/system.module.ts index 54f3252e0..51b773792 100644 --- a/src/app/system/system.module.ts +++ b/src/app/system/system.module.ts @@ -17,6 +17,14 @@ import { ManageSurveysComponent } from './manage-surveys/manage-surveys.componen import { ManageSchedulerJobsComponent } from './manage-scheduler-jobs/manage-scheduler-jobs.component'; import { GlobalConfigurationsComponent } from './global-configurations/global-configurations.component'; import { EditConfigurationComponent } from './global-configurations/edit-configuration/edit-configuration.component'; +import { AmazonS3Component } from './external-services/amazon-s3/amazon-s3.component'; +import { EmailComponent } from './external-services/email/email.component'; +import { SMSComponent } from './external-services/sms/sms.component'; +import { NotificationComponent } from './external-services/notification/notification.component'; +import { EditAmazonS3Component } from './external-services/amazon-s3/edit-amazon-s3/edit-amazon-s3.component'; +import { EditEmailComponent } from './external-services/email/edit-email/edit-email.component'; +import { EditNotificationComponent } from './external-services/notification/edit-notification/edit-notification.component'; +import { EditSMSComponent } from './external-services/sms/edit-sms/edit-sms.component'; @NgModule({ imports: [ @@ -34,7 +42,15 @@ import { EditConfigurationComponent } from './global-configurations/edit-configu ManageSurveysComponent, ManageSchedulerJobsComponent, GlobalConfigurationsComponent, - EditConfigurationComponent + EditConfigurationComponent, + AmazonS3Component, + EmailComponent, + SMSComponent, + NotificationComponent, + EditAmazonS3Component, + EditEmailComponent, + EditNotificationComponent, + EditSMSComponent ] }) export class SystemModule { } diff --git a/src/app/system/system.service.ts b/src/app/system/system.service.ts index 025d1007f..95f14d477 100644 --- a/src/app/system/system.service.ts +++ b/src/app/system/system.service.ts @@ -99,4 +99,21 @@ export class SystemService { return this.http.put(`/configurations/${configurationId}`, configuration); } + /** + * @param {string} externalConfigurationName External Configuration Name. + * @returns {Observable} External Configuration. + */ + getExternalConfiguration(externalConfigurationName: string): Observable { + return this.http.get(`/externalservice/${externalConfigurationName}`); + } + + /** + * @param {string} externalConfigurationName External Configuration Name. + * @param {any} externalConfiguration External Configuration. + * @returns {Observable} + */ + updateExternalConfiguration(externalConfigurationName: string, externalConfiguration: any): Observable { + return this.http.put(`/externalservice/${externalConfigurationName}`, externalConfiguration); + } + }