{"id":295565,"date":"2019-12-17T16:19:47","date_gmt":"2019-12-17T16:19:47","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=295565"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=295565","title":{"rendered":"ExtJS 7 \u0438 Spring Boot 2. \u041a\u0430\u043a \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c SPA, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0441 \u0432\u0430\u0448\u0438\u043c API \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 ReactJS \u043f\u043b\u0430\u0433\u0438\u043d\u0430\u043c\u0438?"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/479676\/\">\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 Ext JS, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e Modern Toolkit \u0441\u043d\u0438\u0437\u0438\u043b\u0438 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0432\u043e \u0432\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a (\u043f\u0440\u0438\u043c\u0435\u0440\u044b Kitchen Sink), \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 (\u043f\u0440\u0438\u0432\u0435\u0442 Sencha Architect) \u0438 \u0434\u043e\u0431\u0438\u043b\u0438\u0441\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 (Sencha Cmd).<\/p>\n<p>  \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u0425\u0430\u0431\u0440 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u00ab\u0441\u0438\u0442\u0443\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0446\u0435\u043d\u0442\u0440\u0430\u00bb, \u0433\u0434\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u043a\u0430\u043c\u0435\u0440\u044b \u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0441 \u043d\u0438\u0445 (\u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0435\u0439\u043a\u043e\u0432\u044b\u0435).<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ic\/yg\/pv\/icygpvzc4tbfn9jon93q78z2u-w.png\"><br \/>  <a name=\"habracut\"><\/a><br \/>  \u041d\u0430\u0447\u043d\u0435\u043c. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c Spring Boot \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 2 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043a\u0430\u043c\u0435\u0440, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 \u043d\u0430 \u043d\u043e\u0432\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f (\u0447\u0435\u0440\u0435\u0437 WebSocket). <br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qz\/gq\/y5\/qzgqy5rj1yiovuxbeiej7xjdmas.png\"><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u0432\u044c\u044e\u0448\u043a\u0438 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dr\/aw\/xb\/drawxbnnfe07zwday70x3xdf1q0.png\"><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0411\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0432\u044c\u044e\u0448\u043a\u0430 \u043a\u0430\u0440\u0442\u044b, \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0441 React \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c \u043a\u0430\u0440\u0442\u044b.<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">Ext.define('Cameras.view.override.Map', {     override: 'Cameras.view.Map',          config: {         cameras: {},         react: null     },          initialize: function() {         let that = this;         let e = React.createElement;                  this.setReact(ReactDOM.render(e(createReactClass({             getInitialState: function() {                 return { items: [], center: [55.751574, 37.573856]};             },             render: function() {                 let placemarks = [];                  for(let i=0; i &lt; this.state.items.length; i++) {                     let location = this.state.items[i].get(\"location\");                      placemarks.push(e(window.ReactYandexMaps.Placemark, {                         geometry: [location.latitude, location.longitude],                             options: {                                 preset: 'islands#blueCircleDotIconWithCaption',                                 iconCaptionMaxWidth: '50'                             }                         }));                 }                           let map = e(window.ReactYandexMaps.Map, {                     state: { center: this.state.center, zoom: 10 },                     width: '100%',                     height: '100%'                 }, placemarks);                  return e(window.ReactYandexMaps.YMaps, null, map);             }         })), this.mapContainer.dom));     },          getElementConfig: function() {         return {             reference: 'element',             className: 'x-container',             children: [{                 reference: 'bodyElement',                 style: 'width: 100%; height: 100%',                 className: 'x-inner',                 children: [{                     style: 'width: 100%; height: 100%',                     reference: 'mapContainer',                     className: Ext.baseCSSPrefix + 'map-container'                 }]             }]         };     },          addCamera: function(cameraModel) {             if(!this.containsCamera(cameraModel)) {             this.getCameras()[cameraModel.get(\"id\")] = cameraModel;                          this.getReact().setState({                 items: Object.values(this.getCameras())             });                          this.fitCamera(cameraModel);         }     },          removeCamera: function(cameraModel) {         if(this.containsCamera(cameraModel)) {             delete this.getCameras()[cameraModel.get(\"id\")];                          this.getReact().setState({                 items: Object.values(this.getCameras())             });         }     },          fitCamera: function(cameraModel) {         if(this.containsCamera(cameraModel)) {             let location = this.getCameras()[cameraModel.get(\"id\")].get(\"location\");                          this.getReact().setState({                 center: [location.latitude, location.longitude]             });         }     },          privates: {         containsCamera: function(cameraModel) {             cameraId = \"\" + cameraModel.get(\"id\");                      return Object.keys(this.getCameras()).includes(cameraId);         }     } });<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 CamerasGrid, \u0442.\u043a. \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043c\u0435\u0440 \u0441 \u043a\u0430\u0440\u0442\u044b. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 CamerasGrid, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">Ext.define('Cameras.view.CamerasGridViewController', {     extend: 'Ext.app.ViewController',     alias: 'controller.camerasgrid',      init: function() {         let socket = new WebSocket(\"ws:\/\/localhost:8080\/events\/sub\");          socket.onopen = function(e) {             console.log('onopen');         };          socket.onmessage = this.onMessage.bind(this);     },      onMessage: function(event) {         let data = Ext.decode(event.data);          let gridData = this.getView().getStore().getData();          for(let i=0; i &lt; gridData.length; i++) {             let checked = gridData.getAt(i).get(\"checked\");              if(checked !== undefined &amp;&amp; checked) {                 if(gridData.getAt(i).get(\"id\") == data.camera.id) {                     this.fireViewEvent(\"cameraRecognition\", data);                 }             }         }     } });<\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0437\u0430\u043d\u044f\u0442\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441. \u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0434\u0430\u0436\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0433\u043e), \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u043d\u043e\u0433\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u0432\u0435\u043b\u0438\u043a\u043e, \u0434\u043e \u043f\u0430\u0440\u044b \u0447\u0430\u0441\u043e\u0432. <\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/el\/mu\/av\/elmuav_-ihtklpkeqe-vimfnbkk.gif\"><\/p>\n<p>  \u041a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/lampaa\/SituationCenter\">github.com<\/a>.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/479676\/\"> https:\/\/habr.com\/ru\/post\/479676\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/479676\/\">\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 Ext JS, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e Modern Toolkit \u0441\u043d\u0438\u0437\u0438\u043b\u0438 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0432\u043e \u0432\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a (\u043f\u0440\u0438\u043c\u0435\u0440\u044b Kitchen Sink), \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 (\u043f\u0440\u0438\u0432\u0435\u0442 Sencha Architect) \u0438 \u0434\u043e\u0431\u0438\u043b\u0438\u0441\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 (Sencha Cmd).<\/p>\n<p>  \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u0425\u0430\u0431\u0440 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u00ab\u0441\u0438\u0442\u0443\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0446\u0435\u043d\u0442\u0440\u0430\u00bb, \u0433\u0434\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u043a\u0430\u043c\u0435\u0440\u044b \u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0441 \u043d\u0438\u0445 (\u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0444\u0435\u0439\u043a\u043e\u0432\u044b\u0435).<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ic\/yg\/pv\/icygpvzc4tbfn9jon93q78z2u-w.png\">  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-295565","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295565","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=295565"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295565\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=295565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=295565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=295565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}