MOBILE-2995 qr: Add scan QR button in login
parent
e14b3ed0f8
commit
394dd6e24d
|
@ -47,6 +47,11 @@
|
||||||
<ion-option *ngFor="let site of fixedSites" [value]="site.url">{{site.name}}</ion-option>
|
<ion-option *ngFor="let site of fixedSites" [value]="site.url">{{site.name}}</ion-option>
|
||||||
</ion-select>
|
</ion-select>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
|
<a *ngIf="showScanQR" ion-button block color="light" margin-top icon-start (click)="scanQR()">
|
||||||
|
<core-icon name="fa-qrcode" aria-hidden="true"></core-icon>
|
||||||
|
{{ 'core.scanqr' | translate }}
|
||||||
|
</a>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<!-- Pick the site from a list of fixed sites. -->
|
<!-- Pick the site from a list of fixed sites. -->
|
||||||
|
|
|
@ -58,6 +58,7 @@ export class CoreLoginSitePage {
|
||||||
loadingSites = false;
|
loadingSites = false;
|
||||||
onlyWrittenSite = false;
|
onlyWrittenSite = false;
|
||||||
searchFnc: Function;
|
searchFnc: Function;
|
||||||
|
showScanQR: boolean;
|
||||||
|
|
||||||
constructor(navParams: NavParams,
|
constructor(navParams: NavParams,
|
||||||
protected navCtrl: NavController,
|
protected navCtrl: NavController,
|
||||||
|
@ -74,6 +75,7 @@ export class CoreLoginSitePage {
|
||||||
protected utils: CoreUtilsProvider) {
|
protected utils: CoreUtilsProvider) {
|
||||||
|
|
||||||
this.showKeyboard = !!navParams.get('showKeyboard');
|
this.showKeyboard = !!navParams.get('showKeyboard');
|
||||||
|
this.showScanQR = this.utils.canScanQR();
|
||||||
|
|
||||||
let url = '';
|
let url = '';
|
||||||
|
|
||||||
|
@ -356,4 +358,17 @@ export class CoreLoginSitePage {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scan a QR code and put its text in the URL input.
|
||||||
|
*/
|
||||||
|
scanQR(): void {
|
||||||
|
// Scan for a QR code.
|
||||||
|
this.utils.scanQR().then((text) => {
|
||||||
|
if (text) {
|
||||||
|
this.siteForm.controls.siteUrl.setValue(text);
|
||||||
|
|
||||||
|
this.connect(new Event('click'), text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue