Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
generated schema browser view
Browse files Browse the repository at this point in the history
  • Loading branch information
robmckinnon committed Apr 27, 2008
1 parent 41906f2 commit 7424e54
Show file tree
Hide file tree
Showing 26 changed files with 3,248 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/controllers/schema_browser_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class SchemaBrowserController < ApplicationController
layout "schema_browser", :except => [:schema]

def schema
respond_to do |format|
format.xml
end
end
end
130 changes: 130 additions & 0 deletions app/views/layouts/schema_browser.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<html>
<head>
<!--
WWW SQL Designer, (C) 2005-2007 Ondra Zara, [email protected]
Version: 1.4
This file is a main part of WWW SQL Designer.
WWW SQL Designer is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
WWW SQL Designer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with WWW SQL Designer; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-->

<title>SQL Designer</title>
<%= stylesheet_link_tag "schema_browser/style" %>
<%= javascript_include_tag "schema_browser/settings" %> <!-- globalni nastaveni -->
<%= javascript_include_tag "schema_browser/style" %> <!-- globalni nastaveni -->
<%= javascript_include_tag "schema_browser/generic" %> <!-- funkce nezavisle na projektu -->
<%= javascript_include_tag "schema_browser/ajax" %> <!-- ajax -->
<%= javascript_include_tag "schema_browser/sql_types" %> <!-- sql datove typy -->
<%= javascript_include_tag "schema_browser/main" %> <!-- hlavni skript -->
<%= javascript_include_tag "schema_browser/objects" %> <!-- deklarace objektu -->
<%= javascript_include_tag "schema_browser/animator" %> <!-- animovane pridani/ubrani radku -->
<%= javascript_include_tag "schema_browser/io" %> <!-- import/export -->
</head>

<body onload="load('bla')">
<div id="root">
<div id="bar"> <!-- navigacni lista nahore -->
<div id="shadow"> <!-- stin listy na jejim spodku -->
</div>

<div id="table_admin">
<div id="table_admin_label">TABLE</div>
<label for="table_name" id="table_name_label">Name:</label>
<div id="table_add_button" class="button">New table</div>
<div id="table_del_button" class="button">Delete table</div>
<div id="table_move_button" class="button">Align tables</div>

<div id="table_clear_button" class="button">Clear tables</div>
<input type="text" id="table_name" />
</div>
<div id="row_admin">
<div id="row_admin_label">ROW</div>
<label for="row_name" id="row_name_label">Name:</label>
<div id="row_add_button" class="button">Add row</div>

<div id="row_del_button" class="button">Delete row</div>
<div id="row_up_button" class="button">Up</div>
<div id="row_down_button" class="button">Down</div>
<input type="text" id="row_name" />

<input type="radio" id="row_primary" title="Primary Key" />
<label for="row_primary" id="row_primary_label" title="Primary Key">PK</label>

<label for="row_index" id="row_index_label" title="Index" >IDX</label>
<input type="checkbox" id="row_index" title="Index" />

<label for="row_notnull" id="row_notnull_label" title="Not NULL" >NN</label>
<input type="checkbox" id="row_notnull" title="Not NULL" />

<label for="row_default" id="row_default_label">Default</label>
<input type="text" id="row_default" />

<label for="row_type" id="row_type_label">Type:</label>
<select id="row_type" /></select>

<div id="row_spec_1">(</div>
<input type="text" id="row_spec" /></select>
<div id="row_spec_2">)</div>
</div>

<div id="io_admin">
<div id="io_admin_label">IMPORT/EXPORT</div>
<label for="io_select" id="io_select_label">Method:</label>
<div id="io_button" class="button">GO!</div>
<div id="io_settings_button" class="button">Settings</div>
<select id="io_select">

<!-- <option selected="selected" value="db_import">Import from database</option> -->
<option value="xml_out">Export to XML</option>
<option value="xml_in">Import from XML</option>
<option value="db_out">Save to database</option>
<option value="db_out_as">Save As... to database</option>
<option value="db_in">Load from database</option>

<!---------- CODE BEGIN ---------->

<option value="show_keywords">Show keywords</option>
<option value="print_view">Open print view</option>

<!---------- CODE END ---------->

<option value="mssql">Generate MSSQL script</option>
<option value="mysql">Generate MySQL script</option>
<option value="propel">Generate PROPEL script </option>

<option value="symfony">Generate Symfony script </option>
<option value="oci">Generate Oracle script</option>
<option value="postgresql">Generate PostgreSQL script</option>
<option selected="selected" value="sqlite">Generate SQLite script</option>
</select>
</div>
<div id="position" style="padding-left:580px;"></div>

</div>
<div id="map"> <!-- experimentalni mapa -->
<div id="map_"> <!-- cervene okenko v experimentalni mape -->
</div>
</div>
<div id="io">
<textarea id="area"></textarea>

<input id="import" value="Load" type="button" />
<input id="close" value="Close" type="button" onclick="javascript:document.getElementById('io').style.display='none'" />
</div>
</div>

</body>
</html>
1 change: 1 addition & 0 deletions app/views/schema_browser/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Content from index
24 changes: 24 additions & 0 deletions app/views/schema_browser/schema.xml.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
schema_browser = SchemaBrowser.new
xml.instruct!
xml.sql {
schema_browser.tables.each { |table|
xml.table(table.attributes) {
table.columns.each { |column|
xml.row(column.attributes) {
xml.title(column.name)
xml.default(column.default)
xml.type(column.type)
}
}
}
}

schema_browser.relations.each { |relation|
xml.relation {
xml.table_1(relation.origin_table_id)
xml.row_1(relation.origin_row_id)
xml.table_2(relation.destination_table_id)
xml.row_2(relation.destination_row_id)
}
}
}
Binary file added public/images/schema_browser/back.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/schema_browser/h_1-n.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/schema_browser/h_n-1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/schema_browser/move_cross.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/schema_browser/shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/schema_browser/shadow_bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/schema_browser/shadow_corner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/schema_browser/shadow_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/schema_browser/v_1-n.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/schema_browser/v_n-1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
163 changes: 163 additions & 0 deletions public/javascripts/schema_browser/ajax.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*
ajax_command(method, target, data_func, return_func);
ajax_manage(id, event, method, target, data_func, return_func);
*/

var GET = 1;
var POST = 2;

function ajax_command(method, target, data_func, return_func) {
var xmlhttp = new XMLHTTP();
var data = null; /* default - no data */
var callback_response = function() {
if (xmlhttp.getReadyState() == 4) {
if (xmlhttp.getStatus() == 200) {
return_func(xmlhttp.getResponseText());
} else {
xmlhttp.error("problem retrieving data");
}
} /* response complete */
} /* callback_response */
xmlhttp.setResponse(callback_response);

data = data_func(); /* request them from some user-specified routine */

switch (method) {
case GET:
var newtarget = (/\?/.test(target) ? target+"&"+data : target+"?"+data);
xmlhttp.open("GET",newtarget,true);
break;
case POST:
xmlhttp.open("POST",target,true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
break;
} /* method */
xmlhttp.send(data); /* off we go */
}

function ajax_manage(id, event, method, target, data_func, return_func) {
var element = document.getElementById(id);
if (!element) {
alert("Element '"+id+"' not found");
return;
}
if (method == POST && !XMLHTTP_supported()) {
alert("IFRAME mode active -> POSTs not allowed");
return;
}
var callback_request = function() {
ajax_command(method,target,data_func,return_func);
} /* callback_request */

universalAttacher(element,event,callback_request);
}

function XMLHTTP_error(text) {
alert('XMLHTTP error: "'+text+'", sorry...');
}

function XMLHTTP_open(method, target, async) {
if (this.iframe) {
this.temp_src = target;
} else {
this.obj.open(method, target, async);
}
}

function XMLHTTP_send(data) {
if (this.iframe) {
this.ifr.src = this.temp_src;
} else {
this.obj.send(data);
}
}

function XMLHTTP_setResponse(callback) {
if (this.iframe) {
universalAttacher(this.ifr,"load",callback);
} else {
this.obj.onreadystatechange = callback;
}
}

function XMLHTTP_getResponseText() {
if (this.iframe) {
var data = this.ifr.contentWindow.document.body.innerHTML;
/* uncomment this to save memory and confuse gecko: */
/* this.ifr.parentNode.removeChild(this.ifr); */
return data;
} else {
return this.obj.responseText;
}
}

function XMLHTTP_getResponseXML() {
if (this.iframe) {
this.error("IFRAME mode active -> XML data not supported");
return "";
} else {
return this.obj.responseXML;
}
}

function XMLHTTP_getReadyState() {
if (this.iframe) {
return 4;
} else {
return this.obj.readyState;
}
}

function XMLHTTP_getStatus() {
if (this.iframe) {
return 200;
} else {
return this.obj.status;
}
}

function XMLHTTP_setRequestHeader(name,value) {
if (!this.iframe) {
this.obj.setRequestHeader(name,value);
}
}

function XMLHTTP_isIframe() {
return this.iframe;
}

function XMLHTTP() {
this.iframe = false;
this.open = XMLHTTP_open;
this.send = XMLHTTP_send;
this.error = XMLHTTP_error;
this.setResponse = XMLHTTP_setResponse;
this.getResponseText = XMLHTTP_getResponseText;
this.getResponseXML = XMLHTTP_getResponseXML;
this.getReadyState = XMLHTTP_getReadyState;
this.getStatus = XMLHTTP_getStatus;
this.setRequestHeader = XMLHTTP_setRequestHeader;
this.isIframe = XMLHTTP_isIframe;
this.obj = false;

if (window.XMLHttpRequest) {
/* gecko */
this.obj = new XMLHttpRequest();
} else if (window.ActiveXObject) {
/* ie */
this.obj = new ActiveXObject("Microsoft.XMLHTTP");
}
if (!this.obj) {
/* no luck -> iframe */
this.iframe = true;
this.ifr = document.createElement("iframe");
this.ifr.style.display = "none";
this.ifr.src = "javascript:;";
document.body.appendChild(this.ifr);
}
}

function XMLHTTP_supported() {
var dummy = new XMLHTTP();
return (!dummy.isIframe());
}
Loading

0 comments on commit 7424e54

Please sign in to comment.