Skip to content

Commit

Permalink
Merge pull request #138 from suvarnakale/main
Browse files Browse the repository at this point in the history
#839 -Attestation workflow is appearing after refreshing the page- bu…
  • Loading branch information
Pratikshakhandagale authored Oct 10, 2023
2 parents 9f4ce87 + 700d67e commit 1bfa92f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ <h3 class="fs-4 fw-bold">{{'PROPERTIS_REQUIRED_FOR_ATTESTATION' | translate}}</h
<tr>
<th scope="col" class="fw-bold">
<input class="form-check-input" id="form-check-input-select-all"
[checked]="modalSelectedAttributes.length === selectedMenuFields[0].length"
[checked]="modalSelectedAttributes.length === (selectedMenuFields[0]?.length || 0)"
(change)="checkAll($event, '')" type="checkbox" /> &nbsp;
<label class="p-1 ml-2"> {{'ATTRIBUTES' | translate}}</label>
</th>
Expand Down
51 changes: 38 additions & 13 deletions src/app/admin/config-workflow/config-workflow.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class ConfigWorkflowComponent implements OnInit {
workflow: any;
cardData: any[] = [];
CurrentSchema: any;
executed: boolean = false;

constructor(
private activeRoute: ActivatedRoute,
Expand Down Expand Up @@ -113,9 +114,15 @@ export class ConfigWorkflowComponent implements OnInit {
}

ngOnInit(): void {
if (!this.executed) {
this.addWorkflowItems();
this.addNewAttestCondition(0);
this.addFieldCondition(0, 0);
this.executed = true;
}
this.entityName = this.activeRoute.snapshot.params.entity;
let selectedMenuList: any;
this.generalService.getData("/Schema").subscribe((res) => {
this.generalService.getData("/Schema").subscribe((res) => {
this.fullSchemas = res;
for (let i = 0; i < res.length; i++) {
this.schemaName.push(JSON.parse(res[i]["schema"]));
Expand All @@ -138,32 +145,47 @@ export class ConfigWorkflowComponent implements OnInit {
if (typeof (this.fullSchemas[i].schema) == 'string') {
this.CurrentSchema = JSON.parse(this.fullSchemas[i].schema);
}
if (!this.CurrentSchema['_osConfig']['attestationPolicies']) {
if (!this.CurrentSchema['_osConfig']['attestationPolicies'] || this.CurrentSchema['_osConfig']['attestationPolicies'].length == 0) {
if (!this.executed) {
this.addWorkflowItems();
this.addNewAttestCondition(0);
this.addFieldCondition(0, 0);
this.executed = true;
}
}
if (this.CurrentSchema['_osConfig']['attestationPolicies'] && this.CurrentSchema['_osConfig']['attestationPolicies'].length > 0) {
this.CurrentSchema['_osConfig']['attestationPolicies'].forEach((policy, index) => {
if (!this.executed) {
if (index === 0) {
this.addWorkflowItems();
this.addNewAttestCondition(0);
this.addFieldCondition(0, 0);
this.executed = true;
}
}else{
if (index === 0) {
return;
}
this.addWorkflowItems();
this.addNewAttestCondition(index);
this.addFieldCondition(index, 0);
}
});
}
}
}

}

async readAttestationPolicy() {
for (let i = 0; i < this.fullSchemas.length; i++) {
if (this.entityName == this.fullSchemas[i].name) {
if (typeof (this.fullSchemas[i].schema) == 'string') {
this.fullSchemas[i].schema = JSON.parse(this.fullSchemas[i].schema);
this.generalService.getData("/Schema").subscribe((res) => {
for (let i = 0; i < res.length; i++) {
if (this.entityName == res[i].name) {
if (typeof (res[i].schema) == 'string') {
res[i].schema = JSON.parse(res[i].schema);
}
if (this.fullSchemas[i].schema['_osConfig']['attestationPolicies']) {
if (!this.fullSchemas[i].schema['isRefSchema'] && this.fullSchemas[i].schema['_osConfig']['attestationPolicies'] && this.fullSchemas[i].schema['_osConfig']['attestationPolicies'].length > 0) {
let attestationPolicies = this.fullSchemas[i].schema['_osConfig']['attestationPolicies'];
if (res[i].schema['_osConfig']['attestationPolicies']) {
if (!res[i].schema['isRefSchema'] && res[i].schema['_osConfig']['attestationPolicies'] && res[i].schema['_osConfig']['attestationPolicies'].length > 0) {
let attestationPolicies = res[i].schema['_osConfig']['attestationPolicies'];
for (let l = 0; l < attestationPolicies.length; l++) {
this.workflow = this.workflowForm.value.workflowItems[l];
let pIndex = l;
Expand Down Expand Up @@ -293,6 +315,7 @@ export class ConfigWorkflowComponent implements OnInit {
}
}
}
});
}

setHigherOderAttestorProp(wIndex, aIndex, key, property) {
Expand Down Expand Up @@ -404,6 +427,7 @@ export class ConfigWorkflowComponent implements OnInit {


ngOnChanges(changes: SimpleChanges): void {
this.executed = false;
const latestRequest = changes['usecaseSchema'];
if (latestRequest.currentValue) {
this.entityName = latestRequest.currentValue;
Expand Down Expand Up @@ -953,11 +977,12 @@ export class ConfigWorkflowComponent implements OnInit {

let setAttestationProperties = {}
let setAdditionalInput = submittedWorkflowData[i].additionalInput; // additional Input field of the workflow
let additionalInputKeys = Object.keys(setAdditionalInput);

if(setAdditionalInput != undefined){
var additionalInputKeys = Object.keys(setAdditionalInput);
}
// Loop to change the attestationProperties to the desired format according to the schema
for (let j = 0; j < submittedWorkflowData[i].attestationProperties?.length; j++) {
if (!additionalInputKeys.includes(submittedWorkflowData[i].attestationProperties[j])) {
if (additionalInputKeys && !additionalInputKeys.includes(submittedWorkflowData[i].attestationProperties[j])) {

let entityProperty = submittedWorkflowData[i].attestationProperties[j];
let keys = entityProperty.split(".");
Expand Down

0 comments on commit 1bfa92f

Please sign in to comment.