-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathmodule.html
180 lines (162 loc) · 7.37 KB
/
module.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<div class="row" ng-controller="CabinetController">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{{ currentDirectory }}</h3>
</div>
<div class="panel-body">
<form class="form-inline pull-right" role="form">
<div class="input-group">
<input type="text" placeholder="Change Directory" class="form-control" ng-model="userDirectory">
<span class="input-group-btn">
<button type="submit" class="btn btn-default" ng-click="getDirectoryContents(userDirectory)">Go</button>
</span>
</div>
</form>
<span class="input-group-btn pull-left">
<button type="button" class="btn btn-default btn-sm" ng-show="currentDirectory == '/'" disabled>Back</button>
<button type="button" class="btn btn-default btn-sm" ng-click="goToParentDirctory()" ng-hide="currentDirectory == '/'">Back</button>
<button type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#fileModal">New File</button>
<button type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#folderModal">New Folder</button>
<button type="button" class="btn btn-default btn-sm" ng-click="getDirectoryContents(currentDirectory)">Refresh</button>
</span>
<br />
<hr/>
<div class="table-responsive">
<table class="table table-striped" align="center">
<thead>
<th>File Name</th>
<th>Location</th>
<th>Permissions</th>
<th>Size</th>
<th>Delete</th>
<th>Edit</th>
</thead>
<tbody>
<tr ng-repeat="item in directoryContents">
<td ng-hide="item.directory">{{ item.name }}</td>
<td ng-show="item.directory"><a href="javascript:;" ng-click="getDirectoryContents(item.path)">{{ item.name }}</a></td>
<td class="text-muted"><i>{{ item.path }}</i></td>
<td class="text-muted"><i>{{ item.permissions }}</i></td>
<td class="text-muted"><i>{{ item.size }}</i></td>
<td><a href="" data-toggle="modal" data-target="#deleteModal" ng-click="requestDeleteFile(item)">Delete</a></td>
<td><a href="" ng-hide="item.directory" ng-click="requestEditFile(item)" data-toggle="modal" data-target="#fileModal">Edit</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Edit file Modal -->
<div id="fileModal" class="modal fade" role="dialog">
<script type="text/javascript">
// Thanks to sud0nick on forums.hak5.org for this snippet
$(document).delegate('#cabinetEditor', 'keydown', function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 9) {
for (var i = 0; i < 4; i++) {
// get caret position/selection
var start = this.selectionStart;
var end = this.selectionEnd;
var $this = $(this);
var value = $this.val();
// set textarea value to: text before caret + tab + text after caret
$this.val(value.substring(0, start)
+ " "
+ value.substring(end));
// put caret at right position again (add one for the tab)
this.selectionStart = this.selectionEnd = start + 1;
// prevent the focus lose
e.preventDefault();
}
}
});
</script>
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" ng-click="editFile = {}">×</button>
<h4 class="modal-title">File Editor {{ editFile.name }}</h4>
</div>
<div class="modal-body">
<label class="control-label">File Name</label>
<input type="text" class="form-control" ng-model="editFile.name" placeholder="Notes.txt">
<br />
<label class="control-label">File Contents</label>
<a href="javascript:;" ng-click="editFile.content = ''" class="pull-right">Clear</a>
<textarea class="form-control" rows="10" id="cabinetEditor" ng-model="editFile.content" placeholder="Write some text here"></textarea>
<label class="control-label pull-right">File Size: {{ editFile.size }}</label>
<a href="javascript:;" class="pull-left" ng-click="download(editFile.path)">Download</a>
<br />
</div>
<div class="modal-footer">
<button type="button" ng-click="sendEditFile()" class="btn btn-success pull-right" data-dismiss="modal">Save</button>
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" ng-click="editFile = {}">Cancel</button>
</div>
</div>
</div>
</div>
<!-- Delete file Modal -->
<div id="deleteModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" ng-click="deleteFile = {}">×</button>
<h4 class="modal-title">Delete File {{ deleteFile.name }}</h4>
</div>
<div class="modal-body">
<p>You are about to delete {{ deleteFile.name }}. Once you do this it can not be undone.</p>
<p ng-show="deleteFile.directory">{{ deleteFile.name }} is a directory. Deleteing it will also delete all files and folders contained inside.</p>
<p><b>Are you absolutely sure you want to delete {{ deleteFile.name }} located at {{ deleteFile.path }}?</b></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary pull-right" data-dismiss="modal" ng-click="deleteFile = {}">Cancel</button>
<button type="button" class="btn btn-danger pull-left" data-dismiss="modal" ng-click="sendDeleteFile()">Delete</button>
</div>
</div>
</div>
</div>
<!-- Create directory Modal -->
<div id="folderModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Create Folder</h4>
</div>
<div class="modal-body">
<form class="form-inline" role="form">
<label class="control-label">Folder Name</label>
<input type="text" class="form-control" ng-model="newFolder.name" placeholder="Notes.txt">
</form>
</div>
<div class="modal-footer">
<button type="button" ng-click="createFolder()" class="btn btn-success pull-left" data-dismiss="modal">Create</button>
<button type="button" class="btn btn-default pull-right" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
<!-- Create Message Modal -->
<div id="messageModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">{{ message.title }}</h4>
</div>
<div class="modal-body">
<p>{{ message.body }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-right" data-dismiss="modal">Dismiss</button>
</div>
</div>
</div>
</div>
</div>