Beispiel #1
0
	users.forEach(function(user) {

		try {
			return Meteor.call('addUserToRoom', {
				rid: item.rid,
				username: user.username,
			});
		} catch ({ error }) {
			if (error === 'cant-invite-for-direct-room') {
				RocketChat.Notifications.notifyUser(userId, 'message', {
					_id: Random.id(),
					rid: item.rid,
					ts: new Date,
					msg: TAPi18n.__('Cannot_invite_users_to_direct_rooms', null, currentUser.language),
				});
			} else {
				RocketChat.Notifications.notifyUser(userId, 'message', {
					_id: Random.id(),
					rid: item.rid,
					ts: new Date,
					msg: TAPi18n.__(error, null, currentUser.language),
				});
			}
		}
	});
Beispiel #2
0
export const displayError = (error) => {
    if (error) {
        // It would be better to not alert the error here but inform the user in some
        // more subtle way
        alert(TAPi18n.__(error.error)); // eslint-disable-line no-alert
    }
};
Beispiel #3
0
Template.signin.onRendered(function () {
  pageSession.set( 'error', false );
  pageSession.set( 'cities', null );
  pageSession.set('codepostal', null );
  pageSession.set('cityselect', null );

  let geolocate = Session.get('geolocate');
  if(geolocate){
    var onOk=IonPopup.confirm({template:TAPi18n.__('Utiliser votre position actuelle ?'),
    onOk: function(){
      let geo = Location.getReactivePosition();
      if(geo && geo.latitude){
        let latlng = {latitude: parseFloat(geo.latitude), longitude: parseFloat(geo.longitude)};
        Meteor.call('getcitiesbylatlng',latlng,function(error, result){
          if(result){
            pageSession.set('codepostal', result.postalCodes[0].postalCode);
            pageSession.set('cityselect', result.insee);
            Meteor.call('getcitiesbypostalcode',result.postalCodes[0].postalCode,function(error, data){
              if(data){
              pageSession.set( 'cities', data);
              }
            })
        }
        });
      }
    }});
  }
});
Beispiel #4
0
function excuteEditForm(doc) {
    swal({
        title: "Pleas Wait",
        text: "Getting RingPullTransfers....", showConfirmButton: false
    });
    alertify.ringPullTransfer(fa('pencil', TAPi18n.__('pos.ringPullTransfer.title')), renderTemplate(editTmpl, doc)).maximize();
}
Beispiel #5
0
	blockUnsafeImages(message) {
		if (this.enabled && this.serviceAccount && message && message.file && message.file._id) {
			const file = RocketChat.models.Uploads.findOne({ _id: message.file._id });
			if (file && file.type && file.type.indexOf('image') !== -1 && file.store === 'GoogleCloudStorage:Uploads' && file.GoogleStorage) {
				if (this.incCallCount(1)) {
					const bucket = this.storageClient.bucket(RocketChat.settings.get('FileUpload_GoogleStorage_Bucket'));
					const bucketFile = bucket.file(file.GoogleStorage.path);
					const results = Meteor.wrapAsync(this.visionClient.detectSafeSearch, this.visionClient)(bucketFile);
					if (results && results.adult === true) {
						FileUpload.getStore('Uploads').deleteById(file._id);
						const user = RocketChat.models.Users.findOneById(message.u && message.u._id);
						if (user) {
							RocketChat.Notifications.notifyUser(user._id, 'message', {
								_id: Random.id(),
								rid: message.rid,
								ts: new Date,
								msg: TAPi18n.__('Adult_images_are_not_allowed', {}, user.language),
							});
						}
						throw new Meteor.Error('GoogleVisionError: Image blocked');
					}
				} else {
					console.error('Google Vision: Usage limit exceeded');
				}
				return message;
			}
		}
	}
Beispiel #6
0
  ProjectLogo.resumable.on('fileAdded', (file) => {
    // Available extensions for pictures
    const acceptedExtensions = ['jpg', 'jpeg', 'png', 'gif'];

    // Make sure the file extension is allowed
    if (fileNameEndsWith(file.file.name, acceptedExtensions)) {
      // Insert record about file to collection
      ProjectLogo.insert({
        _id: file.uniqueIdentifier,
        filename: file.fileName,
        contentType: file.file.type,
      }, (error) => {
        if (error) {
          // Handle error condition
          throw new Meteor.Error('File creation failed!', error);
        }

        // Start uploading
        Session.set('logoUploading', true);

        // Upload file
        ProjectLogo.resumable.upload();
      });
    } else {
      // Finish uploading
      Session.set('logoUploading', false);

      // Get extension error message
      const message = TAPi18n.__('uploadProjectLogo_acceptedExtensions');

      // Alert user of extension error
      sAlert.error(message, { timeout: 'none' });
    }
  });
Beispiel #7
0
			Messages.find(query).forEach((message) => {
				rows.push(opentr);

				// The timestamp
				rows.push(open20td);
				rows.push(moment(message.ts).tz(timeZone).format('YYYY-MM-DD HH-mm-ss z'));
				rows.push(closetd);

				// The sender
				rows.push(open20td);
				const sender = Users.findOne({ _id: message.u._id });
				if (data.users.indexOf(sender._id) === -1) {
					data.users.push(sender._id);
				}

				// Get the user's email, can be nothing if it is an unconfigured bot account (like rocket.cat)
				if (sender.emails && sender.emails[0] && sender.emails[0].address) {
					rows.push(`${ sender.name } <${ sender.emails[0].address }>`);
				} else {
					rows.push(`${ sender.name } <${ smarshMissingEmail }>`);
				}
				rows.push(closetd);

				// The message
				rows.push(open60td);
				data.msgs++;
				if (message.t) {
					const messageType = MessageTypes.getType(message);
					if (messageType) {
						rows.push(TAPi18n.__(messageType.message, messageType.data ? messageType.data(message) : '', 'en'));
					} else {
						rows.push(`${ message.msg } (${ message.t })`);
					}
				} else if (message.file) {
					data.files.push(message.file._id);
					rows.push(`${ message.attachments[0].title } (${ _getLink(message.attachments[0]) })`);
				} else if (message.attachments) {
					const attaches = [];
					_.each(message.attachments, function _loopThroughMessageAttachments(a) {
						if (a.image_url) {
							attaches.push(a.image_url);
						}
						// TODO: Verify other type of attachments which need to be handled that aren't file uploads and image urls
						// } else {
						// 	console.log(a);
						// }
					});

					rows.push(`${ message.msg } (${ attaches.join(', ') })`);
				} else {
					rows.push(message.msg);
				}
				rows.push(closetd);

				rows.push(closetr);
			});
		Meteor.call('saveRoomSettings', this.rid, 'streamingOptions', clearedObject, function(err) {
			if (err) {
				return handleError(err);
			}
			i.editing.set(false);
			i.streamingOptions.set(clearedObject);
			const roomAnnouncement = new RocketChatAnnouncement().getByRoom(i.data.rid);
			if (roomAnnouncement.getMessage() !== '') { roomAnnouncement.clear(); }
			return toastr.success(TAPi18n.__('Livestream_source_changed_succesfully'));
		});
Beispiel #9
0
	keys.forEach((key) => {
		RocketChat.Notifications.notifyUser(Meteor.userId(), 'message', {
			_id: Random.id(),
			rid: item.rid,
			ts: new Date,
			msg: TAPi18n.__(Object.keys(key)[0], {
				postProcess: 'sprintf',
				sprintf: [key[Object.keys(key)[0]]],
			}, user.language),
		});
	});
Beispiel #10
0
            Meteor.call('isLendingStockHasRelation', data._id, function (error, result) {
                if (error) {
                    alertify.error(error.message);
                } else {
                    if (result) {
                        swal('បញ្ជាក់!', `សូមធ្វើការលុប Receive Item លេខ​ ${result} ជាមុនសិន!​​​​`, 'error');
                    } else {
                        alertify.lendingStock(fa('pencil', TAPi18n.__('pos.lendingStock.title')), renderTemplate(editTmpl, data));

                    }
                }
            });
Beispiel #11
0
  'click .pin-button': function (event, templateInstance) {
    const organizationId = templateInstance.data.organization._id;
    const featuredApiId = templateInstance.data.api._id;
    const featuredApiList = templateInstance.data.organization.featuredApiIds;

    // Check what can be done for API card in question
    if (Organizations.findOne({ featuredApiIds: featuredApiId })) {
      // if the API was already featured, remove it from featured list
      Organizations.update({ _id: organizationId },
        { $pull:
          { featuredApiIds: featuredApiId },
        }
      );
      // Get localized success message
      const message = TAPi18n.__('apiCardPin_unfeaturedSuccessfully');

      // Display success message to user
      sAlert.success(message);
    } else if (!featuredApiList || featuredApiList.length < 4) {
      // If there is room in featured list, add API there
      Organizations.update({ _id: organizationId },
        { $push:
          { featuredApiIds: featuredApiId },
        }
      );
      // Get localized success message
      const message = TAPi18n.__('apiCardPin_featuredSuccessfully');

      // Display success message to user
      sAlert.success(message);
    } else {
      // There is no room in featured list, API can not be added
      // Get localized error message
      const message = TAPi18n.__('apiCardPin_featuredListAlreadyFull');

        // Display success message to user
      sAlert.error(message, { timeout: 'none' });
    }
  },
Beispiel #12
0
 Meteor.call('isLendingStockHasRelation', id, function (error, result) {
     if (error) {
         alertify.error(error.message);
     } else {
         if (result) {
             swal('បញ្ជាក់!', `សូមធ្វើការលុប Receive Item លេខ​ ${result} ជាមុនសិន!​​​​`, 'error');
         } else {
             destroyAction(
                 LendingStocks,
                 {_id: id},
                 {title: TAPi18n.__('pos.lendingStock.title'), itemTitle: id}
             );
         }
     }
 });
Beispiel #13
0
	const applyLanguage = (language = 'en') => {
		language = filterLanguage(language);

		if (!availableLanguages[language]) {
			language = language.split('-').shift();
		}

		if (!language) {
			return;
		}

		document.documentElement.classList[isRtl(language) ? 'add' : 'remove']('rtl');
		TAPi18n.setLanguage(language);
		loadMomentLocale(language).then((locale) => moment.locale(locale), (error) => console.error(error));
	};
Beispiel #14
0
	users = users.fetch().filter(function(user) {
		const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(item.rid, user._id, { fields: { _id: 1 } });
		if (subscription == null) {
			return true;
		}
		RocketChat.Notifications.notifyUser(userId, 'message', {
			_id: Random.id(),
			rid: item.rid,
			ts: new Date,
			msg: TAPi18n.__('Username_is_already_in_here', {
				postProcess: 'sprintf',
				sprintf: [user.username],
			}, currentUser.language),
		});
		return false;
	});
Beispiel #15
0
  ProjectLogo.resumable.on('fileSuccess', (file) => {
    // Finish uploading
    Session.set('logoUploading', false);

    // Get the id from project logo file object
    const projectLogoFileId = file.uniqueIdentifier;

    // Get branding
    const branding = Branding.findOne();

    // Update logo id field
    Branding.update(branding._id, { $set: { projectLogoFileId } });

    // Get upload success message translation
    const message = TAPi18n.__('uploadProjectLogo_successfully_uploaded');

    // Alert user of successful upload
    sAlert.success(message);
  });
Beispiel #16
0
		Meteor.call('saveRoomSettings', this.rid, 'streamingOptions', streamingOptions, function(err) {
			if (err) {
				return handleError(err);
			}
			i.editing.set(false);
			i.streamingOptions.set(streamingOptions);
			if (streamingOptions.url !== '') {
				new RocketChatAnnouncement({
					room: i.data.rid,
					message: 'Broadcast is now live. Click here to watch!',
					callback: 'openBroadcast',
				}).save();
			} else {
				const roomAnnouncement = new RocketChatAnnouncement().getByRoom(i.data.rid);
				if (roomAnnouncement.getMessage() !== '') {
					roomAnnouncement.clear();
				}
			}
			return toastr.success(TAPi18n.__('Livestream_source_changed_succesfully'));
		});
Beispiel #17
0
		const closeRoom = (comment) => Meteor.call('livechat:closeRoom', this.rid, comment, function(error/* , result*/) {
			if (error) {
				return handleError(error);
			}
			modal.open({
				title: t('Chat_closed'),
				text: t('Chat_closed_successfully'),
				type: 'success',
				timer: 1000,
				showConfirmButton: false,
			});
		});

		if (!settings.get('Livechat_request_comment_when_closing_conversation')) {
			const comment = TAPi18n.__('Chat_closed_by_agent');
			return closeRoom(comment);
		}

		// Setting for Ask_for_conversation_finished_message is set to true
		modal.open({
			title: t('Closing_chat'),
			type: 'input',
			inputPlaceholder: t('Please_add_a_comment'),
			showCancelButton: true,
			closeOnConfirm: false,
		}, (inputValue) => {
			if (!inputValue) {
				modal.showInputError(t('Please_add_a_comment_to_close_the_room'));
				return false;
			}
Beispiel #18
0
 'click .js-update-item': function (event, instance) {
     alertify.tmpItem(fa('pencil', TAPi18n.__('pos.order.schema.itemId.label')), renderTemplate(Template.Pos_schemeItemsEdit, this));
 },
Beispiel #19
0
    // Create new  alertify
    createNewAlertify('item', {size: 'lg'});
    createNewAlertify('addOn');
    createNewAlertify('tmpItem');
    createNewAlertify('addNewChartAccount');
});

indexTmpl.helpers({
    tabularTable(){
        return ItemTabular;
    }
});

indexTmpl.events({
    'click .js-create' (event, instance) {
        alertify.item(fa('plus', TAPi18n.__('pos.item.title')), renderTemplate(newTmpl)).maximize();
    },
    'click .js-update' (event, instance) {
        alertify.item(fa('pencil', TAPi18n.__('pos.item.title')), renderTemplate(editTmpl, this)).maximize();
    },
    'click .js-destroy' (event, instance) {
        var id = this._id;
        Meteor.call('isItemHasRelation', id, function (error, result) {
            if (error) {
                alertify.error(error.message);
            } else {
                if (result) {
                    alertify.warning("Data has been used. Can't remove.");
                } else {
                    destroyAction(
                        Item,
Beispiel #20
0
 label: function () {
     return TAPi18n.__('core.welcome.branch');
 },
Beispiel #21
0
// Index
indexTmpl.onCreated(function () {
    // Create new  alertify
    createNewAlertify('item');
});

indexTmpl.helpers({
    tabularTable(){
        return ItemTabular;
    }
});

indexTmpl.events({
    'click .js-create' (event, instance) {
        alertify.item(fa('plus', TAPi18n.__('simplePos.item.title')), renderTemplate(formTmpl));
    },
    'click .js-update' (event, instance) {
        alertify.item(fa('pencil', TAPi18n.__('simplePos.item.title')), renderTemplate(formTmpl, {itemId: this._id}));
    },
    'click .js-destroy' (event, instance) {
        destroyAction(
            Item,
            {_id: this._id},
            {title: TAPi18n.__('simplePos.item.title'), itemTitle: this._id}
        );
    },
    'click .js-display' (event, instance) {
        alertify.item(fa('eye', TAPi18n.__('simplePos.item.title')), renderTemplate(showTmpl, {itemId: this._id}));
    }
});
Beispiel #22
0
 'click .js-update-item': function (event, instance) {
     alertify.item(fa('pencil', TAPi18n.__('acc.order.schema.itemId.label')), renderTemplate(editItemsTmpl, this));
 },
 Meteor.call('companyExchangeRingPullShowItem', {_id: this._id}, function (err, result) {
     swal.close();
     alertify.companyExchangeRingPullShow(fa('eye', TAPi18n.__('pos.companyExchangeRingPull.title')), renderTemplate(showTmpl, result));
 });
Beispiel #24
0
function Invite(command, params, item) {

	if (command !== 'invite' || !Match.test(params, String)) {
		return;
	}

	const usernames = params.split(/[\s,]/).map((username) => username.replace(/(^@)|( @)/, '')).filter((a) => a !== '');
	if (usernames.length === 0) {
		return;
	}
	let users = Meteor.users.find({
		username: {
			$in: usernames,
		},
	});
	const userId = Meteor.userId();
	const currentUser = Meteor.users.findOne(userId);
	if (users.count() === 0) {
		Notifications.notifyUser(userId, 'message', {
			_id: Random.id(),
			rid: item.rid,
			ts: new Date,
			msg: TAPi18n.__('User_doesnt_exist', {
				postProcess: 'sprintf',
				sprintf: [usernames.join(' @')],
			}, currentUser.language),
		});
		return;
	}
	users = users.fetch().filter(function(user) {
		const subscription = Subscriptions.findOneByRoomIdAndUserId(item.rid, user._id, { fields: { _id: 1 } });
		if (subscription == null) {
			return true;
		}
		Notifications.notifyUser(userId, 'message', {
			_id: Random.id(),
			rid: item.rid,
			ts: new Date,
			msg: TAPi18n.__('Username_is_already_in_here', {
				postProcess: 'sprintf',
				sprintf: [user.username],
			}, currentUser.language),
		});
		return false;
	});

	users.forEach(function(user) {

		try {
			return Meteor.call('addUserToRoom', {
				rid: item.rid,
				username: user.username,
			});
		} catch ({ error }) {
			if (error === 'cant-invite-for-direct-room') {
				Notifications.notifyUser(userId, 'message', {
					_id: Random.id(),
					rid: item.rid,
					ts: new Date,
					msg: TAPi18n.__('Cannot_invite_users_to_direct_rooms', null, currentUser.language),
				});
			} else {
				Notifications.notifyUser(userId, 'message', {
					_id: Random.id(),
					rid: item.rid,
					ts: new Date,
					msg: TAPi18n.__(error, null, currentUser.language),
				});
			}
		}
	});
}
Beispiel #25
0
		if (!Match.test(file.rid, String)) {
			return false;
		}

		// livechat users can upload files but they don't have an userId
		const user = file.userId ? Meteor.users.findOne(file.userId) : null;

		const room = Rooms.findOneById(file.rid);
		const directMessageAllow = settings.get('FileUpload_Enabled_Direct');
		const fileUploadAllowed = settings.get('FileUpload_Enabled');
		if (canAccessRoom(room, user, file) !== true) {
			return false;
		}
		const language = user ? user.language : 'en';
		if (!fileUploadAllowed) {
			const reason = TAPi18n.__('FileUpload_Disabled', language);
			throw new Meteor.Error('error-file-upload-disabled', reason);
		}

		if (!directMessageAllow && room.t === 'd') {
			const reason = TAPi18n.__('File_not_allowed_direct_messages', language);
			throw new Meteor.Error('error-direct-message-file-upload-not-allowed', reason);
		}

		// -1 maxFileSize means there is no limit
		if (maxFileSize > -1 && file.size > maxFileSize) {
			const reason = TAPi18n.__('File_exceeds_allowed_size_of_bytes', {
				size: filesize(maxFileSize),
			}, language);
			throw new Meteor.Error('error-file-too-large', reason);
		}
Beispiel #26
0
 label: function () {
     return TAPi18n.__('core.welcome.username');
 }
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';

import '/imports/ui/components/navbar-main.js';

import './settings.html';


Template.Settings_page.helpers({
  languages() {
    var currentLang = TAPi18n.getLanguage();
    var langs = TAPi18n.getLanguages();
    var key;
    var lang;
    var langsArray = [];
    for (key in langs) {
      lang = langs[key];
      lang._id = key;
      if (key === currentLang) {
        lang.selected = true;
      }
      langsArray.push(lang);
    }
    return langsArray;
  }
});


Template.Settings_page.onRendered(function(){

  var instance = Template.instance();
Beispiel #28
0
 label: function () {
     return TAPi18n.__('core.welcome.password');
 }
Beispiel #29
0
});

indexTmpl.helpers({
    tabularTable(){
        return PenaltyTabular;
    },
    selector() {
        return {};
    }

});

indexTmpl.events({
    'click .js-create' (event, instance) {
        alertify.penalty(fa('plus', TAPi18n.__('pos.penalty.title')), renderTemplate(newTmpl));
    },
    'click .js-update' (event, instance) {
        alertify.penalty(fa('pencil', TAPi18n.__('pos.penalty.title')), renderTemplate(editTmpl, this));
    },
    'click .js-destroy' (event, instance) {
        var id = this._id;
        destroyAction(
            Penalty,
            {_id: id},
            {title: TAPi18n.__('pos.penalty.title'), itemTitle: id});

    },
    'click .js-display' (event, instance) {
        alertify.penaltyShow(fa('eye', TAPi18n.__('pos.penalty.title')), renderTemplate(showTmpl, this));
    }
Beispiel #30
0
 label: function () {
     return TAPi18n.__('core.welcome.module');
 },