You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by hu...@apache.org on 2015/03/22 11:13:29 UTC

svn commit: r1668350 - in /steve/trunk/pytest/www/htdocs: ./ admin/ css/ images/ js/

Author: humbedooh
Date: Sun Mar 22 10:13:29 2015
New Revision: 1668350

URL: http://svn.apache.org/r1668350
Log:
First stab at moving admin interface into a separate dir.
My bathroom is being redone, so apologies, greg! ;)

Added:
    steve/trunk/pytest/www/htdocs/admin/
    steve/trunk/pytest/www/htdocs/admin/add_issue.html
    steve/trunk/pytest/www/htdocs/admin/create_election.html
    steve/trunk/pytest/www/htdocs/admin/edit_election.html
    steve/trunk/pytest/www/htdocs/admin/index.html
    steve/trunk/pytest/www/htdocs/admin/invite.html
    steve/trunk/pytest/www/htdocs/images/icon_add.png   (with props)
    steve/trunk/pytest/www/htdocs/images/icon_close.png   (with props)
    steve/trunk/pytest/www/htdocs/images/icon_edit.png   (with props)
    steve/trunk/pytest/www/htdocs/images/icon_invite.png   (with props)
Removed:
    steve/trunk/pytest/www/htdocs/create_election.html
    steve/trunk/pytest/www/htdocs/edit_election.html
Modified:
    steve/trunk/pytest/www/htdocs/css/steve_interactive.css
    steve/trunk/pytest/www/htdocs/js/steve_rest.js

Added: steve/trunk/pytest/www/htdocs/admin/add_issue.html
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/admin/add_issue.html?rev=1668350&view=auto
==============================================================================
--- steve/trunk/pytest/www/htdocs/admin/add_issue.html (added)
+++ steve/trunk/pytest/www/htdocs/admin/add_issue.html Sun Mar 22 10:13:29 2015
@@ -0,0 +1,71 @@
+ <!DOCTYPE HTML>
+<html>
+<head>
+<link rel="stylesheet" href="/css/steve_interactive.css">
+<link rel="stylesheet" href="/css/jquery-ui.css">
+<script src="/js/steve_rest.js" type="text/javascript"></script>
+<script src="/js/jquery.js" type="text/javascript"></script>
+<script src="/js/jquery-ui.js" type="text/javascript"></script>
+<title>Add issue</title>
+</head>
+<body onload="document.getElementById('iid').value = parseInt(Math.random()*987654321).toString(16).toLowerCase();">
+       <p style="text-align: center;">
+        <img src="/images/steve_logo.png"/>
+    </p>
+<div class="formbox">
+       <h2>Add a new issue:</h2>
+ <fieldset>
+        <legend>Base data</legend>
+    <div class="keyvaluepair">
+        <div class="keyfield">Issue ID:</div>
+        <input type="text" id="iid"/><br>
+    </div>
+    <div class="keyvaluepair">
+        <div class="keyfield">Issue title:</div>
+        <input type="text" id="ititle" style="width: 300px;"/><br>
+    </div>
+    <div class="keyvaluepair">
+        <div class="keyfield">Issue type:</div>
+        <select id="type" onchange="changeSTVType(this.value)">
+            <option value="">------</option>
+            <option value="yna">YNA (Yes/No/Abstain)</option>
+            <option value="stv1">STV with 1 seat</option>
+            <option value="stv2">STV with 2 seats</option>
+            <option value="stv3">STV with 3 seats</option>
+            <option value="stv4">STV with 4 seats</option>
+            <option value="stv5">STV with 5 seats</option>
+            <option value="stv6">STV with 6 seats</option>
+            <option value="stv7">STV with 7 seats</option>
+            <option value="stv8">STV with 8 seats</option>
+            <option value="stv9">STV with 9 seats</option>
+        </select>
+        <br>
+    </div>
+    <div class="keyvaluepair">
+        <div class="keyfield">Description of issue:</div>
+        <textarea id="description" style="width: 400px; height: 200px;"></textarea>
+    </div>
+    <div id="yna" style="display: none;">
+        <div class="keyvaluepair">
+            <div class="keyfield">Put forward (nominated) by:</div>
+            <input type="text" id="nominatedby" style="width: 300px;"/><br>
+        </div>
+        <div class="keyvaluepair">
+            <div class="keyfield">Seconds (one per line):</div>
+            <textarea name="seconds" style="width: 300px; height: 200px;"></textarea>
+        </div>
+    </div>
+    <div id="stv" style="display: none;">
+        
+        <div class="keyvaluepair">
+            <div class="keyfield">Candidates (one per line):</div>
+            <textarea name="candidates" style="width: 300px; height: 200px;"></textarea>
+        </div>
+    </div>
+    <div class="keyvaluepair">
+        <input type="button" onclick="createIssue();" value="Create issue" class="btn-green"/>
+    </div>
+    </fieldset>
+</div></body>
+</html>
+    
\ No newline at end of file

Added: steve/trunk/pytest/www/htdocs/admin/create_election.html
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/admin/create_election.html?rev=1668350&view=auto
==============================================================================
--- steve/trunk/pytest/www/htdocs/admin/create_election.html (added)
+++ steve/trunk/pytest/www/htdocs/admin/create_election.html Sun Mar 22 10:13:29 2015
@@ -0,0 +1,60 @@
+ <!DOCTYPE HTML>
+<html>
+<head>
+<link rel="stylesheet" href="/css/steve_interactive.css">
+<link rel="stylesheet" href="/css/jquery-ui.css">
+<script src="/js/steve_rest.js" type="text/javascript"></script>
+<script src="/js/jquery.js" type="text/javascript"></script>
+<script src="/js/jquery-ui.js" type="text/javascript"></script>
+<title>Create a new election</title>
+</head>
+<body onload="document.getElementById('eid').value = parseInt(Math.random()*987654321).toString(16);">
+    <div id="popups"></div>
+    <p style="text-align: center;">
+        <img src="/images/steve_logo.png"/>
+    </p>
+<div class="formbox">
+    <a href="index.html">Back to adminstration front page</a>
+<h2>Create a new election:</h2>
+<form>
+    <fieldset>
+        <legend>Base data</legend>
+    <div class="keyvaluepair">
+        <div class="keyfield">ID of election:</div>
+        <input type="text" id="eid"/> You can enter your own EID if you like, for instance foo-election-2015.<br>
+    </div>
+    <div class="keyvaluepair">
+        <div class="keyfield">Name of election:</div>
+        <input type="text" id="title"/>This is the official title of the election<br>
+    </div>
+    <div class="keyvaluepair">
+        <div class="keyfield">Owner of election (UID):</div>
+        <input type="text" id="owner"/>Owner of the election, as found in the karma section of steve.cfg<br>
+    </div>
+    <div class="keyvaluepair">
+        <div class="keyfield">Election monitors (emails):</div>
+        <input type="text" id="monitors"/><br>
+    </div>
+    </fieldset>
+    <fieldset>
+        <legend>Optional information</legend>
+            <div class="keyvaluepair">
+        <div class="keyfield">Date election opens (optional):</div>
+        <input type="text" placeholder="YYYY-MM-DD" id="starts" onfocus="$('#starts').datepicker({
+            dateFormat: 'yy-mm-dd'
+               });"/><br>
+    </div>
+    <div class="keyvaluepair">
+        <div class="keyfield">Date election ends (optional):</div>
+        <input type="text" placeholder="YYYY-MM-DD" id="ends" onfocus="$('#ends').datepicker({
+            dateFormat: 'yy-mm-dd'
+               });"/><br>
+    </div>
+    </fieldset>
+    <div class="keyvaluepair">
+        <input type="button" onclick="createElection();" value="Create election" class="btn-green"/>
+    </div>
+</form>
+</div>
+</body>
+</html>
\ No newline at end of file

Added: steve/trunk/pytest/www/htdocs/admin/edit_election.html
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/admin/edit_election.html?rev=1668350&view=auto
==============================================================================
--- steve/trunk/pytest/www/htdocs/admin/edit_election.html (added)
+++ steve/trunk/pytest/www/htdocs/admin/edit_election.html Sun Mar 22 10:13:29 2015
@@ -0,0 +1,38 @@
+ <!DOCTYPE HTML>
+<html>
+<head>
+<link rel="stylesheet" href="/css/steve_interactive.css">
+<link rel="stylesheet" href="/css/jquery-ui.css">
+<script src="/js/steve_rest.js" type="text/javascript"></script>
+<script src="/js/jquery.js" type="text/javascript"></script>
+<script src="/js/jquery-ui.js" type="text/javascript"></script>
+<title>Edit election</title>
+</head>
+<body onload="window.setTimeout(loadAdminElectionData, 1000);">
+    <div id="popups"></div>
+    <p style="text-align: center;">
+        <img src="/images/steve_logo.png"/>
+    </p>
+<div class="formbox">
+    <a href="index.html">Back to adminstration front page</a>
+<h2 id="title">Edit an election:</h2>
+
+<fieldset>
+        <legend>General options</legend>
+        <a href="javascript:void(location.href='invite.html'+document.location.search);" class="btn-yellow"><img style="vertical-align: middle;" src="/images/icon_invite.png"/> Invite people</a>
+        &nbsp; 
+        <a href="javascript:void(location.href='add_issue.html'+document.location.search);" class="btn-green"><img style="vertical-align: middle;"  src="/images/icon_add.png"/> Add an issue</a>
+        &nbsp; 
+        <a href="javascript:void(location.href='close.html'+document.location.search);" class="btn-red"><img style="vertical-align: middle;"  src="/images/icon_close.png"/> Close election</a>
+        <br/>
+</fieldset>
+<form>
+    <h3>Issues in this election:</h3>
+    <ol id="ballot">
+        <img src="/images/steve_spinner.gif"/>
+    </ol>
+</form>
+
+</div>
+</body>
+</html>
\ No newline at end of file

Added: steve/trunk/pytest/www/htdocs/admin/index.html
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/admin/index.html?rev=1668350&view=auto
==============================================================================
--- steve/trunk/pytest/www/htdocs/admin/index.html (added)
+++ steve/trunk/pytest/www/htdocs/admin/index.html Sun Mar 22 10:13:29 2015
@@ -0,0 +1,25 @@
+ <!DOCTYPE HTML>
+<html>
+<head>
+<link rel="stylesheet" href="/css/steve_interactive.css">
+<link rel="stylesheet" href="/css/jquery-ui.css">
+<script src="/js/steve_rest.js" type="text/javascript"></script>
+<script src="/js/jquery.js" type="text/javascript"></script>
+<script src="/js/jquery-ui.js" type="text/javascript"></script>
+
+<title>STeVe administration</title>
+</head>
+<body onload="getJSON('/steve/admin/list', null, showElections);">
+    <div id="popups"></div>
+    <p style="text-align: center;">
+        <img src="/images/steve_logo.png"/>
+    </p>
+<div class="formbox">
+<h1 id="title">STeVe administration</h1>
+<a href="create_election.html" class="btn-green">Create a new election</a><br/>
+<div id="preloaderWrapper">
+    
+</div>
+</div>
+</body>
+</html>
\ No newline at end of file

Added: steve/trunk/pytest/www/htdocs/admin/invite.html
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/admin/invite.html?rev=1668350&view=auto
==============================================================================
--- steve/trunk/pytest/www/htdocs/admin/invite.html (added)
+++ steve/trunk/pytest/www/htdocs/admin/invite.html Sun Mar 22 10:13:29 2015
@@ -0,0 +1,80 @@
+ <!DOCTYPE HTML>
+<html>
+<head>
+<link rel="stylesheet" href="/css/steve_interactive.css">
+<link rel="stylesheet" href="/css/jquery-ui.css">
+<script src="/js/steve_rest.js" type="text/javascript"></script>
+<script src="/js/jquery.js" type="text/javascript"></script>
+<script src="/js/jquery-ui.js" type="text/javascript"></script>
+<script type="text/javascript">
+    var ecount = 0;
+    function seedInvite(type) {
+        if (type == "closed") {
+            document.getElementById('msgtemplate').value = "A private election for \"$title\" has been called\n\nTo vote, please visit: $votelink\nThis is a private vote URL for your eyes only."
+        } else {
+            document.getElementById('msgtemplate').value = "A public election for \"$title\" has been called\n\nTo vote, please register for a vote at: $votelink\nAnyone can register to vote."
+        }
+    }
+    function removeEmail(code, response, state) {
+        if (code == 200) {
+            ecount--;
+            document.getElementById('invitestatus').innerHTML = ecount + " emails left to send..."
+            if (ecount == 0) {
+                document.getElementById('invitestatus').innerHTML = "All invites have been sent!"
+            }
+        } else {
+            alert(response.message)
+        }
+    }
+    function sendInvites() {
+        var emails = document.getElementById('emails').value.split(/\r?\n/)
+        var msgtype = document.getElementById('msgtype').value;
+        var msgtemplate = document.getElementById('msgtemplate').value;
+        var election = document.location.search.substr(1);
+        ecount = emails.length;
+        for (i in emails) {
+            var email = emails[i]
+            postREST("/steve/admin/invite/" + election, {
+                email: email,
+                msgtype: msgtype,
+                msgtemplate: msgtemplate
+            },
+            undefined,
+            removeEmail,
+            null)
+        }
+    }
+</script>
+<title>Invite people</title>
+</head>
+<body onload="seedInvite('closed');">
+       <p style="text-align: center;">
+        <img src="/images/steve_logo.png"/>
+    </p>
+<div class="formbox">
+       
+<fieldset>
+        <legend>Invite one or more users to this election</legend>
+    <div class="keyvaluepair">
+        <div class="keyfield">Invitation type:</div>
+        <select id="msgtype" onchange="seedInvite(this.value)">
+            <option value="closed">Closed (private) invite</option>
+            <option value="open">Open (public) invite</option>
+        </select>
+    </div>
+    <div class="keyvaluepair">
+        <div class="keyfield">Invitation type:</div>
+        <textarea id="msgtemplate" style="width: 600px; height: 200px;">
+            
+        </textarea>
+    </div>
+    <div class="keyvaluepair">
+        <div class="keyfield">Email address(es) to invite<br/>(one per line):</div>
+        <textarea id="emails" style="width: 300px; height: 300px;"></textarea>
+    </div>
+    <input type="button" value="Send invitation(s)" onclick="sendInvites()"/><br/>
+    <span id="invitestatus"></span>
+    </fieldset>
+</div>
+</body>
+</html>
\ No newline at end of file

Modified: steve/trunk/pytest/www/htdocs/css/steve_interactive.css
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/css/steve_interactive.css?rev=1668350&r1=1668349&r2=1668350&view=diff
==============================================================================
--- steve/trunk/pytest/www/htdocs/css/steve_interactive.css (original)
+++ steve/trunk/pytest/www/htdocs/css/steve_interactive.css Sun Mar 22 10:13:29 2015
@@ -374,6 +374,7 @@ body, html {
   min-height: 20px;
   min-width: 160px;
   float: left;
+  margin-right: 10px;
 }
 
 

Added: steve/trunk/pytest/www/htdocs/images/icon_add.png
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/images/icon_add.png?rev=1668350&view=auto
==============================================================================
Binary file - no diff available.

Propchange: steve/trunk/pytest/www/htdocs/images/icon_add.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: steve/trunk/pytest/www/htdocs/images/icon_close.png
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/images/icon_close.png?rev=1668350&view=auto
==============================================================================
Binary file - no diff available.

Propchange: steve/trunk/pytest/www/htdocs/images/icon_close.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: steve/trunk/pytest/www/htdocs/images/icon_edit.png
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/images/icon_edit.png?rev=1668350&view=auto
==============================================================================
Binary file - no diff available.

Propchange: steve/trunk/pytest/www/htdocs/images/icon_edit.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: steve/trunk/pytest/www/htdocs/images/icon_invite.png
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/images/icon_invite.png?rev=1668350&view=auto
==============================================================================
Binary file - no diff available.

Propchange: steve/trunk/pytest/www/htdocs/images/icon_invite.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: steve/trunk/pytest/www/htdocs/js/steve_rest.js
URL: http://svn.apache.org/viewvc/steve/trunk/pytest/www/htdocs/js/steve_rest.js?rev=1668350&r1=1668349&r2=1668350&view=diff
==============================================================================
--- steve/trunk/pytest/www/htdocs/js/steve_rest.js (original)
+++ steve/trunk/pytest/www/htdocs/js/steve_rest.js Sun Mar 22 10:13:29 2015
@@ -427,4 +427,34 @@ function castVoteCallback(code, response
 	} else {
 		alert(response.message)
 	}
+}
+
+function showElections(code, response, state) {
+	var obj = document.getElementById('preloaderWrapper')
+	//obj.setAttribute("id", "electionWrapper")
+	obj.innerHTML = "<h2>Your elections:</h2>"
+	var ol = document.createElement('ol')
+	obj.appendChild(ol)
+	obj.setAttribute("class", "issueList")
+	var s = 0
+	for (i in response.elections) {
+		s++;
+		var election = response.elections[i]
+
+		var outer = document.createElement('li');
+		outer.setAttribute("class", "issueListItem")
+		
+		var no = document.createElement('div');
+		no.setAttribute("class", "issueNumber")
+		no.innerHTML = (s)
+		
+		
+		// Add election
+		var inner = document.createElement('span')
+		inner.innerHTML = election.id + ": " + election.title;
+		outer.appendChild(no)
+		outer.appendChild(inner)
+		outer.setAttribute("onclick", "location.href='edit_election.html?" + election.id + "';")
+		ol.appendChild(outer)
+	}
 }
\ No newline at end of file