Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing submit button #15

Merged
123 changes: 123 additions & 0 deletions scripts/build-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env bash

#
# Copyright (c) 2020 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.
#

ME=$(basename "$0")
ROOT_DIR=$(realpath $(dirname "$0")/..)
cd $ROOT_DIR

DEFAULT_IMAGE=csa-certification-tool-frontend


GHCR_ORG="ghcr.io"
ORG=${DOCKER_BUILD_ORG:-project-chip}

# Latest commit hash
GIT_SHA=$(git rev-parse --short HEAD)

# If working copy has changes, append `-local` to hash
GIT_DIFF=$(git diff -s --exit-code || echo "-local")
if [[ $GIT_DIFF ]]; then
echo " 🔴 Git repo has changes. Please commit all changes before publishing."
fi
GIT_REV=$GIT_SHA$GIT_DIFF
echo "$GIT_REV"


IMAGE=${DOCKER_BUILD_IMAGE:-$DEFAULT_IMAGE}

# version
VERSION=${DOCKER_BUILD_VERSION:-$GIT_REV}

# verify that repo is clean
DIRTY=`git status --porcelain --untracked-files=no`


# help
[[ ${*/--help//} != "${*}" ]] && {
set +x
echo "Usage: $me <OPTIONS>

Build and (optionally tag as latest, push) a docker image from Dockerfile in CWD

Options:
--no-cache passed as a docker build argument
--latest update latest to the current built version (\"$VERSION\")
--push push image(s) to $GHCR_ORG (requires docker login for \"$ORG\")
--skip-build skip the build/prune step
--help get this message
--squash squash docker layers before push them to $GHCR_ORG (requires docker-squash python module)
--clear remove images after after publishing them

"
exit 0
}

die() {
echo "$me: *** ERROR: $*"
exit 1
}

set -ex

[[ -n $VERSION ]] || die "version cannot be empty"

BUILD_ARGS=()
if [[ ${*/--no-cache//} != "${*}" ]]; then
BUILD_ARGS+=(--no-cache)
fi

# Don't run `docker build` and `docker image prune` when `--skip-build` in arguments
[[ ${*/--skip-build//} != "${*}" ]] || {
docker build "${BUILD_ARGS[@]}" --build-arg TARGETPLATFORM="$TARGET_PLATFORM_TYPE" --build-arg GIT_SHA="$GIT_REV" --build-arg VERSION="$VERSION" -t "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" .
docker image prune --force
}

[[ ${*/--squash//} != "${*}" ]] && {
command -v docker-squash >/dev/null &&
docker-squash "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" -t "$GHCR_ORG"/"$ORG"/"$IMAGE":squashed
}

[[ ${*/--latest//} != "${*}" ]] && {
if [[ ${*/--squash//} != "${*}" ]]; then
docker tag "$GHCR_ORG"/"$ORG"/"$IMAGE":squashed "$GHCR_ORG"/"$ORG"/"$IMAGE":latest
else
docker tag "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION" "$GHCR_ORG"/"$ORG"/"$IMAGE":latest
fi
}

[[ ${*/--push//} != "${*}" ]] && {
if [[ $GIT_DIFF ]]; then
die "Don't push image with local changes"
fi
docker push "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION"
[[ ${*/--latest//} != "${*}" ]] && {
docker push "$GHCR_ORG"/"$ORG"/"$IMAGE":latest
}
}

[[ ${*/--clear//} != "${*}" ]] && {
docker rmi -f "$GHCR_ORG"/"$ORG"/"$IMAGE":"$VERSION"
[[ ${*/--latest//} != "${*}" ]] && {
docker rmi -f "$GHCR_ORG"/"$ORG"/"$IMAGE":latest
}
[[ ${*/--squash//} != "${*}" ]] && {
docker rmi -f "$GHCR_ORG"/"$ORG"/"$IMAGE":squashed
}
}

docker images --filter=reference="$GHCR_ORG/$ORG/*"
10 changes: 7 additions & 3 deletions src/app/components/test/test-details/test-details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,13 @@ export class TestDetailsComponent {
}
}
}
const testConfig: any = await this.testSandbox.createTestRunConfig(this.selectedDataFinal);
this.testSandbox.createTestRunExecution(this.callbackForStartTestExecution.bind(this),
testConfig.id, this.testName, this.testRunAPI.getSelectedOperator().id, this.description);
this.testSandbox.createTestRunExecution(
this.callbackForStartTestExecution.bind(this),
this.selectedDataFinal,
this.testName,
this.testRunAPI.getSelectedOperator().id,
this.description
);
}
}
}
Expand Down
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 { Component, Injectable } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { DialogService } from 'primeng/dynamicdialog';
Expand Down Expand Up @@ -229,8 +229,7 @@ export class TestExecutionHistoryComponent {
const title: any = executionData.title.slice(0, executionData.title.length - 20);
this.sharedAPI.setAppState(APP_STATE[1]);
this.sharedAPI.setWebSocketLoader(true);
this.testSandbox.createTestRunExecution(this.repeatExecution.bind(this), executionData.test_run_config_id,
title, executionData.operator.id, executionData.description);
this.testSandbox.repeatTestRunExecution(this.repeatExecution.bind(this), executionData.id);
}
}
repeatExecution(execId: any) {
Expand Down
73 changes: 40 additions & 33 deletions src/app/components/test/test-execution/test-execution.sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class TestExecutionSandbox {

showExecutionPrompt(promptData: any) {
// Converting the prompt BE json to component required JSON format.
const promptType = promptData.type;
const popupObject = {
popupId: '',
subHeader: promptData.payload.prompt,
Expand All @@ -36,47 +37,53 @@ export class TestExecutionSandbox {
inputItems: [] as any,
messageId: promptData.payload.message_id
};
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;
const buttons = [
{
id: 1,
label: 'Submit',
class: 'buttonYes',
callback: this.onYesClick.bind(this)
}
} else if (promptData.payload.placeholder_text) { // Displaying the Textbox popup
];

if (promptType === 'message_request') { // Displaying the message popup
popupObject.popupId = 'TEXTBOX_' + promptData.payload.message_id;
} else if (promptType === 'options_request') { // Displaying the radio buttons popup
const options = Object.entries(promptData.payload.options).map(([key, value]) => ({ key: value, value: key }));
const inputItems = [
{ id: 1, type: 'inputbox', value: promptData.payload.default_value, placeHolder: promptData.payload.placeholder_text }
{
id: 1,
type: 'radioButton',
value: '',
groupName: 'group_1',
options: options
}
];
popupObject.popupId = 'RADIO_' + promptData.payload.message_id;
popupObject.inputItems = inputItems;
} else if (promptData.payload.path) { // Displaying the File-upload popup
popupObject.buttons = buttons;
} else if (promptData.payload.placeholder_text) { // Displaying the text field popup
popupObject.popupId = 'TEXTBOX_' + promptData.payload.message_id;
const inputItems = [
{ id: 1,
type: 'inputbox',
value: promptData.payload.default_value,
placeHolder: promptData.payload.placeholder_text
}
];
popupObject.inputItems = inputItems;
popupObject.buttons = buttons;
} else if (promptType === 'file_upload_request') { // Displaying the file upload popup

popupObject.popupId = 'FILE_UPLOAD_' + promptData.payload.message_id;
const inputItems = [
{ id: 1, type: 'file_upload', value: '' }
{ id: 1,
type: 'file_upload',
value: ''
}
];
popupObject.inputItems = inputItems;
popupObject.buttons = buttons;
}
this.sharedAPI.setCustomPopupData(popupObject);
this.sharedAPI.setShowCustomPopup(popupObject.popupId);
Expand Down Expand Up @@ -128,4 +135,4 @@ export class TestExecutionSandbox {
}
return testData;
}
}
}
45 changes: 22 additions & 23 deletions src/app/components/test/test.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 Down Expand Up @@ -135,15 +135,14 @@ export class TestSandbox {
setDefaultSelectedData(selectedData: any) {
this.testRunStore.setSelectedTestCase(selectedData);
}
// Trigger core_apis function to create new test-run-config
async createTestRunConfig(requestJson: any) {
const testConfigData = await this.testRunAPI.createTestRunConfig(requestJson);
return testConfigData;
}
// Trigger core_apis function to create new test-run-executions
createTestRunExecution(callback: any, testConfigId: number, testName: string, operatorId: any, description: any) {
createTestRunExecution(callback: any, selectedDataFinal: any, testName: string, operatorId: any, description: any) {
const selectedProjectId = this.sharedAPI.getSelectedProjectType().id;
this.testRunAPI.createTestRunExecution(callback, testConfigId, selectedProjectId, testName, operatorId, description);
this.testRunAPI.createTestRunExecution(callback, selectedDataFinal, selectedProjectId, testName, operatorId, description);
}
// Trigger core_apis function to repeat test-run-executions
repeatTestRunExecution(callback: any, testExecutionId: number) {
this.testRunAPI.repeatTestRunExecution(callback, testExecutionId);
}
// Start test execution and set initial running testcase data
setRunningTestsDataOnStart(execId: any) {
Expand Down
Loading