Commit 2cc55962 authored by laurent l's avatar laurent l

Upgrade nativescript

parent ae122e44
......@@ -25,4 +25,18 @@ configurations.all {
}
}
}
}
\ No newline at end of file
}
def settingsGradlePath
if(project.hasProperty("appResourcesPath")){
settingsGradlePath = "$project.appResourcesPath/Android/settings.gradle";
} else {
settingsGradlePath = "$rootDir/../../app/App_Resources/Android/settings.gradle";
}
def settingsGradleFile = new File(settingsGradlePath);
if(settingsGradleFile.exists())
{
apply from: settingsGradleFile;
}
import groovy.json.JsonSlurper
task replaceSettings {
description "Replaces configuration settings."
def jsonSlurper = new JsonSlurper()
def pathToSettingsJson
if (project.hasProperty("appResourcesPath")) {
pathToSettingsJson = "$project.appResourcesPath/Android/settings.json";
} else {
pathToSettingsJson = "$rootDir/../../app/App_Resources/Android/settings.json";
}
def settingsJsonFile = file(pathToSettingsJson);
def settingsResolvedPath = settingsJsonFile.getAbsolutePath();
if(settingsJsonFile.exists())
{
println "\t Applying settings from $settingsResolvedPath"
String settingsGradleTemplate = """android {
defaultConfig {
applicationId = "__appId__"
if (__minSdkVersion__) {
minSdkVersion = __minSdkVersion__
}
if (__targetSdkVersion__) {
targetSdkVersion = __targetSdkVersion__
}
}
}"""
def settingsJsonContent = settingsJsonFile.getText("UTF-8");
def settingsMap = jsonSlurper.parseText(settingsJsonContent);
for ( setting in settingsMap ) {
def placeholder = "__${setting.key}__";
def settingValue = setting.value;
if (settingValue == null) {
settingValue = false
}
settingsGradleTemplate = settingsGradleTemplate.replaceAll( placeholder, settingValue as String);
}
new File( "$rootDir/temp_setting.gradle" ).write( settingsGradleTemplate, 'UTF-8');
apply from: "$rootDir/temp_setting.gradle";
}
}
{"appId":"fr.afi_sa.MyBibApp","minSdkVersion":null,"targetSdkVersion":null}
......@@ -19,9 +19,11 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<string>1.0.1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>Need to access camera to scan barcode of books, CD, DVD, ... that you want to search for, or scan your library card to autofill your identifier when you create an account</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiresFullScreen</key>
......@@ -49,4 +51,4 @@
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
\ No newline at end of file
</plist>
// You can add custom settings here
// for example you can uncomment the following line to force distribution code signing
// CODE_SIGN_IDENTITY = iPhone Distribution
CODE_SIGN_IDENTITY = Arnaud Lelache
// To build for device with XCode 8 you need to specify your development team. More info: https://developer.apple.com/library/prerelease/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html
// DEVELOPMENT_TEAM = YOUR_TEAM_ID;
DEVELOPMENT_TEAM = 7C2P69LB62;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
......@@ -6,7 +6,7 @@ import { Database, Manager, NSHTTPClient, BackgroundJobs } from './models';
import * as config from "./config/config";
import { AccountsController } from './controllers/accounts';
import * as Frames from 'ui/frame';
import * as Frames from 'tns-core-modules/ui/frame';
function myReloadPage() {
let frame: any = Frames.topmost();
if (frame && frame._currentEntry) {
......
import { ObservableArray } from 'data/observable-array'
import { Observable } from 'data/observable'
import { Page } from 'ui/page'
import { ObservableArray } from 'tns-core-modules/data/observable-array'
import { Observable } from 'tns-core-modules/data/observable'
import { Page } from 'tns-core-modules/ui/page'
import { Controller } from './controller'
import { LibraryController } from './library'
import { MyBibAppController } from './mybibapp'
......
import { Observable } from 'data/observable';
import * as Frames from 'ui/frame';
import * as dialogs from 'ui/dialogs';
import { Label } from 'ui/label';
import { Observable } from 'tns-core-modules/data/observable';
import * as Frames from 'tns-core-modules/ui/frame';
import * as dialogs from 'tns-core-modules/ui/dialogs';
import { Label } from 'tns-core-modules/ui/label';
import * as Utils from "tns-core-modules/utils/utils"
let validator = require('validator');
......
import { ObservableArray } from 'data/observable-array';
import { ObservableArray } from 'tns-core-modules/data/observable-array';
import { Controller } from './controller';
import { BarcodeScanner } from 'nativescript-barcodescanner';
import { AccountsController } from '../controllers/accounts';
......@@ -20,10 +20,9 @@ import {
} from '../models/';
import { RadSideDrawer } from 'nativescript-ui-sidedrawer';
import { WebView } from 'ui/web-view';
import { WebView } from 'tns-core-modules/ui/web-view';
import { OAuthWebViewClient } from './utils/oauth-webview-client';
import { MbaWebView } from './utils/mba-web-view';
import * as LocalNotifications from "nativescript-local-notifications";
import * as imageSource from "tns-core-modules/image-source";
export class LibraryController extends Controller {
......@@ -68,16 +67,6 @@ export class LibraryController extends Controller {
}
public sendNotification(message: string) {
LocalNotifications.requestPermission();
LocalNotifications.schedule([{
body: message,
smallIcon: 'res://presence_online'
}]);
}
public goHomeAction() {
this.navigate({
moduleName: "views/accounts/list-page",
......
import { WebView } from 'ui/web-view'
import { WebView } from 'tns-core-modules/ui/web-view'
export class MbaWebView extends WebView {
......
import { WebView } from 'ui/web-view'
import { WebView } from 'tns-core-modules/ui/web-view'
import { Cookies } from '../../models/';
export class MbaWebView extends WebView {
......
import { Account, Cookies } from '../../models';
import { WebView } from 'ui/web-view';
import { WebView } from 'tns-core-modules/ui/web-view';
export class OAuthWebViewClient {
protected static _onTokenSet: any;
......
import { Account } from '../../models';
import { WebView } from 'ui/web-view';
import { WebView } from 'tns-core-modules/ui/web-view';
export declare class OAuthWebViewClient {
public static newWithWebView(webview: WebView): OAuthWebViewClient;
......
import { Account, Cookies } from '../../models';
import { WebView } from 'ui/web-view';
import { WebView } from 'tns-core-modules/ui/web-view';
var NSWKNavigationDelegate = (NSObject as any).extend(
......
import {ObservableArray} from 'data/observable-array';
import {Account} from './account';
import { ObservableArray } from 'tns-core-modules/data/observable-array';
import { Account } from './account';
export class Accounts extends ObservableArray<Account> {
}
import * as Application from 'application'
import { WebView } from 'ui/web-view'
import * as Application from 'tns-core-modules/application'
import { WebView } from 'tns-core-modules/ui/web-view'
declare var android: any
declare var java: any
......
import { WebView } from 'ui/web-view'
import { WebView } from 'tns-core-modules/ui/web-view'
export class Cookies {
public syncHttpToWebView(webview: WebView): Promise<any> {
......
import {HTTPClient} from './http-client';
import * as http from 'http';
import { HTTPClient } from './http-client';
export class NullHTTPClient implements HTTPClient {
public request(options: any): Promise<any> {
return new Promise((resolve, reject) => {
resolve({ content: { toString: () => {return '';} }});
});
}
public request(options: any): Promise<any> {
return new Promise((resolve, reject) => {
resolve({ content: { toString: () => { return ''; } } });
});
}
}
import {Account, Portal, Record} from '../models/';
import { ObservableArray } from 'data/observable-array';
import { Account, Portal, Record } from '../models/';
import { ObservableArray } from 'tns-core-modules/data/observable-array';
export class Novelties extends ObservableArray<Record> {
protected _page: number = 1;
......@@ -14,14 +14,14 @@ export class Novelties extends ObservableArray<Record> {
this._account = account;
}
public loadNext(): Promise<any> {
if (this._done)
return Promise.resolve(new Array());
return this._portal
.fetchNovelties(this._account, this._page)
.then( (records) => {
.then((records) => {
this._page = this._page + 1;
this._done = (records.length == 0);
this.push(records);
......
import {Observable} from 'data/observable';
import { Observable } from 'tns-core-modules/data/observable';
export abstract class Persistable extends Observable {
protected _id: string;
protected _id: string;
constructor(id?:string) {
super();
this._id = id;
}
constructor(id?: string) {
super();
this._id = id;
}
public getId() {
return this._id;
}
public getId() {
return this._id;
}
public setId(id:string) {
this._id = id;
return this;
}
public setId(id: string) {
this._id = id;
return this;
}
public deleteChilds(datasource: DataSource): Persistable {
return this;
}
public deleteChilds(datasource: DataSource): Persistable {
return this;
}
public beforeSave(datasource: DataSource) {
}
public afterSave(datasource: DataSource) {
}
......@@ -37,23 +37,23 @@ export abstract class Persistable extends Observable {
return true;
}
public abstract serializeOn(serializable: Serializable);
public abstract materializeFrom(serializable: Serializable);
public abstract serializeOn(serializable: Serializable);
public abstract materializeFrom(serializable: Serializable);
}
export interface Serializable {
set(name, value): Serializable;
get(name, modelClass?:any): any;
serialize(): Object;
set(name, value): Serializable;
get(name, modelClass?: any): any;
serialize(): Object;
}
export interface DataSource {
delete(model: Persistable): DataSource;
delete(model: Persistable): DataSource;
save(model: Persistable): DataSource;
findAll(modelClass: any): any ;
findAll(modelClass: any): any;
}
import * as http from 'http';
import {Koha} from './koha';
import {WrongLoginPassword} from './wrong-login-password';
import {Account} from '../../models';
import { Koha } from './koha';
import { WrongLoginPassword } from './wrong-login-password';
import { Account } from '../../models';
import * as cheerio from 'cheerio';
export class KohaCas extends Koha {
public getIdentifier(): string {
public getIdentifier(): string {
return 'koha-cas';
}
......@@ -23,20 +22,20 @@ export class KohaCas extends Koha {
protected _signIn(account): Promise<any> {
if (!(account.credentials['login'] && account.credentials['password']))
return Promise.reject(new WrongLoginPassword());
account.setCookies([])
return this
.request(account,
{ url: account.getUrl() })
.then( (response) => {
{ url: account.getUrl() })
.then((response) => {
let $ = cheerio.load(response.content.toString());
let cas_link = $('a[href*="/cas/login?service="]').attr('href');
return cas_link;
})
.then( (cas_link) => {
.then((cas_link) => {
return this
.request(account, { url: cas_link })
.then( (response) => {
.then((response) => {
let $ = cheerio.load(response.content.toString());
let form_inputs = this._extractForm($);
let form_data = {
......@@ -50,20 +49,22 @@ export class KohaCas extends Koha {
return this
.request(account,
{ url: cas_link,
method: "POST",
content: this._encodeForm(form_data),
headers: {"Content-Type": "application/x-www-form-urlencoded"} });
{
url: cas_link,
method: "POST",
content: this._encodeForm(form_data),
headers: { "Content-Type": "application/x-www-form-urlencoded" }
});
})
})
.then( (response) => {
.then((response) => {
let $ = cheerio.load(response.content.toString());
let cas_link = $('a[href*="/cas/login?service="]').attr('href');
return cas_link
? this.request(account, { url: cas_link })
: response;
}).then( (response) => {
}).then((response) => {
return this._handleSignIn(account, response);
});
}
......@@ -72,7 +73,7 @@ export class KohaCas extends Koha {
protected _extractForm($): any {
let form_data = [];
$('form input')
.filter( (i, elem) => { return $(elem).attr('name') != undefined; } )
.filter((i, elem) => { return $(elem).attr('name') != undefined; })
.each((i, elem) => {
let input = $(elem)
form_data[input.attr('name')] = input.attr('value') || ''
......
declare var describe, expect, it, before, chai: any;
import {AccountsController} from '../controllers/accounts';
import {Account, Database, Manager, NullHTTPClient} from '../models/';
import {StubFrames} from './stub-frames';
import {StubDialogs} from './stub-dialogs';
import {Observable} from 'data/observable';
import { AccountsController } from '../controllers/accounts';
import { Account, Database, Manager, NullHTTPClient } from '../models/';
import { StubFrames } from './stub-frames';
import { StubDialogs } from './stub-dialogs';
import { Observable } from 'tns-core-modules/data/observable';
describe('AccountsController with one account in database', () => {
let db: Database;
......@@ -13,14 +13,16 @@ describe('AccountsController with one account in database', () => {
let account_form: Observable;
let manager: Manager;
before( () => {
before(() => {
bibliofil = (new Account())
.setLabel('Bibliofil')
.setUrl('http://mylib.fr')
.setCredentials({login: "david",
password: "guetta",
portal: "orpheemedia"});
.setCredentials({
login: "david",
password: "guetta",
portal: "orpheemedia"
});
db = Database.open('testdb').clear();
db.save(bibliofil);
......@@ -35,8 +37,10 @@ describe('AccountsController with one account in database', () => {
it('on edit account should navigate to accounts/edit', () => {
expect(navigate_spy).to.have.been.called.with({moduleName: 'views/accounts/edit',
bindingContext: accounts_controller});
expect(navigate_spy).to.have.been.called.with({
moduleName: 'views/accounts/edit',
bindingContext: accounts_controller
});
});
......@@ -70,10 +74,12 @@ describe('AccountsController with one account in database', () => {
let confirm_spy = chai.spy.on(accounts_controller.dialogs, 'confirm');
accounts_controller.deleteAccountAction();
expect(confirm_spy).to.have.been.called.with({title: L('confirm'),
message: L('sure_to_delete'),
okButtonText: L('OK'),
cancelButtonText: L('cancel')});
expect(confirm_spy).to.have.been.called.with({
title: L('confirm'),
message: L('sure_to_delete'),
okButtonText: L('OK'),
cancelButtonText: L('cancel')
});
expect(db.findAll(Account)).to.be.empty;
})
});
require("application");
if (!global["__snapshot"]) {
/*
In case snapshot generation is enabled these modules will get into the bundle but will not be required/evaluated.
The snapshot webpack plugin will add them to the tns-java-classes.js bundle file. This way, they will be evaluated on app start as early as possible.
*/
require("ui/frame");
require("ui/frame/activity");
}
require("application");
require("tns-core-modules/application");
if (!global["__snapshot"]) {
/*
In case snapshot generation is enabled these modules will get into the bundle but will not be required/evaluated.
The snapshot webpack plugin will add them to the tns-java-classes.js bundle file. This way, they will be evaluated on app start as early as possible.
*/
require("ui/frame");
require("ui/frame/activity");
/*
In case snapshot generation is enabled these modules will get into the bundle but will not be required/evaluated.
The snapshot webpack plugin will add them to the tns-java-classes.js bundle file. This way, they will be evaluated on app start as early as possible.
*/
require("tns-core-modules/ui/frame");
require("tns-core-modules/ui/frame/activity");
}
require("./vendor-platform");
require("bundle-entry-points");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVuZG9yLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsidmVuZG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sQ0FBQyxtQkFBbUIsQ0FBQyxDQUFDO0FBRTdCLE9BQU8sQ0FBQyxxQkFBcUIsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsicmVxdWlyZShcIi4vdmVuZG9yLXBsYXRmb3JtXCIpO1xuXG5yZXF1aXJlKFwiYnVuZGxlLWVudHJ5LXBvaW50c1wiKTtcbiJdfQ==
\ No newline at end of file
module.exports = require("nativescript-dev-typescript/lib/before-watchPatterns.js");
......@@ -6,13 +6,13 @@
"nativescript": {
"id": {
"android": "fr.afi_sa.MyBibApp",
"ios": "fr.afisa.MyBibApp"
"ios": "fr.afi.MyBibApp"
},
"tns-android": {
"version": "5.2.1"
"version": "5.3.1"
},
"tns-ios": {
"version": "5.2.0"
"version": "5.3.1"
}
},
"dependencies": {
......@@ -26,7 +26,6 @@
"nativescript-couchbase": "git+https://github.com/Afibre/nativescript-couchbase.git",
"nativescript-i18n": "^0.2.4",
"nativescript-intl": "^3.0.0",
"nativescript-local-notifications": "^2.0.0",
"nativescript-swiss-army-knife": "^3.1.1",
"nativescript-theme-core": "^1.0.4",
"nativescript-ui-autocomplete": "^3.5.0",
......@@ -41,7 +40,6 @@
"url-parse": "^1.4.4",
"util": "^0.10.0",
"validator": "^7.0.0",
"webpack": "^4.29.6",
"xml-js": "^1.6.7"
},
"devDependencies": {
......@@ -63,7 +61,8 @@
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.1.0",
"sass-loader": "^7.1.0",
"typescript": "^3.3.4000"
"typescript": "^3.3.4000",
"webpack": "^4.29.6"
},
"nativescript-i18n": {
"defaultLang": "en"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment