wip get all public rooms but no users

This commit is contained in:
simplonco
2023-01-08 17:49:36 +01:00
parent b132c154e4
commit f4dc5cde53
7 changed files with 492 additions and 144 deletions

View File

@@ -14,11 +14,21 @@ export class ChatController {
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
@Get('rooms')
async getRooms(@Req() req, @Res() res): Promise<object>
@Get('myrooms')
async getMyRooms(@Req() req, @Res() res): Promise<object>
{
console.log("- in getRooms controller");
const rooms = await this.chatService.getRooms(req.user);
console.log("- in getMyRooms controller");
const rooms = await this.chatService.getMyRooms(req.user);
return res.status(HttpStatus.OK).json({ rooms: rooms });
}
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
@Get('allrooms')
async getAllRooms(@Req() req, @Res() res): Promise<object>
{
console.log("- in getAllRooms controller");
const rooms = await this.chatService.getAllNotMyRooms(req.user);
return res.status(HttpStatus.OK).json({ rooms: rooms });
}

View File

@@ -24,13 +24,29 @@ export class ChatService {
return new Promise(resolve => setTimeout(resolve, ms));
}
async getRooms(user: User)
async getMyRooms(user: User)
{
console.log("-- in getRooms service");
console.log("-- in getMyRooms service");
const rooms = await this.chatroomRepository
.createQueryBuilder('chatroom')
.where(':user_id IN (chatroom.users)', { user_id: user.fortyTwoId })
.getMany();
return rooms;
}
async getAllNotMyRooms(user: User)
{
console.log("-- in getAllNotMyRooms service");
const user_db = await this.usersService.findOneByFourtyTwoId(user.fortyTwoId);
const rooms = await this.chatroomRepository
.createQueryBuilder('chatroom')
.where('chatroom.type != :type', { type: 'private' })
.andWhere(':user_id NOT IN (chatroom.users)', { user_id: user.fortyTwoId })
.getMany();
//const users = await this.findAllUsers();
//let allRooms = [...rooms, ...users];
return rooms;
}
@@ -58,6 +74,8 @@ export class ChatService {
return room;
}
/* temp *****************************************
*/
async findUserByName(name: string)
{
console.log("-- in findUserByName service");
@@ -69,6 +87,18 @@ export class ChatService {
return user;
}
/* temp *****************************************
*/
async findAllUsers()
{
console.log("-- in findAllUsers service");
const users = await this.userRepository
.createQueryBuilder('user')
.getMany();
return users;
}
async setCurrentRoom(user: User, name: string)
{
console.log("-- in setCurrentRoom service");

View File

@@ -1228,7 +1228,7 @@ var app = (function () {
/* node_modules/svelte-spa-router/Router.svelte generated by Svelte v3.53.1 */
const { Error: Error_1, Object: Object_1, console: console_1$b } = globals;
const { Error: Error_1, Object: Object_1, console: console_1$c } = globals;
// (267:0) {:else}
function create_else_block$6(ctx) {
@@ -2008,7 +2008,7 @@ var app = (function () {
const writable_props = ['routes', 'prefix', 'restoreScrollState'];
Object_1.keys($$props).forEach(key => {
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console_1$b.warn(`<Router> was created with unknown prop '${key}'`);
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console_1$c.warn(`<Router> was created with unknown prop '${key}'`);
});
function routeEvent_handler(event) {
@@ -2292,7 +2292,7 @@ var app = (function () {
/* src/pieces/Header.svelte generated by Svelte v3.53.1 */
const { console: console_1$a } = globals;
const { console: console_1$b } = globals;
const file$v = "src/pieces/Header.svelte";
// (27:39)
@@ -2551,7 +2551,7 @@ var app = (function () {
const writable_props = [];
Object.keys($$props).forEach(key => {
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console_1$a.warn(`<Header> was created with unknown prop '${key}'`);
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console_1$b.warn(`<Header> was created with unknown prop '${key}'`);
});
const click_handler = () => push('/');
@@ -3905,10 +3905,10 @@ var app = (function () {
/* src/pieces/chat/Layout_home.svelte generated by Svelte v3.53.1 */
const { console: console_1$9 } = globals;
const { console: console_1$a } = globals;
const file$p = "src/pieces/chat/Layout_home.svelte";
function get_each_context$5(ctx, list, i) {
function get_each_context$6(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[7] = list[i];
return child_ctx;
@@ -3996,7 +3996,7 @@ var app = (function () {
}
// (1:0) <script> import { onMount }
function create_catch_block$1(ctx) {
function create_catch_block$2(ctx) {
const block = {
c: noop,
m: noop,
@@ -4008,7 +4008,7 @@ var app = (function () {
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_catch_block$1.name,
id: create_catch_block$2.name,
type: "catch",
source: "(1:0) <script> import { onMount }",
ctx
@@ -4018,7 +4018,7 @@ var app = (function () {
}
// (73:3) {:then}
function create_then_block$1(ctx) {
function create_then_block$2(ctx) {
let each_1_anchor;
let current;
let each_value = /*rooms*/ ctx[1];
@@ -4026,7 +4026,7 @@ var app = (function () {
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$5(get_each_context$5(ctx, each_value, i));
each_blocks[i] = create_each_block$6(get_each_context$6(ctx, each_value, i));
}
const out = i => transition_out(each_blocks[i], 1, 1, () => {
@@ -4056,13 +4056,13 @@ var app = (function () {
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context$5(ctx, each_value, i);
const child_ctx = get_each_context$6(ctx, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block$5(child_ctx);
each_blocks[i] = create_each_block$6(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
@@ -4104,7 +4104,7 @@ var app = (function () {
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_then_block$1.name,
id: create_then_block$2.name,
type: "then",
source: "(73:3) {:then}",
ctx
@@ -4149,7 +4149,7 @@ var app = (function () {
}
// (74:4) {#each rooms as room}
function create_each_block$5(ctx) {
function create_each_block$6(ctx) {
let button;
let current;
@@ -4196,7 +4196,7 @@ var app = (function () {
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_each_block$5.name,
id: create_each_block$6.name,
type: "each",
source: "(74:4) {#each rooms as room}",
ctx
@@ -4206,14 +4206,14 @@ var app = (function () {
}
// (70:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}
function create_pending_block$1(ctx) {
function create_pending_block$2(ctx) {
let p;
const block = {
c: function create() {
p = element("p");
p.textContent = "rooms are loaded...";
add_location(p, file$p, 71, 4, 1582);
add_location(p, file$p, 71, 4, 1584);
},
m: function mount(target, anchor) {
insert_dev(target, p, anchor);
@@ -4228,7 +4228,7 @@ var app = (function () {
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_pending_block$1.name,
id: create_pending_block$2.name,
type: "pending",
source: "(70:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}",
ctx
@@ -4316,9 +4316,9 @@ var app = (function () {
current: null,
token: null,
hasCatch: false,
pending: create_pending_block$1,
then: create_then_block$1,
catch: create_catch_block$1,
pending: create_pending_block$2,
then: create_then_block$2,
catch: create_catch_block$2,
blocks: [,,,]
};
@@ -4344,17 +4344,17 @@ var app = (function () {
t6 = space();
info.block.c();
attr_dev(p0, "class", "title svelte-1jygwt2");
add_location(p0, file$p, 64, 2, 1350);
add_location(p0, file$p, 64, 2, 1352);
attr_dev(p1, "class", "__center");
add_location(p1, file$p, 67, 4, 1460);
add_location(p1, file$p, 67, 4, 1462);
attr_dev(div0, "class", "__show_if_only_child");
add_location(div0, file$p, 66, 3, 1421);
add_location(div0, file$p, 66, 3, 1423);
attr_dev(div1, "class", "room_list");
add_location(div1, file$p, 65, 2, 1394);
add_location(div1, file$p, 65, 2, 1396);
attr_dev(div2, "class", "panel panel_home __border_top svelte-1jygwt2");
add_location(div2, file$p, 63, 1, 1304);
add_location(div2, file$p, 63, 1, 1306);
attr_dev(div3, "class", "grid_box svelte-1jygwt2");
add_location(div3, file$p, 45, 0, 945);
add_location(div3, file$p, 45, 0, 947);
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -4477,7 +4477,7 @@ var app = (function () {
];
// ask api for the rooms
const get_rooms = fetch('/api/v2/chat/rooms').then(resp => resp.json()).then(data => {
const get_rooms = fetch('/api/v2/chat/myrooms').then(resp => resp.json()).then(data => {
console.log("data.rooms:", data.rooms);
for (let room of data.rooms) console.log(room.name);
$$invalidate(1, rooms = data.rooms);
@@ -4503,14 +4503,14 @@ var app = (function () {
$$self.$$.on_mount.push(function () {
if (layout === undefined && !('layout' in $$props || $$self.$$.bound[$$self.$$.props['layout']])) {
console_1$9.warn("<Layout_home> was created without expected prop 'layout'");
console_1$a.warn("<Layout_home> was created without expected prop 'layout'");
}
});
const writable_props = ['layout'];
Object.keys($$props).forEach(key => {
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console_1$9.warn(`<Layout_home> was created with unknown prop '${key}'`);
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console_1$a.warn(`<Layout_home> was created with unknown prop '${key}'`);
});
function button0_layout_binding(value) {
@@ -4739,14 +4739,14 @@ var app = (function () {
/* src/pieces/chat/Layout_room.svelte generated by Svelte v3.53.1 */
const file$n = "src/pieces/chat/Layout_room.svelte";
function get_each_context$4(ctx, list, i) {
function get_each_context$5(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[4] = list[i];
return child_ctx;
}
// (44:1) <Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
function create_default_slot_4$2(ctx) {
function create_default_slot_4$3(ctx) {
let t;
const block = {
@@ -4763,7 +4763,7 @@ var app = (function () {
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_default_slot_4$2.name,
id: create_default_slot_4$3.name,
type: "slot",
source: "(44:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
ctx
@@ -4863,7 +4863,7 @@ var app = (function () {
}
// (61:3) {#each $msgs as msg}
function create_each_block$4(ctx) {
function create_each_block$5(ctx) {
let msg_1;
let current;
@@ -4910,7 +4910,7 @@ var app = (function () {
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_each_block$4.name,
id: create_each_block$5.name,
type: "each",
source: "(61:3) {#each $msgs as msg}",
ctx
@@ -4976,7 +4976,7 @@ var app = (function () {
new_layout: /*back*/ ctx[1],
my_class: "back icon",
my_title: "go back " + /*back*/ ctx[1],
$$slots: { default: [create_default_slot_4$2] },
$$slots: { default: [create_default_slot_4$3] },
$$scope: { ctx }
};
@@ -5027,7 +5027,7 @@ var app = (function () {
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$4(get_each_context$4(ctx, each_value, i));
each_blocks[i] = create_each_block$5(get_each_context$5(ctx, each_value, i));
}
const out = i => transition_out(each_blocks[i], 1, 1, () => {
@@ -5167,13 +5167,13 @@ var app = (function () {
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context$4(ctx, each_value, i);
const child_ctx = get_each_context$5(ctx, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block$4(child_ctx);
each_blocks[i] = create_each_block$5(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(div0, null);
@@ -5396,10 +5396,18 @@ var app = (function () {
}
/* src/pieces/chat/Layout_new.svelte generated by Svelte v3.53.1 */
const { console: console_1$9 } = globals;
const file$m = "src/pieces/chat/Layout_new.svelte";
// (12:1) <Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
function create_default_slot_3$3(ctx) {
function get_each_context$4(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[7] = list[i];
return child_ctx;
}
// (30:1) <Button bind:layout new_layout={back} my_class="back icon" my_title="go back {back}">
function create_default_slot_4$2(ctx) {
let t;
const block = {
@@ -5416,17 +5424,17 @@ var app = (function () {
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_default_slot_3$3.name,
id: create_default_slot_4$2.name,
type: "slot",
source: "(12:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
source: "(30:1) <Button bind:layout new_layout={back} my_class=\\\"back icon\\\" my_title=\\\"go back {back}\\\">",
ctx
});
return block;
}
// (17:1) <Button my_class="new deactivate">
function create_default_slot_2$7(ctx) {
// (35:1) <Button my_class="new deactivate">
function create_default_slot_3$3(ctx) {
let t;
const block = {
@@ -5443,17 +5451,17 @@ var app = (function () {
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_default_slot_2$7.name,
id: create_default_slot_3$3.name,
type: "slot",
source: "(17:1) <Button my_class=\\\"new deactivate\\\">",
source: "(35:1) <Button my_class=\\\"new deactivate\\\">",
ctx
});
return block;
}
// (22:1) <Button bind:layout new_layout="close" my_class="close icon">
function create_default_slot_1$7(ctx) {
// (40:1) <Button bind:layout new_layout="close" my_class="close icon">
function create_default_slot_2$7(ctx) {
let t;
const block = {
@@ -5470,17 +5478,17 @@ var app = (function () {
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_default_slot_1$7.name,
id: create_default_slot_2$7.name,
type: "slot",
source: "(22:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
source: "(40:1) <Button bind:layout new_layout=\\\"close\\\" my_class=\\\"close icon\\\">",
ctx
});
return block;
}
// (28:2) <Button bind:layout new_layout="create" my_class="create">
function create_default_slot$9(ctx) {
// (46:2) <Button bind:layout new_layout="create" my_class="create">
function create_default_slot_1$7(ctx) {
let t;
const block = {
@@ -5495,11 +5503,253 @@ var app = (function () {
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_default_slot_1$7.name,
type: "slot",
source: "(46:2) <Button bind:layout new_layout=\\\"create\\\" my_class=\\\"create\\\">",
ctx
});
return block;
}
// (1:0) <script> import Button from './Element_button.svelte'; export let layout = ""; export let back = ""; let rooms = []; // ask api for the rooms const get_rooms = fetch('/api/v2/chat/allrooms') .then(resp => resp.json()) .then(data => { console.log("data.rooms:", data.rooms); for (let room of data.rooms) console.log(room.name); rooms = data.rooms; }
function create_catch_block$1(ctx) {
const block = {
c: noop,
m: noop,
p: noop,
i: noop,
o: noop,
d: noop
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_catch_block$1.name,
type: "catch",
source: "(1:0) <script> import Button from './Element_button.svelte'; export let layout = \\\"\\\"; export let back = \\\"\\\"; let rooms = []; // ask api for the rooms const get_rooms = fetch('/api/v2/chat/allrooms') .then(resp => resp.json()) .then(data => { console.log(\\\"data.rooms:\\\", data.rooms); for (let room of data.rooms) console.log(room.name); rooms = data.rooms; }",
ctx
});
return block;
}
// (57:3) {:then}
function create_then_block$1(ctx) {
let each_1_anchor;
let current;
let each_value = /*rooms*/ ctx[2];
validate_each_argument(each_value);
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$4(get_each_context$4(ctx, each_value, i));
}
const out = i => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
const block = {
c: function create() {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each_1_anchor = empty$1();
},
m: function mount(target, anchor) {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert_dev(target, each_1_anchor, anchor);
current = true;
},
p: function update(ctx, dirty) {
if (dirty & /*join_rooms, rooms*/ 4) {
each_value = /*rooms*/ ctx[2];
validate_each_argument(each_value);
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context$4(ctx, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block$4(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
}
}
group_outros();
for (i = each_value.length; i < each_blocks.length; i += 1) {
out(i);
}
check_outros();
}
},
i: function intro(local) {
if (current) return;
for (let i = 0; i < each_value.length; i += 1) {
transition_in(each_blocks[i]);
}
current = true;
},
o: function outro(local) {
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
current = false;
},
d: function destroy(detaching) {
destroy_each(each_blocks, detaching);
if (detaching) detach_dev(each_1_anchor);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_then_block$1.name,
type: "then",
source: "(57:3) {:then}",
ctx
});
return block;
}
// (59:5) <Button my_class="list" on_click={join_rooms}>
function create_default_slot$9(ctx) {
let t0_value = /*room*/ ctx[7].name + "";
let t0;
let t1;
const block = {
c: function create() {
t0 = text(t0_value);
t1 = space();
},
m: function mount(target, anchor) {
insert_dev(target, t0, anchor);
insert_dev(target, t1, anchor);
},
p: function update(ctx, dirty) {
if (dirty & /*rooms*/ 4 && t0_value !== (t0_value = /*room*/ ctx[7].name + "")) set_data_dev(t0, t0_value);
},
d: function destroy(detaching) {
if (detaching) detach_dev(t0);
if (detaching) detach_dev(t1);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_default_slot$9.name,
type: "slot",
source: "(28:2) <Button bind:layout new_layout=\\\"create\\\" my_class=\\\"create\\\">",
source: "(59:5) <Button my_class=\\\"list\\\" on_click={join_rooms}>",
ctx
});
return block;
}
// (58:4) {#each rooms as room}
function create_each_block$4(ctx) {
let button;
let current;
button = new Element_button({
props: {
my_class: "list",
on_click: join_rooms,
$$slots: { default: [create_default_slot$9] },
$$scope: { ctx }
},
$$inline: true
});
const block = {
c: function create() {
create_component(button.$$.fragment);
},
m: function mount(target, anchor) {
mount_component(button, target, anchor);
current = true;
},
p: function update(ctx, dirty) {
const button_changes = {};
if (dirty & /*$$scope, rooms*/ 1028) {
button_changes.$$scope = { dirty, ctx };
}
button.$set(button_changes);
},
i: function intro(local) {
if (current) return;
transition_in(button.$$.fragment, local);
current = true;
},
o: function outro(local) {
transition_out(button.$$.fragment, local);
current = false;
},
d: function destroy(detaching) {
destroy_component(button, detaching);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_each_block$4.name,
type: "each",
source: "(58:4) {#each rooms as room}",
ctx
});
return block;
}
// (54:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}
function create_pending_block$1(ctx) {
let p;
const block = {
c: function create() {
p = element("p");
p.textContent = "rooms are loaded...";
add_location(p, file$m, 55, 4, 1128);
},
m: function mount(target, anchor) {
insert_dev(target, p, anchor);
},
p: noop,
i: noop,
o: noop,
d: function destroy(detaching) {
if (detaching) detach_dev(p);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_pending_block$1.name,
type: "pending",
source: "(54:21) <!-- promise is pending --> <p>rooms are loaded...</p> {:then}",
ctx
});
@@ -5525,17 +5775,18 @@ var app = (function () {
let div1;
let div0;
let p1;
let t7;
let current;
function button0_layout_binding(value) {
/*button0_layout_binding*/ ctx[2](value);
/*button0_layout_binding*/ ctx[4](value);
}
let button0_props = {
new_layout: /*back*/ ctx[1],
my_class: "back icon",
my_title: "go back " + /*back*/ ctx[1],
$$slots: { default: [create_default_slot_3$3] },
$$slots: { default: [create_default_slot_4$2] },
$$scope: { ctx }
};
@@ -5549,20 +5800,20 @@ var app = (function () {
button1 = new Element_button({
props: {
my_class: "new deactivate",
$$slots: { default: [create_default_slot_2$7] },
$$slots: { default: [create_default_slot_3$3] },
$$scope: { ctx }
},
$$inline: true
});
function button2_layout_binding(value) {
/*button2_layout_binding*/ ctx[3](value);
/*button2_layout_binding*/ ctx[5](value);
}
let button2_props = {
new_layout: "close",
my_class: "close icon",
$$slots: { default: [create_default_slot_1$7] },
$$slots: { default: [create_default_slot_2$7] },
$$scope: { ctx }
};
@@ -5574,13 +5825,13 @@ var app = (function () {
binding_callbacks.push(() => bind(button2, 'layout', button2_layout_binding));
function button3_layout_binding(value) {
/*button3_layout_binding*/ ctx[4](value);
/*button3_layout_binding*/ ctx[6](value);
}
let button3_props = {
new_layout: "create",
my_class: "create",
$$slots: { default: [create_default_slot$9] },
$$slots: { default: [create_default_slot_1$7] },
$$scope: { ctx }
};
@@ -5591,6 +5842,19 @@ var app = (function () {
button3 = new Element_button({ props: button3_props, $$inline: true });
binding_callbacks.push(() => bind(button3, 'layout', button3_layout_binding));
let info = {
ctx,
current: null,
token: null,
hasCatch: false,
pending: create_pending_block$1,
then: create_then_block$1,
catch: create_catch_block$1,
blocks: [,,,]
};
handle_promise(/*get_rooms*/ ctx[3], info);
const block = {
c: function create() {
div3 = element("div");
@@ -5610,17 +5874,19 @@ var app = (function () {
div0 = element("div");
p1 = element("p");
p1.textContent = "/ there are no public rooms yet /";
add_location(p0, file$m, 30, 2, 578);
t7 = space();
info.block.c();
add_location(p0, file$m, 48, 2, 912);
attr_dev(p1, "class", "__center");
add_location(p1, file$m, 33, 4, 668);
add_location(p1, file$m, 51, 4, 1002);
attr_dev(div0, "class", "__show_if_only_child");
add_location(div0, file$m, 32, 3, 629);
add_location(div0, file$m, 50, 3, 963);
attr_dev(div1, "class", "public_rooms");
add_location(div1, file$m, 31, 2, 599);
add_location(div1, file$m, 49, 2, 933);
attr_dev(div2, "class", "panel panel_new __border_top");
add_location(div2, file$m, 26, 1, 450);
add_location(div2, file$m, 44, 1, 784);
attr_dev(div3, "class", "grid_box svelte-1b4c0qx");
add_location(div3, file$m, 8, 0, 117);
add_location(div3, file$m, 26, 0, 451);
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -5641,14 +5907,19 @@ var app = (function () {
append_dev(div2, div1);
append_dev(div1, div0);
append_dev(div0, p1);
append_dev(div1, t7);
info.block.m(div1, info.anchor = null);
info.mount = () => div1;
info.anchor = null;
current = true;
},
p: function update(ctx, [dirty]) {
p: function update(new_ctx, [dirty]) {
ctx = new_ctx;
const button0_changes = {};
if (dirty & /*back*/ 2) button0_changes.new_layout = /*back*/ ctx[1];
if (dirty & /*back*/ 2) button0_changes.my_title = "go back " + /*back*/ ctx[1];
if (dirty & /*$$scope*/ 32) {
if (dirty & /*$$scope*/ 1024) {
button0_changes.$$scope = { dirty, ctx };
}
@@ -5661,14 +5932,14 @@ var app = (function () {
button0.$set(button0_changes);
const button1_changes = {};
if (dirty & /*$$scope*/ 32) {
if (dirty & /*$$scope*/ 1024) {
button1_changes.$$scope = { dirty, ctx };
}
button1.$set(button1_changes);
const button2_changes = {};
if (dirty & /*$$scope*/ 32) {
if (dirty & /*$$scope*/ 1024) {
button2_changes.$$scope = { dirty, ctx };
}
@@ -5681,7 +5952,7 @@ var app = (function () {
button2.$set(button2_changes);
const button3_changes = {};
if (dirty & /*$$scope*/ 32) {
if (dirty & /*$$scope*/ 1024) {
button3_changes.$$scope = { dirty, ctx };
}
@@ -5692,6 +5963,7 @@ var app = (function () {
}
button3.$set(button3_changes);
update_await_block_branch(info, ctx, dirty);
},
i: function intro(local) {
if (current) return;
@@ -5699,6 +5971,7 @@ var app = (function () {
transition_in(button1.$$.fragment, local);
transition_in(button2.$$.fragment, local);
transition_in(button3.$$.fragment, local);
transition_in(info.block);
current = true;
},
o: function outro(local) {
@@ -5706,6 +5979,12 @@ var app = (function () {
transition_out(button1.$$.fragment, local);
transition_out(button2.$$.fragment, local);
transition_out(button3.$$.fragment, local);
for (let i = 0; i < 3; i += 1) {
const block = info.blocks[i];
transition_out(block);
}
current = false;
},
d: function destroy(detaching) {
@@ -5714,6 +5993,9 @@ var app = (function () {
destroy_component(button1);
destroy_component(button2);
destroy_component(button3);
info.block.d();
info.token = null;
info = null;
}
};
@@ -5728,15 +6010,28 @@ var app = (function () {
return block;
}
function join_rooms() {
console.log("inside join_rooms");
}
function instance$p($$self, $$props, $$invalidate) {
let { $$slots: slots = {}, $$scope } = $$props;
validate_slots('Layout_new', slots, []);
let { layout = "" } = $$props;
let { back = "" } = $$props;
let rooms = [];
// ask api for the rooms
const get_rooms = fetch('/api/v2/chat/allrooms').then(resp => resp.json()).then(data => {
console.log("data.rooms:", data.rooms);
for (let room of data.rooms) console.log(room.name);
$$invalidate(2, rooms = data.rooms);
});
const writable_props = ['layout', 'back'];
Object.keys($$props).forEach(key => {
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console.warn(`<Layout_new> was created with unknown prop '${key}'`);
if (!~writable_props.indexOf(key) && key.slice(0, 2) !== '$$' && key !== 'slot') console_1$9.warn(`<Layout_new> was created with unknown prop '${key}'`);
});
function button0_layout_binding(value) {
@@ -5759,11 +6054,19 @@ var app = (function () {
if ('back' in $$props) $$invalidate(1, back = $$props.back);
};
$$self.$capture_state = () => ({ Button: Element_button, layout, back });
$$self.$capture_state = () => ({
Button: Element_button,
layout,
back,
rooms,
get_rooms,
join_rooms
});
$$self.$inject_state = $$props => {
if ('layout' in $$props) $$invalidate(0, layout = $$props.layout);
if ('back' in $$props) $$invalidate(1, back = $$props.back);
if ('rooms' in $$props) $$invalidate(2, rooms = $$props.rooms);
};
if ($$props && "$$inject" in $$props) {
@@ -5773,6 +6076,8 @@ var app = (function () {
return [
layout,
back,
rooms,
get_rooms,
button0_layout_binding,
button2_layout_binding,
button3_layout_binding
@@ -7484,21 +7789,21 @@ var app = (function () {
p.textContent = "choose a password :";
t1 = space();
input = element("input");
attr_dev(p, "class", "svelte-1b1eu8h");
add_location(p, file$h, 82, 28, 2624);
attr_dev(p, "class", "svelte-1ulnmwp");
add_location(p, file$h, 82, 28, 2634);
attr_dev(label, "for", "chat_pswd");
attr_dev(label, "class", "svelte-1b1eu8h");
add_location(label, file$h, 82, 5, 2601);
attr_dev(label, "class", "svelte-1ulnmwp");
add_location(label, file$h, 82, 5, 2611);
attr_dev(input, "id", "chat_pswd");
attr_dev(input, "type", "password");
attr_dev(input, "placeholder", "minimum 8 characters");
attr_dev(input, "minlength", "8");
attr_dev(input, "name", "password");
input.required = true;
attr_dev(input, "class", "svelte-1b1eu8h");
add_location(input, file$h, 83, 5, 2664);
attr_dev(div, "class", "svelte-1b1eu8h");
add_location(div, file$h, 81, 4, 2590);
attr_dev(input, "class", "svelte-1ulnmwp");
add_location(input, file$h, 83, 5, 2674);
attr_dev(div, "class", "svelte-1ulnmwp");
add_location(div, file$h, 81, 4, 2600);
},
m: function mount(target, anchor) {
insert_dev(target, div, anchor);
@@ -7663,17 +7968,17 @@ var app = (function () {
if (if_block1) if_block1.c();
t16 = space();
input4 = element("input");
attr_dev(p0, "class", "svelte-1b1eu8h");
attr_dev(p0, "class", "svelte-1ulnmwp");
add_location(p0, file$h, 62, 26, 1787);
attr_dev(label0, "for", "chat_name");
attr_dev(label0, "class", "svelte-1b1eu8h");
attr_dev(label0, "class", "svelte-1ulnmwp");
add_location(label0, file$h, 62, 3, 1764);
attr_dev(input0, "id", "chat_name");
attr_dev(input0, "name", "room_name");
input0.required = true;
attr_dev(input0, "class", "svelte-1b1eu8h");
attr_dev(input0, "class", "svelte-1ulnmwp");
add_location(input0, file$h, 63, 3, 1821);
attr_dev(p1, "class", "svelte-1b1eu8h");
attr_dev(p1, "class", "svelte-1ulnmwp");
add_location(p1, file$h, 66, 4, 1964);
attr_dev(input1, "id", "chat_public");
attr_dev(input1, "type", "radio");
@@ -7681,49 +7986,49 @@ var app = (function () {
input1.__value = "public";
input1.value = input1.__value;
input1.required = true;
attr_dev(input1, "class", "svelte-1b1eu8h");
attr_dev(input1, "class", "svelte-1ulnmwp");
/*$$binding_groups*/ ctx[12][0].push(input1);
add_location(input1, file$h, 67, 4, 1982);
attr_dev(label1, "for", "chat_public");
attr_dev(label1, "class", "_radio svelte-1b1eu8h");
attr_dev(label1, "class", "_radio svelte-1ulnmwp");
add_location(label1, file$h, 65, 3, 1919);
attr_dev(p2, "class", "svelte-1b1eu8h");
add_location(p2, file$h, 71, 4, 2170);
attr_dev(p2, "class", "svelte-1ulnmwp");
add_location(p2, file$h, 71, 4, 2175);
attr_dev(input2, "id", "chat_private");
attr_dev(input2, "type", "radio");
attr_dev(input2, "name", "room_type");
input2.__value = "private";
input2.value = input2.__value;
input2.required = true;
attr_dev(input2, "class", "svelte-1b1eu8h");
attr_dev(input2, "class", "svelte-1ulnmwp");
/*$$binding_groups*/ ctx[12][0].push(input2);
add_location(input2, file$h, 72, 4, 2189);
add_location(input2, file$h, 72, 4, 2194);
attr_dev(label2, "for", "chat_private");
attr_dev(label2, "class", "_radio svelte-1b1eu8h");
attr_dev(label2, "class", "_radio hide svelte-1ulnmwp");
add_location(label2, file$h, 70, 3, 2124);
attr_dev(p3, "class", "svelte-1b1eu8h");
add_location(p3, file$h, 76, 4, 2383);
attr_dev(p3, "class", "svelte-1ulnmwp");
add_location(p3, file$h, 76, 4, 2393);
attr_dev(input3, "id", "chat_protected");
attr_dev(input3, "type", "radio");
attr_dev(input3, "name", "room_type");
input3.__value = "protected";
input3.value = input3.__value;
input3.required = true;
attr_dev(input3, "class", "svelte-1b1eu8h");
attr_dev(input3, "class", "svelte-1ulnmwp");
/*$$binding_groups*/ ctx[12][0].push(input3);
add_location(input3, file$h, 77, 4, 2404);
add_location(input3, file$h, 77, 4, 2414);
attr_dev(label3, "for", "chat_protected");
attr_dev(label3, "class", "_radio svelte-1b1eu8h");
add_location(label3, file$h, 75, 3, 2335);
attr_dev(label3, "class", "_radio hide svelte-1ulnmwp");
add_location(label3, file$h, 75, 3, 2340);
attr_dev(input4, "type", "submit");
input4.value = "⮡";
attr_dev(input4, "class", "svelte-1b1eu8h");
add_location(input4, file$h, 86, 3, 2828);
attr_dev(form, "class", "svelte-1b1eu8h");
attr_dev(input4, "class", "svelte-1ulnmwp");
add_location(input4, file$h, 86, 3, 2838);
attr_dev(form, "class", "svelte-1ulnmwp");
add_location(form, file$h, 57, 2, 1613);
attr_dev(div0, "class", "panel panel_create __border_top svelte-1b1eu8h");
attr_dev(div0, "class", "panel panel_create __border_top svelte-1ulnmwp");
add_location(div0, file$h, 56, 1, 1565);
attr_dev(div1, "class", "grid_box svelte-1b1eu8h");
attr_dev(div1, "class", "grid_box svelte-1ulnmwp");
add_location(div1, file$h, 38, 0, 1220);
},
l: function claim(nodes) {

File diff suppressed because one or more lines are too long

View File

@@ -79,12 +79,12 @@
<input id="chat_public" bind:group={room_type} type="radio" name="room_type" value="public" required>
</label>
<!-- [ ] private -->
<label for="chat_private" class="_radio">
<label for="chat_private" class="_radio hide">
<p>private</p>
<input id="chat_private" bind:group={room_type} type="radio" name="room_type" value="private" required>
</label>
<!-- [ ] protected -->
<label for="chat_protected" class="_radio">
<label for="chat_protected" class="_radio hide">
<p>protected</p>
<input id="chat_protected" bind:group={room_type} type="radio" name="room_type" value="protected" required>
</label>
@@ -116,6 +116,11 @@
/ auto 1fr auto ;
}
/* temp
*/
.hide {
display: none !important;
}
/* radio elements style check
*/

View File

@@ -13,7 +13,7 @@
];
// ask api for the rooms
const get_rooms = fetch('/api/v2/chat/rooms')
const get_rooms = fetch('/api/v2/chat/myrooms')
.then(resp => resp.json())
.then(data =>
{

View File

@@ -4,6 +4,24 @@
export let layout = "";
export let back = "";
let rooms = [];
// ask api for the rooms
const get_rooms = fetch('/api/v2/chat/allrooms')
.then(resp => resp.json())
.then(data =>
{
console.log("data.rooms:", data.rooms);
for (let room of data.rooms)
console.log(room.name);
rooms = data.rooms;
});
function join_rooms()
{
console.log("inside join_rooms");
}
</script>
<div class="grid_box">
@@ -33,36 +51,16 @@
<div class="__show_if_only_child">
<p class="__center">/ there are no public rooms yet /</p>
</div>
<!-- placeholders
<Button bind:layout new_layout="room" my_class="list">
placeholder
</Button>
<Button bind:layout new_layout="room" my_class="list">
room
</Button>
<Button bind:layout new_layout="room" my_class="list">
one room
</Button>
<Button bind:layout new_layout="room" my_class="list">
another room
</Button>
<Button bind:layout new_layout="room" my_class="list">
one room
</Button>
<Button bind:layout new_layout="room" my_class="list">
another room
</Button>
<Button bind:layout new_layout="room" my_class="list">
one room
</Button>
<Button bind:layout new_layout="room" my_class="list">
another room
</Button>
<Button bind:layout new_layout="room" my_class="list">
one more room
</Button>
------------- -->
<!-- END placeholders -->
{#await get_rooms}
<!-- promise is pending -->
<p>rooms are loaded...</p>
{:then}
{#each rooms as room}
<Button my_class="list" on_click={join_rooms}>
{room.name}
</Button>
{/each}
{/await}
</div>
</div>