commit
bc97553259
|
@ -0,0 +1,10 @@
|
|||
Package updates known problems
|
||||
=================
|
||||
|
||||
@ionic/app-scripts 3.2.3 shows error Cannot find type definition file for '@types'. on ngc build.
|
||||
|
||||
com-darryncampbell-cordova-plugin-intent 2.0.0 onwards needs Android X Support. Unsupported on PGB.
|
||||
|
||||
typescript is needed to be less than 2.7 for @angular/compiler-cli
|
||||
|
||||
cordova-plugin-ionic-keyboard has problems on greater verisons than 2.1.3
|
File diff suppressed because it is too large
Load Diff
109
package.json
109
package.json
|
@ -40,57 +40,56 @@
|
|||
"windows.store": "npx electron-windows-store --input-directory .\\desktop\\dist\\win-unpacked --output-directory .\\desktop\\store -a .\\resources\\desktop -m .\\desktop\\assets\\windows\\AppXManifest.xml --package-version 0.0.0.0 --package-name MoodleDesktop"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/animations": "^5.2.10",
|
||||
"@angular/common": "^5.2.10",
|
||||
"@angular/compiler": "^5.2.10",
|
||||
"@angular/compiler-cli": "^5.2.10",
|
||||
"@angular/core": "^5.2.10",
|
||||
"@angular/forms": "^5.2.10",
|
||||
"@angular/http": "^5.2.10",
|
||||
"@angular/platform-browser": "^5.2.10",
|
||||
"@angular/platform-browser-dynamic": "^5.2.10",
|
||||
"@ionic-native/badge": "^4.17.0",
|
||||
"@ionic-native/camera": "^4.17.0",
|
||||
"@ionic-native/clipboard": "^4.17.0",
|
||||
"@ionic-native/core": "^4.11.0",
|
||||
"@ionic-native/device": "^4.17.0",
|
||||
"@ionic-native/file": "^4.17.0",
|
||||
"@ionic-native/file-opener": "^4.17.0",
|
||||
"@ionic-native/file-transfer": "^4.17.0",
|
||||
"@ionic-native/geolocation": "^4.17.0",
|
||||
"@ionic-native/globalization": "^4.17.0",
|
||||
"@ionic-native/in-app-browser": "^4.17.0",
|
||||
"@ionic-native/keyboard": "^4.17.0",
|
||||
"@ionic-native/local-notifications": "^4.17.0",
|
||||
"@ionic-native/media-capture": "^4.17.0",
|
||||
"@ionic-native/network": "^4.17.0",
|
||||
"@ionic-native/push": "^4.17.0",
|
||||
"@ionic-native/screen-orientation": "^4.17.0",
|
||||
"@ionic-native/splash-screen": "^4.17.0",
|
||||
"@ionic-native/sqlite": "^4.17.0",
|
||||
"@ionic-native/status-bar": "^4.17.0",
|
||||
"@ionic-native/web-intent": "^4.17.0",
|
||||
"@ionic-native/zip": "^4.17.0",
|
||||
"@angular/animations": "^5.2.11",
|
||||
"@angular/common": "^5.2.11",
|
||||
"@angular/compiler": "^5.2.11",
|
||||
"@angular/compiler-cli": "^5.2.11",
|
||||
"@angular/core": "^5.2.11",
|
||||
"@angular/forms": "^5.2.11",
|
||||
"@angular/platform-browser": "^5.2.11",
|
||||
"@angular/platform-browser-dynamic": "^5.2.11",
|
||||
"@ionic-native/badge": "^4.20.0",
|
||||
"@ionic-native/camera": "^4.20.0",
|
||||
"@ionic-native/clipboard": "^4.20.0",
|
||||
"@ionic-native/core": "^4.20.0",
|
||||
"@ionic-native/device": "^4.20.0",
|
||||
"@ionic-native/file": "^4.20.0",
|
||||
"@ionic-native/file-opener": "^4.20.0",
|
||||
"@ionic-native/file-transfer": "^4.20.0",
|
||||
"@ionic-native/geolocation": "^4.20.0",
|
||||
"@ionic-native/globalization": "^4.20.0",
|
||||
"@ionic-native/in-app-browser": "^4.20.0",
|
||||
"@ionic-native/keyboard": "^4.20.0",
|
||||
"@ionic-native/local-notifications": "^4.20.0",
|
||||
"@ionic-native/media-capture": "^4.20.0",
|
||||
"@ionic-native/network": "^4.20.0",
|
||||
"@ionic-native/push": "^4.20.0",
|
||||
"@ionic-native/screen-orientation": "^4.20.0",
|
||||
"@ionic-native/splash-screen": "^4.20.0",
|
||||
"@ionic-native/sqlite": "^4.20.0",
|
||||
"@ionic-native/status-bar": "^4.20.0",
|
||||
"@ionic-native/web-intent": "^4.20.0",
|
||||
"@ionic-native/zip": "^4.20.0",
|
||||
"@ngx-translate/core": "^8.0.0",
|
||||
"@ngx-translate/http-loader": "^2.0.1",
|
||||
"ajv": "^6.10.2",
|
||||
"chart.js": "^2.7.2",
|
||||
"ajv": "^6.11.0",
|
||||
"chart.js": "^2.9.3",
|
||||
"com-darryncampbell-cordova-plugin-intent": "^1.3.0",
|
||||
"cordova": "9.0.0",
|
||||
"cordova-android": "8.0.0",
|
||||
"cordova-android": "^8.1.0",
|
||||
"cordova-android-support-gradle-release": "^3.0.1",
|
||||
"cordova-clipboard": "^1.3.0",
|
||||
"cordova-ios": "5.0.1",
|
||||
"cordova-ios": "^5.1.1",
|
||||
"cordova-plugin-badge": "^0.8.8",
|
||||
"cordova-plugin-camera": "^4.1.0",
|
||||
"cordova-plugin-customurlscheme": "^4.4.0",
|
||||
"cordova-plugin-customurlscheme": "^5.0.0",
|
||||
"cordova-plugin-device": "^2.0.3",
|
||||
"cordova-plugin-file": "^6.0.2",
|
||||
"cordova-plugin-file-opener2": "^2.2.1",
|
||||
"cordova-plugin-file-opener2": "^3.0.0",
|
||||
"cordova-plugin-file-transfer": "^1.7.1",
|
||||
"cordova-plugin-geolocation": "^4.0.2",
|
||||
"cordova-plugin-globalization": "^1.11.0",
|
||||
"cordova-plugin-inappbrowser": "^3.1.0",
|
||||
"cordova-plugin-inappbrowser": "^3.2.0",
|
||||
"cordova-plugin-ionic-keyboard": "2.1.3",
|
||||
"cordova-plugin-local-notification": "git+https://github.com/moodlemobile/cordova-plugin-local-notification.git#moodle",
|
||||
"cordova-plugin-media-capture": "^3.0.3",
|
||||
|
@ -100,48 +99,48 @@
|
|||
"cordova-plugin-statusbar": "^2.4.3",
|
||||
"cordova-plugin-whitelist": "^1.3.4",
|
||||
"cordova-plugin-zip": "^3.1.0",
|
||||
"cordova-sqlite-storage": "^3.4.0",
|
||||
"cordova-support-google-services": "^1.2.1",
|
||||
"cordova-sqlite-storage": "^4.0.0",
|
||||
"cordova-support-google-services": "^1.3.2",
|
||||
"es6-promise-plugin": "^4.2.2",
|
||||
"font-awesome": "^4.7.0",
|
||||
"ionic-angular": "3.9.3",
|
||||
"ionic-angular": "3.9.9",
|
||||
"ionicons": "^3.0.0",
|
||||
"jszip": "^3.1.5",
|
||||
"jszip": "^3.2.2",
|
||||
"mathjax": "2.7.7",
|
||||
"moment": "^2.22.2",
|
||||
"moment": "^2.24.0",
|
||||
"nl.kingsquare.cordova.background-audio": "^1.0.1",
|
||||
"phonegap-plugin-multidex": "^1.0.0",
|
||||
"phonegap-plugin-push": "git+https://github.com/moodlemobile/phonegap-plugin-push.git#moodle-v3",
|
||||
"promise.prototype.finally": "^3.1.0",
|
||||
"rxjs": "^5.5.11",
|
||||
"promise.prototype.finally": "3.1.0",
|
||||
"rxjs": "^5.5.12",
|
||||
"sw-toolbox": "^3.6.0",
|
||||
"ts-md5": "^1.2.4",
|
||||
"web-animations-js": "^2.3.1",
|
||||
"zone.js": "^0.8.26"
|
||||
"ts-md5": "^1.2.7",
|
||||
"web-animations-js": "^2.3.2",
|
||||
"zone.js": "^0.8.29"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ionic/app-scripts": "3.2.2",
|
||||
"@ionic/app-scripts": "3.2.3",
|
||||
"@types/cordova": "^0.0.34",
|
||||
"@types/cordova-plugin-file-transfer": "^0.0.3",
|
||||
"@types/cordova-plugin-globalization": "^0.0.3",
|
||||
"@types/cordova-plugin-network-information": "^0.0.3",
|
||||
"@types/node": "^8.10.19",
|
||||
"@types/promise.prototype.finally": "^2.0.2",
|
||||
"@types/node": "^8.10.59",
|
||||
"@types/promise.prototype.finally": "^2.0.3",
|
||||
"electron-builder-lib": "^20.23.1",
|
||||
"electron-rebuild": "^1.8.1",
|
||||
"electron-rebuild": "^1.10.0",
|
||||
"gulp": "4.0.2",
|
||||
"gulp-clip-empty-files": "^0.1.2",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-flatten": "^0.4.0",
|
||||
"gulp-htmlmin": "^5.0.1",
|
||||
"gulp-rename": "^1.3.0",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-slash": "^1.1.3",
|
||||
"lodash.template": "^4.5.0",
|
||||
"node-loader": "^0.6.0",
|
||||
"through": "^2.3.8",
|
||||
"typescript": "^2.6.2",
|
||||
"typescript": "~2.6.2",
|
||||
"vinyl": "^2.2.0",
|
||||
"webpack-merge": "^4.1.2"
|
||||
"webpack-merge": "^4.2.2"
|
||||
},
|
||||
"browser": {
|
||||
"electron": false
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http, Response } from '@angular/http';
|
||||
import { CoreFileProvider } from '@providers/file';
|
||||
import { CoreFilepoolProvider } from '@providers/filepool';
|
||||
import { CoreLoggerProvider } from '@providers/logger';
|
||||
|
@ -25,7 +24,7 @@ import { CoreCourseProvider } from '@core/course/providers/course';
|
|||
import { CoreCourseLogHelperProvider } from '@core/course/providers/log-helper';
|
||||
import { CoreSite } from '@classes/site';
|
||||
import { CoreTagItem } from '@core/tag/providers/tag';
|
||||
import { CoreWSExternalWarning, CoreWSExternalFile } from '@providers/ws';
|
||||
import { CoreWSProvider, CoreWSExternalWarning, CoreWSExternalFile } from '@providers/ws';
|
||||
|
||||
/**
|
||||
* Service that provides some features for books.
|
||||
|
@ -37,10 +36,16 @@ export class AddonModBookProvider {
|
|||
protected ROOT_CACHE_KEY = 'mmaModBook:';
|
||||
protected logger;
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private textUtils: CoreTextUtilsProvider,
|
||||
private fileProvider: CoreFileProvider, private filepoolProvider: CoreFilepoolProvider, private http: Http,
|
||||
private utils: CoreUtilsProvider, private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider,
|
||||
private logHelper: CoreCourseLogHelperProvider) {
|
||||
constructor(logger: CoreLoggerProvider,
|
||||
protected sitesProvider: CoreSitesProvider,
|
||||
protected textUtils: CoreTextUtilsProvider,
|
||||
protected fileProvider: CoreFileProvider,
|
||||
protected filepoolProvider: CoreFilepoolProvider,
|
||||
protected wsProvider: CoreWSProvider,
|
||||
protected utils: CoreUtilsProvider,
|
||||
protected courseProvider: CoreCourseProvider,
|
||||
protected domUtils: CoreDomUtilsProvider,
|
||||
protected logHelper: CoreCourseLogHelperProvider) {
|
||||
this.logger = logger.getInstance('AddonModBookProvider');
|
||||
}
|
||||
|
||||
|
@ -128,19 +133,11 @@ export class AddonModBookProvider {
|
|||
return this.sitesProvider.getCurrentSite().checkAndFixPluginfileURL(indexUrl);
|
||||
}
|
||||
|
||||
return promise.then((url) => {
|
||||
// Fetch the URL content.
|
||||
const promise = this.http.get(url).toPromise();
|
||||
return promise.then(async (url) => {
|
||||
const content = await this.wsProvider.getText(url);
|
||||
|
||||
return promise.then((response: Response): any => {
|
||||
const content = response.text();
|
||||
if (typeof content !== 'string') {
|
||||
return Promise.reject(null);
|
||||
} else {
|
||||
// Now that we have the content, we update the SRC to point back to the external resource.
|
||||
return this.domUtils.restoreSourcesInHtml(content, contentsMap[chapterId].paths);
|
||||
}
|
||||
});
|
||||
// Now that we have the content, we update the SRC to point back to the external resource.
|
||||
return this.domUtils.restoreSourcesInHtml(content, contentsMap[chapterId].paths);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import { CoreFilepoolProvider } from '@providers/filepool';
|
|||
import { AddonModPageProvider } from './page';
|
||||
import { CoreFileProvider } from '@providers/file';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { Http, Response } from '@angular/http';
|
||||
import { CoreWSProvider } from '@providers/ws';
|
||||
|
||||
/**
|
||||
* Service that provides some features for page.
|
||||
|
@ -30,9 +30,13 @@ export class AddonModPageHelperProvider {
|
|||
|
||||
protected logger;
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private domUtils: CoreDomUtilsProvider, private filepoolProvider: CoreFilepoolProvider,
|
||||
private fileProvider: CoreFileProvider, private textUtils: CoreTextUtilsProvider, private http: Http,
|
||||
private sitesProvider: CoreSitesProvider) {
|
||||
constructor(logger: CoreLoggerProvider,
|
||||
protected domUtils: CoreDomUtilsProvider,
|
||||
protected filepoolProvider: CoreFilepoolProvider,
|
||||
protected fileProvider: CoreFileProvider,
|
||||
protected textUtils: CoreTextUtilsProvider,
|
||||
protected wsProvider: CoreWSProvider,
|
||||
protected sitesProvider: CoreSitesProvider) {
|
||||
this.logger = logger.getInstance('AddonModPageHelperProvider');
|
||||
}
|
||||
|
||||
|
@ -79,21 +83,12 @@ export class AddonModPageHelperProvider {
|
|||
promise = this.sitesProvider.getCurrentSite().checkAndFixPluginfileURL(indexUrl);
|
||||
}
|
||||
|
||||
return promise.then((url) => {
|
||||
return promise.then(async (url) => {
|
||||
const content = await this.wsProvider.getText(url);
|
||||
|
||||
// Fetch the URL content.
|
||||
const promise = this.http.get(url).toPromise();
|
||||
|
||||
return promise.then((response: Response): any => {
|
||||
const content = response.text();
|
||||
if (typeof content !== 'string') {
|
||||
return Promise.reject(null);
|
||||
}
|
||||
|
||||
// Now that we have the content, we update the SRC to point back to the external resource.
|
||||
// That will be caught by core-format-text.
|
||||
return this.domUtils.restoreSourcesInHtml(content, paths);
|
||||
});
|
||||
// Now that we have the content, we update the SRC to point back to the external resource.
|
||||
// That will be caught by core-format-text.
|
||||
return this.domUtils.restoreSourcesInHtml(content, paths);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
import { CoreWSProvider } from '@providers/ws';
|
||||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreFileProvider } from '@providers/file';
|
||||
import { CoreFilepoolProvider } from '@providers/filepool';
|
||||
|
@ -34,9 +34,13 @@ export class AddonRemoteThemesProvider {
|
|||
protected logger;
|
||||
protected stylesEls: {[siteId: string]: {element: HTMLStyleElement, hash: string}} = {};
|
||||
|
||||
constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private fileProvider: CoreFileProvider,
|
||||
private filepoolProvider: CoreFilepoolProvider, private http: Http, private utils: CoreUtilsProvider,
|
||||
private appProvider: CoreAppProvider) {
|
||||
constructor(logger: CoreLoggerProvider,
|
||||
protected sitesProvider: CoreSitesProvider,
|
||||
protected fileProvider: CoreFileProvider,
|
||||
protected filepoolProvider: CoreFilepoolProvider,
|
||||
protected wsProvider: CoreWSProvider,
|
||||
protected utils: CoreUtilsProvider,
|
||||
protected appProvider: CoreAppProvider) {
|
||||
this.logger = logger.getInstance('AddonRemoteThemesProvider');
|
||||
}
|
||||
|
||||
|
@ -174,18 +178,13 @@ export class AddonRemoteThemesProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
return promise.then((url) => {
|
||||
return promise.then(async (url) => {
|
||||
this.logger.debug('Loading styles from: ', url);
|
||||
|
||||
// Get the CSS content using HTTP because we will treat the styles before saving them in the file.
|
||||
return this.http.get(url).toPromise();
|
||||
}).then((response): any => {
|
||||
const text = response && response.text();
|
||||
if (typeof text == 'string') {
|
||||
return {fileUrl: fileUrl, styles: this.get35Styles(text)};
|
||||
} else {
|
||||
return Promise.reject(null);
|
||||
}
|
||||
const text = await this.wsProvider.getText(url);
|
||||
|
||||
return {fileUrl: fileUrl, styles: this.get35Styles(text)};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -263,23 +262,18 @@ export class AddonRemoteThemesProvider {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return this.http.get(url).toPromise().then((response) => {
|
||||
let text = response && response.text();
|
||||
if (typeof text == 'string') {
|
||||
text = this.get35Styles(text);
|
||||
return this.wsProvider.getText(url).then((text) => {
|
||||
text = this.get35Styles(text);
|
||||
|
||||
const styleEl = document.createElement('style');
|
||||
styleEl.setAttribute('id', 'mobilecssurl-tmpsite');
|
||||
styleEl.innerHTML = text;
|
||||
const styleEl = document.createElement('style');
|
||||
styleEl.setAttribute('id', 'mobilecssurl-tmpsite');
|
||||
styleEl.innerHTML = text;
|
||||
|
||||
document.head.appendChild(styleEl);
|
||||
this.stylesEls.tmpsite = {
|
||||
element: styleEl,
|
||||
hash: ''
|
||||
};
|
||||
} else {
|
||||
return Promise.reject(null);
|
||||
}
|
||||
document.head.appendChild(styleEl);
|
||||
this.stylesEls.tmpsite = {
|
||||
element: styleEl,
|
||||
hash: ''
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|||
import { NgModule, COMPILER_OPTIONS } from '@angular/core';
|
||||
import { IonicApp, IonicModule, Platform, Content, ScrollEvent, Config, Refresher } from 'ionic-angular';
|
||||
import { assert } from 'ionic-angular/util/util';
|
||||
import { HttpModule } from '@angular/http';
|
||||
import { HttpClient, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { JitCompilerFactory } from '@angular/platform-browser-dynamic';
|
||||
import { LocationStrategy } from '@angular/common';
|
||||
|
@ -202,7 +201,6 @@ export const WP_PROVIDER: any = null;
|
|||
BrowserModule,
|
||||
BrowserAnimationsModule,
|
||||
HttpClientModule, // HttpClient is used to make JSON requests. It fails for HEAD requests because there is no content.
|
||||
HttpModule,
|
||||
IonicModule.forRoot(MoodleMobileApp, {
|
||||
pageTransition: 'core-page-transition'
|
||||
}),
|
||||
|
|
|
@ -46,7 +46,6 @@ import { CoreSitePluginsProvider } from '@core/siteplugins/providers/siteplugins
|
|||
// Import other libraries and providers.
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { FormBuilder, Validators } from '@angular/forms';
|
||||
import { Http } from '@angular/http';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { CoreConfigConstants } from '../../../configconstants';
|
||||
import { CoreConstants } from '@core/constants';
|
||||
|
@ -136,7 +135,7 @@ export class CoreCompileProvider {
|
|||
|
||||
// Other Ionic/Angular providers that don't depend on where they are injected.
|
||||
protected OTHER_PROVIDERS = [
|
||||
TranslateService, Http, HttpClient, Platform, DomSanitizer, ActionSheetController, AlertController, LoadingController,
|
||||
TranslateService, HttpClient, Platform, DomSanitizer, ActionSheetController, AlertController, LoadingController,
|
||||
ModalController, PopoverController, ToastController, FormBuilder
|
||||
];
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
|
@ -33,6 +32,7 @@ import { CoreCourseProvider } from '@core/course/providers/course';
|
|||
import { CoreCoursesProvider } from '@core/courses/providers/courses';
|
||||
import { CoreFilterHelperProvider } from '@core/filter/providers/helper';
|
||||
import { CorePluginFileDelegate } from '@providers/plugin-file-delegate';
|
||||
import { CoreWSProvider } from '@providers/ws';
|
||||
|
||||
// Delegates
|
||||
import { CoreMainMenuDelegate } from '@core/mainmenu/providers/delegate';
|
||||
|
@ -93,7 +93,7 @@ export class CoreSitePluginsHelperProvider {
|
|||
private moduleDelegate: CoreCourseModuleDelegate,
|
||||
private userDelegate: CoreUserDelegate,
|
||||
private langProvider: CoreLangProvider,
|
||||
private http: Http,
|
||||
private wsProvider: CoreWSProvider,
|
||||
private sitePluginsProvider: CoreSitePluginsProvider,
|
||||
private prefetchDelegate: CoreCourseModulePrefetchDelegate,
|
||||
private compileProvider: CoreCompileProvider,
|
||||
|
@ -208,15 +208,7 @@ export class CoreSitePluginsHelperProvider {
|
|||
undefined, undefined, undefined, handlerSchema.styles.version).then((url) => {
|
||||
|
||||
// File is downloaded, get the contents.
|
||||
return this.http.get(url).toPromise();
|
||||
}).then((response): any => {
|
||||
const text = response && response.text();
|
||||
|
||||
if (typeof text == 'string') {
|
||||
return text;
|
||||
} else {
|
||||
return Promise.reject(null);
|
||||
}
|
||||
return this.wsProvider.getText(url);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpResponse } from '@angular/common/http';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { FileTransfer, FileUploadOptions } from '@ionic-native/file-transfer';
|
||||
import { CoreAppProvider } from './app';
|
||||
|
@ -92,10 +91,14 @@ export class CoreWSProvider {
|
|||
protected retryCalls = [];
|
||||
protected retryTimeout = 0;
|
||||
|
||||
constructor(private http: HttpClient, private translate: TranslateService, private appProvider: CoreAppProvider,
|
||||
private textUtils: CoreTextUtilsProvider, logger: CoreLoggerProvider,
|
||||
private fileProvider: CoreFileProvider, private fileTransfer: FileTransfer, private commonHttp: Http,
|
||||
private mimeUtils: CoreMimetypeUtilsProvider) {
|
||||
constructor(protected http: HttpClient,
|
||||
protected translate: TranslateService,
|
||||
protected appProvider: CoreAppProvider,
|
||||
protected textUtils: CoreTextUtilsProvider,
|
||||
protected fileProvider: CoreFileProvider,
|
||||
protected fileTransfer: FileTransfer,
|
||||
protected mimeUtils: CoreMimetypeUtilsProvider,
|
||||
logger: CoreLoggerProvider) {
|
||||
this.logger = logger.getInstance('CoreWSProvider');
|
||||
}
|
||||
|
||||
|
@ -499,11 +502,11 @@ export class CoreWSProvider {
|
|||
* @param url URL to perform the request.
|
||||
* @return Promise resolved with the response.
|
||||
*/
|
||||
performHead(url: string): Promise<any> {
|
||||
performHead(url: string): Promise<HttpResponse<any>> {
|
||||
let promise = this.getPromiseHttp('head', url);
|
||||
|
||||
if (!promise) {
|
||||
promise = this.commonHttp.head(url).timeout(this.getRequestTimeout()).toPromise();
|
||||
promise = this.http.head(url, {observe: 'response'}).timeout(this.getRequestTimeout()).toPromise();
|
||||
promise = this.setPromiseHttp(promise, 'head', url);
|
||||
}
|
||||
|
||||
|
@ -828,6 +831,22 @@ export class CoreWSProvider {
|
|||
return Promise.reject(this.translate.instant('core.errorinvalidresponse'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an HTTP request requesting for a text response.
|
||||
*
|
||||
* @param url Url to get.
|
||||
* @return Resolved with the text when done.
|
||||
*/
|
||||
async getText(url: string): Promise<string> {
|
||||
// Fetch the URL content.
|
||||
const content = await this.http.get(url, { responseType: 'text' }).toPromise();
|
||||
if (typeof content !== 'string') {
|
||||
return Promise.reject(null);
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue