2020-04-20 11:22:39 +02:00
|
|
|
use std::cmp::Ordering;
|
2020-03-31 22:05:18 +02:00
|
|
|
use std::str::FromStr;
|
|
|
|
|
2020-03-28 21:41:16 +01:00
|
|
|
use chrono::NaiveDateTime;
|
2020-04-01 13:29:43 +02:00
|
|
|
#[cfg(feature = "backend")]
|
|
|
|
use diesel::*;
|
2020-03-28 21:41:16 +01:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
2020-04-01 13:29:43 +02:00
|
|
|
#[cfg(feature = "backend")]
|
|
|
|
pub use sql::*;
|
|
|
|
|
|
|
|
#[cfg(feature = "backend")]
|
|
|
|
pub mod sql;
|
|
|
|
|
2020-04-09 11:10:52 +02:00
|
|
|
pub trait ToVec {
|
|
|
|
type Item;
|
|
|
|
fn ordered() -> Vec<Self::Item>;
|
|
|
|
}
|
|
|
|
|
2020-04-11 11:18:41 +02:00
|
|
|
pub type IssueId = i32;
|
|
|
|
pub type ProjectId = i32;
|
|
|
|
pub type UserId = i32;
|
|
|
|
pub type CommentId = i32;
|
|
|
|
pub type TokenId = i32;
|
2020-05-06 22:24:58 +02:00
|
|
|
pub type IssueStatusId = i32;
|
2020-04-21 08:35:08 +02:00
|
|
|
pub type InvitationId = i32;
|
2020-04-15 20:28:07 +02:00
|
|
|
pub type EmailString = String;
|
|
|
|
pub type UsernameString = String;
|
2020-04-11 11:18:41 +02:00
|
|
|
|
2020-04-01 13:29:43 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(FromSqlRow, AsExpression))]
|
|
|
|
#[cfg_attr(feature = "backend", sql_type = "IssueTypeType")]
|
2020-04-22 14:12:12 +02:00
|
|
|
#[derive(Clone, Copy, Deserialize, Serialize, Debug, PartialOrd, PartialEq, Hash)]
|
2020-03-31 14:28:30 +02:00
|
|
|
pub enum IssueType {
|
|
|
|
Task,
|
|
|
|
Bug,
|
|
|
|
Story,
|
|
|
|
}
|
|
|
|
|
2020-04-09 11:10:52 +02:00
|
|
|
impl ToVec for IssueType {
|
|
|
|
type Item = IssueType;
|
|
|
|
|
|
|
|
fn ordered() -> Vec<Self> {
|
|
|
|
vec![IssueType::Task, IssueType::Bug, IssueType::Story]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-04 17:42:02 +02:00
|
|
|
impl Default for IssueType {
|
|
|
|
fn default() -> Self {
|
|
|
|
IssueType::Task
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-01 22:41:26 +02:00
|
|
|
impl IssueType {
|
|
|
|
pub fn to_label(&self) -> &str {
|
|
|
|
match self {
|
|
|
|
IssueType::Task => "Task",
|
|
|
|
IssueType::Bug => "Bug",
|
|
|
|
IssueType::Story => "Story",
|
2020-03-31 14:28:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-02 08:45:43 +02:00
|
|
|
impl Into<u32> for IssueType {
|
|
|
|
fn into(self) -> u32 {
|
|
|
|
match self {
|
|
|
|
IssueType::Task => 1,
|
|
|
|
IssueType::Bug => 2,
|
|
|
|
IssueType::Story => 3,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<IssueType> for u32 {
|
|
|
|
fn into(self) -> IssueType {
|
|
|
|
match self {
|
|
|
|
1 => IssueType::Task,
|
|
|
|
2 => IssueType::Bug,
|
|
|
|
3 => IssueType::Story,
|
|
|
|
_ => IssueType::Task,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-01 13:29:43 +02:00
|
|
|
impl std::fmt::Display for IssueType {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2020-03-31 14:28:30 +02:00
|
|
|
match self {
|
2020-04-01 13:29:43 +02:00
|
|
|
IssueType::Task => f.write_str("task"),
|
|
|
|
IssueType::Bug => f.write_str("bug"),
|
|
|
|
IssueType::Story => f.write_str("story"),
|
2020-03-31 14:28:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-01 13:29:43 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(FromSqlRow, AsExpression))]
|
|
|
|
#[cfg_attr(feature = "backend", sql_type = "IssuePriorityType")]
|
2020-04-17 14:10:05 +02:00
|
|
|
#[derive(Clone, Copy, Deserialize, Serialize, Debug, PartialOrd, PartialEq, Hash)]
|
2020-03-31 14:28:30 +02:00
|
|
|
pub enum IssuePriority {
|
|
|
|
Highest,
|
|
|
|
High,
|
|
|
|
Medium,
|
|
|
|
Low,
|
|
|
|
Lowest,
|
|
|
|
}
|
|
|
|
|
2020-04-09 11:10:52 +02:00
|
|
|
impl ToVec for IssuePriority {
|
|
|
|
type Item = IssuePriority;
|
|
|
|
|
|
|
|
fn ordered() -> Vec<Self> {
|
|
|
|
vec![
|
|
|
|
IssuePriority::Highest,
|
|
|
|
IssuePriority::High,
|
|
|
|
IssuePriority::Medium,
|
|
|
|
IssuePriority::Low,
|
|
|
|
IssuePriority::Lowest,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-31 14:28:30 +02:00
|
|
|
impl FromStr for IssuePriority {
|
|
|
|
type Err = String;
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
2020-03-31 22:05:18 +02:00
|
|
|
match s.to_lowercase().trim() {
|
2020-04-09 11:10:52 +02:00
|
|
|
"highest" => Ok(IssuePriority::Highest),
|
|
|
|
"high" => Ok(IssuePriority::High),
|
|
|
|
"medium" => Ok(IssuePriority::Medium),
|
|
|
|
"low" => Ok(IssuePriority::Low),
|
|
|
|
"lowest" => Ok(IssuePriority::Lowest),
|
2020-03-31 14:28:30 +02:00
|
|
|
_ => Err(format!("Unknown priority {}", s)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-04 17:42:02 +02:00
|
|
|
impl Default for IssuePriority {
|
|
|
|
fn default() -> Self {
|
|
|
|
IssuePriority::Medium
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-01 13:29:43 +02:00
|
|
|
impl std::fmt::Display for IssuePriority {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match self {
|
|
|
|
IssuePriority::Highest => f.write_str("highest"),
|
|
|
|
IssuePriority::High => f.write_str("high"),
|
|
|
|
IssuePriority::Medium => f.write_str("medium"),
|
|
|
|
IssuePriority::Low => f.write_str("low"),
|
|
|
|
IssuePriority::Lowest => f.write_str("lowest"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-08 16:14:59 +02:00
|
|
|
impl Into<u32> for IssuePriority {
|
|
|
|
fn into(self) -> u32 {
|
2020-03-31 14:28:30 +02:00
|
|
|
match self {
|
|
|
|
IssuePriority::Highest => 5,
|
|
|
|
IssuePriority::High => 4,
|
|
|
|
IssuePriority::Medium => 3,
|
|
|
|
IssuePriority::Low => 2,
|
|
|
|
IssuePriority::Lowest => 1,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-08 16:14:59 +02:00
|
|
|
impl Into<IssuePriority> for u32 {
|
|
|
|
fn into(self) -> IssuePriority {
|
|
|
|
match self {
|
|
|
|
5 => IssuePriority::Highest,
|
|
|
|
4 => IssuePriority::High,
|
|
|
|
3 => IssuePriority::Medium,
|
|
|
|
2 => IssuePriority::Low,
|
|
|
|
1 => IssuePriority::Lowest,
|
|
|
|
_ => IssuePriority::Medium,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-20 11:22:39 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(FromSqlRow, AsExpression))]
|
|
|
|
#[cfg_attr(feature = "backend", sql_type = "UserRoleType")]
|
|
|
|
#[derive(Clone, Copy, Deserialize, Serialize, Debug, PartialEq, Hash)]
|
|
|
|
pub enum UserRole {
|
|
|
|
User,
|
|
|
|
Manager,
|
|
|
|
Owner,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialOrd for UserRole {
|
|
|
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
|
|
use UserRole::*;
|
|
|
|
|
|
|
|
if self == other {
|
|
|
|
return Some(Ordering::Equal);
|
|
|
|
}
|
|
|
|
let order = match (self, other) {
|
|
|
|
(User, Manager) | (User, Owner) | (Manager, Owner) => Ordering::Less,
|
|
|
|
_ => Ordering::Greater,
|
|
|
|
};
|
|
|
|
Some(order)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ToVec for UserRole {
|
|
|
|
type Item = UserRole;
|
|
|
|
|
|
|
|
fn ordered() -> Vec<Self::Item> {
|
|
|
|
vec![UserRole::User, UserRole::Manager, UserRole::Owner]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FromStr for UserRole {
|
|
|
|
type Err = String;
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
|
|
match s.to_lowercase().trim() {
|
|
|
|
"user" => Ok(UserRole::User),
|
|
|
|
"manager" => Ok(UserRole::Manager),
|
|
|
|
"owner" => Ok(UserRole::Owner),
|
|
|
|
_ => Err(format!("Unknown user role {}", s)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for UserRole {
|
|
|
|
fn default() -> Self {
|
|
|
|
UserRole::User
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for UserRole {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match self {
|
|
|
|
UserRole::User => f.write_str("user"),
|
|
|
|
UserRole::Manager => f.write_str("manager"),
|
|
|
|
UserRole::Owner => f.write_str("owner"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<u32> for UserRole {
|
|
|
|
fn into(self) -> u32 {
|
|
|
|
match self {
|
|
|
|
UserRole::User => 0,
|
|
|
|
UserRole::Manager => 1,
|
|
|
|
UserRole::Owner => 2,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<UserRole> for u32 {
|
|
|
|
fn into(self) -> UserRole {
|
|
|
|
match self {
|
|
|
|
0 => UserRole::User,
|
|
|
|
1 => UserRole::Manager,
|
|
|
|
2 => UserRole::Owner,
|
|
|
|
_ => UserRole::User,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-14 16:20:05 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(FromSqlRow, AsExpression))]
|
|
|
|
#[cfg_attr(feature = "backend", sql_type = "ProjectCategoryType")]
|
2020-04-26 11:37:31 +02:00
|
|
|
#[derive(Clone, Copy, Deserialize, Serialize, Debug, PartialOrd, PartialEq, Hash)]
|
2020-04-14 16:20:05 +02:00
|
|
|
pub enum ProjectCategory {
|
|
|
|
Software,
|
|
|
|
Marketing,
|
|
|
|
Business,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ToVec for ProjectCategory {
|
|
|
|
type Item = ProjectCategory;
|
|
|
|
|
|
|
|
fn ordered() -> Vec<Self> {
|
|
|
|
vec![
|
|
|
|
ProjectCategory::Software,
|
|
|
|
ProjectCategory::Marketing,
|
|
|
|
ProjectCategory::Business,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FromStr for ProjectCategory {
|
|
|
|
type Err = String;
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
|
|
match s.to_lowercase().trim() {
|
|
|
|
"software" => Ok(ProjectCategory::Software),
|
|
|
|
"marketing" => Ok(ProjectCategory::Marketing),
|
|
|
|
"business" => Ok(ProjectCategory::Business),
|
|
|
|
_ => Err(format!("Unknown project category {}", s)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for ProjectCategory {
|
|
|
|
fn default() -> Self {
|
|
|
|
ProjectCategory::Software
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for ProjectCategory {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match self {
|
|
|
|
ProjectCategory::Software => f.write_str("software"),
|
|
|
|
ProjectCategory::Marketing => f.write_str("marketing"),
|
|
|
|
ProjectCategory::Business => f.write_str("business"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<u32> for ProjectCategory {
|
|
|
|
fn into(self) -> u32 {
|
|
|
|
match self {
|
|
|
|
ProjectCategory::Software => 0,
|
|
|
|
ProjectCategory::Marketing => 1,
|
|
|
|
ProjectCategory::Business => 2,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<ProjectCategory> for u32 {
|
|
|
|
fn into(self) -> ProjectCategory {
|
|
|
|
match self {
|
|
|
|
0 => ProjectCategory::Software,
|
|
|
|
1 => ProjectCategory::Marketing,
|
|
|
|
2 => ProjectCategory::Business,
|
|
|
|
_ => ProjectCategory::Software,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-21 08:35:08 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(FromSqlRow, AsExpression))]
|
|
|
|
#[cfg_attr(feature = "backend", sql_type = "InvitationStateType")]
|
|
|
|
#[derive(Clone, Deserialize, Serialize, Debug, PartialOrd, PartialEq, Hash)]
|
|
|
|
pub enum InvitationState {
|
|
|
|
Sent,
|
|
|
|
Accepted,
|
|
|
|
Revoked,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for InvitationState {
|
|
|
|
fn default() -> Self {
|
|
|
|
InvitationState::Sent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl std::fmt::Display for InvitationState {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
match self {
|
|
|
|
InvitationState::Sent => f.write_str("sent"),
|
|
|
|
InvitationState::Accepted => f.write_str("accepted"),
|
|
|
|
InvitationState::Revoked => f.write_str("revoked"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-24 22:32:29 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(FromSqlRow, AsExpression))]
|
|
|
|
#[cfg_attr(feature = "backend", sql_type = "TimeTrackingType")]
|
2020-04-25 16:12:06 +02:00
|
|
|
#[derive(Clone, Copy, Deserialize, Serialize, Debug, PartialOrd, PartialEq, Hash)]
|
2020-04-24 22:32:29 +02:00
|
|
|
pub enum TimeTracking {
|
|
|
|
Untracked,
|
|
|
|
Fibonacci,
|
|
|
|
Hourly,
|
|
|
|
}
|
|
|
|
|
2020-04-25 16:12:06 +02:00
|
|
|
impl Into<u32> for TimeTracking {
|
|
|
|
fn into(self) -> u32 {
|
|
|
|
match self {
|
|
|
|
TimeTracking::Untracked => 0,
|
|
|
|
TimeTracking::Fibonacci => 1,
|
|
|
|
TimeTracking::Hourly => 2,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<TimeTracking> for u32 {
|
|
|
|
fn into(self) -> TimeTracking {
|
|
|
|
match self {
|
|
|
|
0 => TimeTracking::Untracked,
|
|
|
|
1 => TimeTracking::Fibonacci,
|
|
|
|
2 => TimeTracking::Hourly,
|
|
|
|
_ => TimeTracking::Untracked,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-08 20:26:28 +02:00
|
|
|
#[derive(Clone, Serialize, Debug, PartialEq)]
|
2020-03-28 21:41:16 +01:00
|
|
|
pub struct ErrorResponse {
|
|
|
|
pub errors: Vec<String>,
|
|
|
|
}
|
|
|
|
|
2020-04-21 09:19:15 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(Queryable))]
|
2020-04-08 20:26:28 +02:00
|
|
|
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
|
2020-03-28 21:41:16 +01:00
|
|
|
pub struct Project {
|
2020-04-11 11:18:41 +02:00
|
|
|
pub id: ProjectId,
|
2020-03-28 21:41:16 +01:00
|
|
|
pub name: String,
|
|
|
|
pub url: String,
|
|
|
|
pub description: String,
|
2020-04-14 16:20:05 +02:00
|
|
|
pub category: ProjectCategory,
|
2020-03-28 21:41:16 +01:00
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
2020-04-24 22:32:29 +02:00
|
|
|
pub time_tracking: TimeTracking,
|
2020-03-28 21:41:16 +01:00
|
|
|
}
|
|
|
|
|
2020-04-08 20:26:28 +02:00
|
|
|
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
|
2020-03-28 21:41:16 +01:00
|
|
|
pub struct Issue {
|
2020-04-11 11:18:41 +02:00
|
|
|
pub id: IssueId,
|
2020-03-28 21:41:16 +01:00
|
|
|
pub title: String,
|
2020-04-01 13:29:43 +02:00
|
|
|
pub issue_type: IssueType,
|
|
|
|
pub priority: IssuePriority,
|
2020-04-09 08:56:12 +02:00
|
|
|
pub list_position: i32,
|
2020-03-28 21:41:16 +01:00
|
|
|
pub description: Option<String>,
|
|
|
|
pub description_text: Option<String>,
|
2020-04-25 22:20:16 +02:00
|
|
|
pub estimate: Option<i32>,
|
|
|
|
pub time_spent: Option<i32>,
|
|
|
|
pub time_remaining: Option<i32>,
|
2020-04-11 11:18:41 +02:00
|
|
|
pub reporter_id: UserId,
|
|
|
|
pub project_id: ProjectId,
|
2020-03-28 21:41:16 +01:00
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
2020-05-06 22:24:58 +02:00
|
|
|
pub issue_status_id: IssueStatusId,
|
2020-03-28 21:41:16 +01:00
|
|
|
|
|
|
|
pub user_ids: Vec<i32>,
|
|
|
|
}
|
|
|
|
|
2020-05-06 22:24:58 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(Queryable))]
|
|
|
|
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
|
|
|
|
pub struct IssueStatus {
|
|
|
|
pub id: IssueStatusId,
|
|
|
|
pub name: String,
|
|
|
|
pub position: ProjectId,
|
|
|
|
pub project_id: ProjectId,
|
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
|
|
|
}
|
|
|
|
|
2020-04-21 09:19:15 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(Queryable))]
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
|
|
|
pub struct Invitation {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub email: String,
|
|
|
|
pub state: InvitationState,
|
|
|
|
pub project_id: i32,
|
|
|
|
pub invited_by_id: i32,
|
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
2020-04-22 09:26:53 +02:00
|
|
|
pub bind_token: Uuid,
|
2020-04-21 09:19:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "backend", derive(Queryable))]
|
2020-04-08 20:26:28 +02:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
2020-03-28 21:41:16 +01:00
|
|
|
pub struct Comment {
|
2020-04-11 11:18:41 +02:00
|
|
|
pub id: CommentId,
|
2020-03-28 21:41:16 +01:00
|
|
|
pub body: String,
|
2020-04-11 11:18:41 +02:00
|
|
|
pub user_id: UserId,
|
|
|
|
pub issue_id: IssueId,
|
2020-03-28 21:41:16 +01:00
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
|
|
|
}
|
|
|
|
|
2020-04-21 09:19:15 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(Queryable))]
|
2020-04-08 08:58:02 +02:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
2020-03-28 21:41:16 +01:00
|
|
|
pub struct User {
|
2020-04-11 11:18:41 +02:00
|
|
|
pub id: UserId,
|
2020-03-28 21:41:16 +01:00
|
|
|
pub name: String,
|
|
|
|
pub email: String,
|
|
|
|
pub avatar_url: Option<String>,
|
2020-04-11 11:18:41 +02:00
|
|
|
pub project_id: ProjectId,
|
2020-03-28 21:41:16 +01:00
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
2020-04-20 11:22:39 +02:00
|
|
|
pub user_role: UserRole,
|
2020-03-28 21:41:16 +01:00
|
|
|
}
|
|
|
|
|
2020-04-21 09:19:15 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(Queryable))]
|
2020-04-08 20:26:28 +02:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
2020-03-28 21:41:16 +01:00
|
|
|
pub struct Token {
|
2020-04-11 11:18:41 +02:00
|
|
|
pub id: TokenId,
|
|
|
|
pub user_id: UserId,
|
2020-03-28 21:41:16 +01:00
|
|
|
pub access_token: Uuid,
|
|
|
|
pub refresh_token: Uuid,
|
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
2020-04-21 09:19:15 +02:00
|
|
|
pub bind_token: Option<Uuid>,
|
2020-03-28 21:41:16 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 22:32:29 +02:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, PartialOrd)]
|
2020-03-28 21:41:16 +01:00
|
|
|
pub struct UpdateIssuePayload {
|
2020-04-10 08:09:40 +02:00
|
|
|
pub title: String,
|
|
|
|
pub issue_type: IssueType,
|
|
|
|
pub priority: IssuePriority,
|
|
|
|
pub list_position: i32,
|
|
|
|
pub description: Option<String>,
|
|
|
|
pub description_text: Option<String>,
|
2020-04-25 22:20:16 +02:00
|
|
|
pub estimate: Option<i32>,
|
|
|
|
pub time_spent: Option<i32>,
|
|
|
|
pub time_remaining: Option<i32>,
|
2020-04-11 11:18:41 +02:00
|
|
|
pub project_id: ProjectId,
|
|
|
|
pub reporter_id: UserId,
|
2020-05-06 22:24:58 +02:00
|
|
|
pub issue_status_id: IssueStatusId,
|
2020-04-11 11:18:41 +02:00
|
|
|
pub user_ids: Vec<UserId>,
|
2020-03-28 21:41:16 +01:00
|
|
|
}
|
2020-03-29 19:56:55 +02:00
|
|
|
|
2020-04-21 09:19:15 +02:00
|
|
|
#[cfg_attr(feature = "backend", derive(Queryable))]
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
|
|
|
pub struct IssueAssignee {
|
|
|
|
pub id: i32,
|
|
|
|
pub issue_id: i32,
|
|
|
|
pub user_id: i32,
|
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
|
|
|
}
|
|
|
|
|
2020-04-10 22:33:07 +02:00
|
|
|
impl From<Issue> for UpdateIssuePayload {
|
|
|
|
fn from(issue: Issue) -> Self {
|
|
|
|
Self {
|
|
|
|
title: issue.title,
|
|
|
|
issue_type: issue.issue_type,
|
|
|
|
priority: issue.priority,
|
|
|
|
list_position: issue.list_position,
|
|
|
|
description: issue.description,
|
|
|
|
description_text: issue.description_text,
|
|
|
|
estimate: issue.estimate,
|
|
|
|
time_spent: issue.time_spent,
|
|
|
|
time_remaining: issue.time_remaining,
|
|
|
|
project_id: issue.project_id,
|
|
|
|
reporter_id: issue.reporter_id,
|
|
|
|
user_ids: issue.user_ids,
|
2020-05-06 22:24:58 +02:00
|
|
|
issue_status_id: issue.issue_status_id,
|
2020-04-10 22:33:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-08 20:26:28 +02:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
2020-03-29 19:56:55 +02:00
|
|
|
pub struct CreateCommentPayload {
|
2020-04-11 11:18:41 +02:00
|
|
|
pub user_id: Option<UserId>,
|
|
|
|
pub issue_id: IssueId,
|
2020-03-29 19:56:55 +02:00
|
|
|
pub body: String,
|
|
|
|
}
|
|
|
|
|
2020-04-08 20:26:28 +02:00
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
2020-03-29 19:56:55 +02:00
|
|
|
pub struct UpdateCommentPayload {
|
2020-04-13 10:56:42 +02:00
|
|
|
pub id: i32,
|
2020-03-29 19:56:55 +02:00
|
|
|
pub body: String,
|
|
|
|
}
|
|
|
|
|
2020-04-08 20:26:28 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
2020-03-29 19:56:55 +02:00
|
|
|
pub struct CreateIssuePayload {
|
|
|
|
pub title: String,
|
2020-04-01 13:29:43 +02:00
|
|
|
pub issue_type: IssueType,
|
|
|
|
pub priority: IssuePriority,
|
2020-03-29 19:56:55 +02:00
|
|
|
pub description: Option<String>,
|
|
|
|
pub description_text: Option<String>,
|
2020-04-25 22:20:16 +02:00
|
|
|
pub estimate: Option<i32>,
|
|
|
|
pub time_spent: Option<i32>,
|
|
|
|
pub time_remaining: Option<i32>,
|
2020-04-11 11:18:41 +02:00
|
|
|
pub project_id: ProjectId,
|
|
|
|
pub user_ids: Vec<UserId>,
|
|
|
|
pub reporter_id: UserId,
|
2020-05-06 22:24:58 +02:00
|
|
|
pub issue_status_id: IssueStatusId,
|
2020-03-29 19:56:55 +02:00
|
|
|
}
|
|
|
|
|
2020-04-14 16:20:05 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
2020-03-29 19:56:55 +02:00
|
|
|
pub struct UpdateProjectPayload {
|
2020-04-14 16:20:05 +02:00
|
|
|
pub id: ProjectId,
|
2020-03-29 19:56:55 +02:00
|
|
|
pub name: Option<String>,
|
|
|
|
pub url: Option<String>,
|
|
|
|
pub description: Option<String>,
|
2020-04-14 16:20:05 +02:00
|
|
|
pub category: Option<ProjectCategory>,
|
2020-04-25 22:20:16 +02:00
|
|
|
pub time_tracking: Option<TimeTracking>,
|
2020-03-29 19:56:55 +02:00
|
|
|
}
|
2020-04-05 15:15:09 +02:00
|
|
|
|
2020-04-17 14:10:05 +02:00
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
|
|
|
|
pub enum PayloadVariant {
|
|
|
|
OptionI32(Option<i32>),
|
|
|
|
VecI32(Vec<i32>),
|
|
|
|
I32(i32),
|
|
|
|
String(String),
|
|
|
|
IssueType(IssueType),
|
|
|
|
IssuePriority(IssuePriority),
|
|
|
|
ProjectCategory(ProjectCategory),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialOrd, PartialEq, Hash)]
|
|
|
|
pub enum ProjectFieldId {
|
|
|
|
Name,
|
|
|
|
Url,
|
|
|
|
Description,
|
|
|
|
Category,
|
2020-04-25 16:12:06 +02:00
|
|
|
TimeTracking,
|
2020-04-17 14:10:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialOrd, PartialEq, Hash)]
|
2020-04-17 16:28:02 +02:00
|
|
|
pub enum SignInFieldId {
|
2020-04-17 14:10:05 +02:00
|
|
|
Username,
|
|
|
|
Email,
|
|
|
|
Token,
|
|
|
|
}
|
|
|
|
|
2020-04-17 16:28:02 +02:00
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialOrd, PartialEq, Hash)]
|
|
|
|
pub enum SignUpFieldId {
|
|
|
|
Username,
|
|
|
|
Email,
|
|
|
|
}
|
|
|
|
|
2020-04-20 11:22:39 +02:00
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialOrd, PartialEq, Hash)]
|
|
|
|
pub enum UsersFieldId {
|
|
|
|
Username,
|
|
|
|
Email,
|
|
|
|
UserRole,
|
2020-05-05 08:33:40 +02:00
|
|
|
Avatar,
|
2020-04-20 11:22:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialOrd, PartialEq, Hash)]
|
|
|
|
pub enum InviteFieldId {
|
|
|
|
Token,
|
|
|
|
}
|
|
|
|
|
2020-04-17 14:10:05 +02:00
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialOrd, PartialEq, Hash)]
|
|
|
|
pub enum CommentFieldId {
|
|
|
|
Body,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialOrd, PartialEq, Hash)]
|
|
|
|
pub enum IssueFieldId {
|
|
|
|
Type,
|
|
|
|
Title,
|
|
|
|
Description,
|
|
|
|
ListPosition,
|
|
|
|
Assignees,
|
|
|
|
Reporter,
|
|
|
|
Priority,
|
|
|
|
Estimate,
|
2020-04-25 22:20:16 +02:00
|
|
|
TimeSpent,
|
2020-04-17 14:10:05 +02:00
|
|
|
TimeRemaining,
|
2020-05-06 22:24:58 +02:00
|
|
|
IssueStatusId,
|
2020-04-17 14:10:05 +02:00
|
|
|
}
|
|
|
|
|
2020-04-08 20:26:28 +02:00
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
2020-04-05 15:15:09 +02:00
|
|
|
pub enum WsMsg {
|
|
|
|
Ping,
|
|
|
|
Pong,
|
2020-04-07 14:46:56 +02:00
|
|
|
|
|
|
|
// auth
|
2020-04-06 14:25:52 +02:00
|
|
|
AuthorizeRequest(Uuid),
|
|
|
|
AuthorizeLoaded(Result<User, String>),
|
2020-04-07 14:46:56 +02:00
|
|
|
AuthorizeExpired,
|
2020-04-15 20:28:07 +02:00
|
|
|
AuthenticateRequest(EmailString, UsernameString),
|
|
|
|
AuthenticateSuccess,
|
2020-04-16 16:11:19 +02:00
|
|
|
BindTokenCheck(Uuid),
|
|
|
|
BindTokenBad,
|
|
|
|
BindTokenOk(Uuid),
|
2020-04-17 20:44:55 +02:00
|
|
|
|
|
|
|
// Sign up
|
|
|
|
SignUpRequest(EmailString, UsernameString),
|
2020-04-17 16:28:02 +02:00
|
|
|
SignUpSuccess,
|
2020-04-17 20:44:55 +02:00
|
|
|
SignUpPairTaken,
|
2020-04-07 14:46:56 +02:00
|
|
|
|
2020-04-21 08:35:08 +02:00
|
|
|
// invitations
|
|
|
|
InvitationListRequest,
|
|
|
|
InvitationListLoaded(Vec<Invitation>),
|
2020-04-21 13:27:54 +02:00
|
|
|
//
|
2020-04-21 08:35:08 +02:00
|
|
|
InvitedUsersRequest,
|
|
|
|
InvitedUsersLoaded(Vec<User>),
|
2020-04-21 13:27:54 +02:00
|
|
|
//
|
2020-04-21 08:35:08 +02:00
|
|
|
InvitationSendRequest {
|
|
|
|
name: UsernameString,
|
|
|
|
email: EmailString,
|
|
|
|
},
|
|
|
|
InvitationSendSuccess,
|
|
|
|
InvitationSendFailure,
|
|
|
|
//
|
|
|
|
InvitationRevokeRequest(InvitationId),
|
|
|
|
InvitationRevokeSuccess(InvitationId),
|
|
|
|
//
|
|
|
|
InvitationAcceptRequest(InvitationId),
|
|
|
|
InvitationAcceptSuccess(InvitationId),
|
2020-04-22 16:03:43 +02:00
|
|
|
InvitedUserRemoveRequest(EmailString),
|
|
|
|
InvitedUserRemoveSuccess(EmailString),
|
2020-04-21 08:35:08 +02:00
|
|
|
|
2020-04-07 14:46:56 +02:00
|
|
|
// project page
|
2020-04-06 08:38:08 +02:00
|
|
|
ProjectRequest,
|
|
|
|
ProjectLoaded(Project),
|
2020-04-06 22:59:33 +02:00
|
|
|
ProjectIssuesRequest,
|
2020-04-06 08:38:08 +02:00
|
|
|
ProjectIssuesLoaded(Vec<Issue>),
|
2020-04-06 22:59:33 +02:00
|
|
|
ProjectUsersRequest,
|
|
|
|
ProjectUsersLoaded(Vec<User>),
|
2020-04-14 16:20:05 +02:00
|
|
|
ProjectUpdateRequest(UpdateProjectPayload),
|
2020-04-07 14:46:56 +02:00
|
|
|
|
|
|
|
// issue
|
2020-04-17 14:10:05 +02:00
|
|
|
IssueUpdateRequest(IssueId, IssueFieldId, PayloadVariant),
|
2020-04-07 14:46:56 +02:00
|
|
|
IssueUpdated(Issue),
|
2020-04-11 11:18:41 +02:00
|
|
|
IssueDeleteRequest(IssueId),
|
|
|
|
IssueDeleted(IssueId),
|
2020-04-07 14:46:56 +02:00
|
|
|
IssueCreateRequest(CreateIssuePayload),
|
|
|
|
IssueCreated(Issue),
|
2020-04-11 11:18:41 +02:00
|
|
|
|
2020-05-06 22:24:58 +02:00
|
|
|
// issue status
|
|
|
|
IssueStatusesRequest,
|
|
|
|
IssueStatusesResponse(Vec<IssueStatus>),
|
|
|
|
|
2020-04-11 11:18:41 +02:00
|
|
|
// comments
|
|
|
|
IssueCommentsRequest(IssueId),
|
|
|
|
IssueCommentsLoaded(Vec<Comment>),
|
2020-04-13 10:56:42 +02:00
|
|
|
CreateComment(CreateCommentPayload),
|
|
|
|
UpdateComment(UpdateCommentPayload),
|
|
|
|
CommentDeleteRequest(CommentId),
|
|
|
|
CommentDeleted(CommentId),
|
2020-05-05 16:09:26 +02:00
|
|
|
|
|
|
|
// users
|
|
|
|
AvatarUrlChanged(UserId, String),
|
2020-05-06 19:13:16 +02:00
|
|
|
ProfileUpdate(EmailString, UsernameString),
|
|
|
|
ProfileUpdated,
|
2020-04-05 15:15:09 +02:00
|
|
|
}
|