diff options
author | Johannes Zellner <johannes@nebulon.de> | 2016-03-01 16:37:05 +0100 |
---|---|---|
committer | Johannes Zellner <johannes@nebulon.de> | 2016-03-01 16:37:05 +0100 |
commit | 403359cf6986b9c0f8c69f144cd36974d61a2370 (patch) | |
tree | 89ba9b26ff89afc617c89603b40f7b2cbf552c61 /app | |
parent | 61e0b8e4910051d0dfb4d454817b9f0511ba96ad (diff) | |
download | Surfer-403359cf6986b9c0f8c69f144cd36974d61a2370.tar.gz Surfer-403359cf6986b9c0f8c69f144cd36974d61a2370.tar.zst Surfer-403359cf6986b9c0f8c69f144cd36974d61a2370.zip |
Add ui to create directories
Diffstat (limited to 'app')
-rw-r--r-- | app/index.html | 25 | ||||
-rw-r--r-- | app/js/app.js | 33 |
2 files changed, 55 insertions, 3 deletions
diff --git a/app/index.html b/app/index.html index cf1f399..ea14bc1 100644 --- a/app/index.html +++ b/app/index.html | |||
@@ -49,6 +49,29 @@ | |||
49 | </div> | 49 | </div> |
50 | </div> | 50 | </div> |
51 | 51 | ||
52 | <div class="modal fade" tabindex="-1" role="dialog" id="modalcreateDirectory"> | ||
53 | <div class="modal-dialog"> | ||
54 | <div class="modal-content"> | ||
55 | <div class="modal-header"> | ||
56 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | ||
57 | <h4 class="modal-title">New Directory Name</h4> | ||
58 | </div> | ||
59 | <div class="modal-body"> | ||
60 | <form v-on:submit.prevent="createDirectory(createDirectoryData)"> | ||
61 | <div class="form-group"> | ||
62 | <input type="text" class="form-control" v-model="createDirectoryData" placeholder="Name"> | ||
63 | </div> | ||
64 | <button type="submit" style="display: none;"></button> | ||
65 | </form> | ||
66 | </div> | ||
67 | <div class="modal-footer"> | ||
68 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | ||
69 | <button type="button" class="btn btn-primary" v-on:click="createDirectory(createDirectoryData)">Create</button> | ||
70 | </div> | ||
71 | </div> | ||
72 | </div> | ||
73 | </div> | ||
74 | |||
52 | <div class="container" v-show="busy" v-cloak> | 75 | <div class="container" v-show="busy" v-cloak> |
53 | <div class="row"> | 76 | <div class="row"> |
54 | <div class="col-lg-12"> | 77 | <div class="col-lg-12"> |
@@ -126,7 +149,7 @@ | |||
126 | </table> | 149 | </table> |
127 | </div> | 150 | </div> |
128 | <div class="col-lg-12" style="text-align: right;"> | 151 | <div class="col-lg-12" style="text-align: right;"> |
129 | <button class="btn btn-default btn-sm" v-on:click="">Create Directory</button> | 152 | <button class="btn btn-default btn-sm" v-on:click="createDirectoryAsk()">Create Directory</button> |
130 | </div> | 153 | </div> |
131 | </div> | 154 | </div> |
132 | </div> | 155 | </div> |
diff --git a/app/js/app.js b/app/js/app.js index 823e4f7..c0ed616 100644 --- a/app/js/app.js +++ b/app/js/app.js | |||
@@ -79,9 +79,12 @@ function up() { | |||
79 | } | 79 | } |
80 | 80 | ||
81 | function upload() { | 81 | function upload() { |
82 | $(app.$els.upload).change(function () { | 82 | $(app.$els.upload).on('change', function () { |
83 | app.busy = true; | 83 | app.busy = true; |
84 | 84 | ||
85 | // detach event handler | ||
86 | $(app.$els.upload).off('change'); | ||
87 | |||
85 | var file = app.$els.upload.files[0]; | 88 | var file = app.$els.upload.files[0]; |
86 | var path = encode(sanitize(app.path + '/' + file.name)); | 89 | var path = encode(sanitize(app.path + '/' + file.name)); |
87 | 90 | ||
@@ -123,6 +126,29 @@ function del(entry) { | |||
123 | }); | 126 | }); |
124 | } | 127 | } |
125 | 128 | ||
129 | function createDirectoryAsk() { | ||
130 | $('#modalcreateDirectory').modal('show'); | ||
131 | app.createDirectoryData = ''; | ||
132 | } | ||
133 | |||
134 | function createDirectory(name) { | ||
135 | app.busy = true; | ||
136 | |||
137 | var path = encode(sanitize(app.path + '/' + name)); | ||
138 | |||
139 | superagent.put('/api/files' + path).query({ username: app.session.username, password: app.session.password, directory: true }).end(function (error, result) { | ||
140 | app.busy = false; | ||
141 | |||
142 | if (error) return console.error(error); | ||
143 | if (result.statusCode !== 201) return console.error('Error creating directory: ', result.statusCode); | ||
144 | |||
145 | app.createDirectoryData = ''; | ||
146 | refresh(); | ||
147 | |||
148 | $('#modalcreateDirectory').modal('hide'); | ||
149 | }); | ||
150 | } | ||
151 | |||
126 | var app = new Vue({ | 152 | var app = new Vue({ |
127 | el: '#app', | 153 | el: '#app', |
128 | data: { | 154 | data: { |
@@ -134,6 +160,7 @@ var app = new Vue({ | |||
134 | }, | 160 | }, |
135 | loginData: {}, | 161 | loginData: {}, |
136 | deleteData: {}, | 162 | deleteData: {}, |
163 | createDirectoryData: '', | ||
137 | entries: [] | 164 | entries: [] |
138 | }, | 165 | }, |
139 | methods: { | 166 | methods: { |
@@ -144,7 +171,9 @@ var app = new Vue({ | |||
144 | up: up, | 171 | up: up, |
145 | upload: upload, | 172 | upload: upload, |
146 | delAsk: delAsk, | 173 | delAsk: delAsk, |
147 | del: del | 174 | del: del, |
175 | createDirectoryAsk: createDirectoryAsk, | ||
176 | createDirectory: createDirectory | ||
148 | } | 177 | } |
149 | }); | 178 | }); |
150 | 179 | ||