Skip to content

Commit c738bf5

Browse files
Removed namespace and added appropriate comments for methods
1 parent f308546 commit c738bf5

File tree

8 files changed

+45
-28
lines changed

8 files changed

+45
-28
lines changed

app/controllers/InstanceRegistryController.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma
9494
}(myExecutionContext)
9595
}
9696

97-
//This function is for all the POST methods to the Scala web server
97+
/**
98+
* This function is for handling all(start, stop, play, pause, resume) POST request.
99+
* To control the instance State
100+
* @param componentId
101+
*/
98102

99103

100104
def handleRequest(action: String): Action[AnyContent] = Action.async { request =>
@@ -122,7 +126,12 @@ class InstanceRegistryController @Inject()(implicit system: ActorSystem, mat: Ma
122126
}(myExecutionContext)
123127
}
124128

125-
//This function is for adding an instance to the Scala web server
129+
/**
130+
* This function is for handling an POST request for adding an instance to the Scala web server
131+
*
132+
* @param componentType
133+
* @param name
134+
*/
126135
def postInstance(): Action[AnyContent] = Action.async { request =>
127136
var compType = ""
128137
var name = ""

client/src/app/api/model/instance.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface Instance {
3434
/**
3535
* Component Type
3636
*/
37-
componentType?: Instance.ComponentTypeEnum;
37+
componentType?: ComponentType;
3838
dockerId?: string;
3939
/**
4040
* State of the instance
@@ -43,16 +43,6 @@ export interface Instance {
4343
labels?: Array<string>;
4444
}
4545

46-
export namespace Instance {
47-
export type ComponentTypeEnum = 'Crawler' | 'WebApi' | 'WebApp' | 'DelphiManagement';
48-
export const ComponentTypeEnum = {
49-
Crawler: 'Crawler' as ComponentTypeEnum,
50-
WebApi: 'WebApi' as ComponentTypeEnum,
51-
WebApp: 'WebApp' as ComponentTypeEnum,
52-
DelphiManagement: 'DelphiManagement' as ComponentTypeEnum
53-
};
54-
}
55-
5646
export type StateEnum = 'Running' | 'Failed' | 'Stopped' | 'Paused' | 'NotReachable';
5747
export const StateEnum = {
5848
Running: 'Running' as StateEnum,

client/src/app/dashboard/add-dialog/add-dialog.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ export class AddDialogComponent implements OnInit {
1515

1616
formControl = new FormControl('', [
1717
Validators.required
18-
// Validators.email,
1918
]);
2019
ngOnInit() {
21-
// console.log('data.type', this.data);
2220
}
2321

2422
getErrorMessage() {

client/src/app/dashboard/crawler/crawler.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class CrawlerComponent implements OnInit {
3232
compType: string;
3333

3434
constructor(private apiService: ApiService) {
35-
this.compType = Instance.ComponentTypeEnum.Crawler;
35+
3636
}
3737

3838
ngOnInit() {

client/src/app/dashboard/table-all/table-all.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<ng-template #tableBlock>
2222
<div class="container">
2323
<mat-form-field>
24-
<input id="filter_data" matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
24+
<input id="filterData" matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
2525
</mat-form-field>
2626
<table class="mat-elevation-z8 mat-table" mat-table [dataSource]="dataSource">
2727
<ng-container matColumnDef="ID">

client/src/app/dashboard/table-all/table-all.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ describe('TableAllComponent', () => {
5151
useValue: {}
5252
}, {
5353
provide: MAT_DIALOG_DATA,
54-
useValue: {} // Add any data you wish to test if it is passed/used correctly
54+
useValue: {}
5555
},
5656
{
5757
provide: MatTableDataSource,
58-
useValue: {} // Add any data you wish to test if it is passed/used correctly
58+
useValue: {}
5959
}]
6060
})
6161
.compileComponents();

client/src/app/dashboard/table-all/table-all.component.ts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { ApiService } from '../../api/api/api.service';
3131
styleUrls: ['./table-all.component.css']
3232
})
3333
export class TableAllComponent implements OnInit {
34-
@Input() type: Instance.ComponentTypeEnum;
34+
@Input() type: Instance['componentType'];
3535

3636
@Input() set dataArray(dataArray: Instance[]) {
3737
if (this.dataSource != null) {
@@ -58,7 +58,11 @@ export class TableAllComponent implements OnInit {
5858
this.dataSource.paginator = this.paginator;
5959
}
6060

61-
// Function to Delete the data from datasource
61+
/**
62+
* Function for deleting an insatnce. Cannot delete an instance if its running.
63+
* Prompts to Stop the instance before deleting.
64+
* @param InstanceID
65+
*/
6266
openDeleteDialog(i: number, instance: Instance, id: string) {
6367
const dialogRef = this.dialog.open(DeleteDialogComponent, {
6468
width: '250px',
@@ -94,7 +98,11 @@ export class TableAllComponent implements OnInit {
9498
this.dataSource.filter = filterValue.trim().toLowerCase();
9599
}
96100

97-
// Function to add the data into dataSource
101+
/**
102+
* Adding an instance using mat-dialog component
103+
* @param componentType
104+
* @param componentName
105+
*/
98106
openAddDialog() {
99107
const instance: Instance = {};
100108
instance.componentType = this.type;
@@ -107,7 +115,7 @@ export class TableAllComponent implements OnInit {
107115
this.apiService.postInstance(instance.componentType, dialogResult.name).subscribe((result: Instance) => {
108116
this.dataSource.data.push({
109117
id: result.id,
110-
host: result.host,
118+
host: '',
111119
portNumber: result.portNumber,
112120
name: dialogResult.name,
113121
instanceState: result.instanceState,
@@ -121,7 +129,10 @@ export class TableAllComponent implements OnInit {
121129
});
122130
}
123131

124-
// Function to 'start' the instance
132+
/**
133+
* Function used to control the state of the instance. Case1: 'start' an instance
134+
* @param InstanceID
135+
*/
125136
public startInstance(id: string): void {
126137

127138
this.apiService.startInstance(id).subscribe((result: number) => {
@@ -131,7 +142,10 @@ export class TableAllComponent implements OnInit {
131142
});
132143
}
133144

134-
// Function to 'stop' the instance
145+
/**
146+
* Function used to control the state of the instance. Case2: 'stop' an instance
147+
* @param InstanceID
148+
*/
135149
public stopInstance(id: string): void {
136150

137151
this.apiService.stopInstance(id).subscribe((result: number) => {
@@ -141,7 +155,10 @@ export class TableAllComponent implements OnInit {
141155
});
142156
}
143157

144-
// Function to 'pause' the instance
158+
/**
159+
* Function used to control the state of the instance. Case3: 'Pause' an instance
160+
* @param InstanceID
161+
*/
145162
public pauseInstance(id: string): void {
146163

147164
this.apiService.pauseInstance(id).subscribe((result: number) => {
@@ -151,7 +168,10 @@ export class TableAllComponent implements OnInit {
151168
});
152169
}
153170

154-
// Function to 'resume' the instance
171+
/**
172+
* Function used to control the state of the instance. Case4: 'Resume' an instance if Paused
173+
* @param InstanceID
174+
*/
155175
public resumeInstance(id: string): void {
156176

157177
this.apiService.resumeInstance(id).subscribe((result: number) => {

conf/application.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ play.filters {
220220
# Disabled filters remove elements from the enabled list.
221221
#disabled += filters.ExampleFilters
222222
disabled += play.filters.csrf.CSRFFilter
223-
223+
224224
## CORS filter configuration
225225
# https://www.playframework.com/documentation/latest/CorsFilter
226226
# ~~~~~

0 commit comments

Comments
 (0)