Merge pull request #634 from Kamidu/cloud-3.1.0

Cloud 3.1.0
merge-requests/7/head
Harshan Liyanage 8 years ago committed by GitHub
commit da70593110

@ -88,17 +88,25 @@
<label class="wr-input-label"> <label class="wr-input-label">
( {{roleNameHelpText}} ) ( {{roleNameHelpText}} )
</label> </label>
{{#if isCloud}}
<div id="roleNameField" class="form-group wr-input-control input-group">
<!--suppress HtmlFormInputWithoutLabel -->
<span class="input-group-addon" id="basic-addon1">devicemgt</span>
<input aria-describedby="basic-addon1" type="text" id="roleName"
data-regex="{{roleNameJSRegEx}}"
data-error-msg="{{roleNameRegExViolationErrorMsg}}" class="form-control"/>
{{else}}
<div id="roleNameField" class="form-group wr-input-control"> <div id="roleNameField" class="form-group wr-input-control">
<!--suppress HtmlFormInputWithoutLabel --> <!--suppress HtmlFormInputWithoutLabel -->
<input type="text" id="roleName" data-regex="{{roleNameJSRegEx}}" <input type="text" id="roleName" data-regex="{{roleNameJSRegEx}}"
data-error-msg="{{roleNameRegExViolationErrorMsg}}" class="form-control"/> data-error-msg="{{roleNameRegExViolationErrorMsg}}" class="form-control"/>
<span class="roleNameError hidden glyphicon glyphicon-remove form-control-feedback"></span> {{/if}}
<label class="error roleNameEmpty hidden" for="summary"> <span class="roleNameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
Role name is required, should be in minimum 3 characters long and not include any <label class="error roleNameEmpty hidden" for="summary">
whitespaces or "@" character or "/" character. Role name is required, should be in minimum 3 characters long and not include any
</label> whitespaces or "@" character or "/" character.
</div> </label>
</div>
{{#if canViewUsers}} {{#if canViewUsers}}
<label class="wr-input-label"> <label class="wr-input-label">
User list User list
@ -110,33 +118,33 @@
</div> </div>
{{/if}} {{/if}}
</div> </div>
</div>
<br>
<button id="add-role-btn" class="wr-btn">Add Role</button>
</div> </div>
<br>
<button id="add-role-btn" class="wr-btn">Add Role</button>
</div> </div>
</div> <div id="role-created-msg" class="container col-centered wr-content hidden">
<div id="role-created-msg" class="container col-centered wr-content hidden"> <div class="wr-form">
<div class="wr-form"> <p class="page-sub-title">Role was added successfully.</p>
<p class="page-sub-title">Role was added successfully.</p> <br>Please click <b>"Add Another Role"</b>, if you wish to add another role or click
<br>Please click <b>"Add Another Role"</b>, if you wish to add another role or click <b>"View Role List"</b> to complete the process and go back to the role list.
<b>"View Role List"</b> to complete the process and go back to the role list. <hr/>
<hr/> <button class="wr-btn" onclick="window.location.href='{{@app.context}}/roles'">
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/roles'"> View Role List
View Role List </button>
</button> <!--suppress HtmlUnknownTarget -->
<!--suppress HtmlUnknownTarget --> <a href="{{@app.context}}/role/add" class="cu-btn-inner">
<a href="{{@app.context}}/role/add" class="cu-btn-inner">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i> <i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>
</span> </span>
Add Another Role Add Another Role
</a> </a>
</div>
</div> </div>
<!-- /content -->
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
</div> </div>
<!-- /content -->
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
</div>
</div> </div>
<!-- /content/body --> <!-- /content/body -->
{{else}} {{else}}

@ -19,11 +19,11 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<!-- content --> <!-- content -->
<div id="role-create-form" class="container col-centered wr-content"> <div id="role-create-form" data-cloud={{isCloud}} class="container col-centered wr-content">
<div class="wr-form"> <div class="wr-form">
<p class="page-sub-title">Edit Role</p> <p class="page-sub-title">Edit Role</p>
<p>Please note that * sign represents required fields of data.</p> <p>Please note that * sign represents required fields of data.</p>
<hr /> <hr/>
<div class="row"> <div class="row">
<div class="col-lg-8"> <div class="col-lg-8">
<div id="role-create-error-msg" class="alert alert-danger hidden" role="alert"> <div id="role-create-error-msg" class="alert alert-danger hidden" role="alert">
@ -42,46 +42,58 @@
<label class="wr-input-label" id="roleNameValidationText"> <label class="wr-input-label" id="roleNameValidationText">
( {{roleNameHelpText}} ) ( {{roleNameHelpText}} )
</label> </label>
{{#if isCloud}}
<div id="roleNameField" class="form-group wr-input-control input-group">
<!--suppress HtmlFormInputWithoutLabel -->
<span class="input-group-addon" id="basic-addon1">devicemgt</span>
<input aria-describedby="basic-addon1" type="text" id="rolename"
data-regex="{{roleNameJSRegEx}}"
data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control"
data-currentrole="{{role.roleName}}"
value="{{role.roleName}}"/>
{{else}}
<div id="roleNameField" class="form-group wr-input-control"> <div id="roleNameField" class="form-group wr-input-control">
<input type="text" id="rolename" data-regex="{{roleNameJSRegEx}}" <input type="text" id="rolename" data-regex="{{roleNameJSRegEx}}"
data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control" data-errormsg="{{roleNameRegExViolationErrorMsg}}" class="form-control"
data-currentrole="{{role.roleName}}" data-currentrole="{{role.roleName}}"
value="{{role.roleName}}" /> value="{{role.roleName}}"/>
{{/if}}
<span class=" rolenameError hidden glyphicon glyphicon-remove form-control-feedback"></span> <span class=" rolenameError hidden glyphicon glyphicon-remove form-control-feedback"></span>
<label class="error rolenameEmpty hidden" for="summary">Role name is required & Should be in <label class="error rolenameEmpty hidden" for="summary">Role name is required & Should be in
minimum 3 characters long and do not minimum 3 characters long and do not
include any whitespaces. </label> include any whitespaces. </label>
</div> </div>
</div> </div>
</div>
<br>
<button id="add-role-btn" class="wr-btn">Update Role</button>
</div> </div>
<br>
<button id="add-role-btn" class="wr-btn">Update Role</button>
</div> </div>
</div> <div id="role-created-msg" class="container col-centered wr-content hidden">
<div id="role-created-msg" class="container col-centered wr-content hidden"> <div class="wr-form">
<div class="wr-form"> <p class="page-sub-title">Role was updated successfully.</p>
<p class="page-sub-title">Role was updated successfully.</p> <br>Please click <b>"View Updated Role"</b>, if you wish to view the updated role or click
<br>Please click <b>"View Updated Role"</b>, if you wish to view the updated role or click <b>"View Role List"</b> to complete the process and go back to the role list.
<b>"View Role List"</b> to complete the process and go back to the role list. <hr/>
<hr /> <button class="wr-btn" onclick="window.location.href='{{@app.context}}/roles'">
<button class="wr-btn" onclick="window.location.href='{{@app.context}}/roles'"> View Role List
View Role List </button>
</button> <a href="{{@app.context}}/roles/edit-role/{{role.roleName}}"
<a href="{{@app.context}}/roles/edit-role/{{role.roleName}}" class="cu-btn-inner">
class="cu-btn-inner">
<span class="fw-stack"> <span class="fw-stack">
<i class="fw fw-circle-outline fw-stack-2x"></i> <i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>
</span> </span>
View Updated Role View Updated Role
</a> </a>
</div>
</div> </div>
<!-- /content -->
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
</div> </div>
<!-- /content -->
<div id="app-context" data-app-context="{{@app.context}}" class="hidden"></div>
</div> </div>
</div> <!-- /content/body -->
<!-- /content/body --> {{#zone "bottomJs"}}
{{#zone "bottomJs"}} {{js "js/bottomJs.js"}}
{{js "js/bottomJs.js"}} {{/zone}}
{{/zone}}

@ -29,6 +29,7 @@ function onRequest(context) {
var roleName = request.getParameter("rolename"); var roleName = request.getParameter("rolename");
var response; var response;
var userStore; var userStore;
context.isCloud = deviceMgtProps.isCloud;
if (roleName) { if (roleName) {
if (roleName.indexOf("/") > -1) { if (roleName.indexOf("/") > -1) {

@ -83,18 +83,18 @@ clearInline["role-name"] = function () {
*/ */
validateInline["role-name"] = function () { validateInline["role-name"] = function () {
var rolenameinput = $("input#rolename"); var rolenameinput = $("input#rolename");
if (inputIsValid( rolenameinput.data("regex"), rolenameinput.val())) { if (inputIsValid(rolenameinput.data("regex"), rolenameinput.val())) {
disableInlineError("roleNameField", "rolenameEmpty", "rolenameError"); disableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
} else { } else {
enableInlineError("roleNameField", "rolenameEmpty", "rolenameError"); enableInlineError("roleNameField", "rolenameEmpty", "rolenameError");
} }
}; };
function formatRepo (user) { function formatRepo(user) {
if (user.loading) { if (user.loading) {
return user.text return user.text
} }
if (!user.username){ if (!user.username) {
return; return;
} }
var markup = '<div class="clearfix">' + var markup = '<div class="clearfix">' +
@ -102,7 +102,7 @@ function formatRepo (user) {
'<div class="clearfix">' + '<div class="clearfix">' +
'<div class="col-sm-3">' + user.username + '</div>'; '<div class="col-sm-3">' + user.username + '</div>';
if (user.firstname) { if (user.firstname) {
markup += '<div class="col-sm-3"><i class="fa fa-code-fork"></i> ' + user.firstname + '</div>'; markup += '<div class="col-sm-3"><i class="fa fa-code-fork"></i> ' + user.firstname + '</div>';
} }
if (user.emailAddress) { if (user.emailAddress) {
markup += '<div class="col-sm-2"><i class="fa fa-star"></i> ' + user.emailAddress + '</div></div>'; markup += '<div class="col-sm-2"><i class="fa fa-star"></i> ' + user.emailAddress + '</div></div>';
@ -111,14 +111,14 @@ function formatRepo (user) {
return markup; return markup;
} }
function formatRepoSelection (user) { function formatRepoSelection(user) {
return user.username || user.text; return user.username || user.text;
} }
$(document).ready(function () { $(document).ready(function () {
var appContext = $("#app-context").data("app-context"); var appContext = $("#app-context").data("app-context");
$("#users").select2({ $("#users").select2({
multiple:true, multiple: true,
tags: false, tags: false,
ajax: { ajax: {
url: appContext + "/api/invoker/execute/", url: appContext + "/api/invoker/execute/",
@ -148,23 +148,29 @@ $(document).ready(function () {
}, },
cache: true cache: true
}, },
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work escapeMarkup: function (markup) {
return markup;
}, // let our custom formatter work
minimumInputLength: 1, minimumInputLength: 1,
templateResult: formatRepo, // omitted for brevity, see the source of this page templateResult: formatRepo, // omitted for brevity, see the source of this page
templateSelection: formatRepoSelection // omitted for brevity, see the source of this page templateSelection: formatRepoSelection // omitted for brevity, see the source of this page
}); });
/** /**
* Following click function would execute * Following click function would execute
* when a user clicks on "Add Role" button * when a user clicks on "Add Role" button
* on Add Role page in WSO2 MDM Console. * on Add Role page in WSO2 MDM Console.
*/ */
$("button#add-role-btn").click(function() { $("button#add-role-btn").click(function () {
var isCloud = $("#role-create-form").data("cloud");
var rolenameInput = $("input#rolename"); var rolenameInput = $("input#rolename");
var roleName = rolenameInput.val(); var roleName = rolenameInput.val();
var currentRoleName = $("input#rolename").data("currentrole"); var currentRoleName = $("input#rolename").data("currentrole");
if (isCloud) {
currentRoleName = "devicemgt" + currentRoleName;
}
var domain = $("#domain").val(); var domain = $("#domain").val();
var errorMsgWrapper = "#role-create-error-msg"; var errorMsgWrapper = "#role-create-error-msg";
var errorMsg = "#role-create-error-msg span"; var errorMsg = "#role-create-error-msg span";
@ -182,12 +188,17 @@ $(document).ready(function () {
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
} else { } else {
var addRoleFormData = {}; var addRoleFormData = {};
addRoleFormData.roleName = roleName; if (isCloud) {
addRoleFormData.roleName = "devicemgt" + roleName;
} else {
addRoleFormData.roleName = roleName;
}
var addRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(currentRoleName); var addRoleAPI = apiBasePath + "/roles/" + encodeURIComponent(currentRoleName);
if (domain != "PRIMARY"){ if (domain != "PRIMARY") {
addRoleFormData.roleName = domain + "/" + roleName; addRoleFormData.roleName = domain + "/" + roleName;
addRoleAPI = addRoleAPI + "?user-store=" + encodeURIComponent(domain); addRoleAPI = addRoleAPI + "?user-store=" + encodeURIComponent(domain);
} }
invokerUtil.put( invokerUtil.put(
addRoleAPI, addRoleAPI,
addRoleFormData, addRoleFormData,
@ -201,6 +212,7 @@ $(document).ready(function () {
$("#role-created-msg").removeClass("hidden"); $("#role-created-msg").removeClass("hidden");
} }
}, function (data) { }, function (data) {
var payload = JSON.parse(data.responseText); var payload = JSON.parse(data.responseText);
$(errorMsg).text(payload.message); $(errorMsg).text(payload.message);
$(errorMsgWrapper).removeClass("hidden"); $(errorMsgWrapper).removeClass("hidden");
@ -209,11 +221,11 @@ $(document).ready(function () {
} }
}); });
$("#rolename").focus(function() { $("#rolename").focus(function () {
clearInline["role-name"](); clearInline["role-name"]();
}); });
$("#rolename").blur(function() { $("#rolename").blur(function () {
validateInline["role-name"](); validateInline["role-name"]();
}); });

Loading…
Cancel
Save