adds placeholders for the ampeln and adds new endpoints that fetch activeAmpeln and confirmedActiveAmpeln of the user

This commit is contained in:
SimonGschnell
2024-07-23 13:59:04 +02:00
parent 7e983292ea
commit 1211d63ccf
3 changed files with 114 additions and 9 deletions
@@ -27,7 +27,9 @@ class Ampeln extends FHCAPI_Controller
public function __construct()
{
parent::__construct([
'getAmpeln' => self::PERM_LOGGED,
'getNonConfirmedActiveAmpeln' => self::PERM_LOGGED,
'getAllActiveAmpeln' => self::PERM_LOGGED,
'getConfirmedActiveAmpeln' => self::PERM_LOGGED,
]);
@@ -50,7 +52,7 @@ class Ampeln extends FHCAPI_Controller
* @access public
*
*/
public function getAmpeln()
public function getNonConfirmedActiveAmpeln()
{
$userAmpeln = array();
$ampel_result = $this->AmpelModel->active();
@@ -79,6 +81,59 @@ class Ampeln extends FHCAPI_Controller
$this->terminateWithSuccess($userAmpeln);
}
public function getAllActiveAmpeln()
{
$userAmpeln = array();
$ampel_result = $this->AmpelModel->active();
$ampel_result = $this->getDataOrTerminateWithError($ampel_result);
foreach($ampel_result as $ampel){
$userUID_array = $this->AmpelModel->execBenutzerSelect($ampel->benutzer_select);
$userUID_array = $this->getDataOrTerminateWithError($userUID_array);
foreach($userUID_array as $user_obj){
$user_uid = property_exists($user_obj,"uid") ? $user_obj->uid : $user_obj->mitarbeiter_uid;
if($user_uid === $this->uid){
$userAmpeln[] = $ampel;
}
}
}
$this->terminateWithSuccess($userAmpeln);
}
public function getConfirmedActiveAmpeln()
{
$userAmpeln = array();
$ampel_result = $this->AmpelModel->active();
$ampel_result = $this->getDataOrTerminateWithError($ampel_result);
$is_confirmed_array = array();
foreach($ampel_result as $ampel){
$confirmedByUser = $this->AmpelModel->isConfirmed($ampel->ampel_id,$this->uid);
if($confirmedByUser){
$userUID_array = $this->AmpelModel->execBenutzerSelect($ampel->benutzer_select);
$userUID_array = $this->getDataOrTerminateWithError($userUID_array);
foreach($userUID_array as $user_obj){
$user_uid = property_exists($user_obj,"uid") ? $user_obj->uid : $user_obj->mitarbeiter_uid;
if($user_uid === $this->uid){
$userAmpeln[] = $ampel;
}
}
}
}
$this->terminateWithSuccess($userAmpeln);
}
}
+16 -2
View File
@@ -1,10 +1,24 @@
export default {
getAmpeln: function () {
getNonConfirmedActiveAmpeln: function () {
return this.$fhcApi.get(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
FHC_JS_DATA_STORAGE_OBJECT.ci_router +
`/api/frontend/v1/Ampeln/getAmpeln`,{});
`/api/frontend/v1/Ampeln/getNonConfirmedActiveAmpeln`,{});
},
getAllActiveAmpeln: function () {
return this.$fhcApi.get(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
FHC_JS_DATA_STORAGE_OBJECT.ci_router +
`/api/frontend/v1/Ampeln/getAllActiveAmpeln`,{});
},
getConfirmedActiveAmpeln: function () {
return this.$fhcApi.get(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
FHC_JS_DATA_STORAGE_OBJECT.ci_router +
`/api/frontend/v1/Ampeln/getConfirmedActiveAmpeln`,{});
},
}
+41 -5
View File
@@ -7,7 +7,7 @@ export default {
data: () => ({
filter: '',
source: '',
ampeln: []
ampeln: [],
}),
mixins: [
AbstractWidget
@@ -76,13 +76,33 @@ export default {
return buttontext == null ? 'Bestätigen' : buttontext;
}
},
created() {
async created() {
let temporary_ampeln=null;
let temporary_confirmedAmpeln=null;
await this.$fhcApi.factory.ampeln.getAllActiveAmpeln().then(res=>{
temporary_ampeln = res.data;
});
await this.$fhcApi.factory.ampeln.getConfirmedActiveAmpeln().then(res=>{
temporary_confirmedAmpeln = res.data;
});
/* this.ampeln = temporary_ampeln.filter((ampel)=>{
if(temporary_confirmedAmpeln.some((confirmedAmpel)=> confirmedAmpel.ampel_id === ampel.ampel_id)){
return false;
}
return true;
});
*/
this.$emit('setConfig', false);
this.ampeln = TEST_OFFENE_AMPELN;
},
template: `
template: /*html*/`
<div class="widgets-ampel w-100 h-100">
<div class="d-flex flex-column justify-content-between">
<div v-if="ampeln" class="d-flex flex-column justify-content-between">
<div class="d-flex">
<header class="me-auto"><b>Neueste Ampeln</b></header>
<div class="mb-2 text-danger"><a href="#allAmpelOffcanvas" data-bs-toggle="offcanvas">Alle Ampeln</a></div>
@@ -105,12 +125,28 @@ export default {
</div>
</div>
</div>
<div v-if="ampeln.length == 0" class="card card-body mt-4 p-4 text-center">
<span class="text-success h2"><i class="fa fa-solid fa-circle-check"></i></span>
<span class="text-success h5">Super!</span><br>
<span class="small">Keine offenen Ampeln.</span>
</div>
</div>
<div v-else>
<header class="me-auto"><b>Neueste Ampeln</b></header>
<template v-for="n in 4">
<div class="mt-2 card" aria-hidden="true">
<div class="card-body">
<p class="card-text placeholder-glow">
<span class="placeholder col-7"></span>
<span class="placeholder col-12"></span>
</p>
</div>
</div>
</template>
</div>
</div>
<!-- All Ampeln Offcanvas -->