All Projects → ctf0 → Odin

ctf0 / Odin

Licence: MIT license
manage model revisions with ease

Programming Languages

PHP
23972 projects - #3 most used programming language
CSS
56736 projects
Blade
752 projects
javascript
184084 projects - #8 most used programming language
Vue
7211 projects
SCSS
7915 projects

Projects that are alternatives of or similar to Odin

Westore
更好的小程序项目架构
Stars: ✭ 3,897 (+6395%)
Mutual labels:  diff, model
Modelassistant
Elegant library to manage the interactions between view and model in Swift
Stars: ✭ 26 (-56.67%)
Mutual labels:  manager, model
Brush Manager
Brush Manager is an add-on for Blender that helps you to create custom brushes, store them in a file and organize the library of various categories of brushes.
Stars: ✭ 75 (+25%)
Mutual labels:  manager
InitKit
Neo-InitWare is a modular, cross-platform reimplementation of the systemd init system. It is experimental.
Stars: ✭ 364 (+506.67%)
Mutual labels:  manager
jquery.filebrowser
File browser jQuery plugin
Stars: ✭ 29 (-51.67%)
Mutual labels:  manager
acorn-db
Provides Acorn projects with Eloquent Models for WordPress data.
Stars: ✭ 30 (-50%)
Mutual labels:  model
dif
'dif' is a Linux preprocessing front end to gvimdiff/meld/kompare
Stars: ✭ 18 (-70%)
Mutual labels:  diff
tqsdk-js
期货行情/历史数据/交易 开发包
Stars: ✭ 52 (-13.33%)
Mutual labels:  diff
duff
Pure OCaml implementation of libXdiff (Rabin's fingerprint)
Stars: ✭ 20 (-66.67%)
Mutual labels:  diff
ngx-text-diff
A Text Diff component for Angular
Stars: ✭ 49 (-18.33%)
Mutual labels:  diff
lightline-gitdiff
Show added, deleted and modified lines (`git diff`) in your statusline or lightline
Stars: ✭ 27 (-55%)
Mutual labels:  diff
virtio
Virtio implementation in SystemVerilog
Stars: ✭ 38 (-36.67%)
Mutual labels:  model
textdiff-create
Create lean text diff deltas.
Stars: ✭ 25 (-58.33%)
Mutual labels:  diff
KoiCatalog
A card manager for Koikatu. View, search, and sort your collection of character cards.
Stars: ✭ 18 (-70%)
Mutual labels:  manager
DTE
Generate C# class from database table
Stars: ✭ 26 (-56.67%)
Mutual labels:  model
Passky-Desktop
Desktop application for Passky (password manager)
Stars: ✭ 47 (-21.67%)
Mutual labels:  manager
gitdub
📤 A github WebHook that emails detailed diffs of your commits.
Stars: ✭ 25 (-58.33%)
Mutual labels:  diff
eSelection
Dynamic model selection library for SA-MP servers
Stars: ✭ 28 (-53.33%)
Mutual labels:  model
react-native-simple-download-manager
A react native module to schedule downloads on native download manager
Stars: ✭ 35 (-41.67%)
Mutual labels:  manager
hcv-color
🌈 Color model HCV/HCG is an alternative to HSV and HSL, derived by Munsell color system, usable for Dark and Light themes... 🌈
Stars: ✭ 44 (-26.67%)
Mutual labels:  model

Odin
Latest Stable Version Total Downloads

Manage model revisions with ease.

If you are also looking to preview the form data before submitting to the db, you may want to give OverSeer a try.

  • package requires Laravel v5.4+

Installation

  • composer require ctf0/odin

  • (Laravel < 5.5) add the service provider & facade

    'providers' => [
        ctf0\Odin\OdinServiceProvider::class,
    ];
  • publish the package assets with

    php artisan vendor:publish --provider="ctf0\Odin\OdinServiceProvider"

  • after installation, run php artisan odin:setup to add

    • package routes to routes/web.php
    • package assets compiling to webpack.mix.js
  • check laravel-auditing docs for configuration

  • install dependencies

    yarn add vue vue-awesome@v2 vue-notif axios keycode
  • add this one liner to your main js file and run npm run watch to compile your js/css files.

    • if you are having issues Check.
    // app.js
    
    window.Vue = require('vue')
    
    require('../vendor/Odin/js/manager')
    
    new Vue({
        el: '#app'
    })

Features

  • support single & nested values.

  • delete & restore revisions.

  • support soft deletes.

  • revision preview.

  • clear audits for permanently deleted models.

    php artisan odin:gc
    • which can be scheduled as well
      $schedule->command('odin:gc')->sundays();
  • shortcuts

    navigation keyboard mouse (click)
    go to next revision right/down * (revision date)
    go to prev revision left/up * (revision date)
    go to first revision home * (revision date)
    go to last revision end * (revision date)
    hide revision window esc * (x)
  • events "JS"

    event-name description
    odin-show when revision is showen
    odin-hide when revision is hidden

Usage

  • run php artisan migrate

  • add Revisions trait & AuditableContract contract to your model

    use ctf0\Odin\Traits\Revisions;
    use Illuminate\Database\Eloquent\Model;
    use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
    
    class Post extends Model implements AuditableContract
    {
        use Revisions;
    
        /**
         * resolve model title/name for the revision relation
         * this is needed so we can render
         * the model relation attach/detach changes
         */
        public function getMiscTitleAttribute()
        {
            return $this->name;
        }
    
        // ...
    }
  • you can disable creating ghost audits where both old/new values are empty by using

    • remember that without the parent model audit log we cant show the relation changes
    // app/Providers/EventServiceProvider
    
    use OwenIt\Auditing\Models\Audit;
    
    public function boot()
    {
        parent::boot();
    
        Audit::creating(function (Audit $model) {
            if (empty($model->old_values) && empty($model->new_values)) {
                return false;
            }
        });
    }
  • inside the model view ex.post edit view add

    @if (count($post->revisionsWithRelation))
        @include('Odin::list', ['revisions' => $post->revisionsWithRelation])
    @endif

Notes

  • model user_id & id are excluded from the audit log by default.

  • data:uri

    • if you use data:uri in your revisionable content, change audits_table columns type to either mediumText or longText before migrating to avoid future errors of long data.

    • because data:uri is a render blocking & isn't readable by humans, we truncate it to 75 char max
      note that this ONLY effects the displaying of the revision diff, we never touch the data that gets saved to the db.

  • model-relation

    • atm the relation revision is limited, it means we can only show the attach/detach changes but we cant undo/redo any of them through the package it self.
    • also if you use mass update like Model::update() make sure to call $model->touch(); afterwards to make sure an audit is created ex.
      $model = Model::update([...]);
      $model->touch();

Security

If you discover any security-related issues, please email [email protected].

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].