-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Added buttons to start and stop all adapters * Changed variable names, added filters and removed redundancy * Added cypress tests for buttons --------- Co-authored-by: Neetha Reddy <neethareddy@Neethas-MacBook-Pro.local>
- Loading branch information
1 parent
4351714
commit ce1d95f
Showing
9 changed files
with
337 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
import { ConnectUtils } from '../../support/utils/connect/ConnectUtils'; | ||
import { ConnectBtns } from '../../support/utils/connect/ConnectBtns'; | ||
|
||
describe('Testing Start/Stop All Adapters', () => { | ||
beforeEach('Setup Test', () => { | ||
// To set up test, we are adding 2 stream adapters that can be futher configured | ||
cy.initStreamPipesTest(); | ||
ConnectUtils.addMachineDataSimulator('simulator-1'); | ||
ConnectUtils.addMachineDataSimulator('simulator-2'); | ||
}); | ||
|
||
it('Test start/stop all adapters', () => { | ||
// Clicking the stop all adapters button | ||
ConnectBtns.stopAllAdapters().click(); | ||
// Navigating through the stop all adapters dialog box | ||
ConnectUtils.allAdapterActionsDialog(); | ||
// Clicking the start all adapters button | ||
ConnectBtns.startAllAdapters().click(); | ||
// Navigating through the start all adapters dialog box | ||
ConnectUtils.allAdapterActionsDialog(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
ui/src/app/connect/dialog/start-all-adapters/all-adapter-actions-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one or more | ||
~ contributor license agreements. See the NOTICE file distributed with | ||
~ this work for additional information regarding copyright ownership. | ||
~ The ASF licenses this file to You under the Apache License, Version 2.0 | ||
~ (the "License"); you may not use this file except in compliance with | ||
~ the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
~ | ||
--> | ||
|
||
<div class="sp-dialog-container"> | ||
<div class="sp-dialog-content p-15"> | ||
<div> | ||
<div | ||
fxFlex="100" | ||
class="md-dialog-content" | ||
style="padding: 20px" | ||
*ngIf="page === 'preview'" | ||
> | ||
<h4> | ||
You are about to {{ action ? 'start' : 'stop' }} the | ||
following adapters: | ||
</h4> | ||
<div *ngFor="let adapter of adaptersToModify"> | ||
<h5>{{ adapter.name }}</h5> | ||
</div> | ||
<h5><b>Press 'Next' to start the process.</b></h5> | ||
</div> | ||
<div | ||
fxFlex="100" | ||
class="md-dialog-content" | ||
style="padding: 20px" | ||
*ngIf="page === 'running'" | ||
> | ||
<div *ngFor="let status of actionStatus"> | ||
<h4> | ||
{{ action ? 'Starting adapter ' : 'Stopping adapter' }} | ||
{{ status.id + 1 }} of {{ adaptersToModify.length }} ({{ | ||
status.name | ||
}})...{{ status.status }} | ||
</h4> | ||
</div> | ||
<div *ngIf="adaptersToModify.length === 0"> | ||
<h4> | ||
Sorry, there are no adapters that are currently | ||
{{ action ? 'idle.' : 'running.' }} | ||
</h4> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<mat-divider></mat-divider> | ||
<div class="sp-dialog-actions actions-align-right"> | ||
<button | ||
mat-button | ||
mat-raised-button | ||
class="mat-basic" | ||
(click)="close(false)" | ||
style="margin-right: 10px" | ||
> | ||
Cancel | ||
</button> | ||
<button | ||
mat-button | ||
mat-raised-button | ||
color="accent" | ||
[disabled]="actionRunning" | ||
(click)="next()" | ||
> | ||
{{ nextButton }} | ||
</button> | ||
</div> | ||
</div> |
19 changes: 19 additions & 0 deletions
19
ui/src/app/connect/dialog/start-all-adapters/all-adapter-actions-dialog.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
@import '../../../../scss/sp/sp-dialog.scss'; |
120 changes: 120 additions & 0 deletions
120
ui/src/app/connect/dialog/start-all-adapters/all-adapter-actions-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { DialogRef } from '@streampipes/shared-ui'; | ||
import { | ||
AdapterDescriptionUnion, | ||
AdapterService, | ||
AdapterStreamDescription, | ||
} from '@streampipes/platform-services'; | ||
|
||
@Component({ | ||
selector: 'sp-start-all-adapters-dialog', | ||
templateUrl: './all-adapter-actions-dialog.component.html', | ||
styleUrls: ['./all-adapter-actions-dialog.component.scss'], | ||
}) | ||
export class AllAdapterActionsComponent implements OnInit { | ||
@Input() | ||
adapters: AdapterDescriptionUnion[]; | ||
|
||
adaptersToModify: AdapterDescriptionUnion[]; | ||
actionStatus: any; | ||
actionFinished: boolean; | ||
page: string; | ||
nextButton: string; | ||
actionRunning: boolean; | ||
|
||
@Input() | ||
action: boolean; | ||
|
||
constructor( | ||
private dialogRef: DialogRef<AllAdapterActionsComponent>, | ||
private adapterService: AdapterService, | ||
) { | ||
this.adaptersToModify = []; | ||
this.actionStatus = []; | ||
this.actionFinished = false; | ||
this.page = 'preview'; | ||
this.nextButton = 'Next'; | ||
this.actionRunning = false; | ||
} | ||
|
||
ngOnInit() { | ||
this.getAdaptersToModify(); | ||
if (this.adaptersToModify.length === 0) { | ||
this.nextButton = 'Close'; | ||
this.page = 'running'; | ||
} | ||
} | ||
|
||
close(refreshAdapters: boolean) { | ||
this.dialogRef.close(refreshAdapters); | ||
} | ||
|
||
next() { | ||
if (this.page === 'running') { | ||
this.close(true); | ||
} else { | ||
this.page = 'running'; | ||
this.initiateAction(this.adaptersToModify[0], 0); | ||
} | ||
} | ||
|
||
getAdaptersToModify() { | ||
this.adapters.forEach(adapter => { | ||
if ( | ||
adapter instanceof AdapterStreamDescription && | ||
adapter.running != this.action | ||
) { | ||
this.adaptersToModify.push(adapter); | ||
} | ||
}); | ||
} | ||
|
||
initiateAction(adapter: AdapterDescriptionUnion, index) { | ||
this.actionRunning = true; | ||
this.actionStatus.push({ | ||
name: adapter.name, | ||
id: index, | ||
status: 'waiting', | ||
}); | ||
this.runAdapterAction(adapter, index); | ||
} | ||
|
||
runAdapterAction(adapter: AdapterDescriptionUnion, index) { | ||
const observable = this.action | ||
? this.adapterService.startAdapter(adapter) | ||
: this.adapterService.stopAdapter(adapter); | ||
observable | ||
.subscribe(data => { | ||
this.actionStatus[index].status = data.success | ||
? 'success' | ||
: 'error'; | ||
}) | ||
.add(() => { | ||
if (index < this.adaptersToModify.length - 1) { | ||
index++; | ||
this.initiateAction(this.adaptersToModify[index], index); | ||
} else { | ||
this.nextButton = 'Close'; | ||
this.actionRunning = false; | ||
} | ||
}); | ||
} | ||
} |