|
|
@ -223,6 +223,13 @@ function hidePopup() {
|
|
|
|
$(modalPopup).hide();
|
|
|
|
$(modalPopup).hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var errorHandler = function () {
|
|
|
|
|
|
|
|
$(modalPopupContent).html($('#add-group-unexpected-error-content').html());
|
|
|
|
|
|
|
|
$("a#group-unexpected-error-link").click(function () {
|
|
|
|
|
|
|
|
hidePopup();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function attachGroupAdding() {
|
|
|
|
function attachGroupAdding() {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Following click function would execute
|
|
|
|
* Following click function would execute
|
|
|
@ -272,13 +279,7 @@ function attachGroupAdding() {
|
|
|
|
hidePopup();
|
|
|
|
hidePopup();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}, errorHandler
|
|
|
|
function () {
|
|
|
|
|
|
|
|
$(modalPopupContent).html($('#add-group-unexpected-error-content').html());
|
|
|
|
|
|
|
|
$("a#group-unexpected-error-link").click(function () {
|
|
|
|
|
|
|
|
hidePopup();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -309,62 +310,94 @@ function attachEvents() {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$("a.share-group-link").click(function () {
|
|
|
|
$("a.share-group-link").click(function () {
|
|
|
|
var groupId = $(this).data("groupid");
|
|
|
|
var groupId = $(this).data("groupid");
|
|
|
|
var shareGroupApi = "/iotserver/api/group/id/" + groupId + "/share";
|
|
|
|
var username = $("#user-details").data("username");
|
|
|
|
var unShareGroupApi = "/iotserver/api/group/id/" + groupId + "/unshare";
|
|
|
|
$(modalPopupContent).html($('#share-group-w1-modal-content').html());
|
|
|
|
|
|
|
|
$('#user-names').html('Loading...');
|
|
|
|
$(modalPopupContent).html($('#share-group-modal-content').html());
|
|
|
|
|
|
|
|
showPopup();
|
|
|
|
showPopup();
|
|
|
|
|
|
|
|
$("a#share-group-next-link").hide();
|
|
|
|
$("a#share-group-share-link").click(function () {
|
|
|
|
invokerUtil.get("/iotserver/api/users",
|
|
|
|
var data = {"shareUser":"", "role":""};
|
|
|
|
|
|
|
|
invokerUtil.post(
|
|
|
|
|
|
|
|
shareGroupApi,
|
|
|
|
|
|
|
|
data,
|
|
|
|
|
|
|
|
function (data, txtStatus, jqxhr) {
|
|
|
|
function (data, txtStatus, jqxhr) {
|
|
|
|
|
|
|
|
var users = JSON.parse(data);
|
|
|
|
var status = jqxhr.status;
|
|
|
|
var status = jqxhr.status;
|
|
|
|
if (status == 200) {
|
|
|
|
if (status == 200) {
|
|
|
|
|
|
|
|
var str = '<br /><select id="share-user-selector" style="color:#3f3f3f;padding:5px;width:250px;">';
|
|
|
|
} else {
|
|
|
|
var hasUsers = false;
|
|
|
|
displayErrors(status);
|
|
|
|
for (var user in users) {
|
|
|
|
|
|
|
|
if (users[user].username != username) {
|
|
|
|
|
|
|
|
str += '<option value="' + users[user].username + '">' + users[user].username + '</option>';
|
|
|
|
|
|
|
|
hasUsers = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
function () {
|
|
|
|
|
|
|
|
$(modalPopupContent).html($('#group-unexpected-error-content').html());
|
|
|
|
|
|
|
|
$("a#group-unexpected-error-link").click(function () {
|
|
|
|
|
|
|
|
hidePopup();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
str += '</select>';
|
|
|
|
});
|
|
|
|
if (!hasUsers) {
|
|
|
|
|
|
|
|
str = "There is no any other users registered";
|
|
|
|
$("a#share-group-unshare-link").click(function () {
|
|
|
|
return;
|
|
|
|
var data = {"shareUser":"", "role":""};
|
|
|
|
}
|
|
|
|
invokerUtil.post(
|
|
|
|
$('#user-names').html(str);
|
|
|
|
unShareGroupApi,
|
|
|
|
$("a#share-group-next-link").show();
|
|
|
|
data,
|
|
|
|
$("a#share-group-next-link").click(function () {
|
|
|
|
|
|
|
|
var selectedUser = $('#share-user-selector').val();
|
|
|
|
|
|
|
|
$(modalPopupContent).html($('#share-group-w2-modal-content').html());
|
|
|
|
|
|
|
|
$('#user-roles').html('Loading...');
|
|
|
|
|
|
|
|
$("a#share-group-yes-link").hide();
|
|
|
|
|
|
|
|
invokerUtil.get("/iotserver/api/group/id/" + groupId + "/" + selectedUser + "/rolemapping",
|
|
|
|
function (data, txtStatus, jqxhr) {
|
|
|
|
function (data, txtStatus, jqxhr) {
|
|
|
|
|
|
|
|
var roleMap = JSON.parse(data);
|
|
|
|
var status = jqxhr.status;
|
|
|
|
var status = jqxhr.status;
|
|
|
|
if (status == 200) {
|
|
|
|
if (status == 200) {
|
|
|
|
|
|
|
|
var str = '';
|
|
|
|
} else {
|
|
|
|
var isChecked = '';
|
|
|
|
displayErrors(status);
|
|
|
|
var hasRoles = false;
|
|
|
|
|
|
|
|
for (var role in roleMap) {
|
|
|
|
|
|
|
|
if (roleMap[role].assigned == true) {
|
|
|
|
|
|
|
|
isChecked = 'checked';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
str += '<label class="checkbox-text"><input type="checkbox" id="user-role-' + roleMap[role].role + '" value="' + roleMap[role].role
|
|
|
|
|
|
|
|
+ '" ' + isChecked + '/>' + roleMap[role].role + '</label> ';
|
|
|
|
|
|
|
|
hasRoles = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasRoles) {
|
|
|
|
|
|
|
|
str = "There is no any roles for this group";
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
$('#user-roles').html(str);
|
|
|
|
function () {
|
|
|
|
$("a#share-group-yes-link").show();
|
|
|
|
$(modalPopupContent).html($('#group-unexpected-error-content').html());
|
|
|
|
$("a#share-group-yes-link").click(function () {
|
|
|
|
$("a#group-unexpected-error-link").click(function () {
|
|
|
|
var updatedRoleMap = [];
|
|
|
|
|
|
|
|
for (var role in roleMap) {
|
|
|
|
|
|
|
|
if ($('#user-role-' + roleMap[role].role).is(':checked') != roleMap[role].assigned){
|
|
|
|
|
|
|
|
roleMap[role].assigned = $('#user-role-' + roleMap[role].role).is(':checked');
|
|
|
|
|
|
|
|
updatedRoleMap.push(roleMap[role]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
invokerUtil.post("/iotserver/api/group/id/" + groupId + "/" + selectedUser + "/roleupdate",
|
|
|
|
|
|
|
|
updatedRoleMap,
|
|
|
|
|
|
|
|
function (data, txtStatus, jqxhr) {
|
|
|
|
|
|
|
|
var status = jqxhr.status;
|
|
|
|
|
|
|
|
if (status == 200) {
|
|
|
|
|
|
|
|
$(modalPopupContent).html($('#share-group-200-content').html());
|
|
|
|
|
|
|
|
$("a#share-group-200-link").click(function () {
|
|
|
|
hidePopup();
|
|
|
|
hidePopup();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
displayErrors(status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}, errorHandler);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$("a#share-group-yes-link").click(function () {
|
|
|
|
displayErrors(status);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, errorHandler);
|
|
|
|
|
|
|
|
$("a#share-group-w2-cancel-link").click(function () {
|
|
|
|
hidePopup();
|
|
|
|
hidePopup();
|
|
|
|
location.reload();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
displayErrors(status);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, errorHandler);
|
|
|
|
|
|
|
|
|
|
|
|
$("a#share-group-cancel-link").click(function () {
|
|
|
|
$("a#share-group-w1-cancel-link").click(function () {
|
|
|
|
hidePopup();
|
|
|
|
hidePopup();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|