Permalink
Browse files

weekley update

  • Loading branch information...
1 parent 3b9be01 commit 6b23497b0da635063f4af30fac9999434859126c @voloko voloko committed Aug 19, 2011
Showing with 1,711 additions and 1,084 deletions.
  1. +4 −61 ads/controller/app.js
  2. +63 −53 ads/controller/bulkImport.js
  3. +2 −2 ads/controller/delete.js
  4. +22 −7 ads/controller/download.js
  5. +1 −3 ads/controller/downloadBCT.js
  6. +0 −112 ads/controller/downloadConnectedObject.js
  7. +4 −2 ads/controller/duplicate.js
  8. +17 −8 ads/controller/export.js
  9. +5 −6 ads/controller/mutator.js
  10. +99 −0 ads/controller/newAd.js
  11. +17 −36 ads/controller/paste.js
  12. +2 −1 ads/controller/revert.js
  13. +61 −39 ads/controller/upload.js
  14. +28 −0 ads/en_US.js
  15. +32 −10 ads/job/adImporter.js
  16. +21 −8 ads/job/campImporter.js
  17. +27 −5 ads/job/tabSeparatedParser.js
  18. +78 −3 ads/lib/adCreativeType.js
  19. +21 −0 ads/lib/adsUserRole.js
  20. +6 −4 ads/lib/bidTypes.js
  21. +2 −0 ads/lib/completions.js
  22. +0 −3 ads/lib/creativeMap.js
  23. +10 −9 ads/lib/demoLinkBuilder.js
  24. +29 −11 ads/lib/error.js
  25. +1 −1 ads/lib/estimateTargetingStats.js
  26. +20 −0 ads/lib/prop/adgroupStatus.js
  27. +44 −23 ads/lib/prop/campType.js
  28. +28 −29 ads/lib/prop/educationStatus.js
  29. +55 −43 ads/lib/unzipImages.js
  30. +5 −6 ads/model/account.js
  31. +40 −5 ads/model/ad.js
  32. +3 −3 ads/model/ad/group.js
  33. +88 −54 ads/model/ad/props.js
  34. +1 −1 ads/model/adCreative.js
  35. +9 −2 ads/model/baseStat.js
  36. +16 −24 ads/model/campaign.js
  37. +18 −0 ads/model/campaign/group.js
  38. +16 −2 ads/model/connectedObject.js
  39. +34 −7 ads/model/image.js
  40. +1 −1 ads/model/topline.js
  41. +14 −7 ads/view/adEditor/creative.js
  42. +1 −0 ads/view/adEditor/eduWork.js
  43. +2 −1 ads/view/adEditor/pricing.js
  44. +34 −28 ads/view/adPane.js
  45. +1 −1 ads/view/adPane/formatters.js
  46. +91 −10 ads/view/basePane.js
  47. +33 −29 ads/view/campEditor.js
  48. +8 −15 ads/view/campPane.js
  49. +47 −64 ads/view/campPane/formatters.js
  50. +37 −6 ads/view/connectedObjectDialog.js
  51. +10 −9 ads/view/contractPane.js
  52. +1 −1 ads/view/downloadDialog.js
  53. +158 −160 ads/view/imageSelector.js
  54. +1 −2 ads/view/logDialog.js
  55. +4 −0 ads/view/logDialog/loadDialog.css
  56. +69 −0 ads/view/selectDialog.js
  57. +1 −0 app.js
  58. +16 −2 lib/async.js
  59. +4 −0 lib/connect.js
  60. +48 −48 lib/formatters.js
  61. +142 −100 lib/graphlink.js
  62. +1 −1 lib/pathUtils.js
  63. +1 −1 storage/storage.js
  64. +13 −0 tx.js
  65. +7 −8 uki-fb/binding.js
  66. +2 −0 uki-fb/view/dataList.js
  67. +11 −4 uki-fb/view/dataTable.js
  68. +1 −1 uki-fb/view/dataTable/dataTable.css
  69. +17 −0 uki-fb/view/dialog.js
  70. +4 −0 uki-fb/view/searchInput.js
  71. +2 −2 uki-fb/view/text.js
View
@@ -80,12 +80,12 @@ function checkInstalled() {
{ view: 'DialogContent', childViews: [
{ view: 'DialogBody', childViews: [
{ view: 'Text',
- text: 'Please install Power Editor Chrome Extension before using.'
+ text: tx('ads:pe:please-install-chrome')
}
] },
{ view: 'DialogFooter', childViews: [
- { view: 'Button', use: 'confirm', label: 'Install',
- large: true,
+ { view: 'Button', use: 'confirm',
+ label: tx('ads:pe:chrome-install-button'), large: true,
on: { click: function() { location.href = installLink; } } }
] }
] }
@@ -294,6 +294,7 @@ function layout() {
function _initHandler() {
require("./paste").Paste.init();
require("./delete").Delete.init();
+ require("./newAd").NewAd.init();
view.byId('adPane-data').list().on('selection', function() {
if (this.selectedIndexes().length > 1) {
@@ -317,64 +318,6 @@ function _initHandler() {
}
});
- // treat statDates as global control
- // probably should be moved to Head in ui
- view.byId('statDates').on('change.range', function(e) {
- var dateRange = this;
- dateRange.loading(true);
-
- // load remote stat for all campaigns/ads
- models.Account.findAll(function(accounts) {
- // to fetch all accounts
- accounts = accounts.slice();
- models.AdStat.loadFromAccountsAndRange(
- accounts, e.from, e.to,
- function() {
-
- dateRange.loading(false);
- var pane = view.byId('adPane-data'),
- indexes = pane.selectedIndexes(),
- lcIndex = pane.lastClickIndex();
-
- pane.data().statRange(e);
- pane
- .data(pane.data())
- .selectedIndexes(indexes)
- .lastClickIndex(lcIndex)
- .layoutIfVisible();
- });
- });
- });
-
-
- view.byId('campStatDates').on('change.range', function(e) {
- var dateRange = this;
- dateRange.loading(true);
-
- // load remote stat for all campaigns
- models.Account.findAll(function(accounts) {
- // again fetch all accounts from db
- accounts = accounts.slice();
- models.CampStat.loadFromAccountsAndRange(
- accounts, e.from, e.to,
- function() {
-
- dateRange.loading(false);
- var pane = view.byId('campPane-data'),
- indexes = pane.selectedIndexes(),
- lcIndex = pane.lastClickIndex();
-
- pane.data().statRange(e);
- pane
- .data(pane.data())
- .selectedIndexes(indexes)
- .lastClickIndex(lcIndex)
- .layoutIfVisible();
- });
- });
- });
-
-
_initCampaignListHandler();
}
@@ -78,7 +78,7 @@ function startImport() {
BulkImport.importInto(
models.Account.byId(importDialog.accountId()),
data,
- { data: lookup, hashes: {} });
+ lookup);
});
});
}
@@ -90,7 +90,7 @@ function readData(callback) {
callback(reader.result);
};
if (importDialog.dataFileInput().files().length !== 1) {
- BulkImport.logError('Please select file with tab separated data');
+ BulkImport.logError(tx('ads:pe:import-nonts-error'));
return;
}
reader.readAsText(importDialog.dataFileInput().files()[0]);
@@ -100,78 +100,54 @@ function readData(callback) {
}
function readImages(callback) {
+ var lookup = { data: {}, hashes: {} };
+
if (importDialog.importImageFromZip()) {
if (importDialog.imageZipInput().files().length !== 1) {
- BulkImport.logError('Please select zip file with images');
+ BulkImport.logError(tx('ads:pe:import-nozip-error'));
return;
}
- BulkImport.log('Sending zip file to the server to unpack.');
+ BulkImport.log(tx('ads:pe:import-zip-upload-message'));
var progressBar =
BulkImport.progressDialog()
.append({ view: 'ProgressBar', value: 0, visible: false });
var progressMeter =
BulkImport.progressDialog()
.append({ view: 'Text' });
- var UnzipImagesRequest = require("../lib/unzipImages").UnzipImagesRequest;
- var req = new UnzipImagesRequest();
-
- req.file(importDialog.imageZipInput().files()[0]);
- req.on('progress', function(e) {
- progressMeter.text((e.loaded / 1024 << 0) + ' KB');
- progressBar
- .visible(!!e.lengthComputable)
- .value(e.loaded / e.total * 100);
- });
- req.on('fail', function() {
- BulkImport.log('Failed to upload zip file to the server. ' +
- 'Check your connection and try again');
- });
- req.on('load', function(e) {
- if (e.data.error) {
- BulkImport.logError(e.data.error);
- return;
- }
- var result = {};
- var list = new DeferredList();
-
- utils.forEach(e.data.files, function(dataUri, name) {
- var handler = list.newWaitHandler();
- imageReader.resizeIfNeeded(dataUri, function(resizedData) {
- result[name] = resizedData;
- handler();
+ require("../lib/unzipImages").unzip(
+ importDialog.accountId(),
+ importDialog.imageZipInput().files()[0],
+ function(result) {
+ if (result.error) {
+ BulkImport.logError(result.error.message);
+ return;
+ }
+ utils.forEach(result.images, function(img, name) {
+ var parts = name.split('/');
+ var filename = parts[parts.length - 1].toLowerCase();
+ lookup.hashes[filename] = img.hash;
});
+ callback(lookup);
});
-
- list.complete(function() {
- progressBar.parent().removeChild(progressBar);
- progressMeter.parent().removeChild(progressMeter);
-
- BulkImport.log('Unpacking complete.');
- callback(result);
- });
- });
- req.send();
} else {
var list = new DeferredList();
-
var files = utils.reduce(
importDialog.imageFileInputs(),
function(arr, view) {
return arr.concat(utils.toArray(view.files()));
}, []);
- var result = {};
utils.forEach(files, function(f) {
var handler = list.newWaitHandler();
imageReader.read(f, function(dataUri) {
- result[f.name] = dataUri;
+ lookup.data[f.name.toLowerCase()] = dataUri;
handler();
});
});
list.complete(function() {
- callback(result);
+ callback(lookup);
});
}
}
@@ -184,15 +160,19 @@ function initErrors() {
BulkImport.importInto = function(account, text, imageLookup) {
require("../lib/completions").dialog = BulkImport.progressDialog();
+ var message = BulkImport.log(tx(
+ 'ads:pe:import-parsets-message',
+ { percent: formatter(0) }));
var parser = new ParserJob(account, text, imageLookup);
+ var formatter = require("../../lib/formatters").createPercentFormatter(2);
parser.oncomplete(function() {
if (parser.errors().length) {
BulkImport.logError(parser.errors()[0].message());
return;
}
if (parser.foundCampProps().length < 1) {
- BulkImport.logError('Data does not campaign info.');
+ BulkImport.logError(tx('ads:pe:import-nocampaigns-error'));
return;
}
@@ -208,37 +188,67 @@ BulkImport.importInto = function(account, text, imageLookup) {
.adPropsToCopy(utils.pluck(parser.foundAdProps(), 'name'));
}
+ var importMessage = BulkImport.log(
+ tx('ads:pe:import-create-camps-message', { percent: formatter(0) }));
+
+ var firstZerro = true;
+ var secondMessage = false;
importer
.onerror(function(e) { BulkImport.logWarning(e.error.message()); })
- .oncomplete(function() { BulkImport.complete(); }).start();
+ .oncomplete(function() { BulkImport.complete(); })
+ .onprogress(function(e) {
+ var status = e.status;
+ if (status.complete === 0 && !firstZerro) {
+ importMessage = BulkImport.log(
+ tx(
+ 'ads:pe:import-create-ads-message',
+ { percent: formatter(0) }));
+ secondMessage = true;
+ }
+ firstZerro = false;
+ var data = { percent: formatter(status.complete / status.total) };
+ importMessage.text(secondMessage ?
+ tx('ads:pe:import-create-ads-message', data) :
+ tx('ads:pe:import-create-camps-message', data));
+ })
+ .start();
} else {
// import ads only
BulkImport.importAds(account, parser.ads(), parser);
}
- }).start();
+ })
+ .onprogress(function(e) {
+ var status = e.status;
+ var percent = status.complete / status.total;
+ message.text(tx(
+ 'ads:pe:import-parsets-message',
+ { percent: formatter(percent) }));
+ })
+ .start();
};
BulkImport.complete = function() {
- BulkImport.log('Finished importing', 'message');
+ var row = BulkImport.log(tx('ads:pe:import-finished-message'), 'message');
App.reload();
+ return row;
};
BulkImport.logError = function(msg) {
- BulkImport.log(msg, 'error');
+ return BulkImport.log(msg, 'logDialog-error');
};
BulkImport.logWarning = function(msg) {
- BulkImport.log(msg, 'warning');
+ return BulkImport.log(msg, 'logDialog-warning');
};
BulkImport.progressDialog = function() {
return this._progressDialog || (this._progressDialog =
- new LogDialog().title('Importing'));
+ new LogDialog().title(tx('ads:pe:import-title')));
};
BulkImport.log = function(msg, type) {
BulkImport.errors.push({ type: type, msg: msg });
- this.progressDialog().log(msg, 'bulkImport-' + type);
+ return this.progressDialog().log(msg, type);
};
@@ -39,7 +39,7 @@ var Delete = {};
/**
* @param id the ID of the pane that contains the items
- * @param update_status The status field. For ads it's 'adgroup_status'.
+ * @param update_status The status field. For ads it's 'real_adgroup_status'.
* For campaigns it's 'campaign-status'
*/
function delete_items(id, update_status) {
@@ -85,7 +85,7 @@ Delete.init = function() {
};
Delete.handleAds = function() {
- delete_items('adPane', 'adgroup_status');
+ delete_items('adPane', 'real_adgroup_status');
};
Delete.handleCamps = function() {
@@ -30,7 +30,7 @@ var utils = require("../../uki-core/utils"),
storage = require("../../storage/storage"),
libUtils = require("../../lib/utils"),
asyncUtils = require("../../lib/async"),
- graphlink = require("../../lib/graphlink"),
+ graphlink = require("../../lib/graphlink").gl,
App = require("./app").App,
DownloadDialog = require("../view/downloadDialog").DownloadDialog,
@@ -53,7 +53,6 @@ var META_REFRESH_TIMEOUT = 1000 * 60 * 60 * 24 * 7; // once per week
*/
var Download = {};
-
// -------- DOWNLOAD DIALOG SETUP -----------
// Logic from old sync.js
// Moved flow logic to make syncing easier later
@@ -114,12 +113,24 @@ Download._ondownload = function(e) {
* @param callback called on finish
* @param account_ids array of account ids being dl'd
*/
-Download.loadModels = function(progress, callback, account_ids) {
+Download.loadModels = function(progress, cb, account_ids) {
progress = progress || fun.FT;
- callback = callback || fun.FT;
+ var callback = function() {
+ // unset progress handler
+ graphlink.removeListener('progress');
+ graphlink.removeListener('error');
+ cb && cb();
+ };
progress.statusUpdate();
- graphlink.progress = progress;
+ graphlink.on('progress', function(e) {
+ progress.statusUpdate(e.update);
+ });
+ graphlink.on('error', function(e) {
+ var err = e.error;
+ alert(err.message);
+ callback();
+ });
var state = null;
@@ -275,6 +286,7 @@ function loadContracts(account_ids, state, progress, callback) {
}
Contract.loadFromRESTAPI(account_options, function(contracts) {
+ progress.statusUpdate(contracts.length);
progress.completeStep('contracts');
contracts.prefetch && contracts.prefetch();
callback(contracts);
@@ -294,8 +306,7 @@ function loadContracts(account_ids, state, progress, callback) {
* @param callback called on finish with all topliness downloaded
* as a parameter
*/
-function loadToplines(acc_ids, contracts, progress, callback,
- _totalToplines) {
+function loadToplines(acc_ids, contracts, progress, callback, _totalToplines) {
progress.setStep('toplines');
_totalToplines = _totalToplines || [];
@@ -307,11 +318,15 @@ function loadToplines(acc_ids, contracts, progress, callback,
return;
}
+
+
Topline.loadFromRESTAPI(
{ account_id: contracts[0].id() },
function(toplines) {
+ progress.statusUpdate(toplines.length);
progress.completeStep('toplines');
_totalToplines = _totalToplines.concat(toplines);
+
loadToplines(acc_ids, contracts.slice(1),
progress, callback, _totalToplines);
Oops, something went wrong.

0 comments on commit 6b23497

Please sign in to comment.