Skip to content

Commit

Permalink
Merge pull request #477 from SwethaKrish4/mydevelop
Browse files Browse the repository at this point in the history
MOSIP-28187: Sonar duplication fix
  • Loading branch information
mayuradesh committed Aug 10, 2023
2 parents cd3cf3f + b37cba0 commit aa10077
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 146 deletions.
15 changes: 15 additions & 0 deletions src/app/app.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,21 @@ export default class Utils {
});
}

static getSdkProjectDetails(projectId:string, dataService: any, resourceBundleJson: any, dialog:MatDialog) {
return new Promise((resolve, reject) => {
dataService.getSdkProject(projectId).subscribe(
(response: any) => {
console.log(response['response']);
resolve(response['response']);
},
(errors: any) => {
this.showErrorMessage(resourceBundleJson, errors, dialog);
resolve(false);
}
)
});
}

static initBreadCrumb(resourceBundleJson: any, breadcrumbService: BreadcrumbService, sbiProjectData: any,
sdkProjectData: any, abisProjectData: any, projectType: string, collectionName: any) {
const breadcrumbLabels = resourceBundleJson['breadcrumb'];
Expand Down
19 changes: 1 addition & 18 deletions src/app/core/components/dialog/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class DialogComponent implements OnInit {
}
if (this.projectType == appConstants.SDK) {
this.initSdkProjectForm();
await this.getSdkProjectDetails();
this.projectFormData = await Utils.getSdkProjectDetails(this.projectId, this.dataService, this.resourceBundleJson, this.dialog);
this.populateSdkProjectForm();
}
if (this.projectType == appConstants.ABIS) {
Expand Down Expand Up @@ -180,23 +180,6 @@ export class DialogComponent implements OnInit {
return pattern.test(value) ? { toBeAddedPattern: true } : null;
}

async getSdkProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
this.dataService.getSdkProject(this.projectId).subscribe(
(response: any) => {
this.projectFormData = response['response'];
resolve(true);
},
(errors) => {
Utils.showErrorMessage(this.resourceBundleJson, errors, this.dialog);
resolve(false);
}
)
);
});
}

async getAbisProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export class AddCollectionsComponent implements OnInit {
this.sbiProjectData, null, null, this.projectType, null);
}
if (this.projectType == appConstants.SDK) {
await this.getSdkProjectDetails();
const sdkProjectDetails: any = await Utils.getSdkProjectDetails(this.projectId, this.dataService, this.resourceBundleJson, this.dialog);
if(sdkProjectDetails) {
this.sdkProjectData = sdkProjectDetails;
}
await this.getSdkTestcases();
Utils.initBreadCrumb(this.resourceBundleJson, this.breadcrumbService,
null, this.sdkProjectData, null, this.projectType, null);
Expand Down Expand Up @@ -103,23 +106,6 @@ export class AddCollectionsComponent implements OnInit {
});
}

async getSdkProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
this.dataService.getSdkProject(this.projectId).subscribe(
(response: any) => {
this.sdkProjectData = response['response'];
resolve(true);
},
(errors) => {
Utils.showErrorMessage(this.resourceBundleJson, errors, this.dialog);
resolve(false);
}
)
);
});
}

async getAbisProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export class ViewCollectionsComponent implements OnInit {
this.sbiProjectData, null, null, this.projectType, this.collectionName);
}
if (this.projectType == appConstants.SDK) {
await this.getSdkProjectDetails();
const sdkProjectDetails: any = await Utils.getSdkProjectDetails(this.projectId, this.dataService, this.resourceBundleJson, this.dialog);
if(sdkProjectDetails) {
this.sdkProjectData = sdkProjectDetails;
}
Utils.initBreadCrumb(this.resourceBundleJson, this.breadcrumbService,
null, this.sdkProjectData, null, this.projectType, this.collectionName);
}
Expand Down Expand Up @@ -129,23 +132,6 @@ export class ViewCollectionsComponent implements OnInit {
populateCollection() {
this.collectionForm.controls['name'].setValue(this.collectionName);
}

async getSdkProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
this.dataService.getSdkProject(this.projectId).subscribe(
(response: any) => {
this.sdkProjectData = response['response'];
resolve(true);
},
(errors) => {
Utils.showErrorMessage(this.resourceBundleJson, errors, this.dialog);
resolve(false);
}
)
);
});
}

async getAbisProjectDetails() {
return new Promise((resolve, reject) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class ProjectsDashboardComponent implements OnInit {
}
}
if (project.projectType == appConstants.SDK) {
await this.getSdkProjectDetails(project.id);
this.projectFormData = await Utils.getSdkProjectDetails(project.id, this.dataService, this.resourceBundleJson, this.dialog);
const sdkHash = this.projectFormData.sdkHash;
const websiteUrl = this.projectFormData.websiteUrl;
if (sdkHash == 'To_Be_Added'|| websiteUrl == 'To_Be_Added') {
Expand All @@ -192,23 +192,6 @@ export class ProjectsDashboardComponent implements OnInit {
}
}

async getSdkProjectDetails(projectId: any) {
return new Promise((resolve, reject) => {
this.subscriptions.push(
this.dataService.getSdkProject(projectId).subscribe(
(response: any) => {
this.projectFormData = response['response'];
resolve(true);
},
(errors) => {
Utils.showErrorMessage(this.resourceBundleJson, errors, this.dialog);
resolve(false);
}
)
);
});
}

async getAbisProjectDetails(projectId: any) {
return new Promise((resolve, reject) => {
this.subscriptions.push(
Expand Down
19 changes: 1 addition & 18 deletions src/app/features/project/view-project/view-project.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class ViewProjectComponent implements OnInit {
}
if (this.projectType == appConstants.SDK) {
this.initSdkProjectForm();
await this.getSdkProjectDetails();
this.projectFormData = await Utils.getSdkProjectDetails(this.projectId, this.dataService, this.resourceBundleJson, this.dialog);
this.populateSdkProjectForm();
await this.getBioTestDataNames(this.projectForm.controls['sdkPurpose'].value);
}
Expand Down Expand Up @@ -197,23 +197,6 @@ export class ViewProjectComponent implements OnInit {
});
}

async getSdkProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
this.dataService.getSdkProject(this.projectId).subscribe(
(response: any) => {
this.projectFormData = response['response'];
resolve(true);
},
(errors) => {
Utils.showErrorMessage(this.resourceBundleJson, errors, this.dialog);
resolve(false);
}
)
);
});
}

async getAbisProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,23 +197,6 @@ export class ExecuteTestRunComponent implements OnInit {
return true;
}

async getSdkProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
this.dataService.getSdkProject(this.projectId).subscribe(
(response: any) => {
this.sdkProjectData = response['response'];
resolve(true);
},
(errors) => {
this.errorsInGettingTestcases = true;
resolve(true);
}
)
);
});
}

async getAbisProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
Expand Down Expand Up @@ -710,8 +693,12 @@ export class ExecuteTestRunComponent implements OnInit {
}

async executeSDKTestCase(testCase: TestCaseModel) {
if (!this.sdkProjectData)
await this.getSdkProjectDetails();
if (!this.sdkProjectData) {
const sdkProjectDetails: any = await Utils.getSdkProjectDetails(this.projectId, this.dataService, this.resourceBundleJson, this.dialog);
if(sdkProjectDetails) {
this.sdkProjectData = sdkProjectDetails;
}
}
localStorage.setItem(
appConstants.SDK_PROJECT_URL,
this.sdkProjectData ? this.sdkProjectData.url : ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export class TestRunHistoryComponent implements OnInit {
this.initBreadCrumb();
}
if (this.projectType == appConstants.SDK) {
await this.getSdkProjectDetails();
const sdkProjectDetails: any = await Utils.getSdkProjectDetails(this.projectId, this.dataService, this.resourceBundleJson, this.dialog);
if(sdkProjectDetails) {
this.sdkProjectData = sdkProjectDetails;
}
this.initBreadCrumb();
}
if (this.projectType == appConstants.ABIS) {
Expand Down Expand Up @@ -141,24 +144,6 @@ export class TestRunHistoryComponent implements OnInit {
});
}

async getSdkProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
this.dataService.getSdkProject(this.projectId).subscribe(
(response: any) => {
//console.log(response);
this.sdkProjectData = response['response'];
resolve(true);
},
(errors) => {
Utils.showErrorMessage(this.resourceBundleJson, errors, this.dialog);
resolve(false);
}
)
);
});
}

async getAbisProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
Expand Down
22 changes: 4 additions & 18 deletions src/app/features/test-run/test-run/test-run.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ export class TestRunComponent implements OnInit {
}
}
if (this.projectType == appConstants.SDK) {
await this.getSdkProjectDetails();
const sdkProjectDetails: any = await Utils.getSdkProjectDetails(this.projectId, this.dataService, this.resourceBundleJson, this.dialog);
if(sdkProjectDetails) {
this.sdkProjectData = sdkProjectDetails;
}
}
if (this.projectType == appConstants.ABIS) {
await this.getAbisProjectDetails();
Expand Down Expand Up @@ -238,23 +241,6 @@ export class TestRunComponent implements OnInit {
});
}

async getSdkProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
this.dataService.getSdkProject(this.projectId).subscribe(
(response: any) => {
this.sdkProjectData = response['response'];
resolve(true);
},
(errors: any) => {
Utils.showErrorMessage(this.resourceBundleJson, errors, this.dialog);
resolve(false);
}
)
);
});
}

async getAbisProjectDetails() {
return new Promise((resolve, reject) => {
this.subscriptions.push(
Expand Down

0 comments on commit aa10077

Please sign in to comment.