Commit 4c2d36de authored by Florian Kaiser's avatar Florian Kaiser
Browse files

first working version

parent b094c8f7
{
"name": "Kate"
, "files": [ { "git": 1 } ]
}
# TODO
* Use existing ownCloud CSS classes if possible
for consistent look & feel
* Add index page with button, explaining what happens:
"Click here if you really want to load this view, it make take a while"
* Add diagrams
<?php
namespace OCA\StorageUsage\AppInfo;
use OCP\AppFramework\App;
use OCA\StorageUsage\Controller\PageController;
use OCA\StorageUsage\Db\UsageDAO;
class Application extends App {
public function __construct(array $urlParams=array()){
parent::__construct('storageusage', $urlParams);
$container = $this->getContainer();
$container->registerService('UsageDAO', function($c){
return new UsageDAO(
$c->query('ServerContainer')->getDb()
);
});
$container->registerService('PageController', function($c){
return new PageController(
$c->query('AppName'),
$c->query('Request'),
$c->query('UsageDAO')
);
});
}
}
......@@ -16,38 +16,28 @@ use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Controller;
use OCA\StorageUsage\Db\UsageDAO;
class PageController extends Controller {
private $userId;
private $usagedao;
public function __construct($AppName, IRequest $request, $UserId){
public function __construct($AppName, IRequest $request, UsageDAO $usagedao) {
parent::__construct($AppName, $request);
$this->userId = $UserId;
$this->usagedao = $usagedao;
}
/**
* CAUTION: the @Stuff turns off security checks; for this page no admin is
* required and no CSRF check. If you don't know what CSRF is, read
* it up in the docs or you might create a security hole. This is
* basically the only required method to add this exemption, don't
* add it to any other method if you don't exactly know what it does
*
* @NoAdminRequired
* @AdminRequired
* @NoCSRFRequired
*/
public function index() {
$params = ['user' => $this->userId];
$data = $this->usagedao->getUsage();
$params = [ 'data' => $data ];
return new TemplateResponse('storageusage', 'main', $params); // templates/main.php
}
/**
* Simply method that posts back the payload of the request
* @NoAdminRequired
*/
public function doEcho($echo) {
return new DataResponse(['echo' => $echo]);
}
}
\ No newline at end of file
<?php
namespace OCA\StorageUsage\Db;
use OCP\IDBConnection;
class UsageDAO {
private $db;
public function __construct(IDBConnection $db) {
$this->db = $db;
}
public function getUsage() {
$dbPlatform = $this->db->getDatabasePlatform();
$join_storage_expr = $dbPlatform->getConcatExpression('"home::"', '*PREFIX*preferences.userid');
$sql = 'SELECT *PREFIX*preferences.userid AS username, *PREFIX*preferences.configvalue as quotavalue, *PREFIX*filecache.size as bytes, sub.num as objects
FROM *PREFIX*preferences
LEFT JOIN *PREFIX*storages ON (*PREFIX*storages.id=' . $join_storage_expr . ')
LEFT JOIN *PREFIX*filecache ON (*PREFIX*storages.numeric_id=*PREFIX*filecache.storage)
LEFT JOIN (SELECT storage, COUNT(*) as num FROM *PREFIX*filecache GROUP BY storage) sub ON (sub.storage=*PREFIX*storages.numeric_id)
WHERE *PREFIX*preferences.appid="files" and *PREFIX*preferences.configkey="quota"
AND *PREFIX*filecache.path="files"
ORDER BY *PREFIX*filecache.size DESC;';
$stmt = $this->db->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_NUM);
$stmt->closeCursor();
return $result;
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="32" width="32" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/">
<g transform="translate(573.14 110.3)" fill-rule="evenodd">
<path d="m-570.22-108.3c-0.50115 0-0.92082 0.41966-0.92082 0.92081v24.158c0 0.51739 0.40324 0.92073 0.92082 0.92073h26.158c0.51756 0 0.92081-0.40316 0.92081-0.92073l0.00069-14.154c0-0.5011-0.41966-0.92524-0.92081-0.92524h-21.079l-0.0007 11.005c0 0.48012-0.52409 0.97706-1.0042 0.97706-0.48012 0-0.99573-0.49694-0.99573-0.97706l0.0007-12.143c0-0.48012 0.40484-0.86215 0.88497-0.86215h4.5944l14.521 0.00052-0.0007-2.9516c0-0.56713-0.42551-1.0481-0.99245-1.0481h-13.007v-3.0791c0-0.50118-0.40586-0.92081-0.90701-0.92081z"/>
<path d="m-570.22-107.3c-0.50115 0-0.92082 0.41966-0.92082 0.92081v24.158c0 0.51739 0.40324 0.92073 0.92082 0.92073h26.158c0.51756 0 0.92081-0.40316 0.92081-0.92073l0.00069-14.154c0-0.5011-0.41966-0.92524-0.92081-0.92524h-21.079l-0.0007 11.005c0 0.48012-0.52409 0.97706-1.0042 0.97706-0.48012 0-0.99573-0.49694-0.99573-0.97706l0.0007-12.143c0-0.48012 0.40484-0.86214 0.88497-0.86214h4.5944l14.521 0.00052-0.0007-2.9516c0-0.56713-0.42551-1.0481-0.99245-1.0481h-13.007v-3.0791c0-0.50118-0.40586-0.92081-0.90701-0.92081z" fill="#fff"/>
</g>
</svg>
\ No newline at end of file
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="32"
width="32"
version="1.1"
id="svg2"
inkscape:version="0.48.4 r9939"
sodipodi:docname="app.svg">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1000"
inkscape:window-height="736"
id="namedview10"
showgrid="false"
inkscape:zoom="2.6074563"
inkscape:cx="-9.7069451"
inkscape:cy="-10.281508"
inkscape:window-x="2025"
inkscape:window-y="221"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<text
xml:space="preserve"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Source Code Pro;-inkscape-font-specification:Source Code Pro"
x="22.881355"
y="14.338982"
id="text3761"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3763"
x="22.881355"
y="14.338982"
style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Source Code Pro;-inkscape-font-specification:Source Code Pro">1</tspan></text>
<text
xml:space="preserve"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Source Code Pro;-inkscape-font-specification:Source Code Pro"
x="13.363877"
y="19.964249"
id="text3761-1"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3763-1"
x="13.363877"
y="19.964249"
style="font-size:20px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Source Code Pro;-inkscape-font-specification:Source Code Pro">2</tspan></text>
<text
xml:space="preserve"
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Source Code Pro;-inkscape-font-specification:Source Code Pro"
x="0.041837692"
y="28.9473"
id="text3761-1-5"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan3763-1-3"
x="0.041837692"
y="28.9473"
style="font-size:28px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:Source Code Pro;-inkscape-font-specification:Source Code Pro">3</tspan></text>
</svg>
<p>Hello World <?php p($_['user']) ?></p>
<style type="text/css">
<p><button id="hello">click me</button></p>
#storageusage {
/*font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;*/
width: 100%;
border-collapse: collapse;
}
<p><textarea id="echo-content">
Send this as ajax
</textarea></p>
<p><button id="echo">Send ajax request</button></p>
#storageusage td, #storageusage th {
font-size: 1em;
border: 1px solid #ccc;
padding: 3px 7px 2px 7px;
}
Ajax response: <div id="echo-result"></div>
\ No newline at end of file
#storageusage th {
font-size: 1.1em;
text-align: left;
padding-top: 5px;
padding-bottom: 4px;
background-color: #888;
color: #000;
}
</style>
<div style="padding: 12px">
<table id="storageusage">
<thead>
<tr>
<th>User</th>
<th>Objects</th>
<th>Space</th>
<th>Quota</th>
<tr>
</thead>
<tbody>
<?php $alt=false; ?>
<?php foreach($_['data'] as $row){ ?>
<tr class="<?php if ($alt=!$alt) echo 'alt';?>">
<td><?php p($row[0]); ?></td>
<td><?php p($row[3]); ?></td>
<td><?php p($this->human_file_size($row[2])); ?></td>
<td><?php p($row[1]); ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
\ No newline at end of file
<ul>
<li><a href="#">First level entry</a></li>
<li>
<a href="#">First level container</a>
<ul>
<li><a href="#">Second level entry</a></li>
<li><a href="#">Second level entry</a></li>
</ul>
</li>
</ul>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment