Skip to content

Commit 886a0c6

Browse files
authored
Merge pull request #2333 from dpalou/MOBILE-3389
Mobile 3389
2 parents fdb6150 + d4e3015 commit 886a0c6

File tree

10 files changed

+173
-19
lines changed

10 files changed

+173
-19
lines changed

src/assets/img/login/faq_url.png

18.9 KB
Loading

src/assets/lang/en.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@
13311331
"core.block.blocks": "Blocks",
13321332
"core.browser": "Browser",
13331333
"core.cancel": "Cancel",
1334-
"core.cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle {{$a}} or later.",
1334+
"core.cannotconnect": "<strong>Cannot connect</strong>: Verify that you have correctly typed your site address.",
13351335
"core.cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.",
13361336
"core.captureaudio": "Record audio",
13371337
"core.capturedimage": "Taken picture.",
@@ -1707,7 +1707,17 @@
17071707
"core.login.emailnotmatch": "Emails do not match",
17081708
"core.login.erroraccesscontrolalloworigin": "The cross-origin call you're trying to perform has been rejected. Please check https://docs.moodle.org/dev/Moodle_Mobile_development_using_Chrome_or_Chromium",
17091709
"core.login.errordeletesite": "An error occurred while deleting this site. Please try again.",
1710+
"core.login.errorexampleurl": "The URL https://campus.example.edu is only an example URL, it's not a real site. <strong>Please use the URL of your school or organization's site.</strong>",
17101711
"core.login.errorupdatesite": "An error occurred while updating the site's token.",
1712+
"core.login.faqcannotconnectanswer": "Please, contact your site administrator.",
1713+
"core.login.faqcannotconnectquestion": "I typed my site address correctly but I still can't connect.",
1714+
"core.login.faqsetupsiteanswer": "Visit {{$link}} to check out the different options you have to create your own Moodle site.",
1715+
"core.login.faqsetupsitelinktitle": "Get started.",
1716+
"core.login.faqsetupsitequestion": "I want to set up my own Moodle site.",
1717+
"core.login.faqtestappanswer": "To test the app in a Moodle Demo Site, type \"teacher\" or \"student\" in the \"Your site address\" field and click the \"Connect!\" button.",
1718+
"core.login.faqtestappquestion": "I just want to test the app, what can I do?",
1719+
"core.login.faqwhatisurlanswer": "<p>Every organisation or school has their own custom address for their Moodle site.</p><p>To find the address of the Moodle site you want to connect to, do the following:</p><ol><li>Open a web browser and go to your school's or organisation's Moodle site login page</li><li>At the top of the page, on the address bar, you will see the URL of your Moodle site. E.g. \"campus.example.edu\".{{$image}}</li><li>Copy the address (do not copy the /login and what comes after), paste it into the Moodle App and click \"Connect!\"</li><li>Now you can log into your site, using your username and password</li>",
1720+
"core.login.faqwhatisurlquestion": "What is the URL of my Moodle site? How can I find my school’s site?",
17111721
"core.login.findyoursite": "Find your site",
17121722
"core.login.firsttime": "Is this your first time here?",
17131723
"core.login.forcepasswordchangenotice": "You must change your password to proceed.",
@@ -1736,7 +1746,6 @@
17361746
"core.login.mobileservicesnotenabled": "Mobile access is not enabled on your site. Please contact your site administrator if you think it should be enabled.",
17371747
"core.login.mustconfirm": "You need to confirm your account",
17381748
"core.login.newaccount": "New account",
1739-
"core.login.newsitedescription": "Please enter the URL of your Moodle site. Note that it might not be configured to work with this app.",
17401749
"core.login.notloggedin": "You need to be logged in.",
17411750
"core.login.password": "Password",
17421751
"core.login.passwordforgotten": "Forgotten password",
@@ -1762,7 +1771,7 @@
17621771
"core.login.selectacountry": "Select a country",
17631772
"core.login.selectsite": "Please select your site:",
17641773
"core.login.signupplugindisabled": "{{$a}} is not enabled.",
1765-
"core.login.siteaddress": "Site address",
1774+
"core.login.siteaddress": "Your site address",
17661775
"core.login.sitehasredirect": "Your site contains at least one HTTP redirect. The app cannot follow redirects, this could be the issue that's preventing the app from connecting to your site.",
17671776
"core.login.siteinmaintenance": "Your site is in maintenance mode",
17681777
"core.login.sitepolicynotagreederror": "Site policy not agreed.",
@@ -1816,6 +1825,7 @@
18161825
"core.more": "more",
18171826
"core.mygroups": "My groups",
18181827
"core.name": "Name",
1828+
"core.needhelp": "Need help?",
18191829
"core.networkerroriframemsg": "This content is not available offline. Please connect to the internet and try again.",
18201830
"core.networkerrormsg": "There was a problem connecting to the site. Please check your connection and try again.",
18211831
"core.never": "Never",
@@ -2090,6 +2100,7 @@
20902100
"core.warningofflinedatadeleted": "Offline data from {{component}} '{{name}}' has been deleted. {{error}}",
20912101
"core.whatisyourage": "What is your age?",
20922102
"core.wheredoyoulive": "In which country do you live?",
2103+
"core.whoissiteadmin": "\"Site Administrators\" are the people who manage the Moodle at your school/university/company or learning organisation. If you don't know how to contact them, please contact your teachers/trainers.",
20932104
"core.whoops": "Oops!",
20942105
"core.whyisthishappening": "Why is this happening?",
20952106
"core.whyisthisrequired": "Why is this required?",

src/core/login/lang/en.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@
2424
"emailnotmatch": "Emails do not match",
2525
"erroraccesscontrolalloworigin": "The cross-origin call you're trying to perform has been rejected. Please check https://docs.moodle.org/dev/Moodle_Mobile_development_using_Chrome_or_Chromium",
2626
"errordeletesite": "An error occurred while deleting this site. Please try again.",
27+
"errorexampleurl": "The URL https://campus.example.edu is only an example URL, it's not a real site. <strong>Please use the URL of your school or organization's site.</strong>",
2728
"errorupdatesite": "An error occurred while updating the site's token.",
29+
"faqcannotconnectanswer": "Please, contact your site administrator.",
30+
"faqcannotconnectquestion": "I typed my site address correctly but I still can't connect.",
31+
"faqsetupsiteanswer": "Visit {{$link}} to check out the different options you have to create your own Moodle site.",
32+
"faqsetupsitelinktitle": "Get started.",
33+
"faqsetupsitequestion": "I want to set up my own Moodle site.",
34+
"faqtestappanswer": "To test the app in a Moodle Demo Site, type \"teacher\" or \"student\" in the \"Your site address\" field and click the \"Connect!\" button.",
35+
"faqtestappquestion": "I just want to test the app, what can I do?",
36+
"faqwhatisurlanswer": "<p>Every organisation or school has their own custom address for their Moodle site.</p><p>To find the address of the Moodle site you want to connect to, do the following:</p><ol><li>Open a web browser and go to your school's or organisation's Moodle site login page</li><li>At the top of the page, on the address bar, you will see the URL of your Moodle site. E.g. \"campus.example.edu\".{{$image}}</li><li>Copy the address (do not copy the /login and what comes after), paste it into the Moodle App and click \"Connect!\"</li><li>Now you can log into your site, using your username and password</li>",
37+
"faqwhatisurlquestion": "What is the URL of my Moodle site? How can I find my school’s site?",
2838
"findyoursite": "Find your site",
2939
"firsttime": "Is this your first time here?",
3040
"forcepasswordchangenotice": "You must change your password to proceed.",
@@ -53,7 +63,6 @@
5363
"mobileservicesnotenabled": "Mobile access is not enabled on your site. Please contact your site administrator if you think it should be enabled.",
5464
"mustconfirm": "You need to confirm your account",
5565
"newaccount": "New account",
56-
"newsitedescription": "Please enter the URL of your Moodle site. Note that it might not be configured to work with this app.",
5766
"notloggedin": "You need to be logged in.",
5867
"password": "Password",
5968
"passwordforgotten": "Forgotten password",
@@ -79,7 +88,7 @@
7988
"selectacountry": "Select a country",
8089
"selectsite": "Please select your site:",
8190
"signupplugindisabled": "{{$a}} is not enabled.",
82-
"siteaddress": "Site address",
91+
"siteaddress": "Your site address",
8392
"sitehasredirect": "Your site contains at least one HTTP redirect. The app cannot follow redirects, this could be the issue that's preventing the app from connecting to your site.",
8493
"siteinmaintenance": "Your site is in maintenance mode",
8594
"sitepolicynotagreederror": "Site policy not agreed.",

src/core/login/pages/site-help/site-help.html

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,31 @@
1010
</ion-navbar>
1111
</ion-header>
1212
<ion-content padding>
13-
<core-format-text [text]="'core.login.helpmelogin' | translate" [filter]="false"></core-format-text>
13+
<ion-list>
14+
<ion-item text-wrap>
15+
<h2><b>{{ 'core.login.faqwhatisurlquestion' | translate }}</b></h2>
16+
</ion-item>
17+
<ion-item text-wrap>
18+
<div [innerHTML]="'core.login.faqwhatisurlanswer' | translate: {$image: urlImageHtml}">
19+
</div>
20+
</ion-item>
21+
<ion-item text-wrap>
22+
<h2><b>{{ 'core.login.faqcannotconnectquestion' | translate }}</b></h2>
23+
</ion-item>
24+
<ion-item text-wrap>
25+
<p>{{ 'core.login.faqcannotconnectanswer' | translate }} {{ 'core.whoissiteadmin' | translate }}</p>
26+
</ion-item>
27+
<ion-item text-wrap>
28+
<h2><b>{{ 'core.login.faqsetupsitequestion' | translate }}</b></h2>
29+
</ion-item>
30+
<ion-item text-wrap>
31+
<p><core-format-text [text]="'core.login.faqsetupsiteanswer' | translate:{$link: setupLinkHtml}" [filter]="false"></core-format-text></p>
32+
</ion-item>
33+
<ion-item text-wrap>
34+
<h2><b>{{ 'core.login.faqtestappquestion' | translate }}</b></h2>
35+
</ion-item>
36+
<ion-item text-wrap>
37+
<p>{{ 'core.login.faqtestappanswer' | translate }}</p>
38+
</ion-item>
39+
</ion-list>
1440
</ion-content>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
page-core-login-site-help {
2+
.content {
3+
background-color: $white;
4+
}
5+
}

src/core/login/pages/site-help/site-help.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import { Component } from '@angular/core';
1616
import { IonicPage, ViewController } from 'ionic-angular';
17+
import { TranslateService } from '@ngx-translate/core';
1718

1819
/**
1920
* Component that displays some help regarding the CoreLoginSitePage.
@@ -24,7 +25,17 @@ import { IonicPage, ViewController } from 'ionic-angular';
2425
templateUrl: 'site-help.html',
2526
})
2627
export class CoreLoginSiteHelpPage {
27-
constructor(private viewCtrl: ViewController) { }
28+
29+
urlImageHtml: string;
30+
setupLinkHtml: string;
31+
32+
constructor(protected viewCtrl: ViewController,
33+
protected translate: TranslateService) {
34+
35+
this.urlImageHtml = '<img src="assets/img/login/faq_url.png" role="presentation">';
36+
this.setupLinkHtml = '<a href="https://moodle.com/getstarted/" title="' +
37+
this.translate.instant('core.login.faqsetupsitelinktitle') + '">https://moodle.com/getstarted/</a>';
38+
}
2839

2940
/**
3041
* Close help modal.

src/core/login/pages/site/site.html

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
<button ion-button icon-only navPush="CoreAppSettingsPage" [attr.aria-label]="'core.settings.appsettings' | translate">
77
<core-icon name="fa-cogs"></core-icon>
88
</button>
9-
<button ion-button icon-only (click)="showHelp()" [attr.aria-label]="'core.help' | translate">
10-
<ion-icon name="help-circle"></ion-icon>
11-
</button>
129
</ion-buttons>
1310
</ion-navbar>
1411
</ion-header>
@@ -20,9 +17,9 @@
2017
<form ion-list [formGroup]="siteForm" (ngSubmit)="connect($event, siteForm.value.siteUrl)" *ngIf="!fixedSites || fixedDisplay == 'select'" #siteFormEl>
2118
<!-- Form to input the site URL if there are no fixed sites. -->
2219
<ng-container *ngIf="!fixedSites">
23-
<p padding>{{ 'core.login.newsitedescription' | translate }}</p>
2420
<ion-item>
25-
<ion-input type="url" name="url" placeholder="{{ 'core.login.siteaddress' | translate }}" formControlName="siteUrl" [core-auto-focus]="showKeyboard"></ion-input>
21+
<ion-label stacked><h2>{{ 'core.login.siteaddress' | translate }}</h2></ion-label>
22+
<ion-input type="url" name="url" placeholder="https://campus.example.edu" formControlName="siteUrl" [core-auto-focus]="showKeyboard"></ion-input>
2623
</ion-item>
2724
</ng-container>
2825

@@ -50,5 +47,36 @@ <h2>{{site.name}}</h2>
5047
<p class="padding no-padding-bottom">{{ 'core.login.selectsite' | translate }}</p>
5148
<a *ngFor="let site of fixedSites" ion-button block (click)="connect($event, site.url)" [title]="site.name" margin-bottom>{{site.name}}</a>
5249
</div>
50+
51+
<!-- Error. -->
52+
<div padding-top *ngIf="error" >
53+
<ion-card class="core-site-error">
54+
<ion-card-header>
55+
{{ 'core.whoops' | translate }}
56+
</ion-card-header>
57+
<ion-card-content>
58+
<p><core-format-text [text]="error.message" [filter]="false"></core-format-text></p>
59+
<ng-container *ngIf="error.url">
60+
<p>{{ 'core.login.problemconnectingerror' | translate }}</p>
61+
<p padding><a [href]="error.fullUrl" core-link>{{ error.url }}</a></p>
62+
<p><strong>{{ 'core.login.problemconnectingerrorcontinue' | translate }}</strong></p>
63+
</ng-container>
64+
</ion-card-content>
65+
<ion-card-header>
66+
{{ 'core.login.stillcantconnect' | translate }}
67+
</ion-card-header>
68+
<ion-card-content>
69+
<p>{{ 'core.login.contactyouradministrator' | translate }}</p>
70+
<p>{{ 'core.whoissiteadmin' | translate }}</p>
71+
</ion-card-content>
72+
</ion-card>
73+
</div>
74+
75+
<!-- Help. -->
76+
<ion-list no-lines>
77+
<a ion-item text-center class="core-login-need-help" (click)="showHelp()" detail-none>
78+
{{ 'core.needhelp' | translate }}
79+
</a>
80+
</ion-list>
5381
</div>
5482
</ion-content>

src/core/login/pages/site/site.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,24 @@ ion-app.app-root page-core-login-site {
1010
background-color: $searchbar-ios-toolbar-input-background;
1111
}
1212
}
13+
14+
.core-site-error {
15+
background: $red-light;
16+
margin-left: 0;
17+
margin-right: 0;
18+
width: 100%;
19+
user-select: text;
20+
21+
p, ion-card-header {
22+
color: $red-dark;
23+
user-select: text;
24+
}
25+
ion-card-header {
26+
font-weight: bold;
27+
}
28+
}
29+
30+
.core-login-need-help {
31+
text-decoration: underline;
32+
}
1333
}

src/core/login/pages/site/site.ts

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,32 @@ import { CoreAppProvider } from '@providers/app';
1818
import { CoreEventsProvider } from '@providers/events';
1919
import { CoreSitesProvider, CoreSiteCheckResponse } from '@providers/sites';
2020
import { CoreDomUtilsProvider } from '@providers/utils/dom';
21+
import { CoreUrlUtilsProvider } from '@providers/utils/url';
2122
import { CoreConfigConstants } from '../../../../configconstants';
2223
import { CoreLoginHelperProvider } from '../../providers/helper';
2324
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
2425
import { CoreUrl } from '@classes/utils/url';
26+
import { TranslateService } from '@ngx-translate/core';
27+
28+
/**
29+
* Data about an error when connecting to a site.
30+
*/
31+
type CoreLoginSiteError = {
32+
/**
33+
* The error message that ocurred.
34+
*/
35+
message: string;
36+
37+
/**
38+
* URL the user entered.
39+
*/
40+
url?: string;
41+
42+
/**
43+
* URL the user entered with protocol added if needed.
44+
*/
45+
fullUrl?: string;
46+
};
2547

2648
/**
2749
* Page to enter or select the site URL to connect to.
@@ -41,6 +63,7 @@ export class CoreLoginSitePage {
4163
fixedDisplay = 'buttons';
4264
showKeyboard = false;
4365
filter = '';
66+
error: CoreLoginSiteError;
4467

4568
constructor(navParams: NavParams,
4669
protected navCtrl: NavController,
@@ -50,7 +73,9 @@ export class CoreLoginSitePage {
5073
protected loginHelper: CoreLoginHelperProvider,
5174
protected modalCtrl: ModalController,
5275
protected domUtils: CoreDomUtilsProvider,
53-
protected eventsProvider: CoreEventsProvider) {
76+
protected eventsProvider: CoreEventsProvider,
77+
protected translate: TranslateService,
78+
protected urlUtils: CoreUrlUtilsProvider) {
5479

5580
this.showKeyboard = !!navParams.get('showKeyboard');
5681

@@ -99,6 +124,14 @@ export class CoreLoginSitePage {
99124

100125
url = url.trim();
101126

127+
if (url.match(/^(https?:\/\/)?campus\.example\.edu/)) {
128+
this.showLoginIssue(null, this.translate.instant('core.login.errorexampleurl'));
129+
130+
return;
131+
}
132+
133+
this.hideLoginIssue();
134+
102135
const modal = this.domUtils.showModalLoading(),
103136
siteData = this.sitesProvider.getDemoSiteData(url);
104137

@@ -164,19 +197,28 @@ export class CoreLoginSitePage {
164197
modal.present();
165198
}
166199

200+
/**
201+
* Hide the login error.
202+
*/
203+
protected hideLoginIssue(): void {
204+
this.error = null;
205+
}
206+
167207
/**
168208
* Show an error that aims people to solve the issue.
169209
*
170210
* @param url The URL the user was trying to connect to.
171211
* @param error Error to display.
172212
*/
173213
protected showLoginIssue(url: string, error: any): void {
174-
const modal = this.modalCtrl.create('CoreLoginSiteErrorPage', {
175-
siteUrl: url,
176-
issue: this.domUtils.getErrorMessage(error)
177-
});
214+
this.error = {
215+
url: url,
216+
message: this.domUtils.getErrorMessage(error),
217+
};
178218

179-
modal.present();
219+
if (url) {
220+
this.error.fullUrl = this.urlUtils.isAbsoluteURL(url) ? url : 'https://' + url;
221+
}
180222
}
181223

182224
/**

src/lang/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"back": "Back",
1313
"browser": "Browser",
1414
"cancel": "Cancel",
15-
"cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle {{$a}} or later.",
15+
"cannotconnect": "<strong>Cannot connect</strong>: Verify that you have correctly typed your site address.",
1616
"cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.",
1717
"captureaudio": "Record audio",
1818
"capturedimage": "Taken picture.",
@@ -167,6 +167,7 @@
167167
"more": "more",
168168
"mygroups": "My groups",
169169
"name": "Name",
170+
"needhelp": "Need help?",
170171
"networkerroriframemsg": "This content is not available offline. Please connect to the internet and try again.",
171172
"networkerrormsg": "There was a problem connecting to the site. Please check your connection and try again.",
172173
"never": "Never",
@@ -293,6 +294,7 @@
293294
"warningofflinedatadeleted": "Offline data from {{component}} '{{name}}' has been deleted. {{error}}",
294295
"whatisyourage": "What is your age?",
295296
"wheredoyoulive": "In which country do you live?",
297+
"whoissiteadmin": "\"Site Administrators\" are the people who manage the Moodle at your school/university/company or learning organisation. If you don't know how to contact them, please contact your teachers/trainers.",
296298
"whoops": "Oops!",
297299
"whyisthishappening": "Why is this happening?",
298300
"whyisthisrequired": "Why is this required?",

0 commit comments

Comments
 (0)