-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from CropWatchDevelopment/develop
Develop
- Loading branch information
Showing
17 changed files
with
378 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE POLICY "update_if_user_owns_table" | ||
ON cw_locations | ||
FOR UPDATE | ||
USING ( | ||
EXISTS ( | ||
SELECT 1 | ||
FROM cw_location_owners | ||
WHERE cw_location_owners.user_id = auth.uid() | ||
AND cw_location_owners.location_id = cw_locations.location_id | ||
AND cw_location_owners.is_active = true -- Assuming you have a similar condition | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="bg-[#34393f] bg-opacity-50 rounded-xl p-3 text-surface-100 my-3"> | ||
<slot/> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<script lang="ts"> | ||
import { enhance } from '$app/forms'; | ||
import { mdiClose, mdiFloppy, mdiPencil } from '@mdi/js'; | ||
import { toast } from '@zerodevx/svelte-toast'; | ||
import { Button, Dialog, TextField } from 'svelte-ux'; | ||
import { _ } from 'svelte-i18n'; | ||
export let currentSensorName: string = ''; | ||
export let dev_eui: string = -1; | ||
let currentSensorNameStatic = currentSensorName; | ||
let open = false; | ||
const handleSubmit = () => { | ||
fetch(`/api/v1/devices/${dev_eui}`, { | ||
method: 'PUT', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ name: currentSensorName }) | ||
}) | ||
.then((res) => { | ||
if (res.ok) { | ||
toast.push(`Sensor name updated successfully`, { | ||
theme: { | ||
'--toastBackground': 'green', | ||
'--toastColor': 'black' | ||
} | ||
}); | ||
currentSensorNameStatic = currentSensorName; | ||
} else { | ||
toast.push(`Sensor name updated FAILED`, { | ||
theme: { | ||
'--toastBackground': 'red', | ||
'--toastColor': 'black' | ||
} | ||
}); | ||
currentSensorName = currentSensorNameStatic; | ||
open = false; | ||
} | ||
return res.json(); | ||
}) | ||
.then((data) => { | ||
console.log(data); | ||
currentSensorName = data.name; | ||
open = false; | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
currentSensorName = currentSensorNameStatic; | ||
open = false; | ||
}); | ||
}; | ||
const closing = () => { | ||
currentSensorName = currentSensorNameStatic; | ||
open = false; | ||
}; | ||
</script> | ||
|
||
<Button on:click={() => (open = true)} icon={mdiPencil} size="sm" /> | ||
|
||
<form action={`/api/v1/sensors/${dev_eui}`} method="PUT"> | ||
<Dialog bind:open on:close={() => closing()}> | ||
<div slot="title">{$_('rename_dialog.rename')} {currentSensorNameStatic} {$_('rename_dialog.to_what')}</div> | ||
<div class="m-4"> | ||
<TextField name="newName" label={$_('rename_dialog.new_name')} bind:value={currentSensorName} /> | ||
</div> | ||
<div class="flex flex-row mt-1 p-2"> | ||
<Button variant="fill" icon={mdiClose} on:click={() => (open = false)} color="danger">{$_('close')}</Button> | ||
<span class="flex-grow" /> | ||
<Button | ||
variant="fill" | ||
type="button" | ||
icon={mdiFloppy} | ||
on:click={() => handleSubmit()} | ||
color="success">{$_('save')}</Button | ||
> | ||
</div> | ||
</Dialog> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script lang="ts"> | ||
export let title; | ||
export let titleColor; | ||
export let value; | ||
export let unit; | ||
export let message; | ||
</script> | ||
|
||
<div class="bg-[#34393f] bg-opacity-50 rounded-xl px-3 py-6 text-surface-100 m-[0.3rem] w-[10.5rem] h-[10.5rem]"> | ||
<p class="text-[#4FDE6F] font-medium text-sm">{title}</p> | ||
<p class="text-4xl my-4">{value}<span class="text-2xl">{unit}</span></p> | ||
<p class="mt-6 text-sm text-[#7C7886]">{message}</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.