mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: session length
This commit is contained in:
Generated
+7
-7
@@ -9,7 +9,7 @@
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@analytics/google-analytics": "^1.0.5",
|
||||
"@aw-labs/appwrite-console": "^11.0.0",
|
||||
"@aw-labs/appwrite-console": "^12.0.0",
|
||||
"@aw-labs/icons": "0.0.0-77",
|
||||
"@aw-labs/ui": "0.0.0-77",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
@@ -145,9 +145,9 @@
|
||||
"integrity": "sha512-1Yw7u/COtxx06BfwlI+kVhsa/upKYzmCNrT4c8QDeCY2KMYlnijkUjtHiPU08HxyTIVB5j6d75O0YWVIHwQS8g=="
|
||||
},
|
||||
"node_modules/@aw-labs/appwrite-console": {
|
||||
"version": "11.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@aw-labs/appwrite-console/-/appwrite-console-11.0.0.tgz",
|
||||
"integrity": "sha512-V9cI4j6YdvMbM2xCUp0JGHd1B2KEJ3T8rqSVdPecfVBrRn8S2BcwJsJGUJCixca0uhrK+6+IlARShaGegyAiGA==",
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@aw-labs/appwrite-console/-/appwrite-console-12.0.0.tgz",
|
||||
"integrity": "sha512-GEXTpKG4vAMjsf0iGSi/ilsTpjHtc12gA/zbM/mqQU6SdimFaTSKNYg0wu6CM6+afM3jWvEEehB//1WY8mhh5g==",
|
||||
"dependencies": {
|
||||
"cross-fetch": "3.1.5",
|
||||
"isomorphic-form-data": "2.0.0"
|
||||
@@ -7740,9 +7740,9 @@
|
||||
"integrity": "sha512-1Yw7u/COtxx06BfwlI+kVhsa/upKYzmCNrT4c8QDeCY2KMYlnijkUjtHiPU08HxyTIVB5j6d75O0YWVIHwQS8g=="
|
||||
},
|
||||
"@aw-labs/appwrite-console": {
|
||||
"version": "11.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@aw-labs/appwrite-console/-/appwrite-console-11.0.0.tgz",
|
||||
"integrity": "sha512-V9cI4j6YdvMbM2xCUp0JGHd1B2KEJ3T8rqSVdPecfVBrRn8S2BcwJsJGUJCixca0uhrK+6+IlARShaGegyAiGA==",
|
||||
"version": "12.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@aw-labs/appwrite-console/-/appwrite-console-12.0.0.tgz",
|
||||
"integrity": "sha512-GEXTpKG4vAMjsf0iGSi/ilsTpjHtc12gA/zbM/mqQU6SdimFaTSKNYg0wu6CM6+afM3jWvEEehB//1WY8mhh5g==",
|
||||
"requires": {
|
||||
"cross-fetch": "3.1.5",
|
||||
"isomorphic-form-data": "2.0.0"
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
"dependencies": {
|
||||
"@analytics/google-analytics": "^1.0.5",
|
||||
"analytics": "^0.8.1",
|
||||
"@aw-labs/appwrite-console": "^11.0.0",
|
||||
"@aw-labs/appwrite-console": "^12.0.0",
|
||||
"@aw-labs/icons": "0.0.0-77",
|
||||
"@aw-labs/ui": "0.0.0-77",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
|
||||
@@ -23,3 +23,24 @@ export function calculateTime(time: number) {
|
||||
return `${years} y`;
|
||||
}
|
||||
}
|
||||
|
||||
export function timeToMinutes(time: number, unit: string) {
|
||||
switch (unit) {
|
||||
case 'ms':
|
||||
return time / 1000 / 60;
|
||||
case 's':
|
||||
return time / 60;
|
||||
case 'm':
|
||||
return time;
|
||||
case 'h':
|
||||
return time * 60;
|
||||
case 'd':
|
||||
return time * 60 * 24;
|
||||
case 'M':
|
||||
return time * 60 * 24 * 30;
|
||||
case 'y':
|
||||
return time * 60 * 24 * 30 * 12;
|
||||
default:
|
||||
return time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,16 +10,22 @@
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import { timeToMinutes } from '$lib/helpers/timeConversion';
|
||||
|
||||
const projectId = $project.$id;
|
||||
let isLimited = $project.authLimit === 0 ? 'unlimited' : 'limited';
|
||||
let newLimit = $project.authLimit === 0 ? 100 : $project.authLimit;
|
||||
let time: number = $project.authDuration;
|
||||
let period = 'm';
|
||||
let btnActive = false;
|
||||
|
||||
let options = [
|
||||
{ label: 'years', value: 'years' },
|
||||
{ label: 'months', value: 'months' },
|
||||
{ label: 'days', value: 'days' }
|
||||
{ label: 'years', value: 'y' },
|
||||
{ label: 'months', value: 'M' },
|
||||
{ label: 'days', value: 'd' },
|
||||
{ label: 'hours', value: 'h' },
|
||||
{ label: 'minutes', value: 'm' },
|
||||
{ label: 'seconds', value: 's' }
|
||||
];
|
||||
|
||||
$: {
|
||||
@@ -56,7 +62,8 @@
|
||||
}
|
||||
async function updateSessionLength() {
|
||||
try {
|
||||
//TODO: implement correct SDK call
|
||||
await sdkForConsole.projects.updateAuthDuration(projectId, timeToMinutes(time, period));
|
||||
invalidate(Dependencies.PROJECT);
|
||||
|
||||
addNotification({
|
||||
type: 'success',
|
||||
@@ -143,7 +150,7 @@
|
||||
</CardGrid>
|
||||
|
||||
<CardGrid>
|
||||
<Heading tag="h2" size="6">Session Length <Pill>Coming Soon!</Pill></Heading>
|
||||
<Heading tag="h2" size="6">Session Length</Heading>
|
||||
<p>
|
||||
If you reduce the limit, users who are currently logged in will be logged out of the
|
||||
application.
|
||||
@@ -151,12 +158,12 @@
|
||||
<svelte:fragment slot="aside">
|
||||
<form class="form u-grid u-gap-16">
|
||||
<ul class="form-list is-multiple">
|
||||
<InputNumber disabled id="length" label="Length" value={1} />
|
||||
<InputNumber disabled id="length" label="Length" bind:value={time} />
|
||||
<InputSelect
|
||||
disabled
|
||||
id="period"
|
||||
label="Time Period"
|
||||
value={options[0].value}
|
||||
value={period}
|
||||
{options} />
|
||||
</ul>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user