Skip to content

Commit

Permalink
fix: Fix sync issues with Orgs (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
qq815776412 authored May 11, 2024
2 parents 377f7e1 + 2d8989e commit 3e48ff7
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 370 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"dev": "PL_SERVER_URL=http://127.0.0.1:3000 SERVER_PROXY_NNME=zhaohuaiyuan lerna run --scope '@didvault/{server,app,mockbfl,notification,mockws}' --parallel dev",
"dev:1": "PL_SERVER_URL=http://127.0.0.1:3000 lerna run --scope '@didvault/{server,mockbfl}' --parallel dev",
"dev:2": "PL_SERVER_URL=http://127.0.0.1:3010 lerna run --scope '@didvault/{server2,mockbfl2}' --parallel dev",
"dev:desktop": "PL_SERVER_URL=http://127.0.0.1:3000 SERVER_PROXY_NNME=local.guojianmin lerna run --scope '@didvault/app' --parallel dev:desktop",
"dev:desktop": "PL_SERVER_URL=http://127.0.0.1:3000 SERVER_PROXY_NNME=zhaohuaiyuan lerna run --scope '@didvault/app' --parallel dev:desktop",
"dev:files": "PL_SERVER_URL=http://127.0.0.1:3000 SERVER_PROXY_NNME=zhaohuaiyuan lerna run --scope '@didvault/app' --parallel dev:files",
"clean:2": "lerna run --scope '@didvault/{server,server2,mockbfl,mockbfl2,sign2}' --parallel clean",
"dev:mobile": "PL_SERVER_URL=http://127.0.0.1:3000 SERVER_PROXY_NNME=zhaohuaiyuan lerna run --scope '@didvault/app' --parallel dev:mobile",
Expand Down
9 changes: 5 additions & 4 deletions packages/app/src/components/files/ListingItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,14 @@ export default defineComponent({
}
if ((props.type == 'folder' || !props.type) && props.fileSize) {
return humanStorageSize(props.fileSize) === '4.0KB'
? '0KB'
: humanStorageSize(props.fileSize);
return '-';
// return humanStorageSize(props.fileSize) === '4.0KB'
// ? '0KB'
// : humanStorageSize(props.fileSize);
}
return humanStorageSize(props.size) === '4.0KB'
? '0KB'
? '-'
: humanStorageSize(props.size);
};
Expand Down
21 changes: 13 additions & 8 deletions packages/app/src/components/files/prompts/InfoDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ const show = ref(true);
const store = useDataStore();
const humanSize = computed(function () {
if (fileType.value === 'folder') {
return '-';
}
if (store.selectedCount === 0) {
return humanStorageSize(store.req.size);
}
Expand All @@ -96,14 +100,15 @@ const humanSize = computed(function () {
});
const humanNumber = computed(function () {
if (store.selectedCount === 0) {
return 0;
}
const item = store.req.items[store.selected[0]];
let folder = `${item.numDirs} ${item.numDirs > 1 ? 'folders, ' : 'folder, '}`;
let file = `${item.numFiles} ${item.numFiles > 1 ? 'files' : 'file'}`;
return `${item.numDirs > 0 ? folder : ''} ${file}`;
return '-';
// if (store.selectedCount === 0) {
// return 0;
// }
// const item = store.req.items[store.selected[0]];
// let folder = `${item.numDirs} ${item.numDirs > 1 ? 'folders, ' : 'folder, '}`;
// let file = `${item.numFiles} ${item.numFiles > 1 ? 'files' : 'file'}`;
// return `${item.numDirs > 0 ? folder : ''} ${file}`;
});
const name = computed(function () {
Expand Down
82 changes: 7 additions & 75 deletions packages/app/src/pages/Web/Orgs/invites/OrgInvitesList.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
<template>
<div style="width: 100%; height: 60px">
<div class="searchWrap" v-if="filterShowing === 'search'">
<q-input
dense
class="searchInput q-px-sm"
v-model="filterInput"
debounce="500"
borderless
placeholder="Search"
@update:model-value="search"
>
<template v-slot:prepend>
<q-icon name="sym_r_search"> </q-icon>
</template>
<template v-slot:append>
<q-icon class="closeIcon" name="sym_r_close" @click="closeSearch">
<q-tooltip> {{ t('buttons.close') }} </q-tooltip>
</q-icon>
</template>
</q-input>
</div>

<div
class="row justify-between items-center"
v-if="filterShowing === 'default'"
>
<div
class="row justify-between items-center"
style="width: 100%; height: 60px"
>
<div class="row justify-between items-center">
<div class="row items-center q-pl-md">
<q-icon
v-if="isMobile"
Expand Down Expand Up @@ -52,17 +31,6 @@
{{ heading.title }}
</div>
</div>

<div class="row items-center q-py-xs q-my-md">
<q-icon
class="q-mr-md cursor-pointer"
name="sym_r_search"
size="24px"
@click="() => (filterShowing = 'search')"
>
<q-tooltip>{{ t('search') }}</q-tooltip>
</q-icon>
</div>
</div>
</div>

Expand Down Expand Up @@ -114,41 +82,29 @@ import { debounce, Invite } from '@didvault/sdk/src/core';
import { scrollBarStyle } from '../../../../utils/contact';
import { useMenuStore } from '../../../../stores/menu';
import OrgInviteItem from './OrgInviteItem.vue';
// import VaultsMenu from '../../../../layouts/TermipassLayout/VaultsMenu.vue';
import { busOn, busOff } from '../../../../utils/bus';
import { useI18n } from 'vue-i18n';

export default defineComponent({
name: 'OrgInvitesIndex',
components: {
OrgInviteItem
// VaultsMenu
},
setup() {
const $q = useQuasar();
const router = useRouter();
const route = useRoute();
const meunStore = useMenuStore();
const values = ref('');
const vaultItemRef = ref();
const showArrow = ref(false);
const arrowItemObj = ref({});
const contentStyle = ref({
height: 0
});
const checkBoxArr = ref([]);
const filterInput = ref('');
const filterShowing = ref('default');
const isMobile = ref(
process.env.PLATFORM == 'MOBILE' ||
process.env.PLATFORM == 'BEX' ||
$q.platform.is.mobile
);
const platform = ref(process.env.PLATFORM);
const org = ref();

const initOrg = () => {
org.value = app.orgs.find((org) => org.id == meunStore.org_id);
console.log('initOrginitOrg', org.value);
};

const heading = computed(function () {
Expand All @@ -160,13 +116,7 @@ export default defineComponent({

function _getItems() {
initOrg();
const memFilter = filterInput.value.toLowerCase();
console.log('org.valueorg.value', org.value);
const invites = memFilter
? org.value!.invites.filter(({ did }) =>
did.toLowerCase().includes(memFilter)
)
: org.value!.invites;
const invites = org.value!.invites;
return invites;
}

Expand All @@ -189,14 +139,6 @@ export default defineComponent({
updateItems();
}

function closeSearch() {
if (filterInput?.value) {
filterInput.value = '';
updateItems();
}
filterShowing.value = 'default';
}

const goBack = () => {
router.go(-1);
};
Expand Down Expand Up @@ -224,21 +166,11 @@ export default defineComponent({
selectItem,
isSelected,
heading,
filterShowing,
filterInput,
org,
values,
showArrow,
arrowItemObj,
vaultItemRef,
contentStyle,
checkBoxArr,
search,
closeSearch,
isMobile,
goBack,
scrollBarStyle,
platform,
t
};
}
Expand Down
23 changes: 13 additions & 10 deletions packages/app/src/pages/Web/Orgs/invites/OrgInvitesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ export default defineComponent({
const router = useRouter();
const $q = useQuasar();
const meunStore = useMenuStore();
const now = new Date();
const nameRef = ref();
const invite = ref();
const isMobile = ref(
process.env.PLATFORM == 'MOBILE' ||
Expand Down Expand Up @@ -185,6 +183,7 @@ export default defineComponent({
}
invite.value =
org.value && org.value.getInvite(route.params.org_type as string);
if (newVaule) {
updateSecert();
}
Expand All @@ -200,7 +199,12 @@ export default defineComponent({
invite.value!.purpose
)
)[0];
secret.value = newInvite && newInvite.secret!;
if (newInvite) {
router.replace({
path: '/org/Invites/' + (newInvite.id ? newInvite.id : '')
});
secret.value = newInvite.secret!;
}
} catch (e) {
notifyFailed(e.message);
}
Expand All @@ -222,17 +226,18 @@ export default defineComponent({
}
}
function stateUpdate() {
initOrg();
invite.value = getInvite();
async function stateUpdate() {
await initOrg();
invite.value = await getInvite();
}
const goBack = () => {
router.go(-1);
};
onMounted(() => {
busOn('appSubscribe', stateUpdate);
stateUpdate();
busOn('orgSubscribe', stateUpdate);
invite.value =
org.value && org.value.getInvite(route.params.org_type as string);
updateSecert();
Expand All @@ -243,7 +248,7 @@ export default defineComponent({
});
onUnmounted(() => {
busOff('appSubscribe', stateUpdate);
busOff('orgSubscribe', stateUpdate);
});
let updateItems = debounce(() => {
Expand All @@ -258,9 +263,7 @@ export default defineComponent({
onConfirm,
org,
invite,
now,
secret,
nameRef,
status,
isMobile,
goBack,
Expand Down
30 changes: 4 additions & 26 deletions packages/app/src/pages/Web/Orgs/members/OrgMemberItem.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<template>
<div class="member_wrap row items-center justify-center">
<div
class="stretch row items-center justify-start"
:class="isSelected ? 'memberActive' : ''"
>
<div class="stretch row items-center justify-start">
<div class="q-mr-md avator">
<TerminusAvatar
:info="userStore.getUserTerminusInfo(member.id || '')"
Expand All @@ -14,7 +11,7 @@
<div class="did text-subtitle2">{{ member.name }}</div>
<div>
<!-- TODO: snowning.com error-->
<span>@{{ getCurrentDomain }}</span>
<span>@{{ userStore.getCurrentDomain() }}</span>
<span
class="tag text-3ubtitle3 owner"
v-if="member.role === OrgRole.Owner"
Expand Down Expand Up @@ -43,7 +40,6 @@ import { app } from '../../../../globals';
import { useMenuStore } from '../../../../stores/menu';
import { useUserStore } from '../../../../stores/user';
import { useI18n } from 'vue-i18n';
import { TerminusDefaultDomain } from '@bytetrade/core';
export default defineComponent({
name: 'MemberItem',
Expand Down Expand Up @@ -74,23 +70,13 @@ export default defineComponent({
const { t } = useI18n();
const getCurrentDomain = computed(() => {
const current_user = userStore.current_user;
if (current_user && current_user.name.indexOf('@')) {
return current_user.name.split('@')[1];
} else {
return TerminusDefaultDomain;
}
});
return {
org,
OrgMemberStatus,
OrgRole,
groups,
userStore,
t,
getCurrentDomain
t
};
}
});
Expand All @@ -99,19 +85,11 @@ export default defineComponent({
<style lang="scss" scoped>
.member_wrap {
width: 94%;
height: 80px;
.stretch {
width: 96%;
height: 64px;
height: 58px;
border-radius: 8px;
padding-left: 8px;
&.memberActive {
background: $grey-1;
}
&:hover {
background: $grey-1;
}
.avator {
width: 28px;
height: 28px;
Expand Down
Loading

0 comments on commit 3e48ff7

Please sign in to comment.