Commit 3381f264 authored by Mathieu Pionnier's avatar Mathieu Pionnier
Browse files

fix/15333 : query on search account

parent 3a7e31ae
Pipeline #10237 failed with stages
in 50 seconds
......@@ -73,18 +73,19 @@ class serviceAccount
/**
* List all service to display
*
* @param integer $maxResults Max result number to return
* @param string $accountName Name of account
* @param integer $maxResults Max result number to return
*
* @return array The array of stdClass with dislpay name and service identifier
*/
public function search($maxResults = null)
public function search($accountName = null, $maxResults = null)
{
$serviceAccounts = $this->sdoFactory->find('auth/account', $this->getSearchQuery(), null, false, false, $maxResults);
$serviceAccounts = $this->sdoFactory->find('auth/account', $this->getSearchQuery($accountName), null, false, false, $maxResults);
return $serviceAccounts;
}
public function getSearchQuery()
public function getSearchQuery($accountName = null)
{
$accountId = \laabs::getToken("AUTH")->accountId;
$account = $this->sdoFactory->read("auth/account", array("accountId" => $accountId));
......@@ -94,6 +95,10 @@ class serviceAccount
$queryAssert = [];
$queryAssert[] = "accountType='service'";
if (!is_null($accountName) && $accountName != "null") {
$queryAssert[] = "accountName~'*$accountName*'";
}
if ($this->hasSecurityLevel) {
switch ($account->getSecurityLevel()) {
case $account::SECLEVEL_GENADMIN:
......@@ -124,23 +129,11 @@ class serviceAccount
return \laabs\implode(" AND ", $queryAssert);
}
public function searchCount()
public function searchCount($accountName = null)
{
$count = $this->sdoFactory->count('auth/account', $this->getSearchQuery());
return $count;
}
$count = $this->sdoFactory->count('auth/account', $this->getSearchQuery($accountName));
/** Get a service account object
*
* @param id $serviceAccountName The user unique identifier
*
* @return auth/account The service account object
*/
public function searchServiceAccountsByQuery($serviceAccountName)
{
$maxResults = 200;
return $this->sdoFactory->find("auth/account", "accountType = 'service'", $maxResults);
return $count;
}
/**
......
......@@ -36,21 +36,23 @@ interface serviceAccountInterface
/**
* List the service account detail
*
* @param integer $maxResults
*
* @param string $accountName Name of account
* @param integer $maxResults Limit of result display
*
* @action auth/serviceAccount/search
*/
public function readSearch($maxResults = null);
public function readSearch($accountName = null, $maxResults = null);
/**
* List the service account detail
*
* @param integer $maxResults
* @param string $accountName Name of account
* @param integer $maxResults Limit of result display
*
* @action auth/serviceAccount/searchCount
*/
public function readSearchCount($maxResults = null);
public function readSearchCount($accountName = null, $maxResults = null);
/**
* Prepare an empty service Account object
......
......@@ -2336,23 +2336,6 @@ output {
-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
}
.searchBar {
width: 90%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555555;
background-color: #ffffff;
background-image: none;
border: 1px solid #cccccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
}
.form-control:focus {
border-color: #23aae5;
outline: 0;
......
......@@ -6,66 +6,54 @@
<i class="fa fa-laptop"></i>
Manage service account
</h1>
<input type="text" class="searchBar" id="serviceAccount_search" name="serviceAccount" placeholder="Service account search"/>
<button type="button" class="btn btn-primary" id="searchServiceAccount" title="Search"><i class="fa fa-search">&nbsp;</i>Search</button>
<div class="form-group">
<div class="col-sm-6" style="padding-left: 0px;">
<div class="col-md-9" style="padding-left: 0px;">
<input type="text" class="form-control" id="serviceAccountSearch" name="serviceAccountSearch" placeholder="Service account search"/>
</div>
<button type="button" class="btn btn-primary" id="searchServiceAccount" title="Search"><i class="fa fa-search">&nbsp;</i>Search</button>
</div>
</div>
</div>
</div>
<div id="listServiceAccounts"></div>
</div>
<script type="application/javascript">
//index service account
$.ajax({
url : "/serviceaccountslist?maxResults="+$("#maxResults").val(),
type : "GET",
success : function(response){
$("#listServiceAccounts").html(response);
},
error : function(response) {
console.log("error");
//search
var serviceAccounts = {
"search" : function(accountName = null) {
var params;
var accountName = "accountName=" + accountName;
var maxResults = "maxResults=" + $("#maxResults").val();
params = "?" + accountName + "&" + maxResults;
$.ajax({
url : "/serviceaccountslist" + params,
type : "GET",
success : function(response){
$("#listServiceAccounts").empty().html(response);
},
error : function(response) {
console.log("error");
}
})
}
});
}
//add
$("#addServiceAccount").on("click", function(){
load("/serviceAccount");
});
//edit
$("#list-serviceAccount").on('click', '.edit', function() {
var serviceAccountId = $(this).closest('tr').attr('id');
load("/serviceAccount/"+serviceAccountId);
});
//enable
$("#list-serviceAccount").on('click', '.enable', function() {
$.ajax({
url : "/serviceAccount/" + $(this).closest('tr').attr("id")+ '/enable',
type : "PUT",
dataType : "json",
success : function(response){
gritter.show(response.message, response.status, response.errors);
load("/serviceAccounts");
},
error : function(response) {
gritter.show(response.responseJSON.message, response.responseJSON.status, response.responseJSON.errors);
}
});
$("#serviceAccountSearch").val('');
$('#serviceAccountSearch').keyup(function(e){
if(e.keyCode == 13)
{
console.log(this.value);
serviceAccounts.search(this.value);
}
});
//disable
$("#list-serviceAccount").on('click', '.disable', function() {
$.ajax({
url : "/serviceAccount/" + $(this).closest('tr').attr('id')+ "/disable",
type : "PUT",
dataType : "json",
success : function(response){
gritter.show(response.message, response.status, response.errors);
load("/serviceAccounts");
},
error : function(response) {
gritter.show(response.responseJSON.message, response.responseJSON.status, response.responseJSON.errors);
}
});
serviceAccounts.search();
$("#searchServiceAccount").on("click", function() {
serviceAccounts.search($("#serviceAccountSearch").val());
});
</script>
......@@ -62,3 +62,49 @@
</div>
</div>
<script type="application/javascript">
//add
$("#addServiceAccount").on("click", function(){
load("/serviceAccount");
});
//edit
$("#list-serviceAccount").on('click', '.edit', function() {
var serviceAccountId = $(this).closest('tr').attr('id');
load("/serviceAccount/"+serviceAccountId);
});
//enable
$("#list-serviceAccount").on('click', '.enable', function() {
$.ajax({
url : "/serviceAccount/" + $(this).closest('tr').attr("id")+ '/enable',
type : "PUT",
dataType : "json",
success : function(response){
gritter.show(response.message, response.status, response.errors);
load("/serviceAccounts");
},
error : function(response) {
gritter.show(response.responseJSON.message, response.responseJSON.status, response.responseJSON.errors);
}
});
});
//disable
$("#list-serviceAccount").on('click', '.disable', function() {
$.ajax({
url : "/serviceAccount/" + $(this).closest('tr').attr('id')+ "/disable",
type : "PUT",
dataType : "json",
success : function(response){
gritter.show(response.message, response.status, response.errors);
load("/serviceAccounts");
},
error : function(response) {
gritter.show(response.responseJSON.message, response.responseJSON.status, response.responseJSON.errors);
}
});
});
</script>
......@@ -39,14 +39,15 @@ interface adminServiceaccountInterface
/**
* List service accounts list with max results
*
* @param integer $maxResult
* @param string $accountName Name of account
* @param integer $maxResult Limit of result display
*
* @uses auth/serviceAccount/readSearch
* @uses auth/serviceAccount/readSearchCount
*
* @return auth/serviceAccount/accountList
*/
public function readServiceaccountslist($maxResults = null);
public function readServiceaccountslist($accountName = null, $maxResults = null);
/**
* Get a service account
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment