@capillarytech/creatives-library 0.1.29 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,7 +35,7 @@ function* watchCreateTemplate() {
35
35
  yield cancel(watcher);
36
36
  }
37
37
  function* watchUploadAsset() {
38
- console.log("inside watchUploadAsset")
38
+ console.log("inside watchUploadAsset");
39
39
  const watcher = yield takeLatest(types.UPLOAD_ASSET_REQUEST, uploadAsset);
40
40
  yield take(LOCATION_CHANGE);
41
41
  yield cancel(watcher);
@@ -104,5 +104,4 @@ export default [
104
104
  watchEditTemplate,
105
105
  watchGetTemplateDetails,
106
106
  watchLineTemplatesList,
107
- watchUploadAsset,
108
107
  ];
@@ -19,6 +19,7 @@ import FormBuilder from '../../../components/FormBuilder';
19
19
  import * as actions from './actions';
20
20
  import messages from './messages';
21
21
  import * as charCount from '../../../utils/smsCharCount';
22
+ import {updateCharCount, checkUnicode} from '../../../utils/smsCharCountV2';
22
23
  import * as globalActions from '../../../containers/Cap/actions';
23
24
  import {getMessageObject} from '../../../utils/messageUtils';
24
25
 
@@ -378,7 +379,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
378
379
 
379
380
  injectEvents(schema) {
380
381
  console.log('now injecting events');
381
- const temp = schema;
382
+ let temp = schema;
382
383
  temp.standalone.sections = this.injectSections(temp.standalone.sections);
383
384
  _.forEach(temp.containers, (container) => {
384
385
  let tempContainer = container;
@@ -761,7 +762,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
761
762
  startTemplateCreation(data) {
762
763
  if (data.edit) {
763
764
  console.log('startTemplateCreation');
764
- const ifUnicode = charCount.checkUnicode(data.content ? data.content : '');
765
+ const ifUnicode = checkUnicode(data.content ? data.content : '');
765
766
  console.log('smsDetails', ifUnicode, data.content);
766
767
  const content = data.content;
767
768
  const id = _.uniqueId();
@@ -17,7 +17,7 @@ import { makeSelectMetaEntities } from '../../Cap/selectors';
17
17
  import { UserIsAuthenticated } from '../../../utils/authWrapper';
18
18
  import FormBuilder from '../../../components/FormBuilder';
19
19
  import * as actions from './actions';
20
- import * as charCount from '../../../utils/smsCharCount';
20
+ import {checkUnicode, updateCharCount} from '../../../utils/smsCharCountV2';
21
21
  import '../Create/_smsCreate.scss';
22
22
  import messages from './messages';
23
23
  import * as globalActions from '../../../containers/Cap/actions';
@@ -286,7 +286,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
286
286
  }
287
287
  const result = {};
288
288
  result.base = baseData;
289
- const msgObj = charCount.updateCharCount(baseData['sms-editor']);
289
+ const msgObj = updateCharCount(baseData['sms-editor']);
290
290
  result.base.msg_count = msgObj.msgCount;
291
291
  console.log("Message Count", msgObj.msgCount);
292
292
  const response = {
@@ -386,7 +386,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
386
386
  startTemplateCreation(data) {
387
387
  console.log('startTemplateCreation');
388
388
  if (data.edit) {
389
- const ifUnicode = charCount.checkUnicode(data.content);
389
+ const ifUnicode = checkUnicode(data.content);
390
390
  console.log('smsDetails', ifUnicode, data.content);
391
391
  const content = data.content;
392
392
  const tempData = {
@@ -23,7 +23,7 @@ import { makeSelectEdit } from '../Sms/Edit/selectors';
23
23
  import { makeSelectLine } from '../Line/Create/selectors';
24
24
  import { UserIsAuthenticated } from '../../utils/authWrapper';
25
25
  import messages from './messages';
26
- import * as charCount from '../../utils/smsCharCount';
26
+ import {checkUnicode} from '../../utils/smsCharCountV2';
27
27
  import * as actions from './actions';
28
28
  import * as smsActions from '../Sms/Create/actions';
29
29
  import * as mobilepushActions from '../MobilePush/Create/actions';
@@ -657,7 +657,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
657
657
  startTemplateCreation(data) {
658
658
  console.log('startTemplateCreation');
659
659
  if (data.edit) {
660
- const ifUnicode = charCount.checkUnicode(data.content);
660
+ const ifUnicode = checkUnicode(data.content);
661
661
  console.log('smsDetails', ifUnicode, data.content);
662
662
  const content = data.content;
663
663
  const tempData = {
@@ -1146,22 +1146,24 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1146
1146
  this.setState({ device });
1147
1147
  };
1148
1148
 
1149
- renderEmailPreviewModal() {
1150
- const slideboxContent = (
1151
- <div style={{height: "75vh", width: '55vw'}}>
1152
- <iframe />
1153
- </div>
1154
- );
1155
-
1156
- return (
1157
- <SlideBox
1158
- header={this.state.previewTemplate.name}
1159
- content={slideboxContent}
1160
- show={this.state.showEmailPreviewModal}
1161
- handleClose={this.toggleImagePreview}
1162
- width={60}
1163
- />
1164
- );
1149
+ //Gets called only when creatives gets used as node library
1150
+ isEnabledInLibraryModule = (property) => {
1151
+ if (this.props.location.query.type === "embedded" && this.props.location.query.module === "library") {
1152
+ switch (property) {
1153
+ case "showAccountSelection":
1154
+ return (this.props.route && (this.props.route.name.toLowerCase() === "wechat" || this.props.route.name.toLowerCase() === "mobilepush"));
1155
+ case "setLocale":
1156
+ return true;
1157
+ case "callCreateFromProps":
1158
+ return true;
1159
+ case "callSelectFromProps":
1160
+ return true;
1161
+ default:
1162
+ return false;
1163
+ }
1164
+ } else {
1165
+ return false;
1166
+ }
1165
1167
  }
1166
1168
 
1167
1169
  renderDeleteConfirmationModal = () => {
@@ -1182,29 +1184,29 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1182
1184
  </Modal>);
1183
1185
  return modal;
1184
1186
  };
1185
- //Gets called only when creatives gets used as node library
1186
- isEnabledInLibraryModule = (property) => {
1187
- if (this.props.location.query.type === "embedded" && this.props.location.query.module === "library") {
1188
- switch (property) {
1189
- case "showAccountSelection":
1190
- return (this.props.route && (this.props.route.name.toLowerCase() === "wechat" || this.props.route.name.toLowerCase() === "mobilepush"));
1191
- case "setLocale":
1192
- return true;
1193
- case "callCreateFromProps":
1194
- return true;
1195
- case "callSelectFromProps":
1196
- return true;
1197
- default:
1198
- return false;
1199
- }
1200
- } else {
1201
- return false;
1202
- }
1187
+
1188
+ renderEmailPreviewModal() {
1189
+ const slideboxContent = (
1190
+ <div style={{height: "75vh", width: '55vw'}}>
1191
+ <iframe />
1192
+ </div>
1193
+ );
1194
+
1195
+ return (
1196
+ <SlideBox
1197
+ header={this.state.previewTemplate.name}
1198
+ content={slideboxContent}
1199
+ show={this.state.showEmailPreviewModal}
1200
+ handleClose={this.toggleImagePreview}
1201
+ width={60}
1202
+ />
1203
+ );
1203
1204
  }
1204
1205
 
1205
1206
  render() {
1206
1207
  console.log('templates props', this.props);
1207
1208
  let pageHeaderText = '';
1209
+ const moduleName = this.props.location.query.module;
1208
1210
  if (this.props.location.query.type !== 'embedded') {
1209
1211
  if (this.state.channel.toUpperCase() === 'WECHAT') {
1210
1212
  pageHeaderText = this.props.intl.formatMessage(messages.wechatHeader);
@@ -1313,6 +1315,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1313
1315
  </Select>}
1314
1316
  </div>
1315
1317
  );
1318
+ const pageHeaderDvs = (
1319
+ <div>
1320
+ {(this.props.location.query.type === 'embedded' && moduleName === 'dvs') ? `${templateText}` : pageHeaderText}
1321
+ {((this.state.channel.toUpperCase() === 'WECHAT') && (this.props.location.query.type === 'embedded') && !_.isEmpty(this.props.Templates.weCrmAccounts)) &&
1322
+ <Select className="selectAccount" onSelect={this.onAccountSelect} value={this.props.Templates.selectedWeChatAccount ? this.props.Templates.selectedWeChatAccount.name : undefined} placeholder={this.props.intl.formatMessage(messages.selectAccount)}>
1323
+ {accountOptions}
1324
+ </Select>}
1325
+ </div>
1326
+ );
1316
1327
  let actionButton = '';
1317
1328
  if (this.props.location.query.type !== 'embedded') {
1318
1329
  if (this.state.channel.toUpperCase() === 'WECHAT') {
@@ -1445,15 +1456,17 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1445
1456
  <input type="file" id="filename" style={{ display: 'none'}} accept=".zip, .html, .htm" onChange={(event) => this.handleFileUpload(event, {files: event.target.files})} />
1446
1457
  <Row>
1447
1458
  <Col>
1448
- <Breadcrumb>
1449
- <BreadcrumbItem>{this.props.intl.formatMessage(messages.campaigns)}</BreadcrumbItem>
1450
- <BreadcrumbItem>{this.props.intl.formatMessage(messages.creatives)}</BreadcrumbItem>
1451
- <BreadcrumbItem>{ this.state.channel }</BreadcrumbItem>
1452
- </Breadcrumb>
1459
+ {this.props.location.query.type !== "embedded" &&
1460
+ <Breadcrumb>
1461
+ <BreadcrumbItem>{this.props.intl.formatMessage(messages.campaigns)}</BreadcrumbItem>
1462
+ <BreadcrumbItem>{this.props.intl.formatMessage(messages.creatives)}</BreadcrumbItem>
1463
+ <BreadcrumbItem>{ this.state.channel }</BreadcrumbItem>
1464
+ </Breadcrumb>
1465
+ }
1453
1466
  </Col>
1454
1467
  </Row>
1455
1468
  <Row className="template-header-container">
1456
- <div className="template-header">{pageHeader}</div>
1469
+ <div className="template-header">{(this.props.location.query.type === 'embedded' && moduleName === 'dvs') ? pageHeaderDvs : pageHeader}</div>
1457
1470
  {actionButton}
1458
1471
  </Row>
1459
1472
  <Row>
@@ -704,6 +704,7 @@ export class WeChat extends React.Component { // eslint-disable-line react/prefe
704
704
  content: this.state.editTemplateData.versions.base.content,
705
705
  isInternalUrl: this.state.formData['is-internal-url'],
706
706
  creative_template_id: this.state.editTemplateData._id,
707
+ touser: "{{wechat_open_id}}",
707
708
  };
708
709
  _.forEach(this.state.selectedTemplateTags, (templateTag) => {
709
710
  const tagName = templateTag.substr(0, templateTag.indexOf('.'));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "0.1.29",
4
+ "version": "0.1.30",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -25,6 +25,7 @@
25
25
  "express": "4.14.0",
26
26
  "fixed-data-table": "^0.6.4",
27
27
  "fontfaceobserver": "2.0.7",
28
+ "fs": "0.0.1-security",
28
29
  "fs-extra": "^5.0.0",
29
30
  "immutable": "3.8.1",
30
31
  "intl": "1.2.5",
@@ -57,6 +58,7 @@
57
58
  "reselect": "2.5.4",
58
59
  "sanitize.css": "4.1.0",
59
60
  "semantic-ui-react": "0.68.3",
61
+ "source-map-loader": "^0.2.4",
60
62
  "styled-components": "1.1.2",
61
63
  "warning": "3.0.0",
62
64
  "whatwg-fetch": "2.0.1"
@@ -0,0 +1,143 @@
1
+ import React from 'react';
2
+ function getURLParameter(name) {
3
+ return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null
4
+ }
5
+ var charset7bit = ['@', '£', '$', '¥', 'è', 'é', 'ù', 'ì', 'ò', 'Ç', "\n", 'Ø', 'ø', "\r", 'Å', 'å', 'Δ', '_', 'Φ', 'Γ', 'Λ', 'Ω', 'Π', 'Ψ', 'Σ', 'Θ', 'Ξ', 'Æ', 'æ', 'ß', 'É', ' ', '!', '"', '#', '¤', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '¡', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'Ä', 'Ö', 'Ñ', 'Ü', '§', '¿', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'ä', 'ö', 'ñ', 'ü', 'à'];
6
+ var charset7bitext = ["\f", '^', '{', '}', '\\', '[', '~', ']', '|', '€'];
7
+ var udh_template = '<span className="udh"><span className="udh-total-length" title="UDH length">0x05</span><span className="udh-multipart-header" title="UDH header - Multipart SMS">0x00</span><span className="udh-multipart-length" title="Multipart SMS - UDH length">0x03</span><span className="udh-multipart-id" title="Multipart SMS - Unique ID">0x0a</span><span className="udh-total" title="Multipart SMS - Total number of parts"></span><span className="udh-part" title="Multipart SMS - Part order"></span></span>';
8
+
9
+ function charToSpan(chr, coding, isUnicodeEnabled) {
10
+ var ret;
11
+ var clss = '';
12
+ if (coding == '7bit') {
13
+ clss = 'c7b';
14
+ if (charset7bitext.indexOf(chr) >= 0) {
15
+ //ret = <div className="c7eb">ESC</div>;
16
+ }
17
+ }
18
+ let isUnicode = false;
19
+ if (coding == '16bit') {
20
+ clss = 'c16b';
21
+ if (charset7bit.indexOf(chr) == -1 && charset7bitext.indexOf(chr) == -1 && !isUnicodeEnabled) {
22
+ isUnicode = true;
23
+ }
24
+ }
25
+ return <span className={isUnicode ? 'unicode-disabled' : ''}>{isUnicode ? ` \u2588 ` : chr}</span>
26
+ }
27
+
28
+ function getUHDHtml(parts, part) {
29
+ if (parts < 15) {
30
+ udh.find('.udh-total').html('0x0' + parts.toString(16));
31
+ } else {
32
+ udh.find('.udh-total').html('0x' + parts.toString(16));
33
+ }
34
+ if (part < 15) {
35
+ udh.find('.udh-part').html('0x0' + part.toString(16));
36
+ } else {
37
+ udh.find('.udh-part').html('0x' + part.toString(16));
38
+ }
39
+ return udh;
40
+ }
41
+ export function checkUnicode(content) {
42
+ var chars_arr = content.split("");
43
+ for (let i = 0; i < chars_arr.length; i++) {
44
+ let chr = chars_arr[i];
45
+ if (charset7bit.indexOf(chr) == -1 && charset7bitext.indexOf(chr) == -1) {
46
+ return true;
47
+ }
48
+ }
49
+ return false;
50
+ }
51
+ export function updateCharCount(content, isUnicodeEnabled) {
52
+ console.log(content);
53
+ var chars_arr = content.split("");
54
+ console.log(chars_arr);
55
+ var coding = '7bit';
56
+ var parts = 1;
57
+ var part = 1;
58
+ var chars_used = 0;
59
+ var chars_sms = 160;
60
+ var sms_parts_container = [];
61
+ var partc = [];
62
+ for (let i = 0; i < chars_arr.length; i++) {
63
+ if (charset7bit.indexOf(chars_arr[i]) >= 0) {
64
+ chars_used = chars_used + 1;
65
+ console.log('X1:', chars_used);
66
+ } else if (charset7bitext.indexOf(chars_arr[i]) >= 0) {
67
+ chars_used = chars_used + 2;
68
+ console.log('X2:', chars_used);
69
+ } else {
70
+ coding = '16bit';
71
+ chars_used = chars_arr.length;
72
+ console.log('X3:', chars_used);
73
+ break;
74
+ }
75
+ }
76
+ if (coding == '7bit') {
77
+ if (chars_used > 160) {
78
+ var parts = Math.ceil(chars_used / 153);
79
+ var part_chars_used = 7;
80
+ chars_sms = 153;
81
+ // partc.push(getUHDHtml(parts, part));
82
+ for (let i = 0; i < chars_arr.length; i++) {
83
+ if (part_chars_used + 1 > 160) {
84
+ part = part + 1;
85
+ part_chars_used = 7;
86
+ sms_parts_container.push(partc);
87
+ }
88
+ if (charset7bitext.indexOf(chars_arr[i]) >= 0 && part_chars_used + 2 > 160) {
89
+ part = part + 1;
90
+ part_chars_used = 7;
91
+ sms_parts_container.push(partc);
92
+ }
93
+ partc = [...partc, charToSpan(chars_arr[i], coding, isUnicodeEnabled)];
94
+ if (charset7bitext.indexOf(chars_arr[i]) == -1) {
95
+ part_chars_used = part_chars_used + 1;
96
+ } else {
97
+ part_chars_used = part_chars_used + 2;
98
+ }
99
+ }
100
+ } else {
101
+ chars_sms = 160;
102
+ for (let i = 0; i < chars_arr.length; i++) {
103
+ partc = [...partc, charToSpan(chars_arr[i], coding, isUnicodeEnabled)];
104
+ }
105
+ }
106
+ } else {
107
+ if (chars_used > 70) {
108
+
109
+ parts = Math.ceil(chars_used / 67);
110
+ var part_chars_used = 3;
111
+ chars_sms = 67;
112
+ //partc.push(getUHDHtml(parts, part));
113
+ for (let i = 0; i < chars_arr.length; i++) {
114
+ if (part_chars_used + 1 > 70) {
115
+ part = part + 1;
116
+ // partc.push(getUHDHtml(parts, part));
117
+ part_chars_used = 3;
118
+ }
119
+ partc = [...partc, charToSpan(chars_arr[i], coding, isUnicodeEnabled)];
120
+ part_chars_used = part_chars_used + 1;
121
+ }
122
+ } else {
123
+ chars_sms = 70;
124
+ for (let i = 0; i < chars_arr.length; i++) {
125
+ partc = [...partc, charToSpan(chars_arr[i], coding, isUnicodeEnabled)];
126
+ }
127
+ }
128
+ }
129
+
130
+ console.log('Type:', (coding == '7bit' ? '7bit' : 'Unicode'));
131
+ console.log('Parts:', parts);
132
+ console.log('SMS Chars:', chars_sms);
133
+ console.log('SMS Char total:', chars_used);
134
+
135
+ return {
136
+ unicode: (coding === '7bit' ? false : true),
137
+ parts,
138
+ chars_sms,
139
+ chars_used,
140
+ char_list: partc,
141
+ };
142
+ }
143
+