Schriftart gekaufte Rosen

This commit is contained in:
Akki 2016-01-28 23:35:10 +01:00
parent 4db1623408
commit 6dbbc77c30
16 changed files with 102 additions and 74 deletions

View File

@ -1,6 +1,6 @@
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.name="";
@ -8,9 +8,6 @@ angular.module('starter.controllers', [])
$scope.items=[];
$scope.item=[];
//db = Database.getDb();
//$scope.items=$localstorage.getObject('items');
$scope.validate = function() {
@ -52,28 +49,11 @@ angular.module('starter.controllers', [])
};
function successBuyHandler (result) {
/*
var strResult = "";
if(typeof result === 'object') {
strResult = JSON.stringify(result);
} else {
strResult = result;
}
alert("SUCCESS: \r\n"+strResult );
*/
$timeout(consumesuccessHandler, 1000);
}
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';
$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
var url = "http://api.raataar.de/rosen/" + $scope.filetodownload;
alert(url);
// File name only
var filename = url.split("/").pop();
alert(filename);
// Save location
//var targetPath = cordova.file.externalRootDirectory + filename;
var targetPath = cordova.file.applicationStorageDirectory + filename;
var targetpublicPath = cordova.file.externalRootDirectory + "/WolleRosenKaufen/" + filename;
alert(targetPath);
$scope.targetPath='';
$scope.targetPath=targetPath;
$scope.targetpublicPath=targetpublicPath;
$scope.filename=filename;
$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);
alert ($scope.targetPath);
$database.setBuys($scope.name,$scope.targetPath);
//itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath
$database.setBuys($scope.name,$scope.filename,$scope.freitext,'','', $scope.targetpublicPath);
//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) {
console.log('Error');
@ -116,6 +114,17 @@ angular.module('starter.controllers', [])
}
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({
title: 'Oh Nein',
template: 'Der Kauf konnte nicht durchgeführt werden.'
@ -144,12 +153,13 @@ angular.module('starter.controllers', [])
$scope.buyRose = function() {
//alert($scope.preis);
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
if ($rootScope.storeinit==1){
inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
//Wegenbug ausgehebelt
//inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
successConsumeHandler();
}
else{
var alertPopup = $ionicPopup.alert({

View File

@ -61,9 +61,9 @@ angular.module('starter.services', [])
console.log('Database opened');
return self.db;
},
setBuys: function(itemName,itemBild) {
query="INSERT INTO buys (Name, Bild) VALUES (?,?);";
return $cordovaSQLite.execute(self.db,query,[itemName,itemBild]).
setBuys: function(itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath) {
query="INSERT INTO buys (Name, Bild, Bildtext, Kaufdatum, appimgpath, appimgpublicpath) VALUES (?,?,?,?,?,?);";
return $cordovaSQLite.execute(self.db,query,[itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath]).
then(function(result) {
console.log("Gespeichert");
query=null;
@ -81,6 +81,10 @@ angular.module('starter.services', [])
//console.log(result.rows.item(j));
List.name=result.rows.item(j).Name;
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);
}
//console.log(ArrayQ);

View File

@ -9,12 +9,12 @@
<ion-card ng-repeat="i in items" ng-model="items">
<div class="list card">
<div class="item item-avatar"> <img src="img/rose1.png">
<h2>{{i.name}}</h2>
<div class="item item-avatar"> <img ng-src="{{i.appimgpublicpath}}">
<h2> <div class="oleo">{{i.name}}</div> </h2>
</div>
<div class="item item-body">
{{i.freitext}}
<div class="oleo-vsmall">{{i.bildtext}}</div>
</div>
<ion-item>

View File

@ -1,6 +1,6 @@
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.name="";
@ -8,9 +8,6 @@ angular.module('starter.controllers', [])
$scope.items=[];
$scope.item=[];
//db = Database.getDb();
//$scope.items=$localstorage.getObject('items');
$scope.validate = function() {
@ -52,28 +49,11 @@ angular.module('starter.controllers', [])
};
function successBuyHandler (result) {
/*
var strResult = "";
if(typeof result === 'object') {
strResult = JSON.stringify(result);
} else {
strResult = result;
}
alert("SUCCESS: \r\n"+strResult );
*/
$timeout(consumesuccessHandler, 1000);
}
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';
$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
var url = "http://api.raataar.de/rosen/" + $scope.filetodownload;
alert(url);
// File name only
var filename = url.split("/").pop();
alert(filename);
// Save location
//var targetPath = cordova.file.externalRootDirectory + filename;
var targetPath = cordova.file.applicationStorageDirectory + filename;
var targetpublicPath = cordova.file.externalRootDirectory + "/WolleRosenKaufen/" + filename;
alert(targetPath);
$scope.targetPath='';
$scope.targetPath=targetPath;
$scope.targetpublicPath=targetpublicPath;
$scope.filename=filename;
$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);
alert ($scope.targetPath);
$database.setBuys($scope.name,$scope.targetPath);
//itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath
$database.setBuys($scope.name,$scope.filename,$scope.freitext,'','', $scope.targetpublicPath);
//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) {
console.log('Error');
@ -116,6 +114,17 @@ angular.module('starter.controllers', [])
}
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({
title: 'Oh Nein',
template: 'Der Kauf konnte nicht durchgeführt werden.'
@ -144,12 +153,13 @@ angular.module('starter.controllers', [])
$scope.buyRose = function() {
//alert($scope.preis);
if((window.device && device.platform == "Android") && typeof inappbilling !== "undefined") {
if ($rootScope.storeinit==1){
inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
//Wegenbug ausgehebelt
//inappbilling.buy(successBuyHandler, errorBuyHandler, $scope.preis);
successConsumeHandler();
}
else{
var alertPopup = $ionicPopup.alert({

View File

@ -61,9 +61,9 @@ angular.module('starter.services', [])
console.log('Database opened');
return self.db;
},
setBuys: function(itemName,itemBild) {
query="INSERT INTO buys (Name, Bild) VALUES (?,?);";
return $cordovaSQLite.execute(self.db,query,[itemName,itemBild]).
setBuys: function(itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath) {
query="INSERT INTO buys (Name, Bild, Bildtext, Kaufdatum, appimgpath, appimgpublicpath) VALUES (?,?,?,?,?,?);";
return $cordovaSQLite.execute(self.db,query,[itemName,itemBild,itemBildtext,itemKaufdatum,itemappimgpath,itemappimgpublicpath]).
then(function(result) {
console.log("Gespeichert");
query=null;
@ -81,6 +81,10 @@ angular.module('starter.services', [])
//console.log(result.rows.item(j));
List.name=result.rows.item(j).Name;
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);
}
//console.log(ArrayQ);

View File

@ -9,12 +9,12 @@
<ion-card ng-repeat="i in items" ng-model="items">
<div class="list card">
<div class="item item-avatar"> <img src="img/rose1.png">
<h2>{{i.name}}</h2>
<div class="item item-avatar"> <img ng-src="{{i.appimgpublicpath}}">
<h2> <div class="oleo">{{i.name}}</div> </h2>
</div>
<div class="item item-body">
{{i.freitext}}
<div class="oleo-vsmall">{{i.bildtext}}</div>
</div>
<ion-item>

View File

@ -10,11 +10,11 @@
<div class="list card">
<div class="item item-avatar"> <img ng-src="{{i.appimgpublicpath}}">
<h2>{{i.name}}</h2>
<h2> <div class="oleo">{{i.name}}</div> </h2>
</div>
<div class="item item-body">
{{i.bildtext}}
<div class="oleo-vsmall">{{i.bildtext}}</div>
</div>
<ion-item>