Daniel пре 2 година
родитељ
комит
e1d3886b83
4 измењених фајлова са 87 додато и 18 уклоњено
  1. +32
    -0
      httpdocs/public/assets/js/my-bim-score.js
  2. +31
    -11
      httpdocs/src/Controller/UserController.php
  3. +17
    -0
      httpdocs/src/Entity/DinAsset.php
  4. +7
    -7
      httpdocs/templates/pages/risk_analysis.html.twig

+ 32
- 0
httpdocs/public/assets/js/my-bim-score.js Прегледај датотеку

@@ -2,6 +2,7 @@ $(document).ready(function() {
addUser();
listing();
catalogue();
onChangeDinAsset();
});

// Message Box for alerts
@@ -113,6 +114,37 @@ function listing() {
});
}

function onChangeDinAsset() {
$("#asset").on("change", function(e) {
console.log($("#asset").val());
$.ajax({
url: "/get-benchmark-data",
method: "get",
data: { assetId: $("#asset").val() },
success: function (data) {
$("#cycle").attr({
"min" : data.cycleMin,
"max" : data.cycleMax
}).val(data.cycleRecommended);

$('#bandwidth')
.find('option')
.remove()
.end()
;

for (let i in data.benchmarkValues) {
$('#bandwidth').append('<option value="' + i + '">' + data.benchmarkValues[i] + '</option>');
}
},
error: function (xhr, msg, three) {
messageBox(false, "Fehler bei der Anfrage.");
},
dataType: "json"
});
});
}

let savedCatalogueAnswer,
savedCatalogueNote;
$(document).ready(function() {


+ 31
- 11
httpdocs/src/Controller/UserController.php Прегледај датотеку

@@ -16,8 +16,10 @@ use App\Repository\UserRepository;
use App\Utils\Utils;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
use Twig\Environment;

/**
@@ -25,6 +27,13 @@ use Twig\Environment;
*/
class UserController extends AbstractController
{
private $serializer;

public function __construct(SerializerInterface $serializer)
{
$this->serializer = $serializer;
}

/**
* @Route("/start", name="start")
*/
@@ -73,17 +82,7 @@ class UserController extends AbstractController
$benchmarkValues = [];
if (count($dinAssets) > 0) {
$initialDinAsset = $dinAssets[0];
$benchmarks = $initialDinAsset->getBenchmarks();
/** @var DinAssetBenchmark $benchmark */
foreach ($benchmarks as $benchmark) {
$value = $benchmark->getComponent() ? $benchmark->getComponent() . " | " : "";
$value.= $benchmark->getType() ? $benchmark->getType() . " | " : "";
$value.= $benchmark->getBandwidth() ? $benchmark->getBandwidth() . " | " : "";
if (substr($value, -3) === " | ") {
$value = rtrim($value, " | ");
}
$benchmarkValues[$benchmark->getId()] = $value;
}
$benchmarkValues = $initialDinAsset->getBenchMarkSelectValues();
}

return $this->render('pages/risk_analysis.html.twig',
@@ -98,6 +97,27 @@ class UserController extends AbstractController
}


/**
* @Route("/get-benchmark-data", name="get_benchmark_data")
*/
public function getAsset(Request $request)
{
$assetId = $request->query->get('assetId');
/** @var DinAsset $dinAsset */
$dinAsset = $this->getDoctrine()->getRepository(DinAsset::class)->find($assetId);

if (null === $dinAsset) {
return new JsonResponse(null, JsonResponse::HTTP_BAD_REQUEST);
}

$res = [];
$res['cycleRecommended'] = $dinAsset->getCycleMonthsRecommended();
$res['cycleMin'] = $dinAsset->getCycleMonthsMin();
$res['cycleMax'] = $dinAsset->getCycleMonthsMax();
$res['benchmarkValues'] = $dinAsset->getBenchMarkSelectValues();
return $this->json($res);
}

/**
* @Route("/download", name="download")
*


+ 17
- 0
httpdocs/src/Entity/DinAsset.php Прегледај датотеку

@@ -180,4 +180,21 @@ class DinAsset
$this->benchmarks = $benchmarks;
}

public function getBenchMarkSelectValues(): array
{
$benchmarkValues = [];
$benchmarks = $this->getBenchmarks();
/** @var DinAssetBenchmark $benchmark */
foreach ($benchmarks as $benchmark) {
$value = $benchmark->getComponent() ? $benchmark->getComponent() . " | " : "";
$value.= $benchmark->getType() ? $benchmark->getType() . " | " : "";
$value.= $benchmark->getBandwidth() ? $benchmark->getBandwidth() . " | " : "";
if (substr($value, -3) === " | ") {
$value = rtrim($value, " | ");
}
$benchmarkValues[$benchmark->getId()] = $value;
}
return $benchmarkValues;
}

}

+ 7
- 7
httpdocs/templates/pages/risk_analysis.html.twig Прегледај датотеку

@@ -46,17 +46,17 @@
</select>
<label for="cycle">Aktueller Zyklus (in Monaten)</label>
{% if initialDinAsset is not null %}
<input name="cycle" type="number" value="{{ initialDinAsset.cycleMonthsRecommended }}" min="{{ initialDinAsset.cycleMonthsMin }}" max ="{{ initialDinAsset.cycleMonthsMax }}">
<input name="cycle" type="number" id="cycle" value="{{ initialDinAsset.cycleMonthsRecommended }}" min="{{ initialDinAsset.cycleMonthsMin }}" max ="{{ initialDinAsset.cycleMonthsMax }}">
{% else %}
<input name="cycle" type="number" disabled>
<input name="cycle" type="number" id="cycle" disabled>
{% endif %}

<label for="bandwidth">Bandbreite Anlage</label>
<select name="bandwidth" id="bandwidth">
{% for key, benchmarkValue in benchmarkValues %}
<option value="{{ key }}">{{ benchmarkValue }}</option>
{% endfor %}
</select>
<select name="bandwidth" id="bandwidth">
{% for key, benchmarkValue in benchmarkValues %}
<option value="{{ key }}">{{ benchmarkValue }}</option>
{% endfor %}
</select>

</form>
{% endblock %}

Loading…
Откажи
Сачувај