@platformos/pos-cli
Version:
Manage your platformOS application
443 lines (415 loc) • 11.2 kB
JavaScript
import { S as SvelteComponent, i as init, s as safe_not_equal, V as handle_promise, e as element, t as text, b as space, c as claim_element, d as children, f as claim_text, g as detach, h as claim_space, j as attr, k as insert, a as append, n as noop, l as component_subscribe, u as url, J as empty, w as update_keyed_each, W as destroy_block } from './main2.js';
import { a as api } from './api.js';
import './store.js';
/* src\pages\Users\index.svelte generated by Svelte v3.24.1 */
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[3] = list[i].id;
child_ctx[4] = list[i].email;
child_ctx[5] = list[i].deleted_at;
child_ctx[6] = list[i].created_at;
child_ctx[7] = list[i].first_name;
child_ctx[8] = list[i].last_name;
child_ctx[9] = list[i].external_id;
child_ctx[10] = list[i].jwt_token;
child_ctx[11] = list[i].temporary_token;
return child_ctx;
}
// (1:0) <script> import api from "@/lib/api"; import { url }
function create_catch_block(ctx) {
return {
c: noop,
l: noop,
m: noop,
p: noop,
d: noop
};
}
// (21:6) {:then data}
function create_then_block(ctx) {
let each_blocks = [];
let each_1_lookup = new Map();
let each_1_anchor;
let each_value = /*data*/ ctx[2];
const get_key = ctx => /*id*/ ctx[3];
for (let i = 0; i < each_value.length; i += 1) {
let child_ctx = get_each_context(ctx, each_value, i);
let key = get_key(child_ctx);
each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
}
return {
c() {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each_1_anchor = empty();
},
l(nodes) {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].l(nodes);
}
each_1_anchor = empty();
},
m(target, anchor) {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert(target, each_1_anchor, anchor);
},
p(ctx, dirty) {
if (dirty & /*$url, users*/ 3) {
const each_value = /*data*/ ctx[2];
each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, destroy_block, create_each_block, each_1_anchor, get_each_context);
}
},
d(detaching) {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].d(detaching);
}
if (detaching) detach(each_1_anchor);
}
};
}
// (38:16) {#if external_id && external_id.length > 5}
function create_if_block(ctx) {
let li;
let t0;
let t1_value = /*external_id*/ ctx[9] + "";
let t1;
return {
c() {
li = element("li");
t0 = text("External ID: ");
t1 = text(t1_value);
this.h();
},
l(nodes) {
li = claim_element(nodes, "LI", { class: true });
var li_nodes = children(li);
t0 = claim_text(li_nodes, "External ID: ");
t1 = claim_text(li_nodes, t1_value);
li_nodes.forEach(detach);
this.h();
},
h() {
attr(li, "class", "text-xs");
},
m(target, anchor) {
insert(target, li, anchor);
append(li, t0);
append(li, t1);
},
p: noop,
d(detaching) {
if (detaching) detach(li);
}
};
}
// (22:8) {#each data as { id, email, deleted_at, created_at, first_name, last_name, external_id, jwt_token, temporary_token }
function create_each_block(key_1, ctx) {
let a;
let div;
let h1;
let span0;
let t0_value = /*email*/ ctx[4] + "";
let t0;
let t1;
let span1;
let t2;
let t3_value = /*id*/ ctx[3] + "";
let t3;
let t4;
let ul;
let li0;
let t5;
let t6_value = /*first_name*/ ctx[7] + "";
let t6;
let t7;
let li1;
let t8;
let t9_value = /*last_name*/ ctx[8] + "";
let t9;
let t10;
let li2;
let t11;
let t12;
let li3;
let t13;
let t14_value = /*jwt_token*/ ctx[10] + "";
let t14;
let t15;
let a_href_value;
let if_block = /*external_id*/ ctx[9] && /*external_id*/ ctx[9].length > 5 && create_if_block(ctx);
return {
key: key_1,
first: null,
c() {
a = element("a");
div = element("div");
h1 = element("h1");
span0 = element("span");
t0 = text(t0_value);
t1 = space();
span1 = element("span");
t2 = text("ID: ");
t3 = text(t3_value);
t4 = space();
ul = element("ul");
li0 = element("li");
t5 = text("First name: ");
t6 = text(t6_value);
t7 = space();
li1 = element("li");
t8 = text("Last name: ");
t9 = text(t9_value);
t10 = space();
li2 = element("li");
t11 = space();
if (if_block) if_block.c();
t12 = space();
li3 = element("li");
t13 = text("JWT: ");
t14 = text(t14_value);
t15 = space();
this.h();
},
l(nodes) {
a = claim_element(nodes, "A", { class: true, href: true });
var a_nodes = children(a);
div = claim_element(a_nodes, "DIV", { class: true });
var div_nodes = children(div);
h1 = claim_element(div_nodes, "H1", { class: true });
var h1_nodes = children(h1);
span0 = claim_element(h1_nodes, "SPAN", {});
var span0_nodes = children(span0);
t0 = claim_text(span0_nodes, t0_value);
span0_nodes.forEach(detach);
t1 = claim_space(h1_nodes);
span1 = claim_element(h1_nodes, "SPAN", {});
var span1_nodes = children(span1);
t2 = claim_text(span1_nodes, "ID: ");
t3 = claim_text(span1_nodes, t3_value);
span1_nodes.forEach(detach);
h1_nodes.forEach(detach);
t4 = claim_space(div_nodes);
ul = claim_element(div_nodes, "UL", { class: true });
var ul_nodes = children(ul);
li0 = claim_element(ul_nodes, "LI", {});
var li0_nodes = children(li0);
t5 = claim_text(li0_nodes, "First name: ");
t6 = claim_text(li0_nodes, t6_value);
li0_nodes.forEach(detach);
t7 = claim_space(ul_nodes);
li1 = claim_element(ul_nodes, "LI", {});
var li1_nodes = children(li1);
t8 = claim_text(li1_nodes, "Last name: ");
t9 = claim_text(li1_nodes, t9_value);
li1_nodes.forEach(detach);
t10 = claim_space(ul_nodes);
li2 = claim_element(ul_nodes, "LI", { class: true });
children(li2).forEach(detach);
t11 = claim_space(ul_nodes);
if (if_block) if_block.l(ul_nodes);
t12 = claim_space(ul_nodes);
li3 = claim_element(ul_nodes, "LI", { class: true });
var li3_nodes = children(li3);
t13 = claim_text(li3_nodes, "JWT: ");
t14 = claim_text(li3_nodes, t14_value);
li3_nodes.forEach(detach);
ul_nodes.forEach(detach);
div_nodes.forEach(detach);
t15 = claim_space(a_nodes);
a_nodes.forEach(detach);
this.h();
},
h() {
attr(h1, "class", "flex justify-between pb-2 mb-2 text-2xl leading-relaxed");
attr(li2, "class", "pt-2 mt-4 text-xs border-t border-gray-400");
attr(li3, "class", "text-xs");
attr(ul, "class", "text-sm");
attr(div, "class", "relative flex flex-col h-full p-5 bg-gray-200 border border-gray-400 hover:bg-gray-300 hover:shadow-md");
attr(a, "class", "");
attr(a, "href", a_href_value = /*$url*/ ctx[0]("../Manage/:id", { id: /*id*/ ctx[3] }));
this.first = a;
},
m(target, anchor) {
insert(target, a, anchor);
append(a, div);
append(div, h1);
append(h1, span0);
append(span0, t0);
append(h1, t1);
append(h1, span1);
append(span1, t2);
append(span1, t3);
append(div, t4);
append(div, ul);
append(ul, li0);
append(li0, t5);
append(li0, t6);
append(ul, t7);
append(ul, li1);
append(li1, t8);
append(li1, t9);
append(ul, t10);
append(ul, li2);
append(ul, t11);
if (if_block) if_block.m(ul, null);
append(ul, t12);
append(ul, li3);
append(li3, t13);
append(li3, t14);
append(a, t15);
},
p(ctx, dirty) {
if (/*external_id*/ ctx[9] && /*external_id*/ ctx[9].length > 5) if_block.p(ctx, dirty);
if (dirty & /*$url*/ 1 && a_href_value !== (a_href_value = /*$url*/ ctx[0]("../Manage/:id", { id: /*id*/ ctx[3] }))) {
attr(a, "href", a_href_value);
}
},
d(detaching) {
if (detaching) detach(a);
if (if_block) if_block.d();
}
};
}
// (19:22) <p>Loading...</p> {:then data}
function create_pending_block(ctx) {
let p;
let t;
return {
c() {
p = element("p");
t = text("Loading...");
},
l(nodes) {
p = claim_element(nodes, "P", {});
var p_nodes = children(p);
t = claim_text(p_nodes, "Loading...");
p_nodes.forEach(detach);
},
m(target, anchor) {
insert(target, p, anchor);
append(p, t);
},
p: noop,
d(detaching) {
if (detaching) detach(p);
}
};
}
function create_fragment(ctx) {
let h1;
let t0;
let t1;
let p;
let t2;
let t3;
let section;
let div1;
let div0;
let info = {
ctx,
current: null,
token: null,
pending: create_pending_block,
then: create_then_block,
catch: create_catch_block,
value: 2
};
handle_promise(/*users*/ ctx[1](), info);
return {
c() {
h1 = element("h1");
t0 = text("Users");
t1 = space();
p = element("p");
t2 = text("Choose schema that you want to see models for.");
t3 = space();
section = element("section");
div1 = element("div");
div0 = element("div");
info.block.c();
this.h();
},
l(nodes) {
h1 = claim_element(nodes, "H1", { class: true });
var h1_nodes = children(h1);
t0 = claim_text(h1_nodes, "Users");
h1_nodes.forEach(detach);
t1 = claim_space(nodes);
p = claim_element(nodes, "P", {});
var p_nodes = children(p);
t2 = claim_text(p_nodes, "Choose schema that you want to see models for.");
p_nodes.forEach(detach);
t3 = claim_space(nodes);
section = claim_element(nodes, "SECTION", { class: true });
var section_nodes = children(section);
div1 = claim_element(section_nodes, "DIV", { class: true });
var div1_nodes = children(div1);
div0 = claim_element(div1_nodes, "DIV", { class: true });
var div0_nodes = children(div0);
info.block.l(div0_nodes);
div0_nodes.forEach(detach);
div1_nodes.forEach(detach);
section_nodes.forEach(detach);
this.h();
},
h() {
attr(h1, "class", "mb-2 text-5xl");
attr(div0, "class", "grid gap-5 lg:grid-cols-2");
attr(div1, "class", "container py-8");
attr(section, "class", "overflow-hidden");
},
m(target, anchor) {
insert(target, h1, anchor);
append(h1, t0);
insert(target, t1, anchor);
insert(target, p, anchor);
append(p, t2);
insert(target, t3, anchor);
insert(target, section, anchor);
append(section, div1);
append(div1, div0);
info.block.m(div0, info.anchor = null);
info.mount = () => div0;
info.anchor = null;
},
p(new_ctx, [dirty]) {
ctx = new_ctx;
{
const child_ctx = ctx.slice();
child_ctx[2] = info.resolved;
info.block.p(child_ctx, dirty);
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(h1);
if (detaching) detach(t1);
if (detaching) detach(p);
if (detaching) detach(t3);
if (detaching) detach(section);
info.block.d();
info.token = null;
info = null;
}
};
}
function instance($$self, $$props, $$invalidate) {
let $url;
component_subscribe($$self, url, $$value => $$invalidate(0, $url = $$value));
const users = async () => {
const res = await api.getUsers();
return res.users.results;
};
return [$url, users];
}
class Users extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
}
}
export default Users;