Merge pull request #2378 from crazyserver/MOBILE-3401

Mobile 3401
main
Juan Leyva 2020-05-22 13:12:17 +02:00 committed by GitHub
commit 01e54a2a9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 34 deletions

View File

@ -204,6 +204,8 @@ $core-discussion-messages-badge-text: $white !default;
ion-fab button { ion-fab button {
overflow: visible; overflow: visible;
position: relative; position: relative;
box-shadow: $fab-md-box-shadow;
.core-discussion-messages-badge { .core-discussion-messages-badge {
position: absolute; position: absolute;
border-radius: 50%; border-radius: 50%;

View File

@ -6,7 +6,7 @@
</button> </button>
</ion-buttons> </ion-buttons>
<ion-buttons end> <ion-buttons end>
<button ion-button (click)="skip($event)"> <button ion-button (click)="skip($event)" [attr.aria-label]="'core.skip' | translate">
{{'core.skip' | translate}} {{'core.skip' | translate}}
</button> </button>
</ion-buttons> </ion-buttons>

View File

@ -11,7 +11,7 @@
</ion-header> </ion-header>
<ion-content padding> <ion-content padding>
<div> <div>
<div text-center padding margin-bottom [class.hidden]="hasSites" class="core-login-site-logo"> <div text-center padding margin-bottom [class.hidden]="hasSites || enteredSiteUrl" class="core-login-site-logo">
<img src="assets/img/login_logo.png" class="avatar-full login-logo" role="presentation"> <img src="assets/img/login_logo.png" class="avatar-full login-logo" role="presentation">
</div> </div>
<form ion-list [formGroup]="siteForm" (ngSubmit)="connect($event, siteForm.value.siteUrl)" *ngIf="!fixedSites || fixedDisplay == 'select'" #siteFormEl> <form ion-list [formGroup]="siteForm" (ngSubmit)="connect($event, siteForm.value.siteUrl)" *ngIf="!fixedSites || fixedDisplay == 'select'" #siteFormEl>
@ -23,19 +23,28 @@
</ion-item> </ion-item>
</ng-container> </ng-container>
<ion-list *ngIf="!fixedSites" [class.hidden]="!hasSites" class="core-login-site-list" [class.dimmed]="loadingSites"> <ion-list *ngIf="!fixedSites" [class.hidden]="!hasSites && !enteredSiteUrl" class="core-login-site-list">
<div *ngIf="loadingSites" class="core-login-site-list-loading"><ion-spinner></ion-spinner></div> <ion-item no-lines class="core-login-site-list-title"><h2 class="item-heading">{{ 'core.login.selectsite' | translate }}</h2></ion-item>
<ion-item no-lines class="core-login-site-list-title" *ngIf="onlyWrittenSite"><h2 class="item-heading">{{ 'core.login.selectsite' | translate }}</h2></ion-item> <ion-item *ngIf="enteredSiteUrl" (click)="connect($event, enteredSiteUrl.url)" [title]="enteredSiteUrl.name" detail-push class="core-login-entered-site">
<ion-item *ngFor="let site of sites" (click)="connect($event, site.url, site)" [title]="site.name" detail-push [class.core-login-entered-site]="!site.fromWS"> <ion-thumbnail item-start>
<core-icon name="fa-pencil"></core-icon>
</ion-thumbnail>
<h2 text-wrap>{{enteredSiteUrl.name}}</h2>
<p>{{enteredSiteUrl.noProtocolUrl}}</p>
</ion-item>
<div class="core-login-site-list-found" [class.hidden]="!hasSites" [class.dimmed]="loadingSites">
<div *ngIf="loadingSites" class="core-login-site-list-loading"><ion-spinner></ion-spinner></div>
<ion-item *ngFor="let site of sites" (click)="connect($event, site.url, site)" [title]="site.name" detail-push>
<ion-thumbnail item-start> <ion-thumbnail item-start>
<core-icon name="fa-pencil" *ngIf="!site.imageurl && !site.fromWS"></core-icon>
<img [src]="site.imageurl" *ngIf="site.imageurl"> <img [src]="site.imageurl" *ngIf="site.imageurl">
<img src="assets/icon/icon.png" *ngIf="!site.imageurl && site.fromWS" class="core-login-default-icon"> <img src="assets/icon/icon.png" *ngIf="!site.imageurl" class="core-login-default-icon">
</ion-thumbnail> </ion-thumbnail>
<h2 text-wrap>{{site.name}}<ng-container *ngIf="site.alias"> ({{site.alias}})</ng-container></h2> <h2 text-wrap>{{site.name}}<ng-container *ngIf="site.alias"> ({{site.alias}})</ng-container></h2>
<p>{{site.noProtocolUrl}}</p> <p>{{site.noProtocolUrl}}</p>
<p *ngIf="site.country || site.city" text-wrap><ng-container *ngIf="site.city">{{site.city}} - </ng-container>{{site.country}}</p> <p *ngIf="site.country || site.city" text-wrap><ng-container *ngIf="site.city">{{site.city}} - </ng-container>{{site.country}}</p>
</ion-item> </ion-item>
</div>
</ion-list> </ion-list>
<div *ngIf="!fixedSites && !hasSites && loadingSites" class="core-login-site-nolist-loading"><ion-spinner></ion-spinner></div> <div *ngIf="!fixedSites && !hasSites && loadingSites" class="core-login-site-nolist-loading"><ion-spinner></ion-spinner></div>
@ -48,7 +57,7 @@
</ion-select> </ion-select>
</ion-item> </ion-item>
<ng-container *ngIf="!fixedSites && showScanQR && !hasSites"> <ng-container *ngIf="!fixedSites && showScanQR && !hasSites && !enteredSiteUrl">
<div class="core-login-site-qrcode-separator">{{ 'core.login.or' | translate }}</div> <div class="core-login-site-qrcode-separator">{{ 'core.login.or' | translate }}</div>
<ion-item> <ion-item>
<a ion-button block color="light" margin-top icon-start (click)="scanQR()"> <a ion-button block color="light" margin-top icon-start (click)="scanQR()">

View File

@ -43,7 +43,8 @@ ion-app.app-root page-core-login-site {
} }
.core-login-site-logo, .core-login-site-logo,
.core-login-site-list { .core-login-site-list,
.core-login-site-list-found {
transition-delay: 0s; transition-delay: 0s;
visibility: visible; visibility: visible;
opacity: 1; opacity: 1;
@ -59,7 +60,7 @@ ion-app.app-root page-core-login-site {
} }
} }
.core-login-site-list.dimmed { .core-login-site-list-found.dimmed {
pointer-events: none; pointer-events: none;
position: relative; position: relative;
} }

View File

@ -34,7 +34,6 @@ import { TranslateService } from '@ngx-translate/core';
* Extended data for UI implementation. * Extended data for UI implementation.
*/ */
type CoreLoginSiteInfoExtended = CoreLoginSiteInfo & { type CoreLoginSiteInfoExtended = CoreLoginSiteInfo & {
fromWS?: boolean; // If the site came from the WS call.
noProtocolUrl?: string; // Url wihtout protocol. noProtocolUrl?: string; // Url wihtout protocol.
country?: string; // Based on countrycode. country?: string; // Based on countrycode.
}; };
@ -60,9 +59,9 @@ export class CoreLoginSitePage {
sites: CoreLoginSiteInfoExtended[] = []; sites: CoreLoginSiteInfoExtended[] = [];
hasSites = false; hasSites = false;
loadingSites = false; loadingSites = false;
onlyWrittenSite = false;
searchFnc: Function; searchFnc: Function;
showScanQR: boolean; showScanQR: boolean;
enteredSiteUrl: CoreLoginSiteInfoExtended;
constructor(navParams: NavParams, constructor(navParams: NavParams,
protected navCtrl: NavController, protected navCtrl: NavController,
@ -108,33 +107,19 @@ export class CoreLoginSitePage {
siteUrl: [url, this.moodleUrlValidator()] siteUrl: [url, this.moodleUrlValidator()]
}); });
this.searchFnc = this.utils.debounce(async (search: string, isValid: boolean = false) => { this.searchFnc = this.utils.debounce(async (search: string) => {
search = search.trim(); search = search.trim();
if (search.length >= 3) { if (search.length >= 3) {
this.onlyWrittenSite = false;
// Update the sites list. // Update the sites list.
this.sites = await this.sitesProvider.findSites(search); this.sites = await this.sitesProvider.findSites(search);
// UI tweaks. // UI tweaks.
this.sites.forEach((site) => { this.sites.forEach((site) => {
site.noProtocolUrl = CoreUrl.removeProtocol(site.url); site.noProtocolUrl = CoreUrl.removeProtocol(site.url);
site.fromWS = true;
site.country = this.utils.getCountryName(site.countrycode); site.country = this.utils.getCountryName(site.countrycode);
}); });
// If it's a valid URL, add it.
if (isValid) {
this.onlyWrittenSite = !!this.sites.length;
this.sites.unshift({
url: search,
fromWS: false,
name: this.translate.instant('core.login.yourenteredsite'),
noProtocolUrl: CoreUrl.removeProtocol(search),
});
}
this.hasSites = !!this.sites.length; this.hasSites = !!this.sites.length;
} else { } else {
// Not reseting the array to allow animation to be displayed. // Not reseting the array to allow animation to be displayed.
@ -268,7 +253,7 @@ export class CoreLoginSitePage {
error = this.domUtils.getErrorMessage(error); error = this.domUtils.getErrorMessage(error);
if (error == this.translate.instant('core.cannotconnecttrouble')) { if (error == this.translate.instant('core.cannotconnecttrouble')) {
const found = this.sites.find((site) => site.fromWS && site.url == url); const found = this.sites.find((site) => site.url == url);
if (!found) { if (!found) {
error += ' ' + this.translate.instant('core.cannotconnectverify'); error += ' ' + this.translate.instant('core.cannotconnectverify');
@ -311,7 +296,19 @@ export class CoreLoginSitePage {
searchSite(e: Event, search: string): void { searchSite(e: Event, search: string): void {
this.loadingSites = true; this.loadingSites = true;
this.searchFnc(search.trim(), this.siteForm.valid); search = search.trim();
if (this.siteForm.valid && search.length >= 3) {
this.enteredSiteUrl = {
url: search,
name: this.translate.instant('core.login.yourenteredsite'),
noProtocolUrl: CoreUrl.removeProtocol(search),
};
} else {
this.enteredSiteUrl = null;
}
this.searchFnc(search.trim());
} }
/** /**