mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 18:39:33 +00:00
Allow to give human readable summary to user tasks
This commit is contained in:
parent
63331b6399
commit
c36073b852
@ -150,6 +150,7 @@ object OCollective {
|
||||
LearnClassifierArgs.taskName,
|
||||
on,
|
||||
timer,
|
||||
None,
|
||||
LearnClassifierArgs(coll)
|
||||
)
|
||||
_ <- uts.updateOneTask(AccountId(coll, LearnClassifierArgs.taskName), ut)
|
||||
@ -164,6 +165,7 @@ object OCollective {
|
||||
LearnClassifierArgs.taskName,
|
||||
true,
|
||||
CalEvent(WeekdayComponent.All, DateEvent.All, TimeEvent.All),
|
||||
None,
|
||||
LearnClassifierArgs(collective)
|
||||
).encode.toPeriodicTask(AccountId(collective, LearnClassifierArgs.taskName))
|
||||
job <- ut.toJob
|
||||
|
@ -36,7 +36,8 @@ object HouseKeepingTask {
|
||||
"Docspell house-keeping",
|
||||
DocspellSystem.taskGroup,
|
||||
Priority.Low,
|
||||
ce
|
||||
ce,
|
||||
None
|
||||
)
|
||||
.map(_.copy(id = periodicId))
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ import docspell.backend.ops.OItemSearch.{Batch, ListItem, Query}
|
||||
import docspell.common._
|
||||
import docspell.joex.mail.EmilHeader
|
||||
import docspell.joex.scheduler.{Context, Task}
|
||||
import docspell.store.queries.QItem
|
||||
import docspell.store.records._
|
||||
import docspell.query.Date
|
||||
import docspell.query.ItemQuery._
|
||||
import docspell.query.ItemQueryDsl._
|
||||
import docspell.store.queries.QItem
|
||||
import docspell.store.records._
|
||||
|
||||
import emil._
|
||||
import emil.builder._
|
||||
|
@ -3853,6 +3853,8 @@ components:
|
||||
format: ident
|
||||
enabled:
|
||||
type: boolean
|
||||
summary:
|
||||
type: string
|
||||
imapConnection:
|
||||
type: string
|
||||
format: ident
|
||||
@ -4012,6 +4014,8 @@ components:
|
||||
format: ident
|
||||
enabled:
|
||||
type: boolean
|
||||
summary:
|
||||
type: string
|
||||
smtpConnection:
|
||||
type: string
|
||||
format: ident
|
||||
|
@ -112,6 +112,7 @@ object NotifyDueItemsRoutes {
|
||||
NotifyDueItemsArgs.taskName,
|
||||
settings.enabled,
|
||||
settings.schedule,
|
||||
settings.summary,
|
||||
NotifyDueItemsArgs(
|
||||
user,
|
||||
settings.smtpConnection,
|
||||
@ -144,6 +145,7 @@ object NotifyDueItemsRoutes {
|
||||
} yield NotificationSettings(
|
||||
task.id,
|
||||
task.enabled,
|
||||
task.summary,
|
||||
conn.getOrElse(Ident.unsafe("")),
|
||||
task.args.recipients,
|
||||
task.timer,
|
||||
|
@ -105,6 +105,7 @@ object ScanMailboxRoutes {
|
||||
ScanMailboxArgs.taskName,
|
||||
settings.enabled,
|
||||
settings.schedule,
|
||||
settings.summary,
|
||||
ScanMailboxArgs(
|
||||
user,
|
||||
settings.imapConnection,
|
||||
@ -139,6 +140,7 @@ object ScanMailboxRoutes {
|
||||
} yield ScanMailboxSettings(
|
||||
task.id,
|
||||
task.enabled,
|
||||
task.summary,
|
||||
conn.getOrElse(Ident.unsafe("")),
|
||||
task.args.folders,
|
||||
task.timer,
|
||||
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE "periodic_task"
|
||||
ADD COLUMN "summary" varchar(254);
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE `periodic_task`
|
||||
ADD COLUMN `summary` varchar(254);
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE "periodic_task"
|
||||
ADD COLUMN "summary" varchar(254);
|
@ -85,6 +85,6 @@ object QUserTask {
|
||||
)
|
||||
|
||||
def makeUserTask(r: RPeriodicTask): UserTask[String] =
|
||||
UserTask(r.id, r.task, r.enabled, r.timer, r.args)
|
||||
UserTask(r.id, r.task, r.enabled, r.timer, r.summary, r.args)
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ case class RPeriodicTask(
|
||||
marked: Option[Timestamp],
|
||||
timer: CalEvent,
|
||||
nextrun: Timestamp,
|
||||
created: Timestamp
|
||||
created: Timestamp,
|
||||
summary: Option[String]
|
||||
) {
|
||||
|
||||
def toJob[F[_]: Sync]: F[RJob] =
|
||||
@ -66,7 +67,8 @@ object RPeriodicTask {
|
||||
subject: String,
|
||||
submitter: Ident,
|
||||
priority: Priority,
|
||||
timer: CalEvent
|
||||
timer: CalEvent,
|
||||
summary: Option[String]
|
||||
): F[RPeriodicTask] =
|
||||
Ident
|
||||
.randomId[F]
|
||||
@ -91,7 +93,8 @@ object RPeriodicTask {
|
||||
.map(_.toInstant)
|
||||
.map(Timestamp.apply)
|
||||
.getOrElse(Timestamp.Epoch),
|
||||
now
|
||||
now,
|
||||
summary
|
||||
)
|
||||
}
|
||||
)
|
||||
@ -104,9 +107,20 @@ object RPeriodicTask {
|
||||
subject: String,
|
||||
submitter: Ident,
|
||||
priority: Priority,
|
||||
timer: CalEvent
|
||||
timer: CalEvent,
|
||||
summary: Option[String]
|
||||
)(implicit E: Encoder[A]): F[RPeriodicTask] =
|
||||
create[F](enabled, task, group, E(args).noSpaces, subject, submitter, priority, timer)
|
||||
create[F](
|
||||
enabled,
|
||||
task,
|
||||
group,
|
||||
E(args).noSpaces,
|
||||
subject,
|
||||
submitter,
|
||||
priority,
|
||||
timer,
|
||||
summary
|
||||
)
|
||||
|
||||
final case class Table(alias: Option[String]) extends TableDef {
|
||||
val tableName = "periodic_task"
|
||||
@ -124,6 +138,7 @@ object RPeriodicTask {
|
||||
val timer = Column[CalEvent]("timer", this)
|
||||
val nextrun = Column[Timestamp]("nextrun", this)
|
||||
val created = Column[Timestamp]("created", this)
|
||||
val summary = Column[String]("summary", this)
|
||||
val all = NonEmptyList.of[Column[_]](
|
||||
id,
|
||||
enabled,
|
||||
@ -137,7 +152,8 @@ object RPeriodicTask {
|
||||
marked,
|
||||
timer,
|
||||
nextrun,
|
||||
created
|
||||
created,
|
||||
summary
|
||||
)
|
||||
}
|
||||
|
||||
@ -151,7 +167,7 @@ object RPeriodicTask {
|
||||
T.all,
|
||||
fr"${v.id},${v.enabled},${v.task},${v.group},${v.args}," ++
|
||||
fr"${v.subject},${v.submitter},${v.priority},${v.worker}," ++
|
||||
fr"${v.marked},${v.timer},${v.nextrun},${v.created}"
|
||||
fr"${v.marked},${v.timer},${v.nextrun},${v.created},${v.summary}"
|
||||
)
|
||||
|
||||
def update(v: RPeriodicTask): ConnectionIO[Int] =
|
||||
@ -168,7 +184,8 @@ object RPeriodicTask {
|
||||
T.worker.setTo(v.worker),
|
||||
T.marked.setTo(v.marked),
|
||||
T.timer.setTo(v.timer),
|
||||
T.nextrun.setTo(v.nextrun)
|
||||
T.nextrun.setTo(v.nextrun),
|
||||
T.summary.setTo(v.summary)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -16,6 +16,7 @@ case class UserTask[A](
|
||||
name: Ident,
|
||||
enabled: Boolean,
|
||||
timer: CalEvent,
|
||||
summary: Option[String],
|
||||
args: A
|
||||
) {
|
||||
|
||||
@ -47,7 +48,8 @@ object UserTask {
|
||||
s"${account.user.id}: ${ut.name.id}",
|
||||
account.user,
|
||||
Priority.Low,
|
||||
ut.timer
|
||||
ut.timer,
|
||||
ut.summary
|
||||
)
|
||||
.map(r => r.copy(id = ut.id))
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import Data.UiSettings exposing (UiSettings)
|
||||
import Data.Validated exposing (Validated(..))
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onInput)
|
||||
import Http
|
||||
import Styles as S
|
||||
import Util.Http
|
||||
@ -52,6 +53,7 @@ type alias Model =
|
||||
, formMsg : Maybe BasicResult
|
||||
, loading : Int
|
||||
, yesNoDelete : Comp.YesNoDimmer.Model
|
||||
, summary : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -79,6 +81,7 @@ type Msg
|
||||
| Cancel
|
||||
| RequestDelete
|
||||
| YesNoDeleteMsg Comp.YesNoDimmer.Msg
|
||||
| SetSummary String
|
||||
|
||||
|
||||
initWith : Flags -> NotificationSettings -> ( Model, Cmd Msg )
|
||||
@ -121,6 +124,7 @@ initWith flags s =
|
||||
, formMsg = Nothing
|
||||
, loading = im.loading
|
||||
, yesNoDelete = Comp.YesNoDimmer.emptyModel
|
||||
, summary = s.summary
|
||||
}
|
||||
, Cmd.batch
|
||||
[ nc
|
||||
@ -158,6 +162,7 @@ init flags =
|
||||
, formMsg = Nothing
|
||||
, loading = 2
|
||||
, yesNoDelete = Comp.YesNoDimmer.emptyModel
|
||||
, summary = Nothing
|
||||
}
|
||||
, Cmd.batch
|
||||
[ Api.getMailSettings flags "" ConnResp
|
||||
@ -203,6 +208,7 @@ makeSettings model =
|
||||
, capOverdue = model.capOverdue
|
||||
, enabled = model.enabled
|
||||
, schedule = Data.CalEvent.makeEvent timer
|
||||
, summary = model.summary
|
||||
}
|
||||
in
|
||||
Data.Validated.map4 make
|
||||
@ -450,6 +456,12 @@ update flags msg model =
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
SetSummary str ->
|
||||
( { model | summary = Util.Maybe.fromString str }
|
||||
, NoAction
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
|
||||
|
||||
--- View2
|
||||
@ -544,6 +556,22 @@ view2 extraClasses settings model =
|
||||
, id = "notify-enabled"
|
||||
}
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Summary"
|
||||
]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetSummary
|
||||
, class S.textInput
|
||||
, Maybe.withDefault "" model.summary
|
||||
|> value
|
||||
]
|
||||
[]
|
||||
, span [ class "opacity-50 text-sm" ]
|
||||
[ text "Some human readable name, only for displaying"
|
||||
]
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Send via"
|
||||
|
@ -54,13 +54,13 @@ view2 _ items =
|
||||
, th [ class "text-center mr-2" ]
|
||||
[ i [ class "fa fa-check" ] []
|
||||
]
|
||||
, th [ class "text-left " ] [ text "Summary" ]
|
||||
, th [ class "text-left hidden sm:table-cell mr-2" ]
|
||||
[ text "Schedule" ]
|
||||
, th [ class "text-left mr-2" ]
|
||||
[ text "Connection" ]
|
||||
, th [ class "text-left hidden sm:table-cell mr-2" ]
|
||||
[ text "Recipients" ]
|
||||
, th [ class "text-center " ] [ text "Remind Days" ]
|
||||
]
|
||||
]
|
||||
, tbody []
|
||||
@ -76,6 +76,10 @@ viewItem2 item =
|
||||
, td [ class "w-px whitespace-nowrap px-2 text-center" ]
|
||||
[ Util.Html.checkbox2 item.enabled
|
||||
]
|
||||
, td [ class "text-left" ]
|
||||
[ Maybe.withDefault "" item.summary
|
||||
|> text
|
||||
]
|
||||
, td [ class "text-left hidden sm:table-cell mr-2" ]
|
||||
[ code [ class "font-mono text-sm" ]
|
||||
[ text item.schedule
|
||||
@ -87,8 +91,4 @@ viewItem2 item =
|
||||
, td [ class "text-left hidden sm:table-cell mr-2" ]
|
||||
[ String.join ", " item.recipients |> text
|
||||
]
|
||||
, td [ class "text-center" ]
|
||||
[ String.fromInt item.remindDays
|
||||
|> text
|
||||
]
|
||||
]
|
||||
|
@ -75,6 +75,7 @@ type alias Model =
|
||||
, languageModel : Comp.FixedDropdown.Model Language
|
||||
, language : Maybe Language
|
||||
, postHandleAll : Bool
|
||||
, summary : Maybe String
|
||||
, openTabs : Set String
|
||||
}
|
||||
|
||||
@ -121,6 +122,7 @@ type Msg
|
||||
| RemoveLanguage
|
||||
| TogglePostHandleAll
|
||||
| ToggleAkkordionTab String
|
||||
| SetSummary String
|
||||
|
||||
|
||||
initWith : Flags -> ScanMailboxSettings -> ( Model, Cmd Msg )
|
||||
@ -167,6 +169,7 @@ initWith flags s =
|
||||
Comp.FixedDropdown.init (List.map mkLanguageItem Data.Language.all)
|
||||
, language = Maybe.andThen Data.Language.fromString s.language
|
||||
, postHandleAll = Maybe.withDefault False s.postHandleAll
|
||||
, summary = s.summary
|
||||
}
|
||||
, Cmd.batch
|
||||
[ Api.getImapSettings flags "" ConnResp
|
||||
@ -221,6 +224,7 @@ init flags =
|
||||
Comp.FixedDropdown.init (List.map mkLanguageItem Data.Language.all)
|
||||
, language = Nothing
|
||||
, postHandleAll = False
|
||||
, summary = Nothing
|
||||
, openTabs = Set.insert (tabTitle TabGeneral) Set.empty
|
||||
}
|
||||
, Cmd.batch
|
||||
@ -283,6 +287,7 @@ makeSettings model =
|
||||
|> Just
|
||||
, language = Maybe.map Data.Language.toIso3 model.language
|
||||
, postHandleAll = Just model.postHandleAll
|
||||
, summary = model.summary
|
||||
}
|
||||
in
|
||||
Data.Validated.map3 make
|
||||
@ -689,6 +694,12 @@ update flags msg model =
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
SetSummary str ->
|
||||
( { model | summary = Util.Maybe.fromString str }
|
||||
, NoAction
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
|
||||
|
||||
--- View2
|
||||
@ -870,6 +881,22 @@ viewGeneral2 settings model =
|
||||
[ text "Mailbox"
|
||||
, B.inputRequired
|
||||
]
|
||||
, div [ class "mb-4" ]
|
||||
[ label [ class S.inputLabel ]
|
||||
[ text "Summary"
|
||||
]
|
||||
, input
|
||||
[ type_ "text"
|
||||
, onInput SetSummary
|
||||
, class S.textInput
|
||||
, Maybe.withDefault "" model.summary
|
||||
|> value
|
||||
]
|
||||
[]
|
||||
, span [ class "opacity-50 text-sm" ]
|
||||
[ text "Some human readable name, only for displaying"
|
||||
]
|
||||
]
|
||||
, Html.map ConnMsg
|
||||
(Comp.Dropdown.view2
|
||||
DS.mainStyle
|
||||
|
@ -54,12 +54,11 @@ view2 _ items =
|
||||
, th [ class "" ]
|
||||
[ i [ class "fa fa-check" ] []
|
||||
]
|
||||
, th [ class "text-left mr-2 hidden md:table-cell" ] [ text "Schedule" ]
|
||||
, th [ class "text-left mr-2" ] [ text "Connection" ]
|
||||
, th [ class "text-left mr-2" ] [ text "Folders" ]
|
||||
, th [ class "text-left mr-2 hidden md:table-cell" ] [ text "Received Since" ]
|
||||
, th [ class "text-left mr-2 hidden md:table-cell" ] [ text "Target" ]
|
||||
, th [ class "hidden md:table-cell" ] [ text "Delete" ]
|
||||
, th [ class "text-left" ] [ text "Summary" ]
|
||||
, th [ class "text-left mr-2" ] [ text "Schedule" ]
|
||||
, th [ class "text-left mr-2 hidden md:table-cell" ] [ text "Connection" ]
|
||||
, th [ class "text-left mr-2 hidden md:table-cell" ] [ text "Folders" ]
|
||||
, th [ class "text-left mr-2 hidden lg:table-cell" ] [ text "Received Since" ]
|
||||
]
|
||||
]
|
||||
, tbody []
|
||||
@ -75,28 +74,24 @@ viewItem2 item =
|
||||
, td [ class "w-px px-2" ]
|
||||
[ Util.Html.checkbox2 item.enabled
|
||||
]
|
||||
, td [ class "mr-2 hidden md:table-cell" ]
|
||||
, td [ class "text-left" ]
|
||||
[ Maybe.withDefault "–" item.summary |> text
|
||||
]
|
||||
, td [ class "mr-2" ]
|
||||
[ code [ class "font-mono text-sm" ]
|
||||
[ text item.schedule
|
||||
]
|
||||
]
|
||||
, td [ class "text-left mr-2" ]
|
||||
, td [ class "text-left mr-2 hidden md:table-cell" ]
|
||||
[ text item.imapConnection
|
||||
]
|
||||
, td [ class "text-left mr-2" ]
|
||||
, td [ class "text-left mr-2 hidden md:table-cell" ]
|
||||
[ String.join ", " item.folders |> text
|
||||
]
|
||||
, td [ class "text-left mr-2 hidden md:table-cell" ]
|
||||
, td [ class "text-left mr-2 hidden lg:table-cell" ]
|
||||
[ Maybe.map String.fromInt item.receivedSinceHours
|
||||
|> Maybe.withDefault "-"
|
||||
|> text
|
||||
, text " h"
|
||||
]
|
||||
, td [ class "text-left mr-2 hidden md:table-cell" ]
|
||||
[ Maybe.withDefault "-" item.targetFolder
|
||||
|> text
|
||||
]
|
||||
, td [ class "w-px px-2 hidden md:table-cell" ]
|
||||
[ Util.Html.checkbox2 item.deleteMail
|
||||
]
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user