Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onStartBoard() {
// for test
if (this.debugMode) {
this.startBtnState = ClrLoadingState.LOADING;
this.submitBtnState = ClrLoadingState.LOADING;
this.isStart = true;
setTimeout(() => {
this.openSSH = false;
this.installStep += 2;
this.ignoreStep2 = true;
this.installProgress = 100;
this.startBtnState = ClrLoadingState.DEFAULT;
this.submitBtnState = ClrLoadingState.DEFAULT;
}, 20000);
return;
}
this.startBtnState = ClrLoadingState.LOADING;
this.submitBtnState = ClrLoadingState.LOADING;
this.isStart = true;
this.boardService.start(this.user).subscribe(
onSubmit() {
this.loginBtnState = ClrLoadingState.LOADING;
const action = new AuthLogin(this.loginForm.value);
this.store.dispatch(action).subscribe(
() => this.handleLoginSuccess(),
(err) => this.handleLoginError(err),
);
}
}
ngOnInit() {
if (this.fake) {
this.loading.loadingState = ClrLoadingState.LOADING;
setTimeout(() => {
this.load();
this.loading.loadingState = ClrLoadingState.DEFAULT;
}, LATENCY);
} else {
this.load();
}
}
it('test connection button should not be disabled', fakeAsync(() => {
let nameInput = fixture.nativeElement.querySelector('#scanner-name');
nameInput.value = "test2";
nameInput.dispatchEvent(new Event('input'));
let urlInput = fixture.nativeElement.querySelector('#scanner-endpoint');
urlInput.value = "http://168.0.0.1";
urlInput.dispatchEvent(new Event('input'));
expect(component.canTestEndpoint).toBeTruthy();
let el = fixture.nativeElement.querySelector('#button-test');
el.click();
el.dispatchEvent(new Event('click'));
expect(component.checkBtnState).toBe(ClrLoadingState.LOADING);
tick(10000);
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(component.checkBtnState).toBe(ClrLoadingState.SUCCESS);
});
}));
it('add button should not be disabled', fakeAsync(() => {
validate() {
this.validateLoading = ClrLoadingState.LOADING;
this.auth.validateToken().subscribe(res => {
this.validateLoading = res.error
? ClrLoadingState.ERROR
: ClrLoadingState.SUCCESS;
});
}
validateDemo() {
this.validateState = ClrLoadingState.LOADING;
setTimeout(() => {
this.validateState = ClrLoadingState.SUCCESS;
}, 1500);
}
enabledDemo() {
this.enabledState = ClrLoadingState.LOADING;
setTimeout(() => {
this.enabledState = ClrLoadingState.SUCCESS;
this.enabledStateDisabled = false;
}, 1500);
}
onTestEndpoint() {
this.checkBtnState = ClrLoadingState.LOADING;
this.checking = true;
this.webhookService
.testEndpoint(this.projectId, {
targets: [this.webhookTarget]
})
.pipe(finalize(() => (this.checking = false)))
.subscribe(
response => {
if (this.isModify) {
this.inlineAlert.showInlineSuccess({
message: "WEBHOOK.TEST_ENDPOINT_SUCCESS"
});
} else {
this.checkBtnState = ClrLoadingState.SUCCESS;
}
create(): void {
this.onSaving = true;
this.saveBtnState = ClrLoadingState.LOADING;
let scanner: Scanner = new Scanner();
let value = this.newScannerFormComponent.newScannerForm.value;
scanner.name = value.name;
scanner.description = value.description;
scanner.url = value.url;
if (value.auth === "None") {
scanner.auth = "";
} else if (value.auth === "Basic") {
scanner.auth = value.auth;
scanner.access_credential = value.accessCredential.username + ":" + value.accessCredential.password;
} else if (value.auth === "APIKey") {
scanner.auth = value.auth;
scanner.access_credential = value.accessCredential.apiKey;
} else {
scanner.auth = value.auth;
scanner.access_credential = value.accessCredential.token;
getProjectScanner(): void {
this.hasEnabledScanner = false;
this.scanBtnState = ClrLoadingState.LOADING;
this.scanningService.getProjectScanner(this.projectId)
.subscribe(response => {
if (response && "{}" !== JSON.stringify(response) && !response.disabled
&& response.health === "healthy") {
this.scanBtnState = ClrLoadingState.SUCCESS;
this.hasEnabledScanner = true;
} else {
this.scanBtnState = ClrLoadingState.ERROR;
}
}, error => {
this.scanBtnState = ClrLoadingState.ERROR;
});
}