Quellcode durchsuchen

[ADD] download feature

Gogs vor 6 Jahren
Ursprung
Commit
bd92c99d5c

BIN
files/sample.pdf


+ 44 - 0
static/src/css/main.css

@@ -92,3 +92,47 @@
 .pdf_viewer_window .page_wrapper canvas {
     box-shadow: 0px 0px 15px 0px rgba(0,0,0,0.75);
 }
+
+.download_tools_window h2 {
+    font-size: 1.6em;
+    text-align: center;
+}
+
+.download_tools_window p {
+    font-size: 1.1em;
+    text-align: center;
+    margin: 2em 1.5em;
+}
+
+.download_tools_window .download_logo_windows {
+    width: 100px;
+    height: 100px;
+    margin: 0 auto;
+    background: url(../img/windows-logo.png) center center no-repeat;
+    background-size: contain;
+}
+
+.download_tools_window .download_logo_linux {
+    width: 100px;
+    height: 100px;
+    margin: 0 auto;
+    background: url(../img/linux-logo.png) center center no-repeat;
+    background-size: contain;
+}
+
+.download_tools_window .download_button {
+    width: 100%;
+    height: 100%;
+}
+
+.download_tools_window .download_button i, .download_tools_window .download_button div {
+    display: inline-block;
+}
+
+.download_tools_window .download_button i {
+    font-size: 3em;
+}
+
+.download_tools_window .download_button div h2, .download_tools_window .download_button div p {
+    margin: 0;
+}

+ 1 - 0
static/src/img/apple-logo.svg

@@ -0,0 +1 @@
+<svg width="82" height="100" viewBox="0 0 82 100" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="#000"><g><g><g><g><path d="M68.557 53.58C68.43 40.99 78.872 34.95 79.34 34.644c-5.87-8.54-15.01-9.713-18.264-9.846-7.774-.786-15.176 4.558-19.12 4.558-3.936 0-10.03-4.443-16.475-4.33-8.48.126-16.296 4.91-20.66 12.467-8.806 15.21-2.252 37.75 6.33 50.093 4.195 6.034 9.198 12.823 15.762 12.575 6.326-.25 8.713-4.074 16.36-4.074 7.65 0 9.797 4.074 16.49 3.946 6.802-.123 11.115-6.148 15.276-12.206 4.817-7.01 6.8-13.797 6.917-14.14-.148-.07-13.262-5.07-13.398-20.105zM55.983 16.628c3.48-4.207 5.84-10.053 5.198-15.872C56.16.958 50.078 4.08 46.47 8.282c-3.23 3.73-6.057 9.67-5.3 15.383 5.605.433 11.32-2.84 14.813-7.037z"/></g></g></g></g></g></g></svg>

BIN
static/src/img/linux-logo.png


BIN
static/src/img/windows-logo.png


+ 70 - 0
static/src/js/main.js

@@ -182,10 +182,78 @@ openerp.print_engine = function (instance, local) {
         }
     });
 
+    local.DownloadPrinterTools = instance.web.Widget.extend({
+        template: 'DownloadPrinterTools',
+        events: {
+            'click .download_button': 'handle_download'
+        },
+        init: function (parent) {
+            this._super(parent);
+        },
+        start: function () {
+            this.renderElement();
+            this.$el.appendTo($('body'));
+            this.$el.on('hidden.bs.modal', this, this.on_hide);
+
+            if (this.is_linux_platform()) {
+                this.$('.download_logo_windows').css('display', 'none');
+                this.$('.windows_download_button').css('display', 'none');
+            }
+            
+            if (this.is_win_platform()) {
+                this.$('.download_logo_linux').css('display', 'none');
+                this.$('.linux_download_button').css('display', 'none');
+            }
+
+            this.$el.modal('show');
+        },
+        on_hide: function (e) {
+            var self = e.data;
+            self.$el.remove();
+            self.destroy();
+        },
+        is_win_platform: function () {
+            return /^Win(?:32|64)$/.test(navigator.platform);
+        },
+        is_linux_platform: function () {
+            return /^Linux\sx86(?:|_64)$/.test(navigator.platform);
+        },
+        handle_download: function (e) {
+            var download_url = 'https://repo.eiru.com.py/attachments/';
+
+            if (this.is_linux_platform()) {
+                download_url += '94bcc4d4-8fe7-45f9-8715-97c11fdcdd6f';
+            }
+
+            if (this.is_win_platform()) {
+                download_url += '8b9b5283-c5f8-4a62-a798-2691b72936bd';
+            }
+
+            var a = document.createElement('a');
+    
+            a.href = download_url;
+            a.target = '_parent';
+            a.click();
+
+            this.$el.modal('hide');
+        }
+    });
+
     local.PrinterTopNotificator = instance.web.Widget.extend({
         template: 'PrinterTopNotificator',
+        events: {
+            'click .printer_status_notificator': 'handle_click'
+        },
         init: function (parent) {
             this._super(parent);
+        },
+        handle_click: function (e) {
+            e.preventDefault();
+
+            if (local.socket_manager.socket.disconnected) {
+                var widget = new local.DownloadPrinterTools(this);
+                widget.start();
+            }
         }
     });
 
@@ -455,7 +523,9 @@ openerp.print_engine = function (instance, local) {
                 do_update: function () {
                     var printer = new local.PrinterTopNotificator(this);
                     printer.appendTo($('.oe_systray'));
+                    
                     local.socket_manager = new local.SocketManager();
+
                     return this._super.apply(this, arguments);
                 }
             });

+ 38 - 1
static/src/xml/main.xml

@@ -2,11 +2,48 @@
 <templates xml:space="preserve">
     <t t-name="PrinterTopNotificator">
         <li t-att-title='_t("Printer Status")'>
-            <a href="#">
+            <a class="printer_status_notificator" href="#">
                 <i class="fa fa-print" aria-hidden="true" />
                 <div id="printer-status"></div>
             </a>
         </li>
+    </t>
+     <t t-name="DownloadPrinterTools">
+        <div aria-hidden="false" class="modal fade" role="dialog" tabindex="-1">
+            <div class="modal-dialog modal-lg">
+                <div class="modal-content openerp">
+                    <div class="modal-header">
+                        <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
+                        <h3 class="modal-title">Descargar</h3>
+                    </div>
+                    <div class="modal-body download_tools_window">
+                        <h2>Descargar herramienta de gestión de impresoras</h2>
+                        <p>Al instalar esta herramienta en su sistema te dará la facilidad de imprimir directamente sus documentos, evitando los molestos diálogos de configuración del navegador.</p>
+                        <div class="download_logo_windows"></div>
+                        <div class="download_logo_linux"></div>
+                        <div style="width: 200px; height: 65px; margin: 3.8em auto 0;">
+                            <button class="btn btn-default download_button windows_download_button">
+                                <i class="fa fa-download"></i>
+                                <div>
+                                    <h2>Descargar</h2>
+                                    <p>Windows 7, 8 y 10</p>
+                                </div>
+                            </button>
+                            <button class="btn btn-default download_button linux_download_button">
+                                <i class="fa fa-download"></i>
+                                <div>
+                                    <h2>Descargar</h2>
+                                    <p>Debian/Ubuntu</p>
+                                </div>
+                            </button>
+                        </div>
+                    </div>
+                    <div class="modal-footer">
+                        <button class="oe_button oe_highlight" data-dismiss="modal" type="button">Cerrar</button>
+                    </div>
+                </div>                                                
+            </div>
+        </div>
     </t>
     <t t-name="PrinterUnavailableDialog">
         <div aria-hidden="false" class="modal fade" role="dialog" tabindex="-1">