From 163c048de6a81e12b05c86e39239377f9c0305fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=B0=D0=B3=D0=BB=D0=B8=D0=B9=20=D0=90=D0=BD=D1=82?= =?UTF-8?q?=D0=BE=D0=BD=20=D0=9F=D0=B0=D0=B2=D0=BB=D0=BE=D0=B2=D0=B8=D1=87?= <bagliy_ap@studzone.local> Date: Fri, 31 Aug 2018 23:11:14 +0300 Subject: [PATCH] ADD: error content in web interface for failed syncs #297 --- media/js/office/sync.js | 15 +++++++------ .../classes/Controller/Office/Sync.php | 1 + .../application/views/office/sync.twig | 22 ++++++++++++++++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/media/js/office/sync.js b/media/js/office/sync.js index dc51e4e90..def414a4b 100644 --- a/media/js/office/sync.js +++ b/media/js/office/sync.js @@ -1,12 +1,13 @@ "use strict"; $(document).ready(()=>{ - //const pathToSfeduAPIAdapter = $('#sync_api_url').html(); - const pathToSfeduAPIAdapter = 'http://localhost:3000/'; + const pathToSfeduAPIAdapter = $('#sync_api_url').html().trim(); + //const pathToSfeduAPIAdapter = 'http://localhost:3000/'; //$('#syncInnerDepartments').click(()=>{ // $.get(pathToSfeduAPIAdapter + 'subdivisions/inner'); //}); + function parseLogs() { let $logs = $('#json_logs'); @@ -16,11 +17,11 @@ $(document).ready(()=>{ //let logs = parseLogs(); - //$('.syncErrorMessage').click(()=>{ - // const rowIndex = $(this).parent().index(); - // var opened = window.open(""); - // opened.document.write(logs[rowIndex].content); - //}); + $('.syncErrorMessage').click(function() { + const rowIndex = $( this ).parent().parent().index(); + var opened = window.open(""); + opened.document.write($("#message_"+rowIndex).html()); + }); $('#syncDepartments').click(()=>{ $.get(pathToSfeduAPIAdapter + 'subdivisions'); diff --git a/~dev_rating/application/classes/Controller/Office/Sync.php b/~dev_rating/application/classes/Controller/Office/Sync.php index dc5090909..8b0630f09 100644 --- a/~dev_rating/application/classes/Controller/Office/Sync.php +++ b/~dev_rating/application/classes/Controller/Office/Sync.php @@ -40,6 +40,7 @@ class Controller_Office_Sync extends Controller_Environment_Office $date = new DateTime($item->timestamp, new DateTimeZone('UTC')); $date->setTimezone(new DateTimeZone('MSK')); $item->localTimestamp = $date->format('Y-m-d H:i:s'); + $item->content = json_encode($item->content); } return $decoded; diff --git a/~dev_rating/application/views/office/sync.twig b/~dev_rating/application/views/office/sync.twig index 2a5aa2e8d..6e5e44da5 100644 --- a/~dev_rating/application/views/office/sync.twig +++ b/~dev_rating/application/views/office/sync.twig @@ -4,6 +4,7 @@ {% block title %}Синхронизация данных сБРС с 1С:Университет ЮФУ{% endblock %} {% block office_media %} + {{ HTML.script('static/js/libs/jquery.fileDownload.js')|raw }} {{ HTML.style('static/css/office/list.css')|raw }} {{ HTML.style('static/css/admin/sync.css')|raw }} {{ HTML.script('static/js/office/sync.js')|raw }} @@ -172,12 +173,27 @@ </div> + {# <div id="json_logs" style="display: none"> {{ log|json_encode|raw }} </div> + #} + + <div id = "html_errors"> + {% set messageNumber = 0 %} + {% for line in log %} + <div id="message_{{ messageNumber }}" style="display: none;"> + {% if line.success %} + {{ line.message }} + {% else %} + {{ line.content }} + {% endif %} + </div> + {% set messageNumber = messageNumber + 1 %} + {% endfor %} + </div> - {# TODO: передать адрес демона в js здесь #} - {# <div id="sync_api_url" style="display: none"> + <div id="sync_api_url" style="display: none"> {{ api_url }} - </div> #} + </div> {% endblock %} -- GitLab