GithubHelp home page GithubHelp logo

osis-async's Introduction

OSIS Async

OSIS Async is a Django application to create and display asynchronous tasks across OSIS platform.

Requirements

OSIS Async requires

  • Django 2.2+
  • Django REST Framework 3.12+
  • Vue 3

How to install ?

For production

# From your osis install, with python environment activated
pip install git+https://github.com/uclouvain/osis-async.git@dev#egg=osis_async

For development

# From your osis install, with python environment activated
git clone [email protected]:uclouvain/osis-async.git
pip install -e ./osis-async

Configuring Django

Add osis_async to INSTALLED_APPS and apply migrations :

INSTALLED_APPS = (
    ...
    'osis_async',
    ...
)

Using OSIS Async

osis_async provides an API to create and manage async tasks and also a VueJS component to view them in the interface.

Create an async task

Initialize an object describing the notification you want to send:

from osis_async.models.task import AsyncTask

task_uuid = AsyncTask.objects.create(
    name="My task name",
    description="My task longer description",
    person=person,  # Person for which to display the task
    time_to_live=5,  # Time-to-live in minutes
).uuid
# Store its uuid for easy retrieval

Update an async task

It is the implementer role's to start and update its async tasks, you can use the update_task() for that matter:

from django.utils.timezone import now
from osis_async.utils import update_task
from osis_async.models.enums.task import TaskStates

update_task(uuid, state=TaskStates.PROCESSING.name, started_at=now())
update_task(uuid, progression=50)
update_task(uuid, state=TaskStates.DONE.name, completed_at=now())

Integrate the front notification component

Make the dependencies available:

<!-- Dependencies if not already added -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.5.0/css/all.min.css">
<script type="text/javascript" src="https://unpkg.com/jquery"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/bootstrap.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-i18n@8"></script>

<!-- Dependencies if not already added -->
<link href="{% static 'osis_async/osis-async.css' %}" rel="stylesheet"/>

<!-- This line must go at the end of the file -->
<script type="text/javascript" src="{% static 'osis_async/osis-async.umd.min.js' %}"></script>

Then you can integrate the component:

<div id="async-tasks-viewer" data-url="{% url 'osis_async:task-list' %}" data-interval="300"></div>
  • data-url : API endpoint that returns all the tasks.
  • data-interval : The interval, in seconds, to fetch tasks from server (default to 300).

osis-async's People

Contributors

sebcorbin avatar albrugnetti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.