Loading src/main/resources/static/app-client/main.js 0 → 100644 +66 −0 Original line number Diff line number Diff line require([ 'dijit/form/Button' , 'app-client/task/TasksSelect' , 'dijit/form/Select' , 'dojo/dom' , 'app-client/socket/Socket' , 'app-client/tasks' , 'dojo/domReady!' ], function( Button , TasksSelect , Select , dom , Socket , Tasks ){ var socket = new Socket({ url: '/db2es/socket' }); var connectBtn = new Button({ label: 'Connect', onClick: function(){ socket.connect(); } }, 'connectBtn'); var sendBtn = new TasksSelect({ socket: socket }, 'sendBtn'); /* sendBtn.on('subscribed', function() { console.log('Subscrito'); setTimeout(function() { var listTask = ["citation-job", "animaltracking-job"]; socket.sendByTopic('/topic' + sendBtn.reqChannel, listTask); }, 500); });*/ socket.on('connected', function(url) { console.log('Conectado'); /* socket.subscribe('/topic/greeting', function(message) { console.log('Recibo gretting: ' + message); }); socket.subscribe('/topic/jobs/list', function(message) { console.log('Recibo jobs: ' + message); });*/ var tasks = new Tasks({ socket: socket }, 'tasks'); /*socket.subscribe('/topic/jobs/list', function(message) { console.log('Recibo jobs: ' + message); });*/ }); }); No newline at end of file src/main/resources/static/app-client/socket/Socket.js 0 → 100644 +68 −0 Original line number Diff line number Diff line define([ 'dojo/_base/declare' , 'dojo/_base/lang' , 'dojo/Evented' , 'sockjs' , 'stomp' ], function( declare , lang , Evented , SockJS , Stomp ){ return declare([Evented], { _ws: null, _client: null, url: null, constructor: function(args) { this._subscribes = {}; this._isConnected = false; lang.mixin(this, args); this.on('connect', this._connect); this.on('error', this._error); }, connect: function() { this.emit(this.url ? 'connect' : 'error', this.url); }, isConnected: function() { return this._isConnected; }, subscribe: function(channel, callback) { this._subscribes[channel] = callback; this._client.subscribe(channel, function(message) { console.debug('SUBSCRIBE', channel, message); message.body = JSON.parse(message.body); callback(message); }); }, send: function(channel, message) { console.debug('SEND', channel, message); this._client.send(channel, {}, JSON.stringify(message)); }, _connect: function() { this._ws = new SockJS(this.url); this._client = window.Stomp.over(this._ws); this._client.connect({}, lang.hitch(this, this._connected)); }, _connected: function() { this._isConnected = true; this.emit('connected', this); }, _error: function(url) { console.error('ERROR'); } }); }); No newline at end of file src/main/resources/static/app-client/socket/SocketMock.js 0 → 100644 +30 −0 Original line number Diff line number Diff line define([ 'dojo/_base/declare' , 'dojo/_base/lang' , 'app-client/socket/Socket' ], function( declare , lang , Socket ){ return declare([Socket], { subscribe: function(channel, callback) { this._subscribes[channel] = callback; }, sendByTopic: function(channel, message) { this._subscribes[channel] && this._subscribes[channel](message); }, send: function(channel, message) { console.log('Send', channel, message); }, _connect: function() { console.log('Connect'); setTimeout(lang.hitch(this, this._connected), 500); } }); }); No newline at end of file src/main/resources/static/app-client/task/TasksSelect.js 0 → 100644 +144 −0 Original line number Diff line number Diff line define([ 'dojo/_base/declare' , 'dojo/_base/lang' , 'dojo/on' , 'dojo/Evented' , 'dojo/dom-construct' , 'dijit/_WidgetBase' , 'dijit/form/Select' , 'dijit/form/Button' ], function( declare , lang , on , Evented , domConstruct , _Widget , Select , Button ){ return declare([_Widget, Evented], { socket: null, reqChannel: '/jobs/list', url: null, jobsList: null, constructor: function(args) { this._subscriptions = {}; this.i18n = { "indexing-animalTracking-job": "Tracking de animales", "indexing-platformTracking-job": "Tracking de plataformas", "indexing-citation-job": "Citas corológicas", "indexing-timeseriesSurvey-job": "Estaciones fijas con series temporales", "indexing-timeSeries-job": "Series temporales", "indexing-attributeSeries-job": "Series de atributo de Infrastructuras", "indexing-isolines-job": "Isolíneas", "indexing-area-job": "Áreas", "indexing-objectCollectingSurvey-job": "Indexar object survey", "indexing-objectCollectingseries-job": "Serie de colección de objetos", "indexing-infrastructure-job": "Infrastructuras", "indexing-administrativeDomains-job": "Dominios de administración", "indexing-document-job": "Indexar documentos", "indexing-classificationsDomains-job": "Dominios de clasificación", "indexing-parametersDomains-job": "Dominios de parámetros", "indexing-qualityDomains-job": "Dominios de calidad de los datos", "indexing-qualifyDomains-job": "Dominios de calificación de objetos", "indexing-taxonomyDomains-job": "Dominios de taxonomía", "indexing-ancillaryDataDomains-job": "Dominios de datos auxiliares", "indexing-toponymias-job": "Toponimias", "indexing-taxonomy-job": "Taxonomía", "indexing-administrative-job": "Administración", "indexing-atlas-job": "Atlas" }; lang.mixin(this, args); }, postCreate: function() { this._createLayout(); this._startSocket(); }, _createLayout: function() { this._selectNode = domConstruct.create('span', null, this.domNode); this._btnNode = domConstruct.create('span', null, this.domNode); }, _startSocket: function(value) { if (this.socket) { this.socket.isConnected() && this._onSocketOpened(); this.socket.on('connected', lang.hitch(this, this._onSocketOpened)); } }, _onSocketOpened: function() { this.emit('socket-opened'); this._onSubscriptions(); }, _onSubscriptions: function() { this.socket.subscribe('/topic' + this.reqChannel, lang.hitch(this, this._onReceivedJobsList)); this.emit('subscribed'); this.socket.send('/app' + this.reqChannel, {}); }, _onReceivedJobsList: function(message) { this.jobsList = this._parseJobsList(message.body); this.emit('received-jobs-list', this.jobsList); this._createSelectJob(); this._createBtnRunJob(); }, _parseJobsList: function(jobsIn) { var jobs = []; for (var i = 0; i < jobsIn.length; i++) { jobs.push({ value: jobsIn[i], label: this.i18n[jobsIn[i]] }); } return jobs; }, _createSelectJob: function() { this._selectWidget = new Select({ name: 'selectJob', options: this.jobsList, style: 'width: 90%' }, this._selectNode); }, _createBtnRunJob: function() { this._btnWidget = new Button({ onClick: lang.hitch(this, this._runJob), iconClass: 'dijitIconTask', label: null }, this._btnNode); }, _runJob: function() { var jobId = this._selectWidget.get('value'); this.socket.send('/app/jobs/indexing', { jobName: jobId }); }, _sendRequest: function() { this.socket.send(this.reqChannel, {}); }, _createJobList: function() { }, _error: function(url) { console.error('ERROR'); } }); }); No newline at end of file src/main/resources/static/app-client/taskitem.js 0 → 100644 +79 −0 Original line number Diff line number Diff line define([ 'dojo/_base/declare' , 'dojo/_base/lang' , 'dojo/Evented' , 'dojo/dom-construct' , 'dijit/_Widget' , 'dijit/form/Button' ], function( declare , lang , Evented , domConstruct , _WidgetBase , Button ){ return declare([_WidgetBase, Evented], { 'class': 'taskContainer', constructor: function(args) { lang.mixin(this, args); }, postCreate: function() { this.containerNode = domConstruct.create('div', null, this.domNode, 'last'); this.task && this.update(this.task); //this.on('task-status', lang.hitch(this, this._createButton)); this._createButton(); }, add: function(task) { for (var key in task) { domConstruct.create('div', { innerHTML: key + ' - ' + task[key], 'class': 'taskItem' }, this.containerNode, 'last'); } }, update: function(task) { domConstruct.empty(this.containerNode); this.add(task); }, _createButton: function(task) { /*switch(task.status) { case 'STOPPED': console.log('Create button restart'); break; case 'STARTING': console.log('Create button stop'); break; case 'STOPPING': console.log('Create button delete'); break; }*/ this._btnStop = new Button({ label: 'Parar', onClick: lang.hitch(this, this._stopTask) }).placeAt(this.domNode, 'last'); new Button({ label: 'Eliminar', onClick: lang.hitch(this, this._deleteTask) }).placeAt(this.domNode, 'last'); }, _stopTask: function() { this.emit('stop-task', this.task); }, _deleteTask: function() { this.emit('delete-task', this.task); } }); }); No newline at end of file Loading
src/main/resources/static/app-client/main.js 0 → 100644 +66 −0 Original line number Diff line number Diff line require([ 'dijit/form/Button' , 'app-client/task/TasksSelect' , 'dijit/form/Select' , 'dojo/dom' , 'app-client/socket/Socket' , 'app-client/tasks' , 'dojo/domReady!' ], function( Button , TasksSelect , Select , dom , Socket , Tasks ){ var socket = new Socket({ url: '/db2es/socket' }); var connectBtn = new Button({ label: 'Connect', onClick: function(){ socket.connect(); } }, 'connectBtn'); var sendBtn = new TasksSelect({ socket: socket }, 'sendBtn'); /* sendBtn.on('subscribed', function() { console.log('Subscrito'); setTimeout(function() { var listTask = ["citation-job", "animaltracking-job"]; socket.sendByTopic('/topic' + sendBtn.reqChannel, listTask); }, 500); });*/ socket.on('connected', function(url) { console.log('Conectado'); /* socket.subscribe('/topic/greeting', function(message) { console.log('Recibo gretting: ' + message); }); socket.subscribe('/topic/jobs/list', function(message) { console.log('Recibo jobs: ' + message); });*/ var tasks = new Tasks({ socket: socket }, 'tasks'); /*socket.subscribe('/topic/jobs/list', function(message) { console.log('Recibo jobs: ' + message); });*/ }); }); No newline at end of file
src/main/resources/static/app-client/socket/Socket.js 0 → 100644 +68 −0 Original line number Diff line number Diff line define([ 'dojo/_base/declare' , 'dojo/_base/lang' , 'dojo/Evented' , 'sockjs' , 'stomp' ], function( declare , lang , Evented , SockJS , Stomp ){ return declare([Evented], { _ws: null, _client: null, url: null, constructor: function(args) { this._subscribes = {}; this._isConnected = false; lang.mixin(this, args); this.on('connect', this._connect); this.on('error', this._error); }, connect: function() { this.emit(this.url ? 'connect' : 'error', this.url); }, isConnected: function() { return this._isConnected; }, subscribe: function(channel, callback) { this._subscribes[channel] = callback; this._client.subscribe(channel, function(message) { console.debug('SUBSCRIBE', channel, message); message.body = JSON.parse(message.body); callback(message); }); }, send: function(channel, message) { console.debug('SEND', channel, message); this._client.send(channel, {}, JSON.stringify(message)); }, _connect: function() { this._ws = new SockJS(this.url); this._client = window.Stomp.over(this._ws); this._client.connect({}, lang.hitch(this, this._connected)); }, _connected: function() { this._isConnected = true; this.emit('connected', this); }, _error: function(url) { console.error('ERROR'); } }); }); No newline at end of file
src/main/resources/static/app-client/socket/SocketMock.js 0 → 100644 +30 −0 Original line number Diff line number Diff line define([ 'dojo/_base/declare' , 'dojo/_base/lang' , 'app-client/socket/Socket' ], function( declare , lang , Socket ){ return declare([Socket], { subscribe: function(channel, callback) { this._subscribes[channel] = callback; }, sendByTopic: function(channel, message) { this._subscribes[channel] && this._subscribes[channel](message); }, send: function(channel, message) { console.log('Send', channel, message); }, _connect: function() { console.log('Connect'); setTimeout(lang.hitch(this, this._connected), 500); } }); }); No newline at end of file
src/main/resources/static/app-client/task/TasksSelect.js 0 → 100644 +144 −0 Original line number Diff line number Diff line define([ 'dojo/_base/declare' , 'dojo/_base/lang' , 'dojo/on' , 'dojo/Evented' , 'dojo/dom-construct' , 'dijit/_WidgetBase' , 'dijit/form/Select' , 'dijit/form/Button' ], function( declare , lang , on , Evented , domConstruct , _Widget , Select , Button ){ return declare([_Widget, Evented], { socket: null, reqChannel: '/jobs/list', url: null, jobsList: null, constructor: function(args) { this._subscriptions = {}; this.i18n = { "indexing-animalTracking-job": "Tracking de animales", "indexing-platformTracking-job": "Tracking de plataformas", "indexing-citation-job": "Citas corológicas", "indexing-timeseriesSurvey-job": "Estaciones fijas con series temporales", "indexing-timeSeries-job": "Series temporales", "indexing-attributeSeries-job": "Series de atributo de Infrastructuras", "indexing-isolines-job": "Isolíneas", "indexing-area-job": "Áreas", "indexing-objectCollectingSurvey-job": "Indexar object survey", "indexing-objectCollectingseries-job": "Serie de colección de objetos", "indexing-infrastructure-job": "Infrastructuras", "indexing-administrativeDomains-job": "Dominios de administración", "indexing-document-job": "Indexar documentos", "indexing-classificationsDomains-job": "Dominios de clasificación", "indexing-parametersDomains-job": "Dominios de parámetros", "indexing-qualityDomains-job": "Dominios de calidad de los datos", "indexing-qualifyDomains-job": "Dominios de calificación de objetos", "indexing-taxonomyDomains-job": "Dominios de taxonomía", "indexing-ancillaryDataDomains-job": "Dominios de datos auxiliares", "indexing-toponymias-job": "Toponimias", "indexing-taxonomy-job": "Taxonomía", "indexing-administrative-job": "Administración", "indexing-atlas-job": "Atlas" }; lang.mixin(this, args); }, postCreate: function() { this._createLayout(); this._startSocket(); }, _createLayout: function() { this._selectNode = domConstruct.create('span', null, this.domNode); this._btnNode = domConstruct.create('span', null, this.domNode); }, _startSocket: function(value) { if (this.socket) { this.socket.isConnected() && this._onSocketOpened(); this.socket.on('connected', lang.hitch(this, this._onSocketOpened)); } }, _onSocketOpened: function() { this.emit('socket-opened'); this._onSubscriptions(); }, _onSubscriptions: function() { this.socket.subscribe('/topic' + this.reqChannel, lang.hitch(this, this._onReceivedJobsList)); this.emit('subscribed'); this.socket.send('/app' + this.reqChannel, {}); }, _onReceivedJobsList: function(message) { this.jobsList = this._parseJobsList(message.body); this.emit('received-jobs-list', this.jobsList); this._createSelectJob(); this._createBtnRunJob(); }, _parseJobsList: function(jobsIn) { var jobs = []; for (var i = 0; i < jobsIn.length; i++) { jobs.push({ value: jobsIn[i], label: this.i18n[jobsIn[i]] }); } return jobs; }, _createSelectJob: function() { this._selectWidget = new Select({ name: 'selectJob', options: this.jobsList, style: 'width: 90%' }, this._selectNode); }, _createBtnRunJob: function() { this._btnWidget = new Button({ onClick: lang.hitch(this, this._runJob), iconClass: 'dijitIconTask', label: null }, this._btnNode); }, _runJob: function() { var jobId = this._selectWidget.get('value'); this.socket.send('/app/jobs/indexing', { jobName: jobId }); }, _sendRequest: function() { this.socket.send(this.reqChannel, {}); }, _createJobList: function() { }, _error: function(url) { console.error('ERROR'); } }); }); No newline at end of file
src/main/resources/static/app-client/taskitem.js 0 → 100644 +79 −0 Original line number Diff line number Diff line define([ 'dojo/_base/declare' , 'dojo/_base/lang' , 'dojo/Evented' , 'dojo/dom-construct' , 'dijit/_Widget' , 'dijit/form/Button' ], function( declare , lang , Evented , domConstruct , _WidgetBase , Button ){ return declare([_WidgetBase, Evented], { 'class': 'taskContainer', constructor: function(args) { lang.mixin(this, args); }, postCreate: function() { this.containerNode = domConstruct.create('div', null, this.domNode, 'last'); this.task && this.update(this.task); //this.on('task-status', lang.hitch(this, this._createButton)); this._createButton(); }, add: function(task) { for (var key in task) { domConstruct.create('div', { innerHTML: key + ' - ' + task[key], 'class': 'taskItem' }, this.containerNode, 'last'); } }, update: function(task) { domConstruct.empty(this.containerNode); this.add(task); }, _createButton: function(task) { /*switch(task.status) { case 'STOPPED': console.log('Create button restart'); break; case 'STARTING': console.log('Create button stop'); break; case 'STOPPING': console.log('Create button delete'); break; }*/ this._btnStop = new Button({ label: 'Parar', onClick: lang.hitch(this, this._stopTask) }).placeAt(this.domNode, 'last'); new Button({ label: 'Eliminar', onClick: lang.hitch(this, this._deleteTask) }).placeAt(this.domNode, 'last'); }, _stopTask: function() { this.emit('stop-task', this.task); }, _deleteTask: function() { this.emit('delete-task', this.task); } }); }); No newline at end of file