Skip to content

Instantly share code, notes, and snippets.

@dudelis
dudelis / script.js
Created February 25, 2019 11:14
K2 - Hamburger menu instead of tabs
var controls = '<div class="hamburger-wrapper"><button class="hamburger">&#9776;</button><button class="cross">&#735;</button></div>';
$('.runtime-form.theme-entry').prepend(controls);
$( '.hamburger').click(function() {
$('.tab-box-tabs').slideToggle('slow', function() {
$('.hamburger').hide();
$('.cross').show();
});
});
$('.cross').click(function() {
@dudelis
dudelis / swagger.json
Created February 22, 2019 12:41
K2 Swagger WOrklow API
{
"swagger": "2.0",
"info": {
"version": "preview",
"title": "K2 Workflow Api"
},
"host": "porsche-test.onk2.com",
"basePath": "/Api/Workflow/Preview",
"schemes": [
"https"
@dudelis
dudelis / ms-swagger.json
Last active February 20, 2019 15:03
MS Graph Swagger
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "Microsoft Graph Example"
},
"host": "graph.windows.net",
"schemes": [ "https"],
"produces": [ "application/json" ],
"paths": {
@dudelis
dudelis / k2-swagger.json
Last active February 12, 2019 23:23
BLOG: Using K2 with REST API
{
"swagger": "2.0",
"info": {
"title": "K2 and MongoDB integration",
"description": "Sample file",
"version": "0.0.1"
},
"host": "localhost:3000",
"schemes": [
"http"
@dudelis
dudelis / app.js
Last active February 10, 2019 01:56
BLOG: Using K2 with REST API
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var mongoRouter = require('./routes/mongo');
var app = express();
@dudelis
dudelis / 01 - Sample Tables and Data.sql
Last active January 21, 2019 18:53
K2: Row Level Security with K2 and SQL ServiceBroker
--Create a simple table to hold data.
CREATE TABLE [dbo].[Sales](
[OrderId] INT PRIMARY KEY,
[Product] NVARCHAR(50) NULL,
[Qty] INT NULL,
[GroupId] INT NULL
)
GO
--Create a simple data to hold User/Group relations.
CREATE TABLE [dbo].[GroupUsers](
@dudelis
dudelis / change-view-background.js
Created January 14, 2019 20:39
K2: Changing view background in K2 Smartforms
var panelBody = $('[name="dlblViewIdentifier"]').closest('.view').find('.panel-body');
$(panelBody).css('background-image', 'url("/Runtime/Image.ashx?ImID=0000000")'); //ImageID is taken from the hidden control
$(panelBody).css('background-repeat', 'no-repeat');
$(panelBody).css('background-size', 'auto');
@dudelis
dudelis / azure-function-swagger.json
Last active January 5, 2019 01:30
K2: Integration Azure Functions with REST
{
"swagger": "2.0",
"info": {
"title": "K2 Azure Function Demo",
"description": "Used to demo integration with Azure Function",
"version": "0.0.1"
},
"host": "k2-rest-broker-demo.azurewebsites.net",
"schemes": [ "https" ],
"produces": [
@dudelis
dudelis / azure-function-sample.js
Last active January 5, 2019 00:22
K2: Integrate Azure Function with REST ServiceBroker
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
if (req.query.name || (req.body && req.body.name)) {
var output = req.query.name || req.body.name;
context.res = {
// status: 200, /* Defaults to 200 */
body: {
'output': output
}
@dudelis
dudelis / k2-find-toolbar-button.js
Created December 21, 2018 00:20
K2: Find Toolbar Button
//Control Name is Unique across the whole form
var controlName = ""; //give the name of the control you want to find
var controlPath = "Controllers/Controller/Controls/Control[@Name='" + controlName + "']";
var cd = $xml(__runtimeControllersDefinition);
var controlXml = $sn(cd, controlPath);
var controlId = controlXml.getAttribute('ID');
var controlObj = $('#' + controlId + '_ToolbarButton');
//Finding control on a certain view or Form
var viewInstanceName = ""; //Give the name of the view or just type "Form", if the control is on the form.