render: function() { var processedRows = this.model.get('processed_rows') || 0; var processableRows = this.model.get('processable_rows') || 0; var realRows = this.model.get('real_rows') || 0; var isLatLngType = this.model.get('latitude_column') && this.model.get('longitude_column'); var d = { realRows: realRows, tableName: this.model.get('table_name'), canCancel: _.isFunction(this.model.cancelGeocoding), hasFailed: this.model.hasFailed(), hasCompleted: this.model.hasCompleted(), processedRows: processedRows, processableRows: processableRows, processableRowsFormatted: Utils.formatNumber(processableRows), realRowsPluralize: pluralizeString('row', 'rows', this.model.get('real_rows')), realRowsFormatted: Utils.formatNumber(realRows), processableRowsPluralize: pluralizeString('row', 'rows', processableRows), width: realRows > 0 ? (processableRows/realRows) : 100, isLatLngType: isLatLngType } this.$el.html(this.template(d)); return this; },
render_content: function() { var error = this.model.get('error') || {}; var processedRows = this.model.get('processed_rows') || 0; var processableRows = this.model.get('processable_rows') || 0; var realRows = this.model.get('real_rows') || 0; var geometryType = this.model.get('geometry_type') || 'point'; // Related to price and credits var price = this.model.get('price'); var hasPrice = price !== undefined && price !== null; var googleUser = this.user.featureEnabled('google_maps'); var datasetURL; if (this.user && this.model.get('table_name')) { var vis = new cdb.admin.Visualization({ type: 'table', table: { name: this.model.get('table_name') } }); vis.permission.owner = this.user; datasetURL = encodeURI(vis.viewUrl(this.user).edit()); } // Select template var template = 'common/background_polling/views/geocodings/'; if (this.model.hasCompleted()) { template += realRows === 0 ? 'geocoding_no_result_details' : 'geocoding_success_details'; } else { template += 'geocoding_error_details'; } return cdb.templates.getTemplate(template)({ id: this.model.get('id'), geometryTypePluralize: pluralizeString(geometryType, geometryType + 's', processableRows), geometryType: geometryType, remainingQuotaFormatted: Utils.formatNumber(this.model.get('remaining_quota')), googleUser: googleUser, tableName: this.model.get('table_name'), state: this.model.get('state') || '', blockPrice: this.user.get('geocoding').block_price, realRows: realRows, realRowsFormatted: Utils.formatNumber(realRows), processedRows: processedRows, processableRows: processableRows, processableRowsFormatted: Utils.formatNumber(processableRows), hasPrice: hasPrice, price: price, customHosted: cdb.config.get('cartodb_com_hosted'), errorDescription: error.description, showGeocodingDatasetURLButton: this.options.showGeocodingDatasetURLButton && datasetURL, datasetURL: datasetURL }); }
render: function() { var vis = this.model; var user = this.user; var table = vis.tableMetadata(); var isOwner = vis.permission.isOwner(user); var tags = vis.get('tags') || []; var desc = { safeHTML: cdb.core.sanitize.html(markdown.toHTML(vis.get('description') || '')) }; desc.clean = cdb.Utils.stripHTML(desc.safeHTML); var d = { isRaster: vis.get('kind') === 'raster', geometryType: table.statsGeomColumnTypes().length > 0 ? table.statsGeomColumnTypes()[0] : '', title: vis.get('name'), datasetUrl: encodeURI(vis.viewUrl(this.user).edit()), isOwner: isOwner, owner: vis.permission.owner.renderData(this.user), showPermissionIndicator: !isOwner && vis.permission.getPermission(user) === cdb.admin.Permission.READ_ONLY, desc: desc, privacy: vis.get('privacy').toLowerCase(), likes: vis.get('likes') || 0, timeDiff: moment(vis.get('updated_at')).fromNow(), tags: tags, tagsCount: tags.length, router: this.router, maxTagsToShow: 3, rowCount: undefined, datasetSize: undefined, syncStatus: undefined, syncRanAt: undefined }; var rowCount = table.get('row_count'); if (rowCount >= 0) { d.rowCount = ( rowCount < 10000 ? Utils.formatNumber(rowCount) : Utils.readizableNumber(rowCount) ); d.pluralizedRows = pluralizeString('Row', rowCount); } var datasetSize = table.get('size'); if (datasetSize >= 0) { d.datasetSize = Utils.readablizeBytes(datasetSize, true); } if (!_.isEmpty(vis.get("synchronization"))) { d.syncRanAt = moment(vis.get("synchronization").ran_at || new Date()).fromNow(); d.syncStatus = vis.get("synchronization").state; } this.$el.html(this.template(d)); this._renderLikesIndicator(); this._renderTooltips(); // Item selected? this.$el[ vis.get('selected') ? 'addClass' : 'removeClass' ]('is--selected'); return this; },
render: function() { var vis = this.model; var table = this.table; var tags = vis.get('tags') || []; var description = vis.get('description') && Utils.stripHTML(markdown.toHTML(vis.get('description'))) || ''; var d = { isRaster: vis.get('kind') === 'raster', geometryType: table.geomColumnTypes().length > 0 ? table.geomColumnTypes()[0] : '', title: vis.get('name'), isOwner: vis.permission.isOwner(this.user), owner: vis.permission.owner.renderData(this.user), showPermissionIndicator: !vis.permission.hasWriteAccess(this.user), description: description, privacy: vis.get('privacy').toLowerCase(), likes: vis.get('likes') || 0, timeDiff: moment(vis.get('updated_at')).fromNow(), tags: tags, tagsCount: tags.length, maxTagsToShow: 3, rowCount: undefined, datasetSize: undefined, syncStatus: undefined, syncRanAt: undefined }; var rowCount = table.get('row_count'); if (rowCount >= 0) { d.rowCount = ( rowCount < 10000 ? Utils.formatNumber(rowCount) : Utils.readizableNumber(rowCount) ); d.pluralizedRows = pluralizeString('Row', rowCount); } var datasetSize = table.get('size'); if (datasetSize >= 0) { d.datasetSize = Utils.readablizeBytes(datasetSize, true); } if (!_.isEmpty(vis.get("synchronization"))) { d.syncRanAt = moment(vis.get("synchronization").ran_at || new Date()).fromNow(); d.syncStatus = vis.get("synchronization").state; } this.$el.html(this.template(d)); this._renderLikesIndicator(); this._renderTooltips(); // Item selected? this.$el[ vis.get('selected') ? 'addClass' : 'removeClass' ]('is--selected'); return this; },
_getInfo: function () { var processedRows = this._importModel.get('processed_rows') || 0; var processableRows = this._importModel.get('processable_rows') || 0; var realRows = this._importModel.get('real_rows') || 0; var isLatLngType = this._importModel.get('latitude_column') && this._importModel.get('longitude_column'); var d = { realRows: realRows, tableName: this._importModel.get('table_name'), canCancel: _.isFunction(this._importModel.cancelGeocoding), hasFailed: this._importModel.hasFailed(), hasCompleted: this._importModel.hasCompleted(), processedRows: processedRows, processableRows: processableRows, processableRowsFormatted: Utils.formatNumber(processableRows), realRowsFormatted: Utils.formatNumber(realRows), width: realRows > 0 ? (processableRows / realRows).toFixed(0) : 100, isLatLngType: isLatLngType }; return template(d); },
var availablePlans = _.compact(this.collection.map(function(plan) { if (plan.get('price') === 0) { return false; } else { return { name: plan.get('title').toLowerCase(), price: Utils.formatNumber(plan.get('price')), quota: Utils.readablizeBytes(plan.get('bytes_quota')).replace(/\.00/g,''), layers: plan.get('max_layers'), privateMaps: plan.get('private_tables'), removableBrand: plan.get('removable_brand') } } }));
render: function() { var vis = this.model; var table = this.table; var tags = vis.get('tags') || []; var description = vis.get('description') && Utils.stripHTML(markdown.toHTML(vis.get('description'))) || ''; var source = vis.get('source') && markdown.toHTML(vis.get('source')) || ''; var d = { isRaster: vis.get('kind') === 'raster', geometryType: table.statsGeomColumnTypes().length > 0 ? table.statsGeomColumnTypes()[0] : '', title: vis.get('display_name') || vis.get('name'), source: source, description: description, timeDiff: moment(vis.get('updated_at')).fromNow(), tags: tags, tagsCount: tags.length, router: this.router, maxTagsToShow: 3, canImportDataset: this._canImportDataset(), rowCount: undefined, datasetSize: undefined, fromExternalSource: "" }; var rowCount = table.get('row_count'); if (rowCount >= 0) { d.rowCount = ( rowCount < 10000 ? Utils.formatNumber(rowCount) : Utils.readizableNumber(rowCount) ); d.pluralizedRows = pluralizeString('Row', rowCount); } if (!_.isEmpty(vis.get("synchronization"))) { d.fromExternalSource = vis.get("synchronization").from_external_source; } var datasetSize = table.get('size'); if (datasetSize >= 0) { d.datasetSize = Utils.readablizeBytes( datasetSize, datasetSize.toString().length > 9 ? false : true ); } this.$el.html(this.template(d)); this._setItemClasses(); this._renderTooltips(); return this; },
render: function() { var twitterData = this.user.get('twitter'); var remaining = twitterData.quota - twitterData.monthly_use; var per = Math.min(100,Math.ceil((this.model.get('value') * 100) / remaining)); this.$el.html( this.template({ value: this.model.get('value'), remaining: remaining, per: per, remainingFormatted: Utils.formatNumber(remaining), quota: twitterData.quota, block_price: twitterData.block_price, block_size: Utils.readizableNumber(twitterData.block_size) }) ) return this; },
render_content: function() { var imp = this.model.get('import'); var userTwitterValues = this.user.get('twitter'); var availableTweets = userTwitterValues.quota - userTwitterValues.monthly_use; var d = { datasetTotalRows: imp.tweets_georeferenced, datasetTotalRowsFormatted: Utils.formatNumber(imp.tweets_georeferenced), tweetsCost: imp.tweets_cost, tweetsCostFormatted: Utils.formatNumber(imp.tweets_cost), availableTweets: availableTweets, availableTweetsFormatted: Utils.formatNumber(availableTweets), tweetsOverquota: imp.tweets_overquota, tweetsOverquotaFormatted: Utils.formatNumber(imp.tweets_overquota), blockSizeFormatted: Utils.formatNumber(userTwitterValues.block_size), blockPriceFormatted: Utils.formatNumber(userTwitterValues.block_price) }; return this.template(d); }
render: function() { var src = this.options.url + "?api_key=" + this.options.api_key; var wizardName = this.model.get("visualizationType").charAt(0).toUpperCase() + this.model.get("visualizationType").slice(1); var null_count = +(this.model.get("null_ratio") * this.model.get("count")).toFixed(2); var prettyNullCount = Utils.formatNumber(null_count); this.$el.html( this.template({ column: this.model.get("column"), wizard: wizardName, metadata: this.model.get("metadata"), null_count: prettyNullCount, weight: this.model.get("weight") })); if (this.model.get("visualizationType") === "choropleth") { this._addHistogram(); } var self = this; var img = new Image(); img.onerror = function() { cdb.log.info("error loading the image for " + self.model.get("column")); }; img.onload = function() { self.$(".js-loader").hide(); self.$(".js-header").append('<img class="MapCard-preview" src="' + src + '" />'); self.$("img").show(); }; img.src = src; return this; },
render_content: function() { var imp = this.model.get('import'); var userTwitterValues = this.user.get('twitter'); var availableTweets = userTwitterValues.quota - userTwitterValues.monthly_use; var vis = this.model.importedVis(); var url = vis && encodeURI(vis.viewUrl(this.user).edit()) || ''; var d = { type: vis && vis.get('type') === "table" ? "dataset" : "map", mapURL: url, datasetTotalRows: imp.tweets_georeferenced, datasetTotalRowsFormatted: Utils.formatNumber(imp.tweets_georeferenced), tweetsCost: imp.tweets_cost, tweetsCostFormatted: Utils.formatNumber(imp.tweets_cost), availableTweets: availableTweets, availableTweetsFormatted: Utils.formatNumber(availableTweets), tweetsOverquota: imp.tweets_overquota, tweetsOverquotaFormatted: Utils.formatNumber(imp.tweets_overquota), blockSizeFormatted: Utils.formatNumber(userTwitterValues.block_size), blockPriceFormatted: Utils.formatNumber(userTwitterValues.block_price) }; return this.template(d); }
.attr('data-title', function(d) { return Utils.formatNumber(d.mapviews) + ' ' + pluralizeString('mapview', d.mapviews) + ( d.today ? (' today') : (' on ' + d.when) ) })
render: function() { this.clearSubViews(); var vis = this.model; var table = vis.tableMetadata(); var tags = vis.get('tags') || []; var url = vis.viewUrl(this.user); url = (this.router.model.get('liked') && !vis.permission.hasAccess(this.user)) ? url.public() : url.edit(); var d = { isRaster: vis.get('kind') === 'raster', geometryType: table.statsGeomColumnTypes().length > 0 ? table.statsGeomColumnTypes()[0] : '', title: vis.get('name'), datasetUrl: encodeURI(url), isOwner: vis.permission.isOwner(this.user), owner: vis.permission.owner.renderData(this.user), showPermissionIndicator: !vis.permission.hasWriteAccess(this.user), privacy: vis.get('privacy').toLowerCase(), likes: vis.get('likes') || 0, timeDiff: moment(vis.get('updated_at')).fromNow(), tags: tags, tagsCount: tags.length, router: this.router, maxTagsToShow: 3, rowCount: undefined, datasetSize: undefined, syncStatus: undefined, syncRanAt: undefined, fromExternalSource: "" }; var rowCount = table.get('row_count'); if (rowCount >= 0) { d.rowCount = ( rowCount < 10000 ? Utils.formatNumber(rowCount) : Utils.readizableNumber(rowCount) ); d.pluralizedRows = pluralizeString('Row', rowCount); } if (!_.isEmpty(vis.get("synchronization"))) { d.fromExternalSource = vis.get("synchronization").from_external_source; } var datasetSize = table.get('size'); if (datasetSize >= 0) { d.datasetSize = Utils.readablizeBytes(datasetSize, true); } if (!_.isEmpty(vis.get("synchronization"))) { d.syncRanAt = moment(vis.get("synchronization").ran_at || new Date()).fromNow(); d.syncStatus = vis.get("synchronization").state; } this.$el.html(this.template(d)); this._renderDescription(); this._renderTags(); this._renderLikesIndicator(); this._renderTooltips(); // Item selected? this.$el[ vis.get('selected') ? 'addClass' : 'removeClass' ]('is--selected'); return this; },
.attr('data-title', function(d) { return Utils.formatNumber(d[1]) })