Jenkins - Publishing html table on build summary page - jenkins-pipeline

I want to publish html table on build summary page.
Something like this
HTML publisher allows only publish a link to the report while postBuild makes not supporting html tables and makes me to add imagem so those plugins doesnt do the job.
Which plugin can do the job?

The Badge plugin allows you to do this via a "Build Summary", though I never really tried to put a complex dataset like an html table in it:
https://github.com/jenkinsci/badge-plugin#createsummary

First there is summary report plug in
https://plugins.jenkins.io/summary_report/
Second I used markup.html to publish a summary table, for example:
def writer = new StringWriter() // html is written here by markup builder
def markup = new groovy.xml.MarkupBuilder(writer) // the builder
markup.html{
markup.table(class:"table table-bordered table-hover table-condensed") {
markup.thead{
markup.tr {
markup.th(title:"Field #1", "task name")
markup.th(title:"Field #2", "status")
markup.th(title:"Field #3", "link")
} // tr
} // thead
markup.tbody{
markup.tr{
markup.td(align:"right","Name")
markup.td(align:"right","RESULT")
markup.td(align:"right","DATA")
} // tr
} //tbody
} // table
}
manager.createSummary("accept.png").appendText(writer.toString(), false, false, false, "green")

Related

Can I remove extra text in the tab name?

There's a change to the tab name when I receive a notification on social networking sites.
It'll change from Website to 3 Notifications | Website
I'm curious about ways on Firefox I can prevent that sort of change.
Is it possible to filter out certain words from tab names?
You unfortunately cannot prevent tabs from updating the title in any modern browser. The only solution that I've seen, although not ideal, is to use a script to record the initial title of the page and keep the tab updated with that saved value. You can use a greasemonkey script for such a task:
var script = document.createElement("script");
script.textContent = "(" + t.toString() + ")()";
document.body.appendChild(script);
var title = document.title;
var updateTitle = function ()
{
document.title = title;
};
window.setInterval(updateTitle, 0);
The title is usually changed by assigning a new value to the document.title. You can freeze its value after the page is loaded with this user script:
// ==UserScript==
// #name Freeze title page
// #match *://*/*
// #run-at document-idle
// ==/UserScript==
const unsafeDocument = document.wrappedJSObject || document;
let title;
try {
title = unsafeDocument.head.getElementsByTagName('title')[0].innerText;
} catch { }
if (!title) {
title = unsafeDocument.title;
}
Object.defineProperty(unsafeDocument, 'title', {
get() {
return title;
},
set() { },
});
To avoid race condition with other scripts which might change document.title the title is read from <title> tag.
Note that this solution won't work if the title of the page is set to something like 3 Notifications | Website with the <title> element and not via scripts. In such case I have no idea how to do what you want in a generic way. You can hovewer force a manually-defined title on a per URL basis.

How to add an external jQuery plugin to the list view on Odoo?

I am using Odoo 10e. I want to integrate a jquery plugin into my module.
I want to integrate the jQuery plugin jquery-resizable-columns. It simple helps user to resize columns of table on the fly and I want to apply this on a specific model's list view
Which method should I extend in order to add the plugin?
I think you should extend (maybe include) some widget in the web module. If you go to the file /addons/web/static/src/js/view_list.js, you can see the widget that renders the table:
instance.web.ListView = instance.web.View.extend( /** #lends instance.web.ListView# */ {
_template: 'ListView',
display_name: _lt('List'),
defaults: {
// records can be selected one by one
'selectable': true,
// list rows can be deleted
'deletable': false,
// whether the column headers should be displayed
'header': true,
// display addition button, with that label
'addable': _lt("Create"),
// whether the list view can be sorted, note that once a view has been
// sorted it can not be reordered anymore
'sortable': true,
// whether the view rows can be reordered (via vertical drag & drop)
'reorderable': true,
'action_buttons': true,
//whether the editable property of the view has to be disabled
'disable_editable_mode': false,
},
view_type: 'tree',
events: {
'click thead th.oe_sortable[data-id]': 'sort_by_column'
},
// [...]
sort_by_column: function (e) {
e.stopPropagation();
var $column = $(e.currentTarget);
var col_name = $column.data('id');
var field = this.fields_view.fields[col_name];
// test whether the field is sortable
if (field && !field.sortable) {
return false;
}
this.dataset.sort(col_name);
if($column.hasClass("sortdown") || $column.hasClass("sortup")) {
$column.toggleClass("sortup sortdown");
} else {
$column.addClass("sortdown");
}
$column.siblings('.oe_sortable').removeClass("sortup sortdown");
this.reload_content();
},
As you can see there is an event declared as sort_by_column, so you would have to add the plugin you want in a similar way.
And if you have any doubts inheriting and modifying widgets you can go to the Odoo Documentation
And if you are using the version 10 you can check how it is built here
/addons/web/static/src/js/views/list_view.js
In .js file you have to first extend particular list view's js. After that give your custom model name in that .js file and run that.
In your case, You need.
Created a new module or modify already custom module
Create file.js and file.xml.
In the file xml you must write this
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/module_name/static/src/css/css_file.css"/>
<script type="text/javascript" src="/module_name/static/src/js/js_file.js"></script>
</xpath>
</template>
</odoo>
And after you needing extent the list_view.js of Odoo to integrate your plugin.

Rich Text Editor (WYSIWYG) in CRM 2013

Sometimes it is useful to have the HTML editor in CRM interface. It is possible to implement the editor directly to CRM 2013. As editor we will use ckeditor which allows to use it without installation on the server.
Identify the field where you would like to use the rich text editor.
Create html-webresource which will define ckeditor. Go to Settings-Customizations-Customize the System-Web Resources.
In html editor of web resource, select the Source tab and insert the following code:
<html>
<head>
<title></title>
<script src="//cdn.ckeditor.com/4.4.7/standard/ckeditor.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
function getTextFieldName()
{
var vals = new Array();
if (location.search != "")
{
vals = location.search.substr(1).split("&");
for (var i in vals)
{
vals[i] = vals[i].replace(/\+/g, " ").split("=");
}
//look for the parameter named 'data'
for (var i in vals)
{
if (vals[i][0].toLowerCase() == "data")
{
var datavalue = vals[i][2];
var vals2 = new Array();
var textFieldName = "";
vals2 = decodeURIComponent(datavalue).split("&");
for (var i in vals2)
{
var queryParam = vals2[i].replace(/\+/g, " ").split("=");
if (queryParam[0] != null && queryParam[0].toLowerCase() == "datafieldname")
{
textFieldName = queryParam[1];
}
}
if (textFieldName == "")
{
alert('No "dataFieldName" parameter has been passed to Rich Text Box Editor.');
return null;
}
else
{
return textFieldName;
}
}
else
{
alert('No data parameter has been passed to Rich Text Box Editor.');
}
}
}
else
{
alert('No data parameter has been passed to Rich Text Box Editor.');
}
return null;
}
CKEDITOR.timestamp = null;
​// Maximize the editor window, i.e. it will be stretched to target field
CKEDITOR.on('instanceReady',
function( evt )
{
var editor = evt.editor;
editor.execCommand('maximize');
});
var Xrm;
$(document).ready(function ()
{
​ // Get the target field name from query string
var fieldName = getTextFieldName();
var Xrm = parent.Xrm;
var data = Xrm.Page.getAttribute(fieldName).getValue();
document.getElementById('editor1').value = data;
/*
// Uncomment only if you would like to update original field on lost focus instead of property change in editor
//Update textbox on lost focus
CKEDITOR.instances.editor1.on('blur', function ()
{
var value = CKEDITOR.instances.editor1.getData();
Xrm.Page.getAttribute(fieldName).setValue(value);
});
*/
// Update textbox on change in editor
CKEDITOR.instances.editor1.on('change', function ()
{
var value = CKEDITOR.instances.editor1.getData();
Xrm.Page.getAttribute(fieldName).setValue(value);
});
// Following settings define that the editor allows whole HTML content without removing tags like head, style etc.
CKEDITOR.config.allowedContent = true;
CKEDITOR.config.fullPage = true;
});
</script>
<meta>
</head>
<body style="word-wrap: break-word;">
<textarea class="ckeditor" cols="80" id="editor1" name="editor1" rows="10"></textarea>
</body>
</html>
Note:
As you can see, there are a few important sections
a) The following code loads the ckeditor and jquery from web so that they don't have to be installed on server.
<script src="//cdn.ckeditor.com/4.4.7/standard/ckeditor.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
b) Function getTextFieldName() which gets the name of target field where should be rich text editor placed. This information is obtained from query string. This will allow to use this web resource on multiple forms.
c) Initialization of ckeditor itself - setting the target field and properties of ckeditor. Also binding the editor with predefined textarea on the page.
Open the form designer on the form where you would like to use ​WYSIWYG editor. Create a text field with sufficient length (e.g. 100 000 chars) which will hold the html source code.
Insert the iframe on the form. As a webresource use the resource created in previous steps. Also define Custom Parameter(data) where you should define the name of the text field defined in step 4. In our situation we created new_bodyhtml text field so the parameter holds this value. This value is returned by the getTextFieldName() of the web resource.
Do not forget to save and publish all changes in CRM customization otherwise added webresources and updated form are not available.
That's all, here is example how it looks like:
Yes, you can use CKEditor, but when I implemented the CKEditor on a form, it turns out it is quite limited in the functionality in provides. Also, the HTML it generates leaves much to be desired. So, I tried a similar idea to Pavel's but using a backing field to store the actual HTML using TinyMCE. You can find the code here:
Javascript
HTML
Documentation
I have package my solution as a managed and unmanaged CRM solution that can be imported and utilised on any form. Moreover, it works on both CRM 2013 and CRM 2015

Firefox addon: how to grab data from webpage?

Purpose
I am trying to make a common answer database for a website form. The form is a description of computer hardware specifications, and I am trying to make it so that based on a model field, other fields are filled in automatically. The extension with have two buttons, "populate" which will based on the model field, check the database for a matching entry, and then populate data into the forms based on that. The second button being "save", which will take data in the fields and marry it to the model field and place it into the database.
Question
So, my main question is on interacting with the webpage itself, how do I grab data from the webpage, and then how do I make changes to fields?
So, my main question is on interacting with the webpage itself, how do I grab data from the webpage, and then how do I make changes to fields?
You can do this with a Firefox Add-on SDK Page-mod, click here for the documentation
Here is an example for getting data:
Example Page-Mod
/lib/main.js:
var tag = "p";
var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "*.mozilla.org",
contentScriptFile: data.url("element-getter.js"),
onAttach: function(worker) {
worker.port.emit("getElements", tag);
worker.port.on("gotElement", function(elementContent) {
console.log(elementContent);
});
}
});
/data/element-getter.js:
self.port.on("getElements", function(tag) {
var elements = document.getElementsByTagName(tag);
for (var i = 0; i < elements.length; i++) {
self.port.emit("gotElement", elements[i].innerHTML);
}
});

How do I track AJAX sections in Magento Onepage with Google Analytics Async

I have a magento store and I am trying to track the progress of users at the checkout process.
I have the Onepage checkout enabled - which does some ajax stuff to essentially load 6 different steps in an accordion format. I would like to track each step with Google Analytics so i know whats putting the users off.. I found this link (http://magentoexpert.co.uk/2009/03/08/tracking-one-page-checkout-abandonment-with-google-analytics-properly/) to do so with Google Analytics - but it uses the old GA code. I am using the Async code which uses the gaq push.
So here is the code they recommend to use.
gotoSection: function(section)
{
try {
pageTracker._trackPageview('/checkout/' + section + '/');
} catch(err) {}
section = $('opc-'+section);
section.addClassName('allow');
this.accordion.openSection(section);
},
To update this to the Asynchronous version, would i use:
gotoSection: function(section)
{
try {
_gaq.push(['_trackPageview', '/checkout/', + section + '/']);
} catch(err) {}
section = $('opc-'+section);
section.addClassName('allow');
this.accordion.openSection(section);
},
Do i need the catch(err) ? What would be the full code - this doesn't seem to work for me?
I believe that the Fooman GoogleAnalyticsPlus extension on MagentoConnect will do what you need. YMMV.
For anyone who comes here, the above code does not work because it needs to be /checkout/onepage/ instead of just /checkout/
View correct example here: http://inchoo.net/ecommerce/magento/onepage-checkout-abandonment-google-analytics/
This is the code I have functioning, note the added function at the bottom. I wanted to track failed submission button action, this is added to the onclick and generates its own independent event tracking adding the Submit Order step just previous to the success goal in the chain:
<!-- Google Funnel Stats -->
<script type="text/javascript">
Checkout.prototype.gotoSection = function(section) {
try {
// Google Analytics non-asynch code
// pageTracker._trackPageview('/checkout/onepage/'+section+'/');
// Google Analytics asynchronus code
_gaq.push(['_trackPageview', '/checkout/onepage/'+section+'/']);
} catch(err) { }
section = $('opc-'+section);
section.addClassName('allow');
this.accordion.openSection(section);
}
function gaqSubmitOrder() {
try {
// Google Analytics non-asynch code
// pageTracker._trackPageview('/checkout/onepage/'+section+'/');
// Google Analytics asynchronus code
_gaq.push(['_trackPageview', '/checkout/onepage/submitorder/']);
} catch(err) { }
}
</script>

Resources