revert-dabc3590
mharindu 9 years ago
commit cf9daf083d

@ -48,7 +48,7 @@ public class MQTTEventAdapterConstants {
public static final int ADAPTER_CONF_DEFAULT_KEEP_ALIVE = 60000;
public static int initialReconnectDuration = 2000;
public static final int reconnectionProgressionFactor = 2;
public static final int reconnectionProgressionFactor = 4;
public static final String EMPTY_STRING = "";
public static final String GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer refresh_token";

@ -49,8 +49,8 @@ public class XMPPEventAdapterConstants {
public static final int DEFAULT_XMPP_PORT = 5222;
public static final int DEFAULT_TIMEOUT_INTERVAL = 5000;
public static int initialReconnectDuration = 10000;
public static final int reconnectionProgressionFactor = 2;
public static int initialReconnectDuration = 2000;
public static final int reconnectionProgressionFactor = 4;
public static final String DEFAULT = "default";

@ -61,9 +61,15 @@ function submitForm(formId) {
var statusIcon = content.find("#status-icon");
var description = content.find("#description");
var successCallBack = function (response) {
var res = response;
try {
res = JSON.parse(response).messageFromServer;
} catch (err) {
//do nothing
}
title.html("Response Received!");
statusIcon.attr("class", defaultStatusClasses + " fw-success");
description.html(response);
statusIcon.attr("class", defaultStatusClasses + " fw-check");
description.html(res);
$(modalPopupContent).html(content.html());
};
var errorCallBack = function (response) {
@ -94,9 +100,9 @@ function submitForm(formId) {
$(document).on('submit', 'form', function (e) {
e.preventDefault();
var postOperationRequest = $.ajax({
url: $(this).attr("action") + '&' + $(this).serialize(),
method: "post"
});
url: $(this).attr("action") + '&' + $(this).serialize(),
method: "post"
});
var btnSubmit = $('#btnSend', this);
btnSubmit.addClass('hidden');

@ -73,7 +73,6 @@ validateStep["policy-profile"] = function () {
};
stepForwardFrom["policy-profile"] = function () {
policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations);
// updating next-page wizard title with selected platform
$("#policy-criteria-page-wizard-title").text("ADD " + deviceTypeLabel + " POLICY");
};
@ -105,6 +104,8 @@ stepForwardFrom["policy-criteria"] = function () {
policy["selectedUsers"] = $("#users-input").val();
} else if ($(this).attr("id") == "user-roles-radio-btn") {
policy["selectedUserRoles"] = $("#user-roles-input").val();
} else if ($(this).attr("id") == "groups-radio-btn") {
policy["selectedUserGroups"] = $("#groups-input").val();
}
}
}
@ -247,12 +248,15 @@ var savePolicy = function (policy, state) {
invokerUtil.post(
serviceURL,
payload,
function () {
$(".add-policy").addClass("hidden");
$(".policy-naming").addClass("hidden");
$(".policy-message").removeClass("hidden");
if (state == "publish") {
publishToDevice();
function (response) {
response = JSON.parse(response);
if (response["statusCode"] == 201) {
$(".add-policy").addClass("hidden");
$(".policy-naming").addClass("hidden");
$(".policy-message").removeClass("hidden");
if (state == "publish") {
publishToDevice();
}
}
},
function (err) {
@ -351,6 +355,31 @@ function formatRepoSelection(user) {
return user.username || user.text;
}
function formatGroupRepo(group) {
if (group.loading) {
return group.text
}
if (!group.name) {
return;
}
var markup = '<div class="clearfix">' +
'<div clas="col-sm-8">' +
'<div class="clearfix">' +
'<div class="col-sm-3">' + group.name + '</div>';
if (group.name) {
markup += '<div class="col-sm-3"><i class="fa fa-code-fork"></i> ' + group.name + '</div>';
}
if (group.owner) {
markup += '<div class="col-sm-2"><i class="fa fa-star"></i> ' + group.owner + '</div></div>';
}
markup += '</div></div>';
return markup;
}
function formatGroupRepoSelection(group) {
return group.name || group.text;
}
// End of functions related to grid-input-view
@ -372,46 +401,85 @@ $(document).ready(function () {
});
$("#users-input").select2({
multiple: true,
tags: true,
ajax: {
url: window.location.origin + "/devicemgt/api/invoker/execute/",
method: "POST",
dataType: 'json',
delay: 250,
id: function (user) {
return user.username;
},
data: function (params) {
var postData = {};
postData.actionMethod = "GET";
postData.actionUrl = "/devicemgt_admin/users";
postData.actionPayload = JSON.stringify({
q: params.term, // search term
page: params.page
});
return JSON.stringify(postData);
},
processResults: function (data, page) {
var newData = [];
$.each(data.responseContent, function (index, value) {
value.id = value.username;
newData.push(value);
});
return {
results: newData
};
},
cache: true
},
escapeMarkup: function (markup) {
return markup;
}, // let our custom formatter work
minimumInputLength: 1,
templateResult: formatRepo, // omitted for brevity, see the source of this page
templateSelection: formatRepoSelection // omitted for brevity, see the source of this page
});
multiple: true,
tags: true,
ajax: {
url: window.location.origin + "/devicemgt/api/invoker/execute/",
method: "POST",
dataType: 'json',
delay: 250,
id: function (user) {
return user.username;
},
data: function (params) {
var postData = {};
postData.actionMethod = "GET";
postData.actionUrl = "/devicemgt_admin/users";
postData.actionPayload = JSON.stringify({
q: params.term, // search term
page: params.page
});
return JSON.stringify(postData);
},
processResults: function (data, page) {
var newData = [];
$.each(data.responseContent, function (index, value) {
value.id = value.username;
newData.push(value);
});
return {
results: newData
};
},
cache: true
},
escapeMarkup: function (markup) {
return markup;
}, // let our custom formatter work
minimumInputLength: 1,
templateResult: formatRepo, // omitted for brevity, see the source of this page
templateSelection: formatRepoSelection // omitted for brevity, see the source of this page
});
$("#groups-input").select2({
multiple: true,
tags: true,
ajax: {
url: window.location.origin + "/devicemgt/api/invoker/execute/",
method: "POST",
dataType: 'json',
delay: 250,
id: function (group) {
return group.name;
},
data: function (params) {
var postData = {};
postData.actionMethod = "GET";
var username = $("#platform").data("username");
postData.actionUrl = "/devicemgt_admin/groups/user/" + username +
"/search?groupName=" + params.term;
return JSON.stringify(postData);
},
processResults: function (data, page) {
var newData = [];
$.each(data, function (index, value) {
value.id = value.name;
newData.push(value);
});
return {
results: newData
};
},
cache: true
},
escapeMarkup: function (markup) {
return markup;
}, // let our custom formatter work
minimumInputLength: 1,
templateResult: formatGroupRepo, // omitted for brevity, see the source of this page
templateSelection: formatGroupRepoSelection // omitted for brevity, see the source of this page
});
// Adding initial state of wizard-steps.
$("#policy-profile-wizard-steps").html($(".wr-steps").html());
@ -427,16 +495,24 @@ $(document).ready(function () {
});
$("#users-select-field").hide();
$("#groups-select-field").hide();
$("#user-roles-select-field").show();
$("input[type='radio'].select-users-radio").change(function () {
if ($("#user-roles-radio-btn").is(":checked")) {
$("#user-roles-select-field").show();
$("#users-select-field").hide();
$("#groups-select-field").hide();
}
if ($("#users-radio-btn").is(":checked")) {
$("#user-roles-select-field").hide();
$("#users-select-field").show();
$("#groups-select-field").hide();
}
if ($("#user-roles-radio-btn").is(":checked")) {
if ($("#groups-radio-btn").is(":checked")) {
$("#user-roles-select-field").hide();
$("#users-select-field").hide();
$("#user-roles-select-field").show();
$("#groups-select-field").show();
}
});
@ -657,7 +733,9 @@ $(document).ready(function () {
// hiding current section of the wizard and showing next section.
$("." + currentStep).addClass("hidden");
$("." + nextStep).removeClass("hidden");
if (nextStep !== "policy-message") {
$("." + nextStep).removeClass("hidden");
}
}
});
});

@ -2,7 +2,7 @@
{{css "css/codemirror.css"}}
{{/zone}}
<span id="platform" class="hidden" data-platform="{{type.name}}" data-platform-id="{{type.id}}"
data-platform-label="{{type.label}}"></span>
data-platform-label="{{type.label}}" data-username="{{username}}"></span>
<div class="row">
<div class="col-md-12">
<div class="wr-steps hidden">
@ -23,7 +23,7 @@
<div class="col-md-3 col-xs-3">
<div class="itm-wiz" data-step="policy-criteria">
<div class="wiz-no">3</div>
<div class="wiz-lbl hidden-xs"><span>Assign to groups</span></div>
<div class="wiz-lbl hidden-xs"><span>Assign</span></div>
</div>
<br class="c-both"/>
</div>
@ -130,48 +130,80 @@
<hr>
<div class="row">
<div class="col-lg-12">
<h4>Step 3: Assign to groups</h4>
<h4>Step 3: Assign</h4>
<br>
<div>
<div class="wr-input-control">
<label class="wr-input-control radio light">
<input id="user-roles-radio-btn" type="radio"
name="select-users-radio-btn" class="select-users-radio"
checked/>
<span class="helper">&nbsp;Set user role(s)</span>
</label>
<label class="wr-input-control radio light" rel="assetfilter">
<input id="users-radio-btn" type="radio"
name="select-users-radio-btn"
class="select-users-radio"/>
<span class="helper">&nbsp;Set user(s)</span>
</label>
{{#if permissions.LIST_ROLES}}
<label class="wr-input-control radio light">
<input id="user-roles-radio-btn" type="radio"
name="select-users-radio-btn" class="select-users-radio"
checked/>
<span class="helper">&nbsp;Set user role(s)</span>
</label>
{{/if}}
{{#if permissions.LIST_USERS}}
<label class="wr-input-control radio light" rel="assetfilter">
<input id="users-radio-btn" type="radio"
name="select-users-radio-btn"
class="select-users-radio"/>
<span class="helper">&nbsp;Set user(s)</span>
</label>
{{/if}}
<!--
{{#if permissions.LIST_GROUPS}}
<label class="wr-input-control radio light" rel="assetfilter">
<input id="groups-radio-btn" type="radio"
name="select-users-radio-btn"
class="select-users-radio"/>
<span class="helper">&nbsp;Set groups(s)</span>
</label>
{{/if}}
-->
</div>
<div id="user-roles-select-field" class="select-users">
<div class="wr-input-control">
<div class="cus-col-50">
<select id="user-roles-input" class="form-control select2"
multiple="multiple">
<option value="ANY" selected>ANY</option>
{{#each roles}}
<option>{{this}}</option>
{{/each}}
</select>
{{#if permissions.LIST_ROLES}}
<div id="user-roles-select-field" class="select-users">
<div class="wr-input-control">
<div class="cus-col-50">
<select id="user-roles-input" class="form-control select2"
multiple="multiple">
<option value="ANY" selected>ANY</option>
{{#each roles}}
<option>{{this}}</option>
{{/each}}
</select>
</div>
<br class="c-both"/>
</div>
<br class="c-both"/>
</div>
</div>
<div id="users-select-field" class="select-users">
<div class="wr-input-control">
<div class="cus-col-50">
<select id="users-input" class="form-control select2"
multiple="multiple">
</select>
{{/if}}
{{#if permissions.LIST_USERS}}
<div id="users-select-field" class="select-users">
<div class="wr-input-control">
<div class="cus-col-50">
<select id="users-input" class="form-control select2"
multiple="multiple">
</select>
</div>
<br class="c-both"/>
</div>
<br class="c-both"/>
</div>
</div>
{{/if}}
<!--
{{#if permissions.LIST_GROUPS}}
<div id="groups-select-field" class="select-users">
<div class="wr-input-control">
<div class="cus-col-50">
<select id="groups-input" class="form-control select2"
multiple="multiple">
</select>
</div>
<br class="c-both"/>
</div>
</div>
{{/if}}
-->
<br>
<label class="wr-input-label" title="">
Set an action upon non-compliance
@ -237,7 +269,7 @@
<a href="javascript:void(0)" class="wr-btn wizard-stepper"
data-current="policy-profile" data-next="policy-criteria"
data-validate="true">
Continue
Continue
</a>
</div>
</div>

@ -18,6 +18,7 @@
function onRequest(context) {
//var log = new Log("wizard.js");
var constants = require("/app/modules/constants.js");
var DTYPE_CONF_DEVICE_TYPE_KEY = "deviceType";
var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label";
@ -43,5 +44,8 @@ function onRequest(context) {
}
}
}
var user = session.get(constants.USER_SESSION_KEY);
wizardPage.username = user.username;
wizardPage.permissions = userModule.getUIPermissions();
return wizardPage;
}

@ -1,4 +1,8 @@
{
"version": "1.0.0",
"extends": "cdmf.unit.device.operation-mod"
"version": "1.0.0",
"pushedUris": [
"/policies",
"/policy/{+any}"
],
"extends": "cdmf.unit.device.operation-mod"
}
Loading…
Cancel
Save