Advertisement
ahmadtri26

ts tsan

Nov 28th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import { NavController, NavParams,ViewController } from 'ionic-angular';
  3. import { MyApp } from '../../app/app.component';
  4. import { AddShowcaseSalesPage } from '../add-showcase-sales/add-showcase-sales';
  5. import { EditShowcaseSalesPage } from '../edit-showcase-sales/edit-showcase-sales';
  6.  
  7. import { HttpService } from '../../providers/http-service';
  8. import { Session } from '../../providers/session';
  9.  
  10. /**
  11. * Generated class for the ShopShowcaseSalesPage page.
  12. *
  13. * See https://ionicframework.com/docs/components/#navigation for more info on
  14. * Ionic pages and navigation.
  15. */
  16.  
  17. @Component({
  18. selector: 'page-shop-showcase-sales',
  19. templateUrl: 'shop-showcase-sales.html',
  20. })
  21. export class ShopShowcaseSalesPage {
  22.  
  23. public searchbarShow: boolean = false;
  24. public data;
  25. public static TAG = "Shop ShowCase";
  26.  
  27.  
  28. public dataList;
  29. public isDataLoad: boolean = false;
  30. public dataListReady: boolean = false;
  31.  
  32.  
  33. constructor(
  34. public navCtrl: NavController,
  35. public navParams: NavParams,
  36. public http: HttpService,
  37. public session: Session,
  38. public viewCtrl: ViewController)
  39. {
  40. try{
  41. this.data = {};
  42. }catch(error) {
  43. MyApp.consoleLog("some error happen", error)
  44. }
  45. }
  46.  
  47. ionViewDidLoad() {
  48. console.log('ionViewDidLoad ShopShowcaseSalesPage');
  49. }
  50.  
  51. Search(){
  52. this.searchbarShow = true;
  53. }
  54.  
  55. hideSearchbar(){
  56. this.searchbarShow = false;
  57. }
  58.  
  59. back(event: Event) {
  60. this.navCtrl.pop();
  61. }
  62.  
  63. navigateToAddShowcase(){
  64. this.navCtrl.push(AddShowcaseSalesPage);
  65. }
  66.  
  67. ionViewDidEnter(){
  68. try{
  69. this.loadShowcase();
  70. }catch(error) {
  71. MyApp.consoleLog("Some Error Happen", error);
  72. }
  73. }
  74.  
  75. loadShowcase(){
  76. let link = "http://localhost/phpscring/shop_showcase_sales/load_showcase";
  77. let user;
  78. user = {};
  79. user.id = this.session.getUserID();
  80. let postParams = {
  81. "link": link,
  82. "data": user
  83. }
  84.  
  85. this.http.postService(postParams).then((data)=> {
  86. let response;
  87. response ={};
  88. response.data = data;
  89. MyApp.consoleLog(ShopShowcaseSalesPage.TAG, "data", data);
  90. MyApp.consoleLog(ShopShowcaseSalesPage.TAG, "response", response);
  91.  
  92. if(this.isDataLoad == true) {
  93. this.dataListReady =false;
  94. this.buildData(response);
  95. }else{
  96. this.isDataLoad = true;
  97. this.dataListReady = false;
  98. this.buildData(response);
  99. }
  100. }, (error) => {
  101. MyApp.consoleError(ShopShowcaseSalesPage.TAG + "Couldn't connect to server", error);
  102. });
  103. }
  104.  
  105. buildData(response){
  106. this.dataList = [];
  107.  
  108. if(response.data.length != 0){
  109. for(let i=0; i<response.data.length; i++){
  110. this.dataList[i] = response.data[i]
  111. }
  112. MyApp.consoleLog(ShopShowcaseSalesPage.TAG, "list data", this.dataList);
  113. }
  114. }
  115.  
  116. deleteShowcase(id: any){
  117. let link = "http://localhost/phpscring/shop_showcase_sales/delete_showcase";
  118. MyApp.consoleLog(ShopShowcaseSalesPage.TAG, "id ", id);
  119.  
  120. let deleteShowcase;
  121. deleteShowcase = {};
  122. deleteShowcase.id = id;
  123.  
  124.  
  125. let postParams = {
  126. "link": link,
  127. "data": deleteShowcase
  128. }
  129.  
  130. MyApp.consoleLog(ShopShowcaseSalesPage.TAG, "postParams ", postParams);
  131.  
  132.  
  133. this.http.postService(postParams).then((data)=>{
  134. this.data.response = data;
  135. MyApp.consoleLog(ShopShowcaseSalesPage.TAG, " data response ", data);
  136. this.viewCtrl._didEnter();
  137. }, error => {
  138. MyApp.consoleError(ShopShowcaseSalesPage.TAG, error);
  139. });
  140.  
  141. MyApp.consoleLog("ShopShowcase", "Delete Showcase");
  142.  
  143. }
  144.  
  145. editShowcase(id: any){
  146. this.navCtrl.push(EditShowcaseSalesPage, {"id": id});
  147. }
  148.  
  149.  
  150.  
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement