소스 검색

crud del modulo de productos mejora para soporte de imagenes, nuevos iconos y splash, servicio de sincronizacion automatica empezado

robert2206 8 년 전
부모
커밋
05a974879d
33개의 변경된 파일326개의 추가작업 그리고 62개의 파일을 삭제
  1. 57 37
      config.xml
  2. BIN
      resources/android/icon/drawable-hdpi-icon.png
  3. BIN
      resources/android/icon/drawable-ldpi-icon.png
  4. BIN
      resources/android/icon/drawable-mdpi-icon.png
  5. BIN
      resources/android/icon/drawable-xhdpi-icon.png
  6. BIN
      resources/android/icon/drawable-xxhdpi-icon.png
  7. BIN
      resources/android/icon/drawable-xxxhdpi-icon.png
  8. BIN
      resources/android/splash/drawable-land-hdpi-screen.png
  9. BIN
      resources/android/splash/drawable-land-ldpi-screen.png
  10. BIN
      resources/android/splash/drawable-land-mdpi-screen.png
  11. BIN
      resources/android/splash/drawable-land-xhdpi-screen.png
  12. BIN
      resources/android/splash/drawable-land-xxhdpi-screen.png
  13. BIN
      resources/android/splash/drawable-land-xxxhdpi-screen.png
  14. BIN
      resources/android/splash/drawable-port-hdpi-screen.png
  15. BIN
      resources/android/splash/drawable-port-ldpi-screen.png
  16. BIN
      resources/android/splash/drawable-port-mdpi-screen.png
  17. BIN
      resources/android/splash/drawable-port-xhdpi-screen.png
  18. BIN
      resources/android/splash/drawable-port-xxhdpi-screen.png
  19. BIN
      resources/android/splash/drawable-port-xxxhdpi-screen.png
  20. BIN
      resources/icon.png
  21. BIN
      resources/splash.png
  22. 66 15
      src/app/app.component.ts
  23. 3 0
      src/app/app.module.ts
  24. BIN
      src/assets/images/no_product.png
  25. 3 2
      src/pages/product-details/product-details.html
  26. 2 2
      src/pages/product-details/product-details.scss
  27. 53 2
      src/pages/product-details/product-details.ts
  28. 4 3
      src/pages/product-list/product-list.html
  29. 18 1
      src/pages/settings/settings.html
  30. 30 0
      src/pages/tools/tools.html
  31. 11 0
      src/pages/tools/tools.scss
  32. 70 0
      src/pages/tools/tools.ts
  33. 9 0
      src/providers/data-provider.ts

+ 57 - 37
config.xml

@@ -1,39 +1,59 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <widget id="com.eiru.odoo" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
-    <name>Odoo by Eiru</name>
-    <description>An awesome Ionic/Cordova app.</description>
-    <author email="robert.gauto@gmail.com" href="http://ionicframework.com/">Robert Alexis GAuto</author>
-    <content src="index.html"/>
-    <access origin="*"/>
-    <allow-intent href="http://*/*"/>
-    <allow-intent href="https://*/*"/>
-    <allow-intent href="tel:*"/>
-    <allow-intent href="sms:*"/>
-    <allow-intent href="mailto:*"/>
-    <allow-intent href="geo:*"/>
-    <platform name="android">
-        <allow-intent href="market:*"/>
-    </platform>
-    <platform name="ios">
-        <allow-intent href="itms:*"/>
-        <allow-intent href="itms-apps:*"/>
-    </platform>
-    <preference name="webviewbounce" value="false"/>
-    <preference name="UIWebViewBounce" value="false"/>
-    <preference name="DisallowOverscroll" value="true"/>
-    <preference name="android-minSdkVersion" value="16"/>
-    <preference name="BackupWebStorage" value="none"/>
-    <preference name="SplashScreenDelay" value="0"/>
-    <preference name="FadeSplashScreen" value="false"/>
-    <preference name="FadeSplashScreenDuration" value="0"/>
-    <preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
-    <feature name="StatusBar">
-        <param name="ios-package" onload="true" value="CDVStatusBar"/>
-    </feature>
-    <plugin name="cordova-plugin-device" spec="~1.1.3"/>
-    <plugin name="cordova-plugin-console" spec="~1.0.4"/>
-    <plugin name="cordova-plugin-whitelist" spec="~1.3.0"/>
-    <plugin name="cordova-plugin-splashscreen" spec="~4.0.0"/>
-    <plugin name="cordova-plugin-statusbar" spec="~2.2.0"/>
-    <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
-</widget>
+  <name>Odoo by Eiru</name>
+  <description>An awesome Ionic/Cordova app.</description>
+  <author email="robert.gauto@gmail.com" href="http://ionicframework.com/">Robert Alexis GAuto</author>
+  <content src="index.html"/>
+  <access origin="*"/>
+  <allow-intent href="http://*/*"/>
+  <allow-intent href="https://*/*"/>
+  <allow-intent href="tel:*"/>
+  <allow-intent href="sms:*"/>
+  <allow-intent href="mailto:*"/>
+  <allow-intent href="geo:*"/>
+  <platform name="android">
+    <allow-intent href="market:*"/>
+    <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/>
+    <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/>
+    <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/>
+    <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/>
+    <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/>
+    <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
+    <splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/>
+    <splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/>
+    <splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/>
+    <splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
+    <splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
+    <splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
+    <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/>
+    <splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/>
+    <splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/>
+    <splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
+    <splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
+    <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
+  </platform>
+  <platform name="ios">
+    <allow-intent href="itms:*"/>
+    <allow-intent href="itms-apps:*"/>
+  </platform>
+  <preference name="webviewbounce" value="false"/>
+  <preference name="UIWebViewBounce" value="false"/>
+  <preference name="DisallowOverscroll" value="true"/>
+  <preference name="android-minSdkVersion" value="16"/>
+  <preference name="BackupWebStorage" value="none"/>
+  <preference name="SplashScreenDelay" value="1000"/>
+  <preference name="FadeSplashScreen" value="true"/>
+  <preference name="FadeSplashScreenDuration" value="500"/>
+  <preference name="SplashScreenBackgroundColor" value="0xFFFFFFFF"/>
+  <preference name="SplashScreen" value="screen"/>
+  <feature name="StatusBar">
+    <param name="ios-package" onload="true" value="CDVStatusBar"/>
+  </feature>
+  <plugin name="cordova-plugin-device" spec="~1.1.3"/>
+  <plugin name="cordova-plugin-console" spec="~1.0.4"/>
+  <plugin name="cordova-plugin-whitelist" spec="~1.3.0"/>
+  <plugin name="cordova-plugin-splashscreen" spec="~4.0.0"/>
+  <plugin name="cordova-plugin-statusbar" spec="~2.2.0"/>
+  <plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
+  <icon src="resources/android/icon/drawable-xhdpi-icon.png"/>
+</widget>

BIN
resources/android/icon/drawable-hdpi-icon.png


BIN
resources/android/icon/drawable-ldpi-icon.png


BIN
resources/android/icon/drawable-mdpi-icon.png


BIN
resources/android/icon/drawable-xhdpi-icon.png


BIN
resources/android/icon/drawable-xxhdpi-icon.png


BIN
resources/android/icon/drawable-xxxhdpi-icon.png


BIN
resources/android/splash/drawable-land-hdpi-screen.png


BIN
resources/android/splash/drawable-land-ldpi-screen.png


BIN
resources/android/splash/drawable-land-mdpi-screen.png


BIN
resources/android/splash/drawable-land-xhdpi-screen.png


BIN
resources/android/splash/drawable-land-xxhdpi-screen.png


BIN
resources/android/splash/drawable-land-xxxhdpi-screen.png


BIN
resources/android/splash/drawable-port-hdpi-screen.png


BIN
resources/android/splash/drawable-port-ldpi-screen.png


BIN
resources/android/splash/drawable-port-mdpi-screen.png


BIN
resources/android/splash/drawable-port-xhdpi-screen.png


BIN
resources/android/splash/drawable-port-xxhdpi-screen.png


BIN
resources/android/splash/drawable-port-xxxhdpi-screen.png


BIN
resources/icon.png


BIN
resources/splash.png


+ 66 - 15
src/app/app.component.ts

@@ -15,6 +15,7 @@ import { CallListPage } from '../pages/call-list/call-list';
 import { ProjectListPage } from '../pages/project-list/project-list';
 import { TaskListPage } from '../pages/task-list/task-list';
 
+import { ToolsPage } from '../pages/tools/tools';
 import { SettingsPage } from '../pages/settings/settings';
 import { AboutPage } from '../pages/about/about'
 
@@ -32,21 +33,71 @@ export class MyApp {
         this.initializeApp();
 
         this.entries = [
-            { title: 'Ventas', pages: [
-                { icon: "people", title: 'Clientes', component: CustomerListPage },
-                { icon: "cube", title: 'Productos', component: ProductListPage },
-                { icon: "bulb", title: 'Iniciativas', component: LeadListPage },
-                { icon: "ribbon", title: 'Oportunidades', component: OpportunityListPage },
-                { icon: "call", title: 'Llamadas', component: CallListPage }
-            ]},
-            { title: 'Proyectos', pages: [
-                { icon: "briefcase", title: 'Proyectos', component: ProjectListPage },
-                { icon: "calendar", title: 'Tareas', component: TaskListPage }
-            ]},
-            { title: 'Herramientas', pages: [
-                { icon: "settings", title: 'Preferencias', component: SettingsPage },
-                { icon: "information-circle", title: 'Acerca', component: AboutPage }
-            ]}
+            {
+                title: 'Ventas',
+                pages: [
+                    {
+                        icon: "people",
+                        title: 'Clientes',
+                        component: CustomerListPage
+                    },
+                    {
+                        icon: "cube",
+                        title: 'Productos',
+                        component: ProductListPage
+                    },
+                    {
+                        icon: "bulb",
+                        title: 'Iniciativas',
+                        component: LeadListPage
+                    },
+                    {
+                        icon: "ribbon",
+                        title: 'Oportunidades',
+                        component: OpportunityListPage
+                    },
+                    {
+                        icon: "call",
+                        title: 'Llamadas',
+                        component: CallListPage
+                    }
+                ]
+            },
+            {
+                title: 'Proyectos',
+                pages: [
+                    {
+                        icon: "briefcase",
+                        title: 'Proyectos',
+                        component: ProjectListPage
+                    },
+                    {
+                        icon: "calendar",
+                        title: 'Tareas',
+                        component: TaskListPage
+                    }
+                ]
+            },
+            {
+                title: 'Herramientas',
+                pages: [
+                    {
+                        icon: "build",
+                        title: 'Herramientas',
+                        component: ToolsPage
+                    },
+                    {
+                        icon: "settings",
+                        title: 'Preferencias',
+                        component: SettingsPage
+                    },
+                    {
+                        icon: "information-circle",
+                        title: 'Acerca',
+                        component: AboutPage
+                    }
+                ]
+            }
         ];
     }
 

+ 3 - 0
src/app/app.module.ts

@@ -15,6 +15,7 @@ import { CallListPage } from '../pages/call-list/call-list';
 import { ProjectListPage } from '../pages/project-list/project-list';
 import { TaskListPage } from '../pages/task-list/task-list';
 
+import { ToolsPage } from '../pages/tools/tools'
 import { SettingsPage } from '../pages/settings/settings';
 import { AboutPage } from '../pages/about/about'
 
@@ -31,6 +32,7 @@ import { AboutPage } from '../pages/about/about'
         CallListPage,
         ProjectListPage,
         TaskListPage,
+        ToolsPage,
         SettingsPage,
         AboutPage
     ],
@@ -50,6 +52,7 @@ import { AboutPage } from '../pages/about/about'
         CallListPage,
         ProjectListPage,
         TaskListPage,
+        ToolsPage,
         SettingsPage,
         AboutPage
     ],

BIN
src/assets/images/no_product.png


+ 3 - 2
src/pages/product-details/product-details.html

@@ -14,10 +14,11 @@
 <ion-content>
     <ion-card>
         <div style="position: relative">
-            <img src="./assets/images/product.png" />
+            <img src="./assets/images/product.png" *ngIf="!product.image"/>
+            <img src="data:image/jpeg;base64,{{ product.image }}" *ngIf="product.image"/>
 
             <ion-fab left bottom>
-                <button ion-fab color="yellow" class="fab-picture">
+                <button ion-fab color="yellow" class="fab-picture" (click)="showPhotoOptions()">
                     <ion-icon name="camera" color="light"></ion-icon>
                 </button>
             </ion-fab>

+ 2 - 2
src/pages/product-details/product-details.scss

@@ -7,9 +7,9 @@ page-product-details {
     ion-card img {
         margin: 10px auto;
         display: block;
-        width: 200px;
+        border-radius: 10px;
         height: 200px;
-        filter: blur(50%)
+        width: auto;
     }
 
     button[fab].fab-picture {

+ 53 - 2
src/pages/product-details/product-details.ts

@@ -1,5 +1,6 @@
 import { Component } from '@angular/core';
-import { NavController, NavParams } from 'ionic-angular';
+import { NavController, NavParams, ActionSheetController } from 'ionic-angular';
+import { Camera } from 'ionic-native';
 import { Product } from '../../models/product'
 import { DataProvider } from '../../providers/data-provider'
 
@@ -19,13 +20,15 @@ export class ProductDetailsPage {
         costPrice: 0,
         quantity: 0,
         salesCount: 0,
+        image: null,
         active: true
     }
 
     constructor(
         public navCtrl: NavController,
         public params: NavParams,
-        public data: DataProvider
+        public data: DataProvider,
+        public actionSheetCtrl: ActionSheetController
     ) { 
         this.initialize();
     }
@@ -49,6 +52,54 @@ export class ProductDetailsPage {
 
         return true;
     }
+
+    /**
+     *
+     */
+    showPhotoOptions() {
+        this.actionSheetCtrl.create({
+            title: "Tomar una foto",
+            buttons: [
+                {
+                    text: "Desde la cámara",
+                    icon: "camera",
+                    handler: () => {
+                        this.takePicture(Camera.PictureSourceType.CAMERA);
+                    }
+                },
+                {
+                    text: "Desde la galería",
+                    icon: "images",
+                    handler: () => {
+                        this.takePicture(Camera.PictureSourceType.SAVEDPHOTOALBUM);
+                    }
+                },
+                {
+                    text: "Cancelar",
+                    role: "cancel"
+                }
+            ]
+        }).present();
+    }
+
+    /**
+     *
+     */
+    takePicture(sourceType: number) {
+        Camera.getPicture({
+            sourceType: sourceType,
+            destinationType: Camera.DestinationType.DATA_URL,
+            correctOrientation: true,
+            saveToPhotoAlbum: false,
+            targetHeight: 300,
+            targetWidth: 300
+        }).then(i => {
+            this.product.image = i; 
+        }).catch(e => {
+            console.log(e);                    
+        });
+    }
+
     /**
      *
      */

+ 4 - 3
src/pages/product-list/product-list.html

@@ -42,9 +42,10 @@
 <ion-content>
 
     <ion-card *ngFor="let p of list(); let i = index;" (tap)="openItem(i)" (press)="toggleDelete(i)">
-        <ion-item>
+        <button ion-item>
             <ion-avatar item-left>
-                <img src="./assets/images/product.png" />
+                <img src="./assets/images/product.png" *ngIf="!p.image"/>
+                <img src="data:image/jpeg;base64,{{ p.image }}" *ngIf="p.image"/>
             </ion-avatar>
 
             <h2>{{ p.name }}</h2>
@@ -55,7 +56,7 @@
             </p>
 
             <ion-icon name="checkmark-circle" color="primary" item-right *ngIf="i == _selectedIndex"></ion-icon>
-        </ion-item>
+        </button>
 
         <ion-row>
             <ion-col>

+ 18 - 1
src/pages/settings/settings.html

@@ -14,5 +14,22 @@
 
 
 <ion-content padding>
-
+    <ion-list>
+        <ion-item>
+            <ion-label stacked>Sincronización automática</ion-label>
+            <ion-toggle></ion-toggle>
+        </ion-item>
+
+        <ion-item>
+            <ion-label stacked>Frecuencia de sincronización</ion-label>
+            <ion-select>
+                <ion-option value="0">10 minutos</ion-option>
+                <ion-option value="1">30 minutos</ion-option>
+                <ion-option value="2">1 hora</ion-option>
+                <ion-option value="2">1 día</ion-option>
+                <ion-option value="2">1 semana</ion-option>
+                <ion-option value="2">1 mes</ion-option>
+            </ion-select>
+        </ion-item>
+    </ion-list>
 </ion-content>

+ 30 - 0
src/pages/tools/tools.html

@@ -0,0 +1,30 @@
+<ion-header>
+
+    <ion-navbar color="primary">
+        <button ion-button menuToggle>
+            <ion-icon name="menu"></ion-icon>
+        </button>
+
+        <ion-title>Herramientas</ion-title>
+    </ion-navbar>
+
+</ion-header>
+<ion-content padding>
+
+    <ion-card>
+        <button ion-item (click)="syncAllData()">
+            <ion-icon name="sync" color="primary" item-left></ion-icon>
+            <h2>Sincronizar datos</h2>
+            <p>Sincroniza sus datos con su cuenta de Odoo</p>
+        </button>
+    </ion-card>
+
+    <ion-card>
+        <button ion-item (click)="deleteAccount()">
+            <ion-icon name="walk" color="primary" item-left></ion-icon>
+            <h2>Eliminar cuenta</h2>
+            <p>Eliminar su cuenta de Odoo guardada en la aplicación incluyendo la base de datos</p>
+        </button>
+    </ion-card>
+
+</ion-content>

+ 11 - 0
src/pages/tools/tools.scss

@@ -0,0 +1,11 @@
+page-tools {
+
+    h2 {
+        padding-top: 10px;
+    }
+
+    p {
+        word-break: keep-all;
+        white-space: normal;
+    }
+}

+ 70 - 0
src/pages/tools/tools.ts

@@ -0,0 +1,70 @@
+import { Component } from '@angular/core';
+import { NavController, AlertController } from 'ionic-angular';
+import { DataProvider } from '../../providers/data-provider';
+import { LoginPage } from '../login/login';
+
+@Component({
+    selector: 'page-tools',
+    providers: [DataProvider],
+    templateUrl: 'tools.html'
+})
+export class ToolsPage {
+
+    constructor(
+        public navCtrl: NavController,
+        public alertCtrl: AlertController,
+        public dataProvider: DataProvider 
+    ) { }
+
+    ionViewDidLoad() {
+      console.log('Hello Tools Page');
+    }
+
+    /**
+     *
+     */
+    syncAllData() {
+         this.alertCtrl.create({
+            title: "Confirmar",
+            message: "Desea sincronizar sus datos ahora?",
+            buttons: [
+                {
+                    text: "Cancelar"
+                },
+                {
+                    text: "Aceptar",
+                    handler: () => {
+                        console.log("ok");
+                    }
+                }
+            ]
+        }).present();
+    }
+
+    /**
+     *
+     */
+    deleteAccount() {
+        this.alertCtrl.create({
+            title: "Confirmar",
+            message: "Desea borrar su cuenta?",
+            buttons: [
+                {
+                    text: "Cancelar"
+                },
+                {
+                    text: "Aceptar",
+                    handler: () => {
+                        this.dataProvider.dropDatabase().then(r => {
+                            localStorage.clear();
+                            this.navCtrl.setRoot(LoginPage);
+                        }).catch(e => {
+                            console.log(e);
+                        });
+                        
+                    }
+                }
+            ]
+        }).present();
+    }
+}

+ 9 - 0
src/providers/data-provider.ts

@@ -102,4 +102,13 @@ export class DataProvider {
         });
         
     }
+
+    /**
+     *
+     */
+    dropDatabase(): any {
+        return new Promise((resolve, reject) => {
+            resolve(this.data.destroy());
+        });
+    } 
 }