Skip to content
Snippets Groups Projects
Verified Commit e9e78894 authored by Damien's avatar Damien
Browse files

FEAT #6986 getHistories when clicking

parent 45e33d05
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@
<a data-toggle="modal" data-target="#manageAbs" id="redirectBasketCard"><i class="fa fa-share"></i> {{lang.manageAbsences}} </a>
</li>
<li style="cursor: pointer">
<a data-toggle="modal" data-target="#manageHistory"><i class="fa fa-history"></i> {{lang.history}} </a>
<a data-toggle="modal" data-target="#manageHistory" (click)="getHistories()"><i class="fa fa-history"></i> {{lang.history}} </a>
</li>
<li style="cursor: pointer">
<a (click)="askRedirectBasket()" ><i class="fa fa-user-times"></i> Activer mon absence </a>
......@@ -337,8 +337,8 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">{{lang.history}}</h4>
</div>
<div class="modal-body">
<table id="historyTable" class="table table-hover table-condensed" [md2Data]="user.histories" #md2="md2DataTable" [sortBy]='event_date' [rowsPerPage]="10">
<div class="modal-body" style="height: 70vh">
<table id="historyTable" class="table table-hover table-condensed" [md2Data]="histories" #md2="md2DataTable" [sortBy]='event_date' [rowsPerPage]="10">
<thead>
<tr>
<td>
......
......@@ -23,6 +23,7 @@ var ProfileComponent = /** @class */ (function () {
this.user = {
baskets: []
};
this.histories = [];
this.passwordModel = {
currentPassword: "",
newPassword: "",
......@@ -387,6 +388,17 @@ var ProfileComponent = /** @class */ (function () {
});
}
};
ProfileComponent.prototype.getHistories = function () {
var _this = this;
if (this.histories.length == 0) {
this.http.get(this.coreUrl + 'rest/histories/users/' + this.user.id)
.subscribe(function (data) {
_this.histories = data.histories;
}, function (err) {
_this.notify.error(err.error.errors);
});
}
};
ProfileComponent.prototype.onSubmit = function () {
var _this = this;
this.http.put(this.coreUrl + 'rest/currentUser/profile', this.user)
......
......@@ -24,6 +24,7 @@ export class ProfileComponent implements OnInit {
user : any = {
baskets : []
};
histories : any[] = [];
passwordModel : any = {
currentPassword : "",
newPassword : "",
......@@ -420,6 +421,17 @@ export class ProfileComponent implements OnInit {
}
}
getHistories() {
if (this.histories.length == 0) {
this.http.get(this.coreUrl + 'rest/histories/users/' + this.user.id)
.subscribe((data : any) => {
this.histories = data.histories;
}, (err) => {
this.notify.error(err.error.errors);
});
}
}
onSubmit() {
this.http.put(this.coreUrl + 'rest/currentUser/profile', this.user)
.subscribe(() => {
......
......@@ -225,6 +225,7 @@ $app->delete('/priorities/{id}', \Core\Controllers\PriorityController::class . '
//History
$app->get('/administration/history/eventDate/{date}', \History\controllers\HistoryController::class . ':getForAdministration');
$app->get('/histories/users/{userSerialId}', \History\controllers\HistoryController::class . ':getByUserId');
//HistoryBatch
$app->get('/administration/historyBatch/eventDate/{date}', \History\controllers\HistoryController::class . ':getBatchForAdministration');
......
......@@ -130,6 +130,18 @@ class HistoryController
]);
}
public function getByUserId(Request $request, Response $response, array $aArgs)
{
$user = UserModel::getById(['id' => $aArgs['userSerialId'], 'select' => ['user_id']]);
if ($user['user_id'] != $GLOBALS['userId'] && !ServiceModel::hasService(['id' => 'view_history', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
$aHistories = HistoryModel::getByUserId(['userId' => $user['user_id'], 'select' => ['info', 'event_date']]);
return $response->withJson(['histories' => $aHistories]);
}
public function getForAdministration(Request $request, Response $response, array $aArgs)
{
if (!ServiceModel::hasService(['id' => 'view_history', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment