Skip to content

Commit

Permalink
Migrate locator-tool to Vue
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Jan 12, 2024
1 parent 6a84178 commit 791140e
Show file tree
Hide file tree
Showing 19 changed files with 830 additions and 636 deletions.
10 changes: 10 additions & 0 deletions app/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<lt-navbar></lt-navbar>
<div class="d-flex flex-grow-1 container-fluid flex-column">
<router-view class="d-flex flex-grow-1" />
</div>
</template>

<script setup lang="ts">
import ltNavbar from './components/ltNavbar.vue';
</script>
57 changes: 31 additions & 26 deletions app/api/ltDataAuth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {CommonsFile, LatLng, User} from '../model';
import {useFetch} from '@vueuse/core';
import {CommonsFile, LatLng} from '../model';

interface UserApiResponse {
user: string;
Expand All @@ -12,34 +13,38 @@ interface EditApiResponse {
};
}

export default class LtDataAuth {
public static $inject = ['$http'];
constructor(private $http: ng.IHttpService) {}

getUserInfo(): ng.IPromise<User> {
return this.$http.get<UserApiResponse>('/user').then(d => d?.data?.user);
}
export function getUserInfo() {
return useFetch<UserApiResponse>('/user');
}

editLocation(title: CommonsFile, coordinates: LatLng): ng.IPromise<void> {
const {pageid} = title;
const {type, lat, lng} = coordinates;
return this.$http<EditApiResponse>({
export function editLocation(title: CommonsFile, coordinates: LatLng) {
const {pageid} = title;
const {type, lat, lng} = coordinates;
return useFetch<EditApiResponse>(
'/edit',
{
method: 'POST',
url: '/edit',
data: {type, lat, lng, pageid}
}).then(response => {
const data = response.data;
if (!data.result || !data.result.edit || data.result.edit.result !== 'Success') {
throw data;
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({type, lat, lng, pageid})
},
{
afterFetch(ctx) {
const {data} = ctx;
if (!data.result || !data.result.edit || data.result.edit.result !== 'Success') {
throw data;
}
return ctx;
}
});
}
}
);
}

get loginURL(): string {
return '/login?next=' + encodeURIComponent('/' + location.hash);
}
export function loginURL(): string {
return '/login?next=' + encodeURIComponent('/' + location.hash);
}

get logoutURL(): string {
return '/logout?next=' + encodeURIComponent('/' + location.hash);
}
export function logoutURL(): string {
return '/logout?next=' + encodeURIComponent('/' + location.hash);
}
214 changes: 0 additions & 214 deletions app/components/ltFilesSelector.html

This file was deleted.

Loading

0 comments on commit 791140e

Please sign in to comment.