added loading icon on login

This commit is contained in:
Nicolas Constant 2020-01-01 19:09:02 +01:00
parent 975b3a6e2b
commit 882d123881
2 changed files with 11 additions and 5 deletions

View File

@ -7,7 +7,8 @@
<input type="text" class="form-control form-control-sm form-color" [(ngModel)]="mastodonFullHandle" name="mastodonFullHandle" [class.comrade__input]="isComrade"
placeholder="@nickname@mastodon.social" />
<br />
<button type="submit" class="btn btn-success btn-sm" [class.comrade__button]="isComrade">Submit</button>
<button *ngIf="!isLoading" type="submit" class="btn btn-success btn-sm" [class.comrade__button]="isComrade">Submit</button>
<app-waiting-animation *ngIf="isLoading" class="waiting-icon"></app-waiting-animation>
</form>
<div *ngIf="isComrade" class="comrade__video">

View File

@ -20,6 +20,8 @@ export class AddNewAccountComponent implements OnInit {
private instance: string;
isComrade: boolean;
isLoading: boolean;
private _mastodonFullHandle: string;
@Input()
set mastodonFullHandle(value: string) {
@ -57,17 +59,20 @@ export class AddNewAccountComponent implements OnInit {
}
onSubmit(): boolean {
// let fullHandle = this.mastodonFullHandle.split('@').filter(x => x != null && x !== '');
// const username = fullHandle[0];
// const instance = fullHandle[1];
this.checkBlockList(this.instance);
this.isLoading = true;
this.checkAndCreateApplication(this.instance)
.then((appData: AppData) => {
this.redirectToInstanceAuthPage(this.username, this.instance, appData);
})
.then(x => {
setTimeout(() => {
this.isLoading = false;
}, 1000);
})
.catch((err: HttpErrorResponse) => {
this.isLoading = false;
if (err instanceof HttpErrorResponse) {
this.notificationService.notifyHttpError(err, null);
} else if ((<Error>err).message === 'CORS') {