Skip to content

Commit

Permalink
Merge pull request #4 from woody-apple/update
Browse files Browse the repository at this point in the history
  • Loading branch information
woody-apple authored Oct 3, 2023
2 parents d87f893 + 89f090a commit d11fab9
Showing 1 changed file with 52 additions and 31 deletions.
83 changes: 52 additions & 31 deletions src/app/components/test/test-execution/test-execution.sandbox.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed 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.
*/
/**
*
* Copyright (c) 2023 Project CHIP Authors
*
* Licensed 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 { Injectable } from '@angular/core';
import { SharedAPI } from 'src/app/shared/core_apis/shared';
import { TestRunAPI } from 'src/app/shared/core_apis/test-run';
Expand All @@ -28,22 +28,43 @@ export class TestExecutionSandbox {

showExecutionPrompt(promptData: any) {
// Converting the prompt BE json to component required JSON format.
const buttons = [{ id: 1, label: 'Submit', class: 'buttonYes', callback: this.onYesClick.bind(this) }];
const popupObject = {
'popupId': '', 'subHeader': promptData.payload.prompt, 'header': ' ', 'buttons': buttons, 'inputItems': [] as any,
'messageId': promptData.payload.message_id
popupId: '',
subHeader: promptData.payload.prompt,
header: ' ',
buttons: [] as any,
inputItems: [] as any,
messageId: promptData.payload.message_id
};

if (promptData.payload.options) { // Displaying the Radio button popup
popupObject.popupId = 'RADIO_' + promptData.payload.message_id;
const options = Object.entries(promptData.payload.options).map(([key, value]) => ({ key: value, value: key }));
const inputItems = [
{
id: 1, type: 'radioButton', value: '', groupName: 'group_1',
options: options
}
];
popupObject.inputItems = inputItems;
if (promptData.payload.options) {
const isOptionsEmpty = Object.keys(promptData.payload.options).length === 0;
if (isOptionsEmpty) {
// If no options available, only display message
popupObject.popupId = 'TEXTBOX_' + promptData.payload.message_id;
} else {
// Displaying the Radio button popup
const options = Object.entries(promptData.payload.options).map(([key, value]) => ({ key: value, value: key }));
const inputItems = [
{
id: 1,
type: 'radioButton',
value: '',
groupName: 'group_1',
options: options
}
];
const buttons = [
{
id: 1,
label: 'Submit',
class: 'buttonYes',
callback: this.onYesClick.bind(this)
}
];
popupObject.popupId = 'RADIO_' + promptData.payload.message_id;
popupObject.buttons = buttons;
popupObject.inputItems = inputItems;
}
} else if (promptData.payload.placeholder_text) { // Displaying the Textbox popup
popupObject.popupId = 'TEXTBOX_' + promptData.payload.message_id;
const inputItems = [
Expand Down Expand Up @@ -107,4 +128,4 @@ export class TestExecutionSandbox {
}
return testData;
}
}
}

0 comments on commit d11fab9

Please sign in to comment.