Skip to content

Commit

Permalink
Merge pull request #60 from katmastt/main
Browse files Browse the repository at this point in the history
Add new filter parameter (expiry) in all_projects view
  • Loading branch information
eleni-adamidi authored Oct 17, 2023
2 parents 23960f9 + 630a664 commit 8f62872
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
12 changes: 6 additions & 6 deletions controllers/AdministrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,9 @@ public function actionAllProjects()

$deleted=Project::getAllDeletedProjects();

$filters=['user'=>Yii::$app->request->post('username',''), 'type'=>Yii::$app->request->post('project_type','-1')];
$all_projects=Project::getAllActiveProjectsAdm($filters['user'],$filters['type']);
$expired_owner=Project::getAllExpiredProjects($filters['user'],$filters['type']);
$filters=['exp'=>Yii::$app->request->post('expiry_date_t','-1'),'user'=>Yii::$app->request->post('username',''), 'type'=>Yii::$app->request->post('project_type','-1')];
$all_projects=Project::getAllActiveProjectsAdm($filters['user'],$filters['type'],$filters['exp']);
$expired_owner=Project::getAllExpiredProjects($filters['user'],$filters['type'],$filters['exp']);
$resources=Project::getActiveResources();
$role=User::getRoleType();
$username=Userw::getCurrentUser()['username'];
Expand Down Expand Up @@ -669,12 +669,12 @@ public function actionAllProjects()
$number_of_active=count($all_projects);
$number_of_expired=count($expired);

$types_dropdown=['-1'=>'','0'=>'On-demand batch computations', '1'=>'24/7 Services', '2'=>'Storage volumes', '3'=>'On-demand computation machines'];

$types_dropdown=['-1'=>'','0'=>'On-demand batch computations', '1'=>'24/7 Services', '2'=>'Storage volumes', '3'=>'On-demand computation machines', '4'=>'On demand notebooks'];
$expiry_date = ['-1'=>'','0'=>'Ascending', '1'=>'Descending'];
return $this->render('all_projects',['button_links'=>$button_links,
'project_types'=>$project_types,'role'=>$role, 'types_dropdown'=>$types_dropdown, 'filters'=>$filters,
'deleted'=>$deleted,'expired'=>$expired, 'active'=>$active, 'number_of_active'=>$number_of_active,
'number_of_expired'=>$number_of_expired, 'schema_url'=>$schema_url, 'active_resources'=>$resources]);
'number_of_expired'=>$number_of_expired, 'schema_url'=>$schema_url, 'active_resources'=>$resources, 'expiry_date'=>$expiry_date]);
}

public function actionManageAnalytics()
Expand Down
22 changes: 20 additions & 2 deletions models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public static function getAllDeletedProjects()

}

public static function getAllExpiredProjects($user='',$type='-1')
public static function getAllExpiredProjects($user='',$type='-1',$exp='-1')
{
$query=new Query;

Expand All @@ -477,6 +477,15 @@ public static function getAllExpiredProjects($user='',$type='-1')
{
$query->andWhere("p.project_type=$type");
}
if (intval($exp)==1){

$query->orderBy('pr.end_date DESC');

}
if (intval($exp)==0){

$query->orderBy('pr.end_date ASC');
}
$results=$query->all();


Expand Down Expand Up @@ -542,7 +551,7 @@ public static function getActiveResources()
return [$active_jupyter, $active_vms, $active_machines, $active_volumes];
}

public static function getAllActiveProjectsAdm($user='',$type='-1')
public static function getAllActiveProjectsAdm($user='',$type='-1', $exp='-1')
{
$query=new Query;
$date=date("Y-m-d");
Expand All @@ -566,6 +575,15 @@ public static function getAllActiveProjectsAdm($user='',$type='-1')
{
$query->andWhere("p.project_type=$type");
}
if (intval($exp)==1){

$query->orderBy('pr.end_date DESC');

}
if (intval($exp)==0){

$query->orderBy('pr.end_date ASC');
}

$results=$query->all();
return $results;
Expand Down
13 changes: 13 additions & 0 deletions views/administration/all_projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,19 @@

<div class="row">&nbsp;</div>

<div class="row">
<div class="col-md-12 text-center">
<?=Html::label('By expiration date:')?>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<?=Html::dropDownList('expiry_date_t',$filters['exp'],$expiry_date,['class'=>'expiry_date','id'=>'expiry_date'])?>
</div>
</div>

<div class="row">&nbsp;</div>


<?=Html::endForm()?>
</div>
Expand Down
4 changes: 4 additions & 0 deletions web/js/administration/all_projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ $(document).ready(function(){
$('#filters-form').submit();
});

$("#expiry_date").change(function(){
$('#filters-form').submit();
});

$(".reactivate_btn").click(function(){
var modal_id='#' + $(this).data()['modalId'];

Expand Down

0 comments on commit 8f62872

Please sign in to comment.