2
* Copyright (C) 2007-2008 The University of Melbourne
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
/* Module: SpecialHome (File Browser, client)
24
/* This module implements the functionality to lay out a special home directory
25
* view on top of the normal listing
28
/* The name of the personal file directory */
29
PERSONALDIR="personal"
31
/* LAYOUT FUNCTIONS */
33
/** Present home directory
35
function home_listing(listing, subjects)
37
listing = listing.listing;
38
var filetablediv = document.getElementById("filetablediv");
45
/* Create the header row */
46
h1 = dom_make_text_elem("h1", "Subjects");
47
filetablediv.appendChild(h1);
48
/* Create the contents */
49
for (var i=0; i<subjects.length; i++)
51
var subject = subjects[i];
52
var path = subject.subj_short_name;
54
h2 = dom_make_text_elem("h2", subject.subj_name);
55
filetablediv.appendChild(h2);
57
/* Print the file listing */
58
ul = document.createElement("ul");
60
ul.appendChild(make_subject_item(path, "personal", "Your personal files here"));
62
/* TODO: List groups */
64
filetablediv.appendChild(ul);
66
/* Remove it from listing */
67
if (subject.subj_short_name in listing)
68
delete listing[subject.subj_short_name];
71
/* FIXME: Old Subjects? */
73
/* STUFF Section -- For the stuff directory */
74
/* Create the header */
75
h1 = dom_make_text_elem("h1", "Stuff");
76
filetablediv.appendChild(h1);
77
/* Create the contents */
78
ul = document.createElement("ul");
79
ul.appendChild(make_subject_item("", "stuff", "stuff"));
80
filetablediv.appendChild(ul);
81
/* Remove stuff from the listing */
82
if ("stuff" in listing)
83
delete listing["stuff"];
85
/* JUNK Section -- All the rest */
86
/* Create the header row */
87
h1 = dom_make_text_elem("h1", "Junk");
88
filetablediv.appendChild(h1);
91
/* Does an series of AJAX requests to find out the properties of this folder
92
* and then updates the folder view
94
function make_subject_item(path, name, description)
96
// Create the temporary item
97
var li = document.createElement("li");
99
li.setAttribute("class", "listing-loading");
100
li.appendChild(dom_make_text_elem("span", name));
101
span = dom_make_text_elem("loading...");
102
span.setAttribute("class","status");
103
li.appendChild(span);
105
// Set the callback function to update when we get the real details
106
var callback = function(response)
108
var sublisting = decode_response(response);
109
dom_removechildren(li);
110
li.setAttribute("class", "listing-dir");
112
// If we could find the file status...
113
if (sublisting != null)
115
var thisdir = sublisting.listing['.'];
116
var versioned = ("svnstatus" in thisdir) && (thisdir.svnstatus != "unversioned");
119
// Default: Just offer a link to the directory
120
li.appendChild(dom_make_link_elem("span", name, description,
121
app_path(this_app, username, path, name)));
125
// Blocked: Offer to rename the directory
126
li.appendChild(dom_make_text_elem("span", name));
127
span = dom_make_text_elem("span", "blocked");
128
span.setAttribute("class", "status");
129
li.appendChild(span);
131
var button = document.createElement("input");
132
button.addEventListener("click", function(event)
134
action_rename(path_join(path, name));
136
// FIXME: Also do checkout here?
139
button.setAttribute("type", "button");
140
button.setAttribute("value", "Rename");
141
span.appendChild(button);
146
// Missing: Try to check out or create the repository
147
li.appendChild(dom_make_text_elem("span", name));
148
span = dom_make_text_elem("span", "missing");
149
span.setAttribute("class", "status");
150
li.appendChild(span);
152
var button = document.createElement("input");
153
button.addEventListener("click", function(event)
155
// Get repository stat
156
response = ajax_call(null, service_app, current_path,
158
"action": "svnrepostat",
159
"path": path_join(username, path, name)
162
if (response.status == 200)
165
do_action("svncheckout", current_path, {"path":
167
path_join(username, path, name), // url
168
path_join(path, name) // localpath
171
else if (response.status == 404)
174
do_action("svnrepomkdir", current_path,
176
"path": path_join(username, path, name),
177
"logmsg": "Automated creation of '" + name + "' work directory"
182
alert("Error: Could not Create repository");
186
button.setAttribute("type", "button");
187
button.setAttribute("value", "Checkout");
188
span.appendChild(button);
192
/* Are we working in a subdirectory or parent? */
193
ajax_call(callback, service_app, path_join(username, path, name), {}, "GET");