Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Work on link to Data Set option (incomplete); closes #28, closes #29

  • Loading branch information...
commit 5134868f943185bd821c9bddf57be317f0d5c5fa 1 parent 9bdd5e7
@benkeen authored
View
2  ajax.php
@@ -40,4 +40,4 @@
}
} else {
echo $encoded;
-}
+}
View
6 docs/thanks.php
@@ -7,7 +7,8 @@
<h2>Thanks!</h2>
<p>
- The Data Generator uses the work of a LOT of people. Thanks to the everybody involved in the following:
+ The Data Generator uses the work of a LOT of people. Thanks to the everybody involved in the following. You all rock. I would be <i>proud</i>
+ if any of you wanted to marry my sister.
</p>
<ul>
@@ -19,6 +20,7 @@
<li><a href="http://harvesthq.github.com/chosen/" target="_blank">Chosen</a> - select box enhancement script</li>
<li><a href="http://code.google.com/p/jquery-json/" target="_blank">jQuery JSON plugin</a></li>
<li><a href="http://twitter.github.com/bootstrap/" target="_blank">Bootstrap</a></li>
+ <li><a href="http://sass-lang.com/" target="_blank">Sass</a> - Syntactically Awesome Stylesheets</li>
<li><a href="http://excanvas.sourceforge.net/" target="_blank">ExplorerCanvas</a> - </li>
<li><a href="http://www.iconfinder.com/icondetails/50830/128/dice_icon" target="_blank">La Glanz Studio - dice icon (main logo)</a></li>
<li><a href="http://led24.de/iconset/" target="_blank">Nice bug icon</a></li>
@@ -26,7 +28,7 @@
<p>
And a big thanks to Addy Osmani for his excellent article: <a href="http://addyosmani.com/largescalejavascript/">Patterns For
- Large-Scale JavaScript Application Architecture</a>. The client-side code was largely based on his article.
+ Large-Scale JavaScript Application Architecture</a>. The client-side code architecture was largely based on his article.
</p>
</div>
View
21 plugins/dataTypes/TextFixed/TextFixed.js
@@ -1,4 +1,4 @@
-/*global $:false*/
+/*global $:false,define:false*/
define([
"manager",
"constants",
@@ -18,11 +18,24 @@ define([
var MODULE_ID = "data-type-TextFixed";
var LANG = L.dataTypePlugins.TextFixed;
- var _saveRow = function() {
-
+ var _saveRow = function(rowNum) {
+ return {
+ numWords: $("dtNumWords_" + rowNum).val()
+ };
};
- var _loadRow = function() {
+ var _loadRow = function(rowNum, data) {
+ return {
+ execute: function() { },
+ isComplete: function() {
+ if (data && $("#dtNumWords_" + rowNum).length) {
+ $("dtNumWords_" + rowNum).val(data.numWords);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ };
};
View
6 plugins/exportTypes/SQL/SQL.class.php
@@ -181,7 +181,7 @@ private function generateCreateTableSQL_MySQL() {
}
if ($this->createTable) {
- $content = "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
+ $content .= "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
if ($this->primaryKey == "default") {
$content .= "{$prefix}{$this->backquote}id{$this->backquote} mediumint(8) unsigned NOT NULL auto_increment,$endLineChar";
}
@@ -258,7 +258,7 @@ private function generateCreateTableSQL_Oracle() {
}
if ($this->createTable) {
- $content = "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
+ $content .= "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
if ($this->primaryKey == "default") {
$content .= "{$prefix}{$this->backquote}id{$this->backquote} number primary key,$endLineChar";
}
@@ -331,7 +331,7 @@ private function generateCreateTableSQL_SQLite() {
}
if ($this->createTable) {
- $content = "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
+ $content .= "CREATE TABLE {$this->backquote}{$this->tableName}{$this->backquote} ($endLineChar";
if ($this->primaryKey == "default") {
$content .= "{$prefix}{$this->backquote}id{$this->backquote} INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,$endLineChar";
}
View
34 resources/classes/Account.class.php
@@ -47,24 +47,25 @@ public function __construct($accountID) {
$this->date_expires = date("U", strtotime($accountInfo["date_expires"]));
$this->firstName = $accountInfo["first_name"];
$this->lastName = $accountInfo["last_name"];
-
$this->getConfigurations();
+ $this->numRowsGenerated = $accountInfo["num_rows_generated"];
}
}
public function getAccount() {
return array(
- "isAnonymous" => $this->isAnonymous,
- "accountID" => $this->accountID,
- "accountType" => $this->accountType,
- "dateCreated" => $this->dateCreated,
- "lastUpdated" => $this->lastUpdated,
- "dateExpires" => $this->dateExpires,
- "firstName" => $this->firstName,
- "lastName" => $this->lastName,
- "email" => $this->email,
- "configurations" => $this->configurations
+ "isAnonymous" => $this->isAnonymous,
+ "accountID" => $this->accountID,
+ "accountType" => $this->accountType,
+ "dateCreated" => $this->dateCreated,
+ "lastUpdated" => $this->lastUpdated,
+ "dateExpires" => $this->dateExpires,
+ "firstName" => $this->firstName,
+ "lastName" => $this->lastName,
+ "email" => $this->email,
+ "configurations" => $this->configurations,
+ "numRowsGenerated" => $this->numRowsGenerated
);
}
@@ -157,8 +158,8 @@ public function saveConfiguration($data) {
if ($configurationID == null) {
$response = Core::$db->query("
- INSERT INTO {$prefix}configurations (date_created, last_updated, account_id, configuration_name, content)
- VALUES ('$now', '$now', $accountID, '" . $configurationName . "', '" . $content . "')
+ INSERT INTO {$prefix}configurations (status, date_created, last_updated, account_id, configuration_name, content)
+ VALUES ('private', '$now', '$now', $accountID, '" . $configurationName . "', '" . $content . "')
");
if ($response["success"]) {
@@ -228,7 +229,6 @@ public static function createUser($accountInfo) {
}
-
public function updateRowsGeneratedCount($configurationID, $rowsGenerated) {
if (!is_numeric($rowsGenerated)) {
return;
@@ -242,6 +242,12 @@ public function updateRowsGeneratedCount($configurationID, $rowsGenerated) {
SET num_rows_generated = num_rows_generated+$cleanRowsGenerated
WHERE account_id = $accountID AND configuration_id = $configurationID
");
+
+ $response = Core::$db->query("
+ UPDATE {$prefix}user_accounts
+ SET num_rows_generated = num_rows_generated+$cleanRowsGenerated
+ WHERE account_id = $accountID
+ ");
}
}
View
19 resources/classes/AjaxRequest.class.php
@@ -227,6 +227,25 @@ public function __construct($action, $post = array()) {
$this->response["content"] = $response["message"];
break;
+ case "getDataSetLink":
+ Core::init();
+ $configurationIDs = $post["configurationIDs"];
+
+ $google_url_shortener_key = "***enter code here***";
+ $url = array("longUrl" => $_POST["url"]);
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, "https://www.googleapis.com/urlshortener/v1/url?key=$google_url_shortener_key");
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($url));
+ $output = curl_exec($ch);
+ curl_close($ch);
+
+ echo $output;
+
+ break;
+
/*
case "login":
break;
View
2  resources/classes/Core.class.php
@@ -27,7 +27,7 @@ class Core {
private static $defaultTheme = "classic";
// non-overidable settings
- private static $version = "3.0.0";
+ private static $version = "3.0.0 alpha 1";
private static $minimumPHPVersion = "5.2.0";
private static $settingsFileExists = false;
private static $dataTypeGroups = array("human_data", "geo", "text", "numeric", "other");
View
2  resources/classes/Installation.class.php
@@ -84,6 +84,7 @@ public static function createCoreTables() {
$queries[] = "
CREATE TABLE {$prefix}configurations (
configuration_id mediumint(9) NOT NULL auto_increment,
+ status ENUM('public','private') NOT NULL,
date_created datetime NOT NULL,
last_updated datetime NOT NULL,
account_id mediumint(9) NOT NULL,
@@ -151,6 +152,7 @@ public static function createCoreTables() {
password varchar(50) NOT NULL,
password_recovery_question varchar(100) default NULL,
password_recovery_answer varchar(100) default NULL,
+ num_rows_generated mediumint(9) default 0,
max_records mediumint(9) default NULL,
PRIMARY KEY (account_id)
)
View
76 resources/scripts/generator.js
@@ -115,6 +115,7 @@ define([
$("#gdResetPluginsBtn").bind("click", _resetPluginsDialog);
$("#gdTextSize").on("click", "li", _changeTextSize);
$("#gdGenerationPanelCancel").on("click", _cancelGeneration);
+ $("#gdDataSetPublic").on("click", _toggleDataSetVisibilityStatus);
// icon actions
$("#gdSaveBtn").on("click", _onClickSaveIcon);
@@ -131,6 +132,7 @@ define([
$("#gdDataSetHelpNav").on("click", "a", _onclickDataTypeHelpNav);
$("#gdTableRows").on("click", ".ui-icon-help", _onClickDataSetRowHelp);
$("#gdSelectAllDataSets").on("click", _onToggleSelectAllDataSets);
+ $("#gdDataSetStatusLine").html("not saved");
_initMainDialog();
_initExportTypeTab();
@@ -197,7 +199,7 @@ define([
// update the status line
var lastUpdated = moment.unix(configuration.last_updated_unix).format("h:mm A, MMM Do YYYY");
- $("#gdDataSetStatusLine").html("Last edited " + lastUpdated);
+ $("#gdDataSetStatusLine").html("last edited " + lastUpdated);
utils.stopProcessing();
@@ -311,10 +313,8 @@ define([
success: function(response) {
if (response.success) {
_currConfigurationID = response.content;
- console.log(response);
-
var lastUpdated = moment.unix(response.lastUpdated).format("h:mm A, MMM Do YYYY");
- $("#gdDataSetStatusLine").html("Last saved: " + lastUpdated);
+ $("#gdDataSetStatusLine").html("last saved: " + lastUpdated);
_getAccount();
} else {
// TODO
@@ -460,6 +460,8 @@ define([
_selectExportTypeTab($(".gdDefaultExportType").data("exportType"), true);
manager.resetExportTypes();
+ $("#gdDataSetStatusLine").html("not saved");
+
manager.publish({
sender: MODULE_ID,
type: C.EVENT.DATA_TABLE.CLEAR
@@ -1232,8 +1234,6 @@ define([
var _onSuccessDeleteDataSets = function(response) {
-
- // if the delete was successful
if (response.success) {
// update the first tab (Num Saved Data Sets)
@@ -1252,6 +1252,8 @@ define([
_displayDataSets();
_toggleDeleteDataSetButton();
+ } else {
+ // TODO
}
};
@@ -1295,17 +1297,13 @@ define([
if (_accountInfo.isAnonymous) {
$("#gdAccount_AccountType").html("Anonymous admin account");
} else {
-
+ // TODO
}
$("#gdAccount_NumSavedDataSets").html(_dataSets.length);
$("#gdAccount_DateAccountCreated").html(moment.unix(_accountInfo.dateCreated).format("MMM Do, YYYY"));
-
- var totalRowsGenerated = 0;
- for (var i=0; i<_dataSets.length; i++) {
- totalRowsGenerated += parseInt(_dataSets[i].num_rows_generated, 10);
- }
- $("#gdAccount_TotalRowsGenerated").html(utils.formatNumWithCommas(totalRowsGenerated));
+ var numRowsGenerated = parseInt(_accountInfo.numRowsGenerated, 10);
+ $("#gdAccount_TotalRowsGenerated").html(utils.formatNumWithCommas(numRowsGenerated));
};
var _displayDataSets = function() {
@@ -1318,11 +1316,13 @@ define([
currDataSet = _dataSets[i];
var dateCreated = moment.unix(currDataSet.date_created_unix).format("MMM Do, YYYY");
var lastUpdated = moment.unix(currDataSet.last_updated_unix).format("MMM Do, YYYY");
+ var isPublic = (currDataSet.status == "public") ? 'checked="checked"' : "";
row = '<tr data-id="' + currDataSet.configuration_id + '">' +
'<td class="leftAligned">' + currDataSet.configuration_name + '</td>' +
'<td class="leftAligned">' + dateCreated + '</td>' +
'<td class="leftAligned">' + lastUpdated + '</td>' +
+ '<td align="center"><input type="checkbox" class="gdDataSetStatus" id="gdDataSetStatus_' + currDataSet.configuration_id + '" ' + isPublic + ' /></td>' +
'<td class="gdDataSetNumRowsGenerated" align="center">' + utils.formatNumWithCommas(currDataSet.num_rows_generated) + '</td>' +
'<td align="center"><a href="#">load</a></td>' +
'<td align="center"><input type="checkbox" class="gdDeleteDataSets" value="' + currDataSet.configuration_id + '"/></td>' +
@@ -1389,7 +1389,55 @@ define([
};
var _openDataSetLinkDialog = function(e) {
-
+ if (_currConfigurationID === null) {
+ $("#gdLinkToDataSet_incomplete").removeClass("hidden");
+ $("#gdLinkToDataSet_complete").addClass("hidden");
+ } else {
+ $("#gdLinkToDataSet_incomplete").addClass("hidden");
+ $("#gdLinkToDataSet_complete").removeClass("hidden");
+ }
+
+ $("#gdLinkToDataSetDialog").dialog({
+ title: 'Link to Data Set',
+ dialogClass: "gdMainDialog",
+ width: 500,
+ modal: true,
+ resizable: false,
+ open: function() {
+ if (_currConfigurationID !== null) {
+ var url = window.location.href.replace(/(#.*)/, "");
+ url = url.replace(/(\?.*)/, "") + "?load=" + _currConfigurationID;
+ $("#gdLinkURL").data("url", url);
+
+ var config = _getConfiguration(_currConfigurationID);
+ if (config.status == "public") {
+ $("#gdDataSetPublic").attr("checked", "checked");
+ $("#gdLinkURL").val(url + "?load=" + _currConfigurationID).removeClass("gdDisabled").removeAttr("disabled").select();
+ } else {
+ $("#gdDataSetPublic").removeAttr("checked");
+ $("#gdLinkURL").val("-").attr("disabled", "disabled").addClass("gdDisabled");
+ }
+ }
+ },
+ buttons: [
+ {
+ text: "Close",
+ click: function() { $(this).dialog("close"); }
+ }
+ ]
+ });
+
+ return false;
+ };
+
+
+ var _toggleDataSetVisibilityStatus = function(e) {
+ if (e.target.checked) {
+ var url = $("#gdLinkURL").data("url");
+ $("#gdLinkURL").removeClass("gdDisabled").removeAttr("disabled").val(url).select();
+ } else {
+ $("#gdLinkURL").addClass("gdDisabled").attr("disabled", "disabled").val("-");
+ }
};
View
18 resources/templates/mainDialog.tpl → resources/templates/dialogs.tpl
@@ -1,3 +1,5 @@
+<div id="gdEmptyFormDialog"></div>
+
<div id="gdMainDialog" class="hidden">
<div id="gdMainDialogTabs">
<ul>
@@ -37,6 +39,7 @@
<th class="leftAligned">Data Set Name</th>
<th class="leftAligned">Data Created</th>
<th class="leftAligned">Last Used</th>
+ <th align="center">Public?</th>
<th align="center">Rows Generated</th>
<th width="60" align="center">Load</th>
<th width="30" align="center"><input type="checkbox" id="gdSelectAllDataSets" /></th>
@@ -56,3 +59,18 @@
</div>
</div>
</div>
+
+<div id="gdLinkToDataSetDialog" class="hidden">
+ <div id="gdLinkToDataSet_incomplete">
+ <p>
+ De-<i>nied</i>. In order to share this Data Set with other people, you need to save it first.
+ </p>
+ </div>
+ <div id="gdLinkToDataSet_complete">
+ <p>
+ <input type="checkbox" id="gdDataSetPublic" />
+ <label for="gdDataSetPublic">Make this Data Set public.</label>
+ </p>
+ <input type="input" id="gdLinkURL" readonly="true" />
+ </div>
+</div>
View
4 resources/templates/footer.tpl
@@ -1,7 +1,7 @@
<footer>
<ul>
<li><span>{$L.version} {$version} - <a href="https://github.com/benkeen/generatedata" target="_blank">GitHub</a></span></li>
- <li><span><a href="docs/">Developer Doc</a></span></li>
- <li><span><a href="https://github.com/benkeen/generatedata/issues" id="gdReportBug" target="_blank">Report a Bug</a></span></li>
+ <li><span><a href="docs/">Developer doc</a></span></li>
+ <li><span><a href="https://github.com/benkeen/generatedata/issues" id="gdReportBug" target="_blank">Report a bug</a></span></li>
</ul>
</footer>
View
3  resources/templates/generate.tab1.tpl
@@ -117,7 +117,6 @@
</form>
-<div id="gdEmptyFormDialog"></div>
<div class="hidden">
<div id="gdTableRowTemplate">
<ul>
@@ -141,4 +140,4 @@
</div>
-{include file="mainDialog.tpl"}
+{include file="dialogs.tpl"}
View
2  resources/templates/generate.tab3.tpl
@@ -48,7 +48,7 @@
<div>
Theme
- <input type="radio" name="theme" value="default" id="gdTheme1" {if $settings.theme == "default"}checked="checked"{/if} />
+ <input type="radio" name="theme" value="default" id="gdTheme1" {if $settings.theme == "default"}checked="checked"{/if} disabled="disabled" />
<label for="gdTheme1">Default</label>
<input type="radio" name="theme" value="classic" id="gdTheme2" {if $settings.theme == "classic"}checked="checked"{/if} />
<label for="gdTheme2">Classic</label>
View
2  resources/templates/index.tpl
@@ -32,7 +32,7 @@
</nav>
</header>
<nav id="gdMainTabs">
- <span id="gdDataSetStatusLine">Not saved.</span>
+ <span id="gdDataSetStatusLine"></span>
<span id="gdProcessingIcon"></span>
<ul>
<li id="gdMainTab1" class="gdSelected">{$L.generate}</li>
View
4 resources/themes/classic/compiled/mainDialog.css
@@ -120,3 +120,7 @@ body .gdMainDialog .ui-dialog-title span {
.gdMainDialog .ui-dialog-title {
background: transparent url(../images/logoSmall.png) center left no-repeat;
padding: 4px 0px 3px 52px; }
+
+#gdLinkURL {
+ font-size: 16pt;
+ width: 100%; }
View
4 resources/themes/classic/compiled/styles.css
@@ -1180,3 +1180,7 @@ body .gdMainDialog .ui-dialog-title span {
.gdMainDialog .ui-dialog-title {
background: transparent url(../images/logoSmall.png) center left no-repeat;
padding: 4px 0px 3px 52px; }
+
+#gdLinkURL {
+ font-size: 16pt;
+ width: 100%; }
View
5 ...urces/themes/classic/sass/mainDialog.scss → resources/themes/classic/sass/dialogs.scss
@@ -164,3 +164,8 @@ body .gdMainDialog .ui-dialog-title span {
padding: 4px 0px 3px 52px;
}
+
+#gdLinkURL {
+ font-size: 16pt;
+ width: 100%;
+}
View
2  resources/themes/classic/sass/styles.scss
@@ -1 +1 @@
-@import "general", "layout", "generator", "buttons", "misc", "notifications", "errorPage", "install", "mainDialog";
+@import "general", "layout", "generator", "buttons", "misc", "notifications", "errorPage", "install", "dialogs";
Please sign in to comment.
Something went wrong with that request. Please try again.