[MIG] Migrated web_widget_image_webcam module from v12 to v13.

pull/2349/head
Shivam Soni 2021-01-21 17:57:23 +05:30 committed by OCA-git-bot
parent 27314c78ac
commit 689c5df032
9 changed files with 121 additions and 98 deletions

View File

@ -14,13 +14,13 @@ Web Widget - Image WebCam
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/12.0/web_widget_image_webcam
:target: https://github.com/OCA/web/tree/13.0/web_widget_image_webcam
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_image_webcam
:target: https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_widget_image_webcam
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/162/12.0
:target: https://runbot.odoo-community.org/runbot/162/13.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -55,7 +55,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_image_webcam%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_image_webcam%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -76,6 +76,7 @@ Contributors
* `Druidoo <https://www.druidoo.io>`_:
* Iván Todorovich
* Shivam Soni <s.soni.serpentcs@gmail.com>
Maintainers
~~~~~~~~~~~
@ -90,6 +91,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/12.0/web_widget_image_webcam>`_ project on GitHub.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/13.0/web_widget_image_webcam>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -4,21 +4,15 @@
{
"name": "Web Widget - Image WebCam",
"summary": "Allows to take image with WebCam",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"category": "web",
"website": "https://github.com/OCA/web",
"author": "Tech Receptives, "
"Kaushal Prajapati, "
"Odoo Community Association (OCA)",
"Kaushal Prajapati, "
"Odoo Community Association (OCA)",
"license": "LGPL-3",
"data": [
"views/assets.xml",
],
"depends": [
"web",
],
"qweb": [
"static/src/xml/web_widget_image_webcam.xml",
],
"data": ["views/assets.xml"],
"depends": ["web"],
"qweb": ["static/src/xml/web_widget_image_webcam.xml"],
"installable": True,
}

View File

@ -11,5 +11,5 @@ class IrConfigParameter(models.Model):
@api.model
def get_webcam_flash_fallback_mode_config(self):
return self.sudo().get_param(
'web_widget_image_webcam.flash_fallback_mode',
default=False)
"web_widget_image_webcam.flash_fallback_mode", default=False
)

View File

@ -3,3 +3,4 @@
* `Druidoo <https://www.druidoo.io>`_:
* Iván Todorovich
* Shivam Soni <s.soni.serpentcs@gmail.com>

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Web Widget - Image WebCam</title>
<style type="text/css">
@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_widget_image_webcam"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_widget_image_webcam"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/web/tree/13.0/web_widget_image_webcam"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/web-13-0/web-13-0-web_widget_image_webcam"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/162/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of the image widget and allows to take snapshots with WebCam.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@ -397,7 +397,7 @@ Here is the steps to do it easily (Always run in Adobe Flash fallback mode, but
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_image_webcam%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_widget_image_webcam%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -418,6 +418,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Iván Todorovich</li>
</ul>
</li>
<li>Shivam Soni &lt;<a class="reference external" href="mailto:s.soni.serpentcs&#64;gmail.com">s.soni.serpentcs&#64;gmail.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
@ -427,7 +428,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/12.0/web_widget_image_webcam">OCA/web</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/13.0/web_widget_image_webcam">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -3,17 +3,20 @@
Copyright 2019-Today: Druidoo (<https://www.druidoo.io>)
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
*/
.o_form_view.o_form_editable .o_form_field_image .o_form_image_controls
.o_form_binary_file_web_cam {
.o_form_view.o_form_editable
.o_form_field_image
.o_form_image_controls
.o_form_binary_file_web_cam {
color: inherit;
}
.o_field_widget.o_field_image .o_form_image_controls > .fa {
margin: 3px;
}
.o_form_view .o_form_field_image .o_form_image_controls > .fa{
.o_form_view .o_form_field_image .o_form_image_controls > .fa {
margin: 3px;
}
.live_webcam_outer_div, .webcam_result_outer_div {
.live_webcam_outer_div,
.webcam_result_outer_div {
padding-left: 20px;
}

View File

@ -2,25 +2,24 @@
Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
*/
odoo.define('web_widget_image_webcam.webcam_widget', function(require) {
odoo.define("web_widget_image_webcam.webcam_widget", function(require) {
"use strict";
var core = require('web.core');
var rpc = require('web.rpc');
var Dialog = require('web.Dialog');
var FieldBinaryImage = require('web.basic_fields').FieldBinaryImage;
var core = require("web.core");
var rpc = require("web.rpc");
var Dialog = require("web.Dialog");
var FieldBinaryImage = require("web.basic_fields").FieldBinaryImage;
var _t = core._t;
var QWeb = core.qweb;
FieldBinaryImage.include({
_render: function () {
_render: function() {
this._super();
var self = this,
WebCamDialog = $(QWeb.render("WebCamDialog")),
img_data;
img_data = false;
// ::webcamjs:: < https://github.com/jhuckaby/webcamjs >
// Webcam: Set Custom Parameters
@ -29,16 +28,16 @@ odoo.define('web_widget_image_webcam.webcam_widget', function(require) {
height: 240,
dest_width: 320,
dest_height: 240,
image_format: 'jpeg',
image_format: "jpeg",
jpeg_quality: 90,
force_flash: false,
fps: 45,
swfURL: '/web_widget_image_webcam/static/src/js/webcam.swf',
swfURL: "/web_widget_image_webcam/static/src/js/webcam.swf",
});
rpc.query({
model: 'ir.config_parameter',
method: 'get_webcam_flash_fallback_mode_config',
model: "ir.config_parameter",
method: "get_webcam_flash_fallback_mode_config",
}).then(function(default_flash_fallback_mode) {
if (default_flash_fallback_mode == 1) {
Webcam.set({
@ -51,34 +50,42 @@ odoo.define('web_widget_image_webcam.webcam_widget', function(require) {
}
});
self.$el.find('.o_form_binary_file_web_cam').off().on('click', function(){
// Init Webcam
var dialog = new Dialog(self, {
size: 'large',
dialogClass: 'o_act_window',
title: _t("WebCam Booth"),
$content: WebCamDialog,
buttons: [
{
text: _t("Take Snapshot"), classes: 'btn-primary take_snap_btn',
click: function () {
Webcam.snap( function(data) {
img_data = data;
// Display Snap besides Live WebCam Preview
WebCamDialog.find("#webcam_result").html('<img src="'+img_data+'"/>');
});
if (Webcam.live) {
// Remove "disabled" attr from "Save & Close" button
$('.save_close_btn').removeAttr('disabled');
}
}
},
{
text: _t("Save & Close"), classes: 'btn-primary save_close_btn', close: true,
click: function () {
var img_data_base64 = img_data.split(',')[1];
self.$el
.find(".o_form_binary_file_web_cam")
.off()
.on("click", function() {
// Init Webcam
var dialog = new Dialog(self, {
size: "large",
dialogClass: "o_act_window",
title: _t("WebCam Booth"),
$content: WebCamDialog,
buttons: [
{
text: _t("Take Snapshot"),
classes: "btn-primary take_snap_btn",
click: function() {
Webcam.snap(function(data) {
img_data = data;
// Display Snap besides Live WebCam Preview
WebCamDialog.find("#webcam_result").html(
'<img src="' + img_data + '"/>'
);
});
if (Webcam.live) {
// Remove "disabled" attr from "Save & Close" button
$(".save_close_btn").removeAttr("disabled");
}
},
},
{
text: _t("Save & Close"),
classes: "btn-primary save_close_btn",
close: true,
click: function() {
var img_data_base64 = img_data.split(",")[1];
/*
/*
Size in base64 is approx 33% overhead the original data size.
Source: -> http://stackoverflow.com/questions/11402329/base64-encoded-image-size
@ -90,38 +97,48 @@ odoo.define('web_widget_image_webcam.webcam_widget', function(require) {
including padding characters. ]
*/
// From the above info, we doing the opposite stuff to find the approx size of Image in bytes.
var approx_img_size = 3 * (img_data_base64.length / 4) - (img_data_base64.match(/=+$/g) || []).length; // like... "3[n/4]"
// From the above info, we doing the opposite stuff to find the approx size of Image in bytes.
var approx_img_size =
3 * (img_data_base64.length / 4) -
(img_data_base64.match(/[=]+$/g) || []).length;
// Like... "3[n/4]"
// Upload image in Binary Field
self.on_file_uploaded(approx_img_size, "web-cam-preview.jpeg", "image/jpeg", img_data_base64);
}
},
{
text: _t("Close"), close: true
}
]
}).open();
// Upload image in Binary Field
self.on_file_uploaded(
approx_img_size,
"web-cam-preview.jpeg",
"image/jpeg",
img_data_base64
);
},
},
{
text: _t("Close"),
close: true,
},
],
}).open();
dialog.opened().then(function() {
Webcam.attach('#live_webcam');
dialog.opened().then(function() {
Webcam.attach("#live_webcam");
// At time of Init "Save & Close" button is disabled
$('.save_close_btn').attr('disabled', 'disabled');
// At time of Init "Save & Close" button is disabled
$(".save_close_btn").attr("disabled", "disabled");
// Placeholder Image in the div "webcam_result"
WebCamDialog.find("#webcam_result").html('<img src="/web_widget_image_webcam/static/src/img/webcam_placeholder.png"/>');
// Placeholder Image in the div "webcam_result"
WebCamDialog.find("#webcam_result").html(
'<img src="/web_widget_image_webcam/static/src/img/webcam_placeholder.png"/>'
);
});
});
});
},
});
Dialog.include({
destroy: function () {
destroy: function() {
// Shut Down the Live Camera Preview | Reset the System
Webcam.reset();
this._super.apply(this, arguments);
},
});
});

View File

@ -1,27 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
Copyright 2019-Today: Druidoo (<https://www.druidoo.io>)
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<template id="template" xml:space="preserve">
<t t-extend="FieldBinaryImage">
<t t-jquery=".o_select_file_button" t-operation="after">
<span class="fa fa-eye o_form_binary_file_web_cam" title="WebCam"/>
<span class="fa fa-eye o_form_binary_file_web_cam" title="WebCam" />
</t>
</t>
<div t-name="WebCamDialog" id="WebCamModal">
<div class="container-fluid">
<div class="row">
<div class="col-md-5 live_webcam_outer_div">
<div id="live_webcam"/>
<div id="live_webcam" />
</div>
<div class="col-md-2 mt64 direction_icon fa fa-angle-right fa-8x"/>
<div class="col-md-2 mt64 direction_icon fa fa-angle-right fa-8x" />
<div class="col-md-5 webcam_result_outer_div">
<div id="webcam_result"/>
<div id="webcam_result" />
</div>
</div>
</div>
</div>
</template>

View File

@ -1,12 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2016 Siddharth Bhalgami <siddharth.bhalgami@gmail.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<template id="assets_backend" inherit_id="web.assets_backend">
<xpath expr=".">
<script type="text/javascript" src="/web_widget_image_webcam/static/src/lib/webcam.js"/>
<script type="text/javascript" src="/web_widget_image_webcam/static/src/js/webcam_widget.js"/>
<link rel="stylesheet" href="/web_widget_image_webcam/static/src/css/web_widget_image_webcam.css"/>
<script
type="text/javascript"
src="/web_widget_image_webcam/static/src/lib/webcam.js"
/>
<script
type="text/javascript"
src="/web_widget_image_webcam/static/src/js/webcam_widget.js"
/>
<link
rel="stylesheet"
href="/web_widget_image_webcam/static/src/css/web_widget_image_webcam.css"
/>
</xpath>
</template>
</odoo>