1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

added "cute" 3d buttons :-)

This commit is contained in:
Adolfo Gómez 2013-11-18 02:54:05 +00:00
parent 96937a397c
commit 67a691768e
14 changed files with 344 additions and 106 deletions

View File

@ -65,7 +65,8 @@ def tmpl(request, template):
t = loader.get_template('uds/admin/tmpl/' + template + ".html")
c = RequestContext(request)
resp = t.render(c)
except:
except Exception as e:
logger.debug('Exception getting template: {0}'.format(e))
resp = _('requested a template that do not exists')
return HttpResponse(resp, content_type="text/plain");

View File

@ -0,0 +1,40 @@
.btn3d {
transition:all .08s linear;
position:relative;
outline:medium none;
-moz-outline-style:none;
border:0px;
margin-right:10px;
margin-top:15px;
}
.btn3d:focus {
outline:medium none;
-moz-outline-style:none;
}
.btn3d:active {
top:9px;
}
.btn-default {
box-shadow:0 0 0 1px #ebebeb inset, 0 0 0 2px rgba(255,255,255,0.15) inset, 0 8px 0 0 #adadad, 0 8px 0 1px rgba(0,0,0,0.4), 0 8px 8px 1px rgba(0,0,0,0.5);
background-color:#fff;
}
.btn-primary {
box-shadow:0 0 0 1px #428bca inset, 0 0 0 2px rgba(255,255,255,0.15) inset, 0 8px 0 0 #357ebd, 0 8px 0 1px rgba(0,0,0,0.4), 0 8px 8px 1px rgba(0,0,0,0.5);
background-color:#428bca;
}
.btn-success {
box-shadow:0 0 0 1px #5cb85c inset, 0 0 0 2px rgba(255,255,255,0.15) inset, 0 8px 0 0 #4cae4c, 0 8px 0 1px rgba(0,0,0,0.4), 0 8px 8px 1px rgba(0,0,0,0.5);
background-color:#5cb85c;
}
.btn-info {
box-shadow:0 0 0 1px #5bc0de inset, 0 0 0 2px rgba(255,255,255,0.15) inset, 0 8px 0 0 #46b8da, 0 8px 0 1px rgba(0,0,0,0.4), 0 8px 8px 1px rgba(0,0,0,0.5);
background-color:#5bc0de;
}
.btn-warning {
box-shadow:0 0 0 1px #f0ad4e inset, 0 0 0 2px rgba(255,255,255,0.15) inset, 0 8px 0 0 #eea236, 0 8px 0 1px rgba(0,0,0,0.4), 0 8px 8px 1px rgba(0,0,0,0.5);
background-color:#f0ad4e;
}
.btn-danger {
box-shadow:0 0 0 1px #c63702 inset, 0 0 0 2px rgba(255,255,255,0.15) inset, 0 8px 0 0 #C24032, 0 8px 0 1px rgba(0,0,0,0.4), 0 8px 8px 1px rgba(0,0,0,0.5);
background-color:#c63702;
}

View File

@ -82,10 +82,11 @@ table.tablesorter thead tr th:hover {
height: 100%;
}
.tbl-button-active {
font-weight: bolder;
.btn3d-tables {
margin-top:0px;
}
/* Edit Below to Customize Widths > 768px */
@media (min-width:768px) {

View File

@ -142,67 +142,4 @@ api.networks = new BasicModelRest('networks');
// Locale related
api.locale = new BasicModelRest('locale');
api.locale.tableInfo = api.locale.types = undefined;
// -------------------------------
// Templates related
// This is not part of REST api provided by UDS, but it's part of the api needed
// for the admin app
// -------------------------------
(function(templates, $) {
templates.cache = {}; // Will cache templates locally. If name contains
// '?', data will not be cached and always
// re-requested
templates.get = function(name, success_fnc) {
api.doLog('Getting tempkate ' + name);
if (name.indexOf('?') != -1) {
if (templates.cache[name] !== undefined) {
if (success_fnc !== undefined) {
success_fnc(templates.cache[name]);
}
return;
}
}
$.ajax({
url : '/adm/tmpl/' + name,
type : "GET",
dataType : "text",
success : function(data) {
templates.cache[name] = data;
api.doLog('Success getting template "' + name + '".');
api.doLog('Received: ' + data);
if (success_fnc !== undefined) {
api.doLog('Executing success method');
success_fnc(data);
}
},
fail: function( jqXHR, textStatus, errorThrown ) {
api.doLog(jqXHR);
api.doLog(textStatus);
apid.doLog(errorThrown);
},
});
};
// Simple JavaScript Templating
// Based on John Resig - http://ejohn.org/ - MIT Licensed
templates.evaluate = function tmpl(str, data) {
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn =
// Generate a reusable function that will serve as a template
// generator (and which will be cached).
new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" +
// Introduce the data as local variables using with(){}
"with(obj){p.push('" +
// Convert the template into pure JavaScript
str.replace(/[\r\t\n]/g, " ").split("<%").join("\t").replace(/((^|%>)[^\t]*)'/g, "$1\r").replace(
/\t=(.*?)%>/g, "',$1,'").split("\t").join("');").split("%>").join("p.push('").split("\r").join(
"\\'") + "');}return p.join('');");
// Provide some basic currying to the user
return data ? fn(data) : fn;
};
}(api.templates = api.templates || {}, jQuery));
api.locale.tableInfo = api.locale.types = undefined;

View File

@ -116,7 +116,7 @@ $.extend( $.fn.dataTableExt.oPagination, {
if ( $.fn.DataTable.TableTools ) {
// Set the classes that TableTools uses to something suitable for Bootstrap
$.extend( true, $.fn.DataTable.TableTools.classes, {
"container": "DTTT btn-group",
"container": "DTTT btn-group-3d",
"buttons": {
"normal": "btn btn-default",
"disabled": "disabled"

View File

@ -13,7 +13,7 @@ gui.providers.link = function(event) {
gui.doLog(this);
gui.doLog(this.fnGetSelectedData());
},
buttons : [ 'edit', 'refresh', 'delete' ],
buttons : [ 'edit', 'refresh', 'delete', 'xls' ],
});
return false;
@ -37,14 +37,14 @@ gui.authenticators.link = function(event) {
gui.authenticators.table({
container : 'auths-placeholder',
rowSelect : 'single',
buttons : [ 'edit', 'refresh', 'delete' ],
buttons : [ 'edit', 'refresh', 'delete', 'xls' ],
onRowSelect : function(nodes) {
var id = this.fnGetSelectedData()[0].id;
var user = new GuiElement(api.authenticators.users.detail(id), 'users');
user.table({
container : 'users-placeholder',
rowSelect : 'multi',
buttons : [ 'edit', 'refresh', 'delete' ],
buttons : [ 'edit', 'refresh', 'delete', 'xls' ],
scroll : true,
});
return false;
@ -65,7 +65,7 @@ gui.osmanagers.link = function(event) {
gui.osmanagers.table({
rowSelect : 'single',
buttons : [ 'edit', 'refresh', 'delete' ],
buttons : [ 'edit', 'refresh', 'delete', 'xls' ],
});
return false;
@ -77,19 +77,23 @@ gui.connectivity = {
};
gui.connectivity.link = function(event) {
gui.clearWorkspace();
gui.appendToWorkspace(gui.breadcrumbs(gettext('Connectivity')));
gui
.appendToWorkspace('<div class="row"><div class="col-lg-6" id="ttbl"></div><div class="col-lg-6" id="ntbl"></div></div>');
api.templates.get('connectivity', function(tmpl) {
gui.clearWorkspace();
gui.appendToWorkspace(api.templates.evaluate(tmpl, {
transports : 'transports-placeholder',
networks : 'networks-placeholder'
}));
gui.connectivity.transports.table({
rowSelect : 'multi',
container : 'ttbl',
buttons : [ 'edit', 'refresh', 'delete', 'pdf' ],
});
gui.connectivity.networks.table({
rowSelect : 'multi',
container : 'ntbl',
buttons : [ 'edit', 'refresh', 'delete' ],
gui.connectivity.transports.table({
rowSelect : 'multi',
container : 'transports-placeholder',
buttons : [ 'edit', 'refresh', 'delete', 'xls' ],
});
gui.connectivity.networks.table({
rowSelect : 'multi',
container : 'networks-placeholder',
buttons : [ 'edit', 'refresh', 'delete', 'xls' ],
});
});
};

View File

@ -185,8 +185,6 @@ GuiElement.prototype = {
// Icon renderer, based on type (created on init methods in styles)
var renderTypeIcon = function(data, type, value){
gui.doLog(type);
gui.doLog(data);
if( type == 'display' ) {
var css = $this.types[value.type].css;
return '<span class="' + css + '"></span> ' + renderEmptyCell(data);
@ -351,7 +349,7 @@ GuiElement.prototype = {
"sButtonText" : gettext('Edit'),
"fnSelect" : editSelected,
"fnClick" : editFnc,
"sButtonClass" : "disabled"
"sButtonClass" : "disabled btn3d btn3d-tables"
};
break;
case 'delete':
@ -360,7 +358,7 @@ GuiElement.prototype = {
"sButtonText" : gettext('Delete'),
"fnSelect" : deleteSelected,
"fnClick" : deleteFnc,
"sButtonClass" : "disabled"
"sButtonClass" : "disabled btn3d btn3d-tables"
};
break;
case 'refresh':
@ -368,7 +366,7 @@ GuiElement.prototype = {
"sExtends" : "text",
"sButtonText" : gettext('Refresh'),
"fnClick" : refreshFnc,
"sButtonClass" : "btn-info"
"sButtonClass" : "btn-info btn3d btn3d-tables"
};
break;
case 'xls':
@ -376,34 +374,42 @@ GuiElement.prototype = {
"sExtends" : "text",
"sButtonText" : 'xls',
"fnClick" : function(){
// Simple export, based on http://jsfiddle.net/lesson8/wVejP/
var uri = 'data:application/vnd.ms-excel;base64,',
template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name><%= worksheet %></x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table border="1"><%= table %></table></body></html>',
base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))); };
table = '<thead>';
api.templates.get('spreadsheet', function(tmpl) {
var styles = { 'bold': 's21', };
var uri = 'data:application/vnd.ms-excel;base64,',
base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))); };
var headings = [], rows = [];
$.each(columns, function(index, heading){
if( heading.bVisible === false ) {
return;
}
table += '<th><b>' + heading.sTitle + '</b></th>';
headings.push(api.spreadsheet.cell(heading.sTitle, 'String', styles.bold));
});
table += '</thead><tbody>';
rows.push(api.spreadsheet.row(headings));
$.each(data, function(index, row) {
var tr = '';
var cells = [];
$.each(columns, function(index, col){
if( col.bVisible === false ) {
return;
}
tr += '<td>' + row[col.mData] + '</td>';
var type = col.sType == 'numeric' ? 'Number':'String';
cells.push(api.spreadsheet.cell(row[col.mData], type));
});
table += '<tr>' + tr + '</tr>';
rows.push(api.spreadsheet.row(cells));
});
table += '</tbody>';
var ctx = {worksheet: title, table: table};
window.location.href = uri + base64(api.templates.evaluate(template, ctx));
var ctx = {
creation_date: (new Date()).toISOString(),
worksheet: title,
columns_count: headings.length,
rows_count: rows.length,
rows: rows.join('\n')
};
window.location.href = uri + base64(api.templates.evaluate(tmpl, ctx));
});
},
"sButtonClass" : "btn-info"
"sButtonClass" : "btn-info btn3d btn3d-tables"
};
/*case 'csv':
btn = {
@ -457,7 +463,7 @@ GuiElement.prototype = {
// First is upper row,
// second row is lower
// (pagination) row
"sDom" : "<'row'<'col-xs-6'T><'col-xs-6'f>r>t<'row'<'col-xs-5'i><'col-xs-7'p>>",
"sDom" : "<'row'<'col-xs-8'T><'col-xs-4'f>r>t<'row'<'col-xs-5'i><'col-xs-7'p>>",
});
$('#' + tableId + '_filter input').addClass('form-control');

View File

@ -0,0 +1,15 @@
(function(spreadsheet, $, undefined) {
spreadsheet.cell = function(data, type, style) {
type = type || 'String';
if( style !== undefined ) {
style = ' ss:StyleID="' + style + '"';
} else {
style = '';
}
return '<Cell' + style + '><Data ss:Type="' + type + '">' + data + '</Data></Cell>';
};
spreadsheet.row = function(cell) {
return '<Row>' + cell + '</Row>';
};
}(api.spreadsheet = api.spreadsheet || {}, jQuery));

View File

@ -0,0 +1,62 @@
// -------------------------------
// Templates related
// Inserted into api
// for the admin app
// -------------------------------
(function(templates, $) {
templates.cache = {}; // Will cache templates locally. If name contains
// '?', data will not be cached and always
// re-requested. We do not care about lang, because page will reload on language change
templates.get = function(name, success_fnc) {
api.doLog('Getting tempkate ' + name);
if (name.indexOf('?') != -1) {
if (templates.cache[name] !== undefined) {
if (success_fnc !== undefined) {
success_fnc(templates.cache[name]);
}
return;
}
}
$.ajax({
url : '/adm/tmpl/' + name,
type : "GET",
dataType : "text",
success : function(data) {
templates.cache[name] = data;
api.doLog('Success getting template "' + name + '".');
api.doLog('Received: ' + data);
if (success_fnc !== undefined) {
api.doLog('Executing success method');
success_fnc(data);
}
},
fail: function( jqXHR, textStatus, errorThrown ) {
api.doLog(jqXHR);
api.doLog(textStatus);
apid.doLog(errorThrown);
},
});
};
// Simple JavaScript Templating
// Based on John Resig - http://ejohn.org/ - MIT Licensed
templates.evaluate = function tmpl(str, data) {
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn =
// Generate a reusable function that will serve as a template
// generator (and which will be cached).
new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" +
// Introduce the data as local variables using with(){}
"with(obj){p.push('" +
// Convert the template into pure JavaScript
str.replace(/[\r\t\n]/g, " ").split("<%").join("\t").replace(/((^|%>)[^\t]*)'/g, "$1\r").replace(
/\t=(.*?)%>/g, "',$1,'").split("\t").join("');").split("%>").join("p.push('").split("\r").join(
"\\'") + "');}return p.join('');");
// Provide some basic currying to the user
return data ? fn(data) : fn;
};
}(api.templates = api.templates || {}, jQuery));

View File

@ -0,0 +1,5 @@
(function(tools, $, undefined) {
tools.base64 = function(s) {
return window.btoa(unescape(encodeURIComponent(s)));
};
}(api.tools = api.tools || {}, jQuery));

View File

@ -23,6 +23,7 @@
<link href="{% get_static_prefix %}adm/css/dataTables.bootstrap.css" rel="stylesheet" media="screen">
<link href="{% get_static_prefix %}css/tables.css" rel="stylesheet" media="screen">
<link href="{% get_static_prefix %}adm/css/buttons.css" rel="stylesheet" media="screen">
<link href="{% get_static_prefix %}adm/css/uds-admin.css" rel="stylesheet" media="screen">
</head>
@ -70,6 +71,17 @@
}(window.api = window.api || {}, jQuery));
</script>
<script src="{% get_static_prefix %}adm/js/api.js"></script>
<!-- templates related, inserts itself into api -->
<script src="{% get_static_prefix %}adm/js/templates.js"></script>
<!-- export to xls, inserts itself into api -->
<script src="{% get_static_prefix %}adm/js/spreadsheet.js"></script>
<!-- utilities attached to api -->
<script src="{% get_static_prefix %}adm/js/tools.js"></script>
<script src="{% get_static_prefix %}adm/js/gui.js"></script>
<script src="{% get_static_prefix %}adm/js/gui-elements.js"></script>

View File

@ -0,0 +1,16 @@
{% load i18n html5 static %}
<div class="row">
<div class="col-xs-12">
<h1>{% trans 'Connectivity' %} <small>{% trans 'overview' %}</small></h1>
<ol class="breadcrumb">
<li><a id="lnk-dashboard" href=""><i class="fa fa-dashboard"></i> Dashboard</a></li>
</ol>
</div>
</div><!-- /.row -->
<div class="row">
<div class="col-lg-6" id="<%= transports %>">
</div>
<div class="col-lg-6" id="<%= networks %>">
</div>
</div>

View File

@ -0,0 +1,60 @@
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>UDS Administration</Author>
<LastAuthor>UDS Administration Interface</LastAuthor>
<Created><%= creation_date %></Created>
<Company>UDS</Company>
<Version>1.0</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>6795</WindowHeight>
<WindowWidth>8460</WindowWidth>
<WindowTopX>120</WindowTopX>
<WindowTopY>15</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom" />
<Borders />
<Font />
<Interior />
<NumberFormat />
<Protection />
</Style>
<Style ss:ID="s21">
<Font x:Family="Verdana" ss:Bold="1" />
</Style>
</Styles>
<Worksheet ss:Name="<%= worksheet %>">
<Table ss:ExpandedColumnCount="<%= columns_count %>" ss:ExpandedRowCount="<%= rows_count %>"
x:FullColumns="1" x:FullRows="1">
<%= rows %>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Print>
<ValidPrinterInfo />
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<Selected />
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>5</ActiveRow>
<ActiveCol>1</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>

View File

@ -0,0 +1,79 @@
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Darl McBride</Author>
<LastAuthor>Bill Gates</LastAuthor>
<Created>2007-03-15T23:04:04Z</Created>
<Company>SCO Group, Inc.</Company>
<Version>11.8036</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>6795</WindowHeight>
<WindowWidth>8460</WindowWidth>
<WindowTopX>120</WindowTopX>
<WindowTopY>15</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom" />
<Borders />
<Font />
<Interior />
<NumberFormat />
<Protection />
</Style>
<Style ss:ID="s21">
<Font x:Family="Swiss" ss:Bold="1" />
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="2" ss:ExpandedRowCount="5"
x:FullColumns="1" x:FullRows="1">
<Row>
<Cell>
<Data ss:Type="String">Texto en celda A1</Data>
</Cell>
</Row>
<Row>
<Cell ss:StyleID="s21">
<Data ss:Type="String">Texto en negrita en celda A2</Data>
</Cell>
</Row>
<Row ss:Index="4">
<Cell ss:Index="2">
<Data ss:Type="Number">43</Data>
</Cell>
</Row>
<Row>
<Cell ss:Index="2" ss:Formula="=R[-1]C/2">
<Data ss:Type="Number">21.5</Data>
</Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Print>
<ValidPrinterInfo />
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<Selected />
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>5</ActiveRow>
<ActiveCol>1</ActiveCol>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>