Filecopy added, Sqlite Database neues Schema
This commit is contained in:
parent
248ab8cb2a
commit
246d279c27
@ -1,6 +1,6 @@
|
|||||||
angular.module('starter.controllers', [])
|
angular.module('starter.controllers', [])
|
||||||
|
|
||||||
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer) {
|
.controller('DashCtrl', function($scope,$ionicPopup,$http, $database, $timeout,$rootScope, $cordovaFileTransfer,$cordovaFile) {
|
||||||
|
|
||||||
$scope.preis="";
|
$scope.preis="";
|
||||||
$scope.name="";
|
$scope.name="";
|
||||||
@ -8,9 +8,6 @@ angular.module('starter.controllers', [])
|
|||||||
$scope.items=[];
|
$scope.items=[];
|
||||||
$scope.item=[];
|
$scope.item=[];
|
||||||
|
|
||||||
//db = Database.getDb();
|
|
||||||
|
|
||||||
//$scope.items=$localstorage.getObject('items');
|
|
||||||
|
|
||||||
$scope.validate = function() {
|
$scope.validate = function() {
|
||||||
|
|
||||||
@ -52,28 +49,11 @@ angular.module('starter.controllers', [])
|
|||||||
};
|
};
|
||||||
|
|
||||||
function successBuyHandler (result) {
|
function successBuyHandler (result) {
|
||||||
/*
|
|
||||||
var strResult = "";
|
|
||||||
if(typeof result === 'object') {
|
|
||||||
strResult = JSON.stringify(result);
|
|
||||||
} else {
|
|
||||||
strResult = result;
|
|
||||||
}
|
|
||||||
alert("SUCCESS: \r\n"+strResult );
|
|
||||||
*/
|
|
||||||
$timeout(consumesuccessHandler, 1000);
|
$timeout(consumesuccessHandler, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function successConsumeHandler (result) {
|
function successConsumeHandler (result) {
|
||||||
/*
|
|
||||||
var strResult = "";
|
|
||||||
if(typeof result === 'object') {
|
|
||||||
strResult = JSON.stringify(result);
|
|
||||||
} else {
|
|
||||||
strResult = result;
|
|
||||||
}
|
|
||||||
alert("SUCCESS: \r\n"+strResult );
|
|
||||||
*/
|
|
||||||
var link = 'http://api.raataar.de/rosen/kauf.php';
|
var link = 'http://api.raataar.de/rosen/kauf.php';
|
||||||
|
|
||||||
$http.post(link, {name : $scope.name, freitext: $scope.freitext, rosen: $scope.preis}).then(function (res){
|
$http.post(link, {name : $scope.name, freitext: $scope.freitext, rosen: $scope.preis}).then(function (res){
|
||||||
@ -82,25 +62,43 @@ angular.module('starter.controllers', [])
|
|||||||
// File for download
|
// File for download
|
||||||
var url = "http://api.raataar.de/rosen/" + $scope.filetodownload;
|
var url = "http://api.raataar.de/rosen/" + $scope.filetodownload;
|
||||||
|
|
||||||
alert(url);
|
|
||||||
// File name only
|
// File name only
|
||||||
var filename = url.split("/").pop();
|
var filename = url.split("/").pop();
|
||||||
|
|
||||||
alert(filename);
|
|
||||||
// Save location
|
// Save location
|
||||||
//var targetPath = cordova.file.externalRootDirectory + filename;
|
//var targetPath = cordova.file.externalRootDirectory + filename;
|
||||||
var targetPath = cordova.file.applicationStorageDirectory + filename;
|
var targetPath = cordova.file.applicationStorageDirectory + filename;
|
||||||
|
var targetpublicPath = $scope.filename, cordova.file.externalRootDirectory + "/WolleRosenKaufen/" + filename;
|
||||||
|
|
||||||
alert(targetPath);
|
|
||||||
$scope.targetPath='';
|
$scope.targetPath='';
|
||||||
$scope.targetPath=targetPath;
|
$scope.targetPath=targetPath;
|
||||||
|
$scope.targetpublicPath=targetpublicPath;
|
||||||
|
|
||||||
|
$scope.filename=filename;
|
||||||
|
|
||||||
$cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result) {
|
$cordovaFileTransfer.download(url, targetPath, {}, true).then(function (result) {
|
||||||
|
|
||||||
$scope.item={name: $scope.name, bild: $scope.targetPath};
|
$scope.item={name: $scope.name, bild: $scope.targetpublicPath};
|
||||||
$scope.items.push($scope.item);
|
$scope.items.push($scope.item);
|
||||||
|
|
||||||
alert ($scope.targetPath);
|
//itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath
|
||||||
$database.setBuys($scope.name,$scope.targetPath);
|
$database.setBuys($scope.name,$scope.filename,$scope.freitext,'','','');
|
||||||
|
//Ordner erstellen auf SD-Karte
|
||||||
|
$cordovaFile.createDir(cordova.file.externalRootDirectory, "WolleRosenKaufen", false)
|
||||||
|
.then(function (success) {
|
||||||
|
// success
|
||||||
|
}, function (error) {
|
||||||
|
// error
|
||||||
|
});
|
||||||
|
|
||||||
|
$cordovaFile.copyFile(cordova.file.applicationStorageDirectory, $scope.filename, cordova.file.externalRootDirectory + "/WolleRosenKaufen", $scope.filename)
|
||||||
|
.then(function (success) {
|
||||||
|
// success
|
||||||
|
}, function (error) {
|
||||||
|
// error
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
console.log('Error');
|
console.log('Error');
|
||||||
@ -116,6 +114,17 @@ angular.module('starter.controllers', [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
function errorBuyHandler (error) {
|
function errorBuyHandler (error) {
|
||||||
|
/*
|
||||||
|
var strResult = "";
|
||||||
|
if(typeof error === 'object') {
|
||||||
|
strResult = JSON.stringify(error);
|
||||||
|
} else {
|
||||||
|
strResult = error;
|
||||||
|
}
|
||||||
|
alert("Feher: \r\n"+strResult );
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
var alertPopup = $ionicPopup.alert({
|
var alertPopup = $ionicPopup.alert({
|
||||||
title: 'Oh Nein',
|
title: 'Oh Nein',
|
||||||
template: 'Der Kauf konnte nicht durchgeführt werden.'
|
template: 'Der Kauf konnte nicht durchgeführt werden.'
|
||||||
@ -149,7 +158,9 @@ angular.module('starter.controllers', [])
|
|||||||
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
|
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
|
||||||
|
|
||||||
if ($rootScope.storeinit==1){
|
if ($rootScope.storeinit==1){
|
||||||
inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
|
//Wegenbug ausgehebelt
|
||||||
|
//inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
|
||||||
|
successConsumeHandler();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
var alertPopup = $ionicPopup.alert({
|
var alertPopup = $ionicPopup.alert({
|
||||||
|
|||||||
@ -61,9 +61,9 @@ angular.module('starter.services', [])
|
|||||||
console.log('Database opened');
|
console.log('Database opened');
|
||||||
return self.db;
|
return self.db;
|
||||||
},
|
},
|
||||||
setBuys: function(itemName,itemBild) {
|
setBuys: function(itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath) {
|
||||||
query="INSERT INTO buys (Name, Bild) VALUES (?,?);";
|
query="INSERT INTO buys (Name, Bild, Bildtext, Kaufdatum, appimgpath, appimgpublicpath) VALUES (?,?,?,?,?,?);";
|
||||||
return $cordovaSQLite.execute(self.db,query,[itemName,itemBild]).
|
return $cordovaSQLite.execute(self.db,query,[itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath]).
|
||||||
then(function(result) {
|
then(function(result) {
|
||||||
console.log("Gespeichert");
|
console.log("Gespeichert");
|
||||||
query=null;
|
query=null;
|
||||||
@ -81,6 +81,10 @@ angular.module('starter.services', [])
|
|||||||
//console.log(result.rows.item(j));
|
//console.log(result.rows.item(j));
|
||||||
List.name=result.rows.item(j).Name;
|
List.name=result.rows.item(j).Name;
|
||||||
List.bild=result.rows.item(j).Bild;
|
List.bild=result.rows.item(j).Bild;
|
||||||
|
List.bildtext=result.rows.item(j).Bildtext;
|
||||||
|
List.kaufdatum=result.rows.item(j).Kaufdatum;
|
||||||
|
List.appimgpath=result.rows.item(j).appimgpath;
|
||||||
|
List.appimgpublicpath=result.rows.item(j).appimgpublicpath;
|
||||||
ArrayQ.push(List);
|
ArrayQ.push(List);
|
||||||
}
|
}
|
||||||
//console.log(ArrayQ);
|
//console.log(ArrayQ);
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user