Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ext.define('prices.desktop.DetectionTab', {
- extend: 'Ext.Panel',
- layout: 'fit',
- initComponent: function () {
- var self = this;
- self.on({
- afterrender: function () {
- self.socket = mh.socket.create({
- path: 'detectionFrontend',
- scope: self
- });
- },
- resize: function (element, info, opt) {
- self.canvas.resizeToParent();
- }
- });
- self.tbar = Ext.create('Ext.toolbar.Toolbar', {
- id: 'toolbar-cmp',
- items: ['->']
- });
- self.canvas = Ext.create('prices.desktop.DetectionCanvas');
- self.items = [self.canvas];
- self.setToolbarToStopState();
- self.callParent();
- },
- onNextPhotoResponse: function (event) {
- var self = this;
- if (event.photo) {
- self.startWorking(event.photo);
- } else {
- self.setToolbarToStopState();
- self.showNoPhotos();
- }
- },
- startWorking: function (photo) {
- var self = this;
- self.currentPhoto = photo;
- self.canvas.showPhoto(photo, self);
- },
- onCancelTaskResponse: function (event) {
- var self = this;
- self.setToolbarToStopState();
- },
- setToolbarToWorkState: function () {
- var self = this;
- self.canvas.setLoading(false);
- setToolbarToWorkState(
- Ext.getCmp('toolbar-cmp'),
- function () {
- self.canvas.setLoading("Загрузка...");
- Ext.getCmp('toolbar-cmp').items.get(1).disable();
- self.socket.send('NextPhotoRequest', {moderatedPhoto: $.extend(self.canvas.getUpdatedPhoto(), {badPhoto: true})});
- self.canvas.clear();
- },
- function () {
- self.setLoading("Загрузка...");
- Ext.getCmp('toolbar-cmp').items.get(1).disable();
- self.socket.send('NextPhotoRequest', {moderatedPhoto: $.extend(self.canvas.getUpdatedPhoto(), {badPhoto: false})});
- self.canvas.clear();
- },
- function () {
- self.canvas.setLoading("Загрузка...");
- self.socket.send('CancelTaskRequest', {id: self.currentPhoto.id});
- self.canvas.clear();
- Ext.getCmp('toolbar-cmp').items.get(1).enable();
- self.canvas.setLoading(false);
- },
- function () {
- }
- )
- },
- setToolbarToStopState: function () {
- var self = this;
- setToolbarToStopState(
- Ext.getCmp('toolbar-cmp'),
- function () {
- self.canvas.setLoading("Загрузка...");
- Ext.getCmp('toolbar-cmp').items.get(1).disable();
- self.socket.send('NextPhotoRequest', {});
- },
- function () {
- }
- )
- },
- showNoPhotos: function () {
- var self = this;
- self.canvas.setLoading(false);
- Ext.Msg.show({
- title: 'Нет фотографий',
- msg: 'Нет фотографий для модерации',
- buttons: Ext.MessageBox.OK
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement