ドメインページを最適化する
This commit is contained in:
@@ -35,6 +35,8 @@ def create_access_token(*, data: dict, expires_delta: timedelta = None):
|
|||||||
return encoded_jwt
|
return encoded_jwt
|
||||||
|
|
||||||
def chacha20Encrypt(plaintext:str, key=config.KINTONE_PSW_CRYPTO_KEY):
|
def chacha20Encrypt(plaintext:str, key=config.KINTONE_PSW_CRYPTO_KEY):
|
||||||
|
if plaintext is None or plaintext == '':
|
||||||
|
return None
|
||||||
nonce = os.urandom(16)
|
nonce = os.urandom(16)
|
||||||
algorithm = algorithms.ChaCha20(key, nonce)
|
algorithm = algorithms.ChaCha20(key, nonce)
|
||||||
cipher = Cipher(algorithm, mode=None)
|
cipher = Cipher(algorithm, mode=None)
|
||||||
|
|||||||
@@ -216,9 +216,9 @@ def edit_domain(
|
|||||||
update_data = domain.dict(exclude_unset=True)
|
update_data = domain.dict(exclude_unset=True)
|
||||||
|
|
||||||
for key, value in update_data.items():
|
for key, value in update_data.items():
|
||||||
if(key != "id"):
|
if key != "id" and not (key == "kintonepwd" and (value is None or value == "")):
|
||||||
setattr(db_domain, key, value)
|
setattr(db_domain, key, value)
|
||||||
|
print(str(db_domain))
|
||||||
db.add(db_domain)
|
db.add(db_domain)
|
||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(db_domain)
|
db.refresh(db_domain)
|
||||||
|
|||||||
@@ -1,54 +1,90 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<q-table title="Treats" :rows="rows" :columns="columns" row-key="id" selection="single" :filter="filter"
|
<q-table title="Treats" :rows="rows" :columns="columns" row-key="id" :filter="filter" :loading="loading">
|
||||||
:loading="loading" v-model:selected="selected">
|
|
||||||
|
|
||||||
<template v-slot:top>
|
<template v-slot:top>
|
||||||
<q-btn color="primary" :disable="loading" label="新規" @click="addRow" />
|
<q-btn color="primary" :disable="loading" label="新規" @click="addRow" />
|
||||||
<q-btn class="q-ml-sm" color="primary" :disable="loading" label="編集" @click="editRow" />
|
|
||||||
<q-btn class="q-ml-sm" color="primary" :disable="loading" label="削除" @click="removeRow" />
|
|
||||||
<q-space />
|
<q-space />
|
||||||
<q-input borderless dense debounce="300" color="primary" v-model="filter">
|
<q-input borderless dense filled debounce="300" v-model="filter" placeholder="Search">
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-icon name="search" />
|
<q-icon name="search" />
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:body-cell-actions="p">
|
||||||
|
<q-td :props="p">
|
||||||
|
<q-btn-group flat>
|
||||||
|
<q-btn flat color="primary" padding="xs" size="1em" icon="edit_note" @click="editRow(p.row)" />
|
||||||
|
<q-btn flat color="negative" padding="xs" size="1em" icon="delete_outline" @click="removeRow(p.row)" />
|
||||||
|
</q-btn-group>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
|
||||||
</q-table>
|
</q-table>
|
||||||
|
|
||||||
<q-dialog :model-value="show" persistent>
|
<q-dialog :model-value="show" persistent>
|
||||||
<q-card style="min-width: 400px">
|
<q-card style="min-width: 36em">
|
||||||
<q-card-section>
|
<q-form class="q-gutter-md" @submit="onSubmit">
|
||||||
<div class="text-h6">Kintone Account</div>
|
<q-card-section>
|
||||||
</q-card-section>
|
<div class="text-h6 q-ma-sm">Kintone Account</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
<q-card-section class="q-pt-none">
|
<q-card-section class="q-pt-none q-mt-none">
|
||||||
<q-form class="q-gutter-md">
|
<div class="q-gutter-lg">
|
||||||
<q-input filled v-model="tenantid" label="Tenant" hint="Tenant ID" lazy-rules
|
|
||||||
:rules="[val => val && val.length > 0 || 'Please type something']" />
|
|
||||||
|
|
||||||
<q-input filled v-model="name" label="Your name *" hint="Kintone envirment name" lazy-rules
|
|
||||||
:rules="[val => val && val.length > 0 || 'Please type something']" />
|
|
||||||
|
|
||||||
<q-input filled type="url" v-model="url" label="Kintone url" hint="Kintone domain address" lazy-rules
|
<q-input filled v-model="tenantid" label="Tenant" hint="Tenant ID" lazy-rules
|
||||||
:rules="[val => val && val.length > 0, isDomain || 'Please type something']" />
|
:rules="[val => val && val.length > 0 || 'Please type something']" />
|
||||||
|
|
||||||
<q-input filled v-model="kintoneuser" label="Login user " hint="Kintone user name" lazy-rules
|
<q-input filled v-model="name" label="Your name *" hint="Kintone envirment name" lazy-rules
|
||||||
:rules="[val => val && val.length > 0 || 'Please type something']" />
|
:rules="[val => val && val.length > 0 || 'Please type something']" />
|
||||||
|
|
||||||
<q-input v-model="kintonepwd" filled :type="isPwd ? 'password' : 'text'" hint="Password with toggle"
|
<q-input filled type="url" v-model="url" label="Kintone url" hint="Kintone domain address" lazy-rules
|
||||||
label="User password">
|
:rules="[val => val && val.length > 0, isDomain || 'Please type something']" />
|
||||||
<template v-slot:append>
|
|
||||||
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer" @click="isPwd = !isPwd" />
|
<q-input filled v-model="kintoneuser" label="Login user " hint="Kintone user name" lazy-rules
|
||||||
</template>
|
:rules="[val => val && val.length > 0 || 'Please type something']" />
|
||||||
</q-input>
|
|
||||||
</q-form>
|
<q-input v-if="isCreate" v-model="kintonepwd" filled :type="isPwd ? 'password' : 'text'"
|
||||||
</q-card-section>
|
hint="Password with toggle" label="User password" :disable="!isCreate" lazy-rules
|
||||||
<q-card-actions align="right" class="text-primary">
|
:rules="[val => val && val.length > 0 || 'Please type something']">
|
||||||
<q-btn label="Save" type="submit" color="primary" @click="onSubmit" />
|
<template v-slot:append>
|
||||||
<q-btn label="Cancel" type="cancel" color="primary" flat class="q-ml-sm" @click="closeDg()" />
|
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
||||||
</q-card-actions>
|
@click="isPwd = !isPwd" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
|
||||||
|
<div class="q-gutter-y-md" v-if="!isCreate">
|
||||||
|
<q-separator />
|
||||||
|
|
||||||
|
<q-item tag="label" class="q-pl-sm q-pr-none q-py-xs">
|
||||||
|
<q-item-section>
|
||||||
|
<q-item-label>Reset Password</q-item-label>
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section avatar>
|
||||||
|
<q-toggle v-model="resetPsw" @update:model-value="updateResetPsw" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
|
||||||
|
<q-input v-model="kintonepwd" filled :type="isPwd ? 'password' : 'text'" hint="Password with toggle"
|
||||||
|
label="User password" :disable="!resetPsw" lazy-rules
|
||||||
|
:rules="[val => val && val.length > 0 || 'Please type something']">
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
||||||
|
@click="isPwd = !isPwd" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
<!-- <q-btn label="asdf"/> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-actions align="right" class="text-primary q-mb-md q-mx-sm">
|
||||||
|
<q-btn label="Save" type="submit" color="primary" />
|
||||||
|
<q-btn label="Cancel" type="cancel" color="primary" flat class="q-ml-sm" @click="closeDg()" />
|
||||||
|
</q-card-actions>
|
||||||
|
</q-form>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
@@ -56,7 +92,7 @@
|
|||||||
<q-dialog v-model="confirm" persistent>
|
<q-dialog v-model="confirm" persistent>
|
||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section class="row items-center">
|
<q-card-section class="row items-center">
|
||||||
<q-avatar icon="confirm" color="primary" text-color="white" />
|
<q-icon name="warning" color="warning" size="2em" />
|
||||||
<span class="q-ml-sm">削除してもよろしいですか?</span>
|
<span class="q-ml-sm">削除してもよろしいですか?</span>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
@@ -73,22 +109,25 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted, reactive } from 'vue';
|
import { ref, onMounted, reactive } from 'vue';
|
||||||
import { api } from 'boot/axios';
|
import { api } from 'boot/axios';
|
||||||
|
import { useAuthStore } from 'stores/useAuthStore';
|
||||||
|
|
||||||
|
const authStore = useAuthStore();
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ name: 'id' },
|
{ name: 'id', label: 'ID', field: 'id', align: 'left', sortable: true },
|
||||||
{
|
{
|
||||||
name: 'tenantid',
|
name: 'tenantid',
|
||||||
required: true,
|
required: true,
|
||||||
label: 'Tenant',
|
label: 'Tenant',
|
||||||
align: 'left',
|
|
||||||
field: row => row.tenantid,
|
field: row => row.tenantid,
|
||||||
format: val => `${val}`,
|
format: val => `${val}`,
|
||||||
|
align: 'left',
|
||||||
sortable: true
|
sortable: true
|
||||||
},
|
},
|
||||||
{ name: 'name', align: 'center', label: 'Name', field: 'name', sortable: true },
|
{ name: 'name', label: 'Name', field: 'name', align: 'left', sortable: true },
|
||||||
{ name: 'url', align: 'left', label: 'URL', field: 'url', sortable: true },
|
{ name: 'url', label: 'URL', field: 'url', align: 'left', sortable: true },
|
||||||
{ name: 'user', label: 'Account', field: 'user' },
|
{ name: 'user', label: 'Account', field: 'user', align: 'left', },
|
||||||
{ name: 'password', label: 'Password', field: 'password' }
|
{ name: 'actions', label: 'Actions', field: 'actions' }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@@ -97,42 +136,39 @@ const filter = ref('');
|
|||||||
const rows = ref([]);
|
const rows = ref([]);
|
||||||
const show = ref(false);
|
const show = ref(false);
|
||||||
const confirm = ref(false);
|
const confirm = ref(false);
|
||||||
const selected = ref([]);
|
const resetPsw = ref(false);
|
||||||
const tenantid = ref('');
|
|
||||||
|
const tenantid = ref(authStore.currentDomain.id);
|
||||||
const name = ref('');
|
const name = ref('');
|
||||||
const url = ref('');
|
const url = ref('');
|
||||||
const isPwd = ref(true);
|
const isPwd = ref(true);
|
||||||
const kintoneuser = ref('');
|
const kintoneuser = ref('');
|
||||||
const kintonepwd = ref('');
|
const kintonepwd = ref('');
|
||||||
|
const kintonepwdBK = ref('');
|
||||||
|
const isCreate = ref(true);
|
||||||
let editId = ref(0);
|
let editId = ref(0);
|
||||||
|
|
||||||
const getDomain = async () => {
|
const getDomain = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const result= await api.get(`api/domains/1`);
|
const result = await api.get(`api/domains/1`);
|
||||||
rows.value= result.data.map((item)=>{
|
rows.value = result.data.map((item) => {
|
||||||
return { id: item.id, tenantid: item.tenantid, name: item.name, url: item.url, user: item.kintoneuser, password: item.kintonepwd }
|
return { id: item.id, tenantid: item.tenantid, name: item.name, url: item.url, user: item.kintoneuser, password: item.kintonepwd }
|
||||||
});
|
});
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getDomain();
|
await getDomain();
|
||||||
})
|
})
|
||||||
|
|
||||||
// emulate fetching data from server
|
// emulate fetching data from server
|
||||||
const addRow = () => {
|
const addRow = () => {
|
||||||
editId.value
|
// editId.value
|
||||||
show.value = true;
|
show.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeRow = () => {
|
const removeRow = (row) => {
|
||||||
//loading.value = true
|
|
||||||
confirm.value = true;
|
confirm.value = true;
|
||||||
let row = JSON.parse(JSON.stringify(selected.value[0]));
|
|
||||||
if (selected.value.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
editId.value = row.id;
|
editId.value = row.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,14 +177,11 @@ const deleteDomain = () => {
|
|||||||
getDomain();
|
getDomain();
|
||||||
})
|
})
|
||||||
editId.value = 0;
|
editId.value = 0;
|
||||||
selected.value = [];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const editRow = () => {
|
const editRow = (row) => {
|
||||||
if (selected.value.length === 0) {
|
isCreate.value = false
|
||||||
return;
|
|
||||||
}
|
|
||||||
let row = JSON.parse(JSON.stringify(selected.value[0]));
|
|
||||||
editId.value = row.id;
|
editId.value = row.id;
|
||||||
tenantid.value = row.tenantid;
|
tenantid.value = row.tenantid;
|
||||||
name.value = row.name;
|
name.value = row.name;
|
||||||
@@ -158,6 +191,16 @@ const editRow = () => {
|
|||||||
isPwd.value = true;
|
isPwd.value = true;
|
||||||
show.value = true;
|
show.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateResetPsw = (value: boolean) => {
|
||||||
|
if (value === true) {
|
||||||
|
kintonepwd.value = ''
|
||||||
|
isPwd.value = true
|
||||||
|
} else {
|
||||||
|
kintonepwd.value = kintonepwdBK.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const closeDg = () => {
|
const closeDg = () => {
|
||||||
show.value = false;
|
show.value = false;
|
||||||
onReset();
|
onReset();
|
||||||
@@ -171,7 +214,7 @@ const onSubmit = () => {
|
|||||||
'name': name.value,
|
'name': name.value,
|
||||||
'url': url.value,
|
'url': url.value,
|
||||||
'kintoneuser': kintoneuser.value,
|
'kintoneuser': kintoneuser.value,
|
||||||
'kintonepwd': kintonepwd.value
|
'kintonepwd': isCreate.value || resetPsw.value ? kintonepwd.value : ''
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
getDomain();
|
getDomain();
|
||||||
closeDg();
|
closeDg();
|
||||||
@@ -192,7 +235,7 @@ const onSubmit = () => {
|
|||||||
onReset();
|
onReset();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
selected.value = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onReset = () => {
|
const onReset = () => {
|
||||||
@@ -202,5 +245,7 @@ const onReset = () => {
|
|||||||
kintonepwd.value = '';
|
kintonepwd.value = '';
|
||||||
isPwd.value = true;
|
isPwd.value = true;
|
||||||
editId.value = 0;
|
editId.value = 0;
|
||||||
|
isCreate.value = true;
|
||||||
|
resetPsw.value = false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user