diff --git a/webpack/lib/client/xhr.js b/webpack/lib/client/xhr.js index d6b8e49..44834eb 100644 --- a/webpack/lib/client/xhr.js +++ b/webpack/lib/client/xhr.js @@ -155,7 +155,8 @@ export default class XHRClientDriver extends ClientDriver{ /* (2) Open connection */ console.log(`API >>> ${this.proto}${request_uri}`); this.xhr.open(http_method, `${this.proto}${request_uri}`, true); - this.xhr.setRequestHeader('Authorization', `Basic ${btoa(http_token)}`); + if( http_token != null ) + this.xhr.setRequestHeader('Authorization', `Basic ${btoa(http_token)}`); /* (3) Send request */ this.xhr.send(form_data); diff --git a/webpack/lib/popup-controller.js b/webpack/lib/popup-controller.js index 28fd2ed..5382aa9 100644 --- a/webpack/lib/popup-controller.js +++ b/webpack/lib/popup-controller.js @@ -103,13 +103,25 @@ export default class PopupController{ submit(){ gs.get.channel.remove() && this.parent.hide(); } }); - /* (6) Leave channel */ + /* (6) Remove channel */ + this.register('room.remove', { + data: { + id: '', + type: '', + name: '', + messages: [] + }, + reset(){ this.data = { id: '', type: '', name: '', messages: [] }; }, + submit(){ gs.get.room.remove(this.data.type, this.data.id) && this.parent.hide(); } + }); + + /* (7) Leave channel */ this.register('channel.leave', { reset(){ }, submit(){ gs.get.channel.remove() && this.parent.hide(); } }); - /* (6) Change password */ + /* (8) Change password */ this.register('password.change', { password: new FieldValidator('password', ''), confirm: new FieldValidator('password', ''), diff --git a/webpack/lib/room-controller.js b/webpack/lib/room-controller.js index 5a4e2e6..8b2f59f 100644 --- a/webpack/lib/room-controller.js +++ b/webpack/lib/room-controller.js @@ -246,5 +246,43 @@ export default class RoomController{ } + /* (7) Remove an existing room + * + * @type room type + * @rid room id + * + * @return removed Whether the room has been removed + * + ---------------------------------------------------------*/ + remove(type=null, rid=null){ + + /* (1) Manage invalid @type */ + if( typeof type !== 'string' || this[type] == null ) + return false; + + /* (2) Manage invalid @rid */ + if( rid === null || isNaN(rid) ) + return false; + + /* (3) Try to create room in API */ + api.call(`DELETE /channel/room/${gs.get.content.cid}/${rid}`, {}, function(rs){ + + /* (1) Manage error */ + if( rs.error !== 0 ) + return false; + + /* (2) Reload room list */ + this.fetch(); + + /* (3) Hide popup */ + gs.get.popup.hide(); + + }.bind(this), auth.token); + + return true; + + } + + } \ No newline at end of file diff --git a/webpack/vue/auth/dialog.vue b/webpack/vue/auth/dialog.vue index 7c6cfef..2da50f7 100644 --- a/webpack/vue/auth/dialog.vue +++ b/webpack/vue/auth/dialog.vue @@ -121,7 +121,9 @@
  • {{ r.name }}
  • + @click='gs.room.nav(r.type, r.id)'>{{ r.name }} + + diff --git a/webpack/vue/auth/wrapper.vue b/webpack/vue/auth/wrapper.vue index 3bb222a..872907d 100644 --- a/webpack/vue/auth/wrapper.vue +++ b/webpack/vue/auth/wrapper.vue @@ -99,6 +99,20 @@ + + +