MOBILE-3313 licenses: Add open source licenses page
parent
815e87afbe
commit
d788c320ff
|
@ -1933,6 +1933,7 @@
|
||||||
"core.settings.fontsizecharacter": "block_accessibility/char",
|
"core.settings.fontsizecharacter": "block_accessibility/char",
|
||||||
"core.settings.general": "moodle",
|
"core.settings.general": "moodle",
|
||||||
"core.settings.language": "moodle",
|
"core.settings.language": "moodle",
|
||||||
|
"core.settings.license": "moodle",
|
||||||
"core.settings.localnotifavailable": "local_moodlemobileapp",
|
"core.settings.localnotifavailable": "local_moodlemobileapp",
|
||||||
"core.settings.locationhref": "local_moodlemobileapp",
|
"core.settings.locationhref": "local_moodlemobileapp",
|
||||||
"core.settings.locked": "admin",
|
"core.settings.locked": "admin",
|
||||||
|
@ -1943,6 +1944,7 @@
|
||||||
"core.settings.networkstatus": "local_moodlemobileapp",
|
"core.settings.networkstatus": "local_moodlemobileapp",
|
||||||
"core.settings.opensourcelicenses": "local_moodlemobileapp",
|
"core.settings.opensourcelicenses": "local_moodlemobileapp",
|
||||||
"core.settings.privacypolicy": "local_moodlemobileapp",
|
"core.settings.privacypolicy": "local_moodlemobileapp",
|
||||||
|
"core.settings.publisher": "local_moodlemobileapp",
|
||||||
"core.settings.pushid": "local_moodlemobileapp",
|
"core.settings.pushid": "local_moodlemobileapp",
|
||||||
"core.settings.reportinbackground": "local_moodlemobileapp",
|
"core.settings.reportinbackground": "local_moodlemobileapp",
|
||||||
"core.settings.screen": "local_moodlemobileapp",
|
"core.settings.screen": "local_moodlemobileapp",
|
||||||
|
|
|
@ -1933,6 +1933,7 @@
|
||||||
"core.settings.fontsizecharacter": "A",
|
"core.settings.fontsizecharacter": "A",
|
||||||
"core.settings.general": "General",
|
"core.settings.general": "General",
|
||||||
"core.settings.language": "Language",
|
"core.settings.language": "Language",
|
||||||
|
"core.settings.license": "License",
|
||||||
"core.settings.localnotifavailable": "Local notifications available",
|
"core.settings.localnotifavailable": "Local notifications available",
|
||||||
"core.settings.locationhref": "Web view URL",
|
"core.settings.locationhref": "Web view URL",
|
||||||
"core.settings.locked": "Locked",
|
"core.settings.locked": "Locked",
|
||||||
|
@ -1943,6 +1944,7 @@
|
||||||
"core.settings.networkstatus": "Internet connection status",
|
"core.settings.networkstatus": "Internet connection status",
|
||||||
"core.settings.opensourcelicenses": "Open Source Licences",
|
"core.settings.opensourcelicenses": "Open Source Licences",
|
||||||
"core.settings.privacypolicy": "Privacy policy",
|
"core.settings.privacypolicy": "Privacy policy",
|
||||||
|
"core.settings.publisher": "Publisher",
|
||||||
"core.settings.pushid": "Push notifications ID",
|
"core.settings.pushid": "Push notifications ID",
|
||||||
"core.settings.reportinbackground": "Report errors automatically",
|
"core.settings.reportinbackground": "Report errors automatically",
|
||||||
"core.settings.screen": "Screen information",
|
"core.settings.screen": "Screen information",
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
"fontsizecharacter": "A",
|
"fontsizecharacter": "A",
|
||||||
"general": "General",
|
"general": "General",
|
||||||
"language": "Language",
|
"language": "Language",
|
||||||
|
"license": "License",
|
||||||
"opensourcelicenses": "Open Source Licences",
|
"opensourcelicenses": "Open Source Licences",
|
||||||
"localnotifavailable": "Local notifications available",
|
"localnotifavailable": "Local notifications available",
|
||||||
"locationhref": "Web view URL",
|
"locationhref": "Web view URL",
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
"navigatoruseragent": "Navigator userAgent",
|
"navigatoruseragent": "Navigator userAgent",
|
||||||
"networkstatus": "Internet connection status",
|
"networkstatus": "Internet connection status",
|
||||||
"privacypolicy": "Privacy policy",
|
"privacypolicy": "Privacy policy",
|
||||||
|
"publisher": "Publisher",
|
||||||
"pushid": "Push notifications ID",
|
"pushid": "Push notifications ID",
|
||||||
"reportinbackground": "Report errors automatically",
|
"reportinbackground": "Report errors automatically",
|
||||||
"entriesincache": "{{$a}} entries in cache",
|
"entriesincache": "{{$a}} entries in cache",
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
<ion-item text-wrap>
|
<ion-item text-wrap>
|
||||||
<h2>{{ appName }} {{ versionName }}</h2>
|
<h2>{{ appName }} {{ versionName }}</h2>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item text-wrap detail-push>
|
<a ion-item text-wrap (click)="openPage('CoreSettingsLicensesPage')" [title]="'core.settings.opensourcelicenses' | translate">
|
||||||
<core-icon name="fa-copyright" item-start></core-icon>
|
<core-icon name="fa-copyright" item-start></core-icon>
|
||||||
{{ 'core.settings.opensourcelicenses' | translate }}
|
{{ 'core.settings.opensourcelicenses' | translate }}
|
||||||
</ion-item>
|
</a>
|
||||||
<a ion-item text-wrap *ngIf="privacyPolicy" [href]="privacyPolicy" core-link auto-login="no">
|
<a ion-item text-wrap *ngIf="privacyPolicy" [href]="privacyPolicy" core-link auto-login="no">
|
||||||
<core-icon name="fa-user-secret" item-start></core-icon>
|
<core-icon name="fa-user-secret" item-start></core-icon>
|
||||||
{{ 'core.settings.privacypolicy' | translate }}
|
{{ 'core.settings.privacypolicy' | translate }}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
<ion-header>
|
||||||
|
<ion-navbar core-back-button>
|
||||||
|
<ion-title>{{ 'core.settings.opensourcelicenses' | translate }}</ion-title>
|
||||||
|
</ion-navbar>
|
||||||
|
</ion-header>
|
||||||
|
<ion-content>
|
||||||
|
<core-loading [hideUntil]="loaded">
|
||||||
|
<a *ngIf="error" ion-item text-wrap [href]="licensesUrl" core-link auto-login="no">
|
||||||
|
{{ 'core.settings.opensourcelicenses' | translate }}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<ng-container *ngIf="!error">
|
||||||
|
<ion-item *ngFor="let license of licenses" text-wrap>
|
||||||
|
<h2>
|
||||||
|
<a *ngIf="license.repository" [href]="license.repository" core-link auto-login="no">{{ license.name }}</a>
|
||||||
|
<ng-container *ngIf="!license.repository">{{ license.name }}</ng-container> - {{ license.version }}
|
||||||
|
</h2>
|
||||||
|
<h3 *ngIf="license.publisher">{{ 'core.settings.publisher' | translate }}{{ 'core.labelsep' | translate }} {{ license.publisher }}</h3>
|
||||||
|
<p>{{ 'core.settings.license' | translate }}{{ 'core.labelsep' | translate }} {{ license.licenses }}</p>
|
||||||
|
<p><a *ngIf="license.url" [href]="license.url" core-link auto-login="no">{{ license.url }}</a></p>
|
||||||
|
<p><a *ngIf="license.email" [href]="'mailto:' +license.email" core-link auto-login="no">{{ license.email }}</a></p>
|
||||||
|
<a *ngIf="license.licenseUrl" [href]="license.licenseUrl" target="_blank" ion-button ion-button clear item-end>{{ 'core.view' | translate }}</a>
|
||||||
|
</ion-item>
|
||||||
|
</ng-container>
|
||||||
|
</core-loading>
|
||||||
|
</ion-content>
|
|
@ -0,0 +1,35 @@
|
||||||
|
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { IonicPageModule } from 'ionic-angular';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { CoreSettingsLicensesPage } from './licenses';
|
||||||
|
import { CoreComponentsModule } from '@components/components.module';
|
||||||
|
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||||
|
import { CorePipesModule } from '@pipes/pipes.module';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
CoreSettingsLicensesPage
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
CoreComponentsModule,
|
||||||
|
CoreDirectivesModule,
|
||||||
|
CorePipesModule,
|
||||||
|
IonicPageModule.forChild(CoreSettingsLicensesPage),
|
||||||
|
TranslateModule.forChild()
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class CoreSettingsLicensesPageModule {}
|
|
@ -0,0 +1,88 @@
|
||||||
|
// (C) Copyright 2015 Moodle Pty Ltd.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { IonicPage } from 'ionic-angular';
|
||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { CoreConfigConstants } from '../../../../configconstants';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines license info
|
||||||
|
*/
|
||||||
|
interface CoreSettingsLicense {
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
licenses: string;
|
||||||
|
repository?: string;
|
||||||
|
publisher?: string;
|
||||||
|
url?: string;
|
||||||
|
email?: string;
|
||||||
|
licenseUrl?: string;
|
||||||
|
licenseFile?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page that displays the open source licenses information.
|
||||||
|
*/
|
||||||
|
@IonicPage({segment: 'core-settings-licenses'})
|
||||||
|
@Component({
|
||||||
|
selector: 'page-core-settings-licenses',
|
||||||
|
templateUrl: 'licenses.html',
|
||||||
|
})
|
||||||
|
export class CoreSettingsLicensesPage {
|
||||||
|
|
||||||
|
licensesUrl: string;
|
||||||
|
loaded = false;
|
||||||
|
licenses: CoreSettingsLicense[];
|
||||||
|
error = false;
|
||||||
|
|
||||||
|
constructor(protected http: HttpClient) {
|
||||||
|
let version = 'v' + CoreConfigConstants.versionname;
|
||||||
|
if (version.indexOf('-') > 0) {
|
||||||
|
version = 'integration';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.licensesUrl = 'https://raw.githubusercontent.com/moodlehq/moodleapp/' + version + '/licenses.json';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View loaded.
|
||||||
|
*/
|
||||||
|
ionViewDidLoad(): void {
|
||||||
|
this.http.get(this.licensesUrl).toPromise().then((licenses) => {
|
||||||
|
this.licenses = Object.keys(licenses).map((name) => {
|
||||||
|
const license = licenses[name];
|
||||||
|
|
||||||
|
const nameSplit = name.lastIndexOf('@');
|
||||||
|
license.name = name.substring(0, nameSplit);
|
||||||
|
license.version = name.substring(nameSplit + 1);
|
||||||
|
|
||||||
|
if (license.repository) {
|
||||||
|
license.repository = license.repository.replace('git://', 'https://');
|
||||||
|
if (license.repository.indexOf('github.com') > 0) {
|
||||||
|
license.licenseUrl = license.repository + '/blob/' + license.version + '/' + license.licenseFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return license;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.error = false;
|
||||||
|
}).catch(() => {
|
||||||
|
this.error = true;
|
||||||
|
}).finally(() => {
|
||||||
|
this.loaded = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue