Working user and link list, (big)restructure
This is now a workspace consisting of: * the pslink app (a wasm frontend for the admin interface) * the pslink binary * shared - modules for communication between the two above.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
authors = ["Dietrich <dietrich@teilgedanken.de>"]
|
||||
categories = ["web-programming", "network-programming", "web-programming::http-server", "command-line-utilities"]
|
||||
description = "A simple webservice that allows registered users to create short links including qr-codes.\nAnyone can visit the shortened links. This is an ideal setup for small busines or for publishing papers."
|
||||
edition = "2018"
|
||||
keywords = ["url", "link", "webpage", "actix", "web"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
name = "shared"
|
||||
readme = "../pslink/README.md"
|
||||
repository = "https://github.com/enaut/pslink/"
|
||||
version = "0.3.1"
|
||||
|
||||
[dependencies]
|
||||
serde = "1.0"
|
||||
chrono = {version = "0.4", features = ["serde"] }
|
||||
enum-map = {version="1", features = ["serde"]}
|
||||
@@ -0,0 +1,27 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[derive(Clone, Deserialize, Serialize, Debug, Default)]
|
||||
pub struct Filter {
|
||||
pub sieve: String,
|
||||
}
|
||||
|
||||
impl Deref for Filter {
|
||||
type Target = String;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.sieve
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize, PartialEq, Eq, Debug)]
|
||||
pub enum Ordering {
|
||||
Ascending,
|
||||
Descending,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize, Debug)]
|
||||
pub struct Operation<T, V> {
|
||||
pub column: T,
|
||||
pub value: V,
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
use enum_map::{Enum, EnumMap};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::general::{Filter, Operation, Ordering};
|
||||
|
||||
/// A generic list returntype containing the User and a Vec containing e.g. Links or Users
|
||||
#[derive(Clone, Deserialize, Serialize, Debug)]
|
||||
pub struct LinkRequestForm {
|
||||
pub filter: EnumMap<LinkOverviewColumns, Filter>,
|
||||
pub order: Option<Operation<LinkOverviewColumns, Ordering>>,
|
||||
pub amount: usize,
|
||||
}
|
||||
|
||||
impl Default for LinkRequestForm {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
filter: EnumMap::default(),
|
||||
order: None,
|
||||
amount: 20,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq, Hash, Enum)]
|
||||
pub enum LinkOverviewColumns {
|
||||
Code,
|
||||
Description,
|
||||
Target,
|
||||
Author,
|
||||
Statistics,
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
pub mod general;
|
||||
pub mod links;
|
||||
pub mod users;
|
||||
@@ -0,0 +1,28 @@
|
||||
use enum_map::{Enum, EnumMap};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::general::{Filter, Operation, Ordering};
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize, Debug)]
|
||||
pub struct UserRequestForm {
|
||||
pub filter: EnumMap<UserOverviewColumns, Filter>,
|
||||
pub order: Option<Operation<UserOverviewColumns, Ordering>>,
|
||||
pub amount: usize,
|
||||
}
|
||||
|
||||
impl Default for UserRequestForm {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
filter: EnumMap::default(),
|
||||
order: None,
|
||||
amount: 20,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq, Hash, Enum)]
|
||||
pub enum UserOverviewColumns {
|
||||
Id,
|
||||
Email,
|
||||
Username,
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
/// A generic list returntype containing the User and a Vec containing e.g. Links or Users
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
pub struct ListWithOwner<T> {
|
||||
pub user: User,
|
||||
pub list: Vec<T>,
|
||||
}
|
||||
|
||||
/// A link together with its author and its click-count.
|
||||
#[derive(Clone, Deserialize, Serialize, Debug)]
|
||||
pub struct FullLink {
|
||||
pub link: Link,
|
||||
pub user: User,
|
||||
pub clicks: Count,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct User {
|
||||
pub id: i64,
|
||||
pub username: String,
|
||||
pub email: String,
|
||||
pub password: String,
|
||||
pub role: i64,
|
||||
pub language: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Link {
|
||||
pub id: i64,
|
||||
pub title: String,
|
||||
pub target: String,
|
||||
pub code: String,
|
||||
pub author: i64,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub struct Count {
|
||||
pub number: i32,
|
||||
}
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct Click {
|
||||
pub id: i64,
|
||||
pub link: i64,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
pub mod apirequests;
|
||||
pub mod datatypes;
|
||||
Reference in New Issue
Block a user