mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Massive rewrite for import routine, part 1.
This commit is contained in:
@@ -50,80 +50,16 @@ class BankController extends Controller
|
|||||||
if (!class_exists($class)) {
|
if (!class_exists($class)) {
|
||||||
throw new FireflyException(sprintf('Cannot find class %s', $class));
|
throw new FireflyException(sprintf('Cannot find class %s', $class));
|
||||||
}
|
}
|
||||||
$importJob = $repository->create($bank);
|
$importJob = $repository->create($bank);
|
||||||
|
$config = $importJob->configuration;
|
||||||
|
$config['has-config-file'] = false;
|
||||||
|
$config['auto-start'] = true;
|
||||||
|
$importJob->configuration = $config;
|
||||||
|
$importJob->save();
|
||||||
|
|
||||||
return redirect(route('import.file.configure', [$importJob->key]));
|
return redirect(route('import.file.configure', [$importJob->key]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method processes the prerequisites the user has entered in the previous step.
|
|
||||||
*
|
|
||||||
* Whatever storePrerequisites does, it should make sure that the system is ready to continue immediately. So
|
|
||||||
* no extra calls or stuff, except maybe to open a session
|
|
||||||
*
|
|
||||||
* @see PrerequisitesInterface::storePrerequisites
|
|
||||||
*
|
|
||||||
* @param Request $request
|
|
||||||
* @param string $bank
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function postPrerequisites(Request $request, string $bank)
|
|
||||||
{
|
|
||||||
Log::debug(sprintf('Now in postPrerequisites for %s', $bank));
|
|
||||||
$class = config(sprintf('firefly.import_pre.%s', $bank));
|
|
||||||
if (!class_exists($class)) {
|
|
||||||
throw new FireflyException(sprintf('Cannot find class %s', $class));
|
|
||||||
}
|
|
||||||
/** @var PrerequisitesInterface $object */
|
|
||||||
$object = app($class);
|
|
||||||
$object->setUser(auth()->user());
|
|
||||||
if (!$object->hasPrerequisites()) {
|
|
||||||
Log::debug(sprintf('No more prerequisites for %s, move to form.', $bank));
|
|
||||||
|
|
||||||
return redirect(route('import.bank.create-job', [$bank]));
|
|
||||||
}
|
|
||||||
Log::debug('Going to store entered preprerequisites.');
|
|
||||||
// store post data
|
|
||||||
$result = $object->storePrerequisites($request);
|
|
||||||
|
|
||||||
if ($result->count() > 0) {
|
|
||||||
Session::flash('error', $result->first());
|
|
||||||
|
|
||||||
return redirect(route('import.bank.prerequisites', [$bank]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect(route('import.bank.create-job', [$bank]));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method shows you, if necessary, a form that allows you to enter any required values, such as API keys,
|
|
||||||
* login passwords or other values.
|
|
||||||
*
|
|
||||||
* @param string $bank
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function prerequisites(string $bank)
|
|
||||||
{
|
|
||||||
$class = config(sprintf('firefly.import_pre.%s', $bank));
|
|
||||||
if (!class_exists($class)) {
|
|
||||||
throw new FireflyException(sprintf('Cannot find class %s', $class));
|
|
||||||
}
|
|
||||||
/** @var PrerequisitesInterface $object */
|
|
||||||
$object = app($class);
|
|
||||||
$object->setUser(auth()->user());
|
|
||||||
|
|
||||||
if ($object->hasPrerequisites()) {
|
|
||||||
$view = $object->getView();
|
|
||||||
$parameters = ['title' => strval(trans('firefly.import_index_title')), 'mainTitleIcon' => 'fa-archive'];
|
|
||||||
$parameters = $object->getViewParameters() + $parameters;
|
|
||||||
|
|
||||||
return view($view, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect(route('import.bank.create-job', [$bank]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
87
app/Http/Controllers/Import/ConfigurationController.php
Normal file
87
app/Http/Controllers/Import/ConfigurationController.php
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Controllers\Import;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use FireflyIII\Import\Configuration\ConfiguratorInterface;
|
||||||
|
use FireflyIII\Models\ImportJob;
|
||||||
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ConfigurationController
|
||||||
|
*/
|
||||||
|
class ConfigurationController extends Controller
|
||||||
|
{
|
||||||
|
/** @var ImportJobRepositoryInterface */
|
||||||
|
public $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
app('view')->share('mainTitleIcon', 'fa-archive');
|
||||||
|
app('view')->share('title', trans('firefly.import_index_title'));
|
||||||
|
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the job. This method is returned to until job is deemed "configured".
|
||||||
|
*
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function index(ImportJob $job)
|
||||||
|
{
|
||||||
|
// create configuration class:
|
||||||
|
$configurator = $this->makeConfigurator($job);
|
||||||
|
|
||||||
|
// is the job already configured?
|
||||||
|
if ($configurator->isJobConfigured()) {
|
||||||
|
$this->repository->updateStatus($job, 'configured');
|
||||||
|
|
||||||
|
return redirect(route('import.file.status', [$job->key]));
|
||||||
|
}
|
||||||
|
$view = $configurator->getNextView();
|
||||||
|
$data = $configurator->getNextData();
|
||||||
|
$subTitle = trans('firefly.import_config_bread_crumb');
|
||||||
|
$subTitleIcon = 'fa-wrench';
|
||||||
|
|
||||||
|
return view($view, compact('data', 'job', 'subTitle', 'subTitleIcon'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return ConfiguratorInterface
|
||||||
|
*
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
private function makeConfigurator(ImportJob $job): ConfiguratorInterface
|
||||||
|
{
|
||||||
|
$type = $job->file_type;
|
||||||
|
$key = sprintf('import.configuration.%s', $type);
|
||||||
|
$className = config($key);
|
||||||
|
if (null === $className || !class_exists($className)) {
|
||||||
|
throw new FireflyException(sprintf('Cannot find configurator class for job of type "%s".',$type)); // @codeCoverageIgnore
|
||||||
|
}
|
||||||
|
/** @var ConfiguratorInterface $configurator */
|
||||||
|
$configurator = app($className);
|
||||||
|
$configurator->setJob($job);
|
||||||
|
|
||||||
|
return $configurator;
|
||||||
|
}
|
||||||
|
}
|
@@ -54,8 +54,8 @@ class FileController extends Controller
|
|||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
View::share('mainTitleIcon', 'fa-archive');
|
app('view')->share('mainTitleIcon', 'fa-archive');
|
||||||
View::share('title', trans('firefly.import_index_title'));
|
app('view')->share('title', trans('firefly.import_index_title'));
|
||||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
@@ -107,6 +107,7 @@ class FileController extends Controller
|
|||||||
$config['column-roles-complete'] = false;
|
$config['column-roles-complete'] = false;
|
||||||
$config['column-mapping-complete'] = false;
|
$config['column-mapping-complete'] = false;
|
||||||
$config['initial-config-complete'] = false;
|
$config['initial-config-complete'] = false;
|
||||||
|
$config['has-file-upload'] = false;
|
||||||
$config['delimiter'] = "\t" === $config['delimiter'] ? 'tab' : $config['delimiter'];
|
$config['delimiter'] = "\t" === $config['delimiter'] ? 'tab' : $config['delimiter'];
|
||||||
|
|
||||||
$result = json_encode($config, JSON_PRETTY_PRINT);
|
$result = json_encode($config, JSON_PRETTY_PRINT);
|
||||||
|
72
app/Http/Controllers/Import/IndexController.php
Normal file
72
app/Http/Controllers/Import/IndexController.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Controllers\Import;
|
||||||
|
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
|
use View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class FileController.
|
||||||
|
*/
|
||||||
|
class IndexController extends Controller
|
||||||
|
{
|
||||||
|
/** @var ImportJobRepositoryInterface */
|
||||||
|
public $repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->middleware(
|
||||||
|
function ($request, $next) {
|
||||||
|
app('view')->share('mainTitleIcon', 'fa-archive');
|
||||||
|
app('view')->share('title', trans('firefly.import_index_title'));
|
||||||
|
$this->repository = app(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new import job for $bank with the default (global) job configuration.
|
||||||
|
*
|
||||||
|
* @param string $bank
|
||||||
|
*
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function create(string $bank)
|
||||||
|
{
|
||||||
|
if (!(config(sprintf('import.enabled.%s', $bank))) === true) {
|
||||||
|
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank));
|
||||||
|
}
|
||||||
|
|
||||||
|
$importJob = $this->repository->create($bank);
|
||||||
|
|
||||||
|
// from here, always go to configure step.
|
||||||
|
return redirect(route('import.configure', [$importJob->key]));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* General import index.
|
||||||
|
*
|
||||||
|
* @return View
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$subTitle = trans('firefly.import_index_sub_title');
|
||||||
|
$subTitleIcon = 'fa-home';
|
||||||
|
$routines = config('import.enabled');
|
||||||
|
|
||||||
|
return view('import.index', compact('subTitle', 'subTitleIcon', 'routines'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
97
app/Http/Controllers/Import/PrerequisitesController.php
Normal file
97
app/Http/Controllers/Import/PrerequisitesController.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Http\Controllers\Import;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use FireflyIII\Import\Prerequisites\PrerequisitesInterface;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class PrerequisitesController
|
||||||
|
*/
|
||||||
|
class PrerequisitesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Once there are no prerequisites, this method will create an importjob object and
|
||||||
|
* redirect the user to a view where this object can be used by a bank specific
|
||||||
|
* class to process.
|
||||||
|
*
|
||||||
|
* @param string $bank
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse|null
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function index(string $bank)
|
||||||
|
{
|
||||||
|
if (!(config(sprintf('import.enabled.%s', $bank))) === true) {
|
||||||
|
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank));
|
||||||
|
}
|
||||||
|
$class = strval(config(sprintf('import.prerequisites.%s', $bank)));
|
||||||
|
if (!class_exists($class)) {
|
||||||
|
throw new FireflyException(sprintf('No class to handle "%s".', $bank));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var PrerequisitesInterface $object */
|
||||||
|
$object = app($class);
|
||||||
|
$object->setUser(auth()->user());
|
||||||
|
|
||||||
|
if ($object->hasPrerequisites()) {
|
||||||
|
$view = $object->getView();
|
||||||
|
$parameters = ['title' => strval(trans('firefly.import_index_title')), 'mainTitleIcon' => 'fa-archive'];
|
||||||
|
$parameters = $object->getViewParameters() + $parameters;
|
||||||
|
|
||||||
|
return view($view, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if no (more) prerequisites, return to create a job:
|
||||||
|
return redirect(route('import.create-job', [$bank]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method processes the prerequisites the user has entered in the previous step.
|
||||||
|
*
|
||||||
|
* Whatever storePrerequisites does, it should make sure that the system is ready to continue immediately. So
|
||||||
|
* no extra calls or stuff, except maybe to open a session
|
||||||
|
*
|
||||||
|
* @see PrerequisitesInterface::storePrerequisites
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
* @param string $bank
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public function postPrerequisites(Request $request, string $bank)
|
||||||
|
{
|
||||||
|
Log::debug(sprintf('Now in postPrerequisites for %s', $bank));
|
||||||
|
$class = config(sprintf('firefly.import_pre.%s', $bank));
|
||||||
|
if (!class_exists($class)) {
|
||||||
|
throw new FireflyException(sprintf('Cannot find class %s', $class));
|
||||||
|
}
|
||||||
|
/** @var PrerequisitesInterface $object */
|
||||||
|
$object = app($class);
|
||||||
|
$object->setUser(auth()->user());
|
||||||
|
if (!$object->hasPrerequisites()) {
|
||||||
|
Log::debug(sprintf('No more prerequisites for %s, move to form.', $bank));
|
||||||
|
|
||||||
|
return redirect(route('import.create-job', [$bank]));
|
||||||
|
}
|
||||||
|
Log::debug('Going to store entered prerequisites.');
|
||||||
|
// store post data
|
||||||
|
$result = $object->storePrerequisites($request);
|
||||||
|
|
||||||
|
if ($result->count() > 0) {
|
||||||
|
$request->session()->flash('error', $result->first());
|
||||||
|
|
||||||
|
return redirect(route('import.prerequisites', [$bank]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect(route('import.create-job', [$bank]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -1,72 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* ImportController.php
|
|
||||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
|
||||||
|
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
|
||||||
use View;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class ImportController.
|
|
||||||
*/
|
|
||||||
class ImportController extends Controller
|
|
||||||
{
|
|
||||||
/** @var ImportJobRepositoryInterface */
|
|
||||||
public $repository;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
|
|
||||||
$this->middleware(
|
|
||||||
function ($request, $next) {
|
|
||||||
View::share('mainTitleIcon', 'fa-archive');
|
|
||||||
View::share('title', trans('firefly.import_index_title'));
|
|
||||||
$this->repository = app(ImportJobRepositoryInterface::class);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* General import index.
|
|
||||||
*
|
|
||||||
* @return View
|
|
||||||
*/
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
$subTitle = trans('firefly.import_index_sub_title');
|
|
||||||
$subTitleIcon = 'fa-home';
|
|
||||||
$importFileTypes = [];
|
|
||||||
$defaultImportType = config('firefly.default_import_format');
|
|
||||||
|
|
||||||
foreach (array_keys(config('firefly.import_formats')) as $type) {
|
|
||||||
$importFileTypes[$type] = trans('firefly.import_file_type_' . $type);
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('import.index', compact('subTitle', 'subTitleIcon', 'importFileTypes', 'defaultImportType'));
|
|
||||||
}
|
|
||||||
}
|
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Import\Configurator;
|
namespace FireflyIII\Import\Configuration;
|
||||||
|
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
|
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* CsvConfigurator.php
|
* FileConfigurator.php
|
||||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||||
*
|
*
|
||||||
* This file is part of Firefly III.
|
* This file is part of Firefly III.
|
||||||
@@ -20,20 +20,21 @@
|
|||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Import\Configurator;
|
namespace FireflyIII\Import\Configuration;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\Csv\Initial;
|
use FireflyIII\Support\Import\Configuration\File\Initial;
|
||||||
use FireflyIII\Support\Import\Configuration\Csv\Map;
|
use FireflyIII\Support\Import\Configuration\File\Map;
|
||||||
use FireflyIII\Support\Import\Configuration\Csv\Roles;
|
use FireflyIII\Support\Import\Configuration\File\Roles;
|
||||||
|
use FireflyIII\Support\Import\Configuration\File\Upload;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CsvConfigurator.
|
* Class FileConfigurator.
|
||||||
*/
|
*/
|
||||||
class CsvConfigurator implements ConfiguratorInterface
|
class FileConfigurator implements ConfiguratorInterface
|
||||||
{
|
{
|
||||||
/** @var ImportJob */
|
/** @var ImportJob */
|
||||||
private $job;
|
private $job;
|
||||||
@@ -95,14 +96,17 @@ class CsvConfigurator implements ConfiguratorInterface
|
|||||||
*/
|
*/
|
||||||
public function getNextView(): string
|
public function getNextView(): string
|
||||||
{
|
{
|
||||||
|
if (!$this->job->configuration['has-file-upload']) {
|
||||||
|
return 'import.file.upload';
|
||||||
|
}
|
||||||
if (!$this->job->configuration['initial-config-complete']) {
|
if (!$this->job->configuration['initial-config-complete']) {
|
||||||
return 'import.csv.initial';
|
return 'import.file.initial';
|
||||||
}
|
}
|
||||||
if (!$this->job->configuration['column-roles-complete']) {
|
if (!$this->job->configuration['column-roles-complete']) {
|
||||||
return 'import.csv.roles';
|
return 'import.file.roles';
|
||||||
}
|
}
|
||||||
if (!$this->job->configuration['column-mapping-complete']) {
|
if (!$this->job->configuration['column-mapping-complete']) {
|
||||||
return 'import.csv.map';
|
return 'import.file.map';
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new FireflyException('No view for state');
|
throw new FireflyException('No view for state');
|
||||||
@@ -124,15 +128,17 @@ class CsvConfigurator implements ConfiguratorInterface
|
|||||||
public function isJobConfigured(): bool
|
public function isJobConfigured(): bool
|
||||||
{
|
{
|
||||||
$config = $this->job->configuration;
|
$config = $this->job->configuration;
|
||||||
|
$config['has-file-upload'] = $config['has-file-upload'] ?? false;
|
||||||
$config['initial-config-complete'] = $config['initial-config-complete'] ?? false;
|
$config['initial-config-complete'] = $config['initial-config-complete'] ?? false;
|
||||||
$config['column-roles-complete'] = $config['column-roles-complete'] ?? false;
|
$config['column-roles-complete'] = $config['column-roles-complete'] ?? false;
|
||||||
$config['column-mapping-complete'] = $config['column-mapping-complete'] ?? false;
|
$config['column-mapping-complete'] = $config['column-mapping-complete'] ?? false;
|
||||||
$this->job->configuration = $config;
|
$this->job->configuration = $config;
|
||||||
$this->job->save();
|
$this->job->save();
|
||||||
|
|
||||||
if ($this->job->configuration['initial-config-complete']
|
if ($config['initial-config-complete']
|
||||||
&& $this->job->configuration['column-roles-complete']
|
&& $config['column-roles-complete']
|
||||||
&& $this->job->configuration['column-mapping-complete']
|
&& $config['column-mapping-complete']
|
||||||
|
&& $config['has-file-upload']
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -162,6 +168,9 @@ class CsvConfigurator implements ConfiguratorInterface
|
|||||||
{
|
{
|
||||||
$class = false;
|
$class = false;
|
||||||
switch (true) {
|
switch (true) {
|
||||||
|
case !$this->job->configuration['has-file-upload']:
|
||||||
|
$class = Upload::class;
|
||||||
|
break;
|
||||||
case !$this->job->configuration['initial-config-complete']:
|
case !$this->job->configuration['initial-config-complete']:
|
||||||
$class = Initial::class;
|
$class = Initial::class;
|
||||||
break;
|
break;
|
@@ -20,14 +20,14 @@
|
|||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Import\Configurator;
|
namespace FireflyIII\Import\Configuration;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
||||||
use FireflyIII\Support\Import\Configuration\Spectre\SelectProvider;
|
|
||||||
use FireflyIII\Support\Import\Configuration\Spectre\InputMandatory;
|
use FireflyIII\Support\Import\Configuration\Spectre\InputMandatory;
|
||||||
use FireflyIII\Support\Import\Configuration\Spectre\SelectCountry;
|
use FireflyIII\Support\Import\Configuration\Spectre\SelectCountry;
|
||||||
|
use FireflyIII\Support\Import\Configuration\Spectre\SelectProvider;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,14 +123,16 @@ class SpectreConfigurator implements ConfiguratorInterface
|
|||||||
*/
|
*/
|
||||||
public function isJobConfigured(): bool
|
public function isJobConfigured(): bool
|
||||||
{
|
{
|
||||||
$config = $this->job->configuration;
|
$config = $this->job->configuration;
|
||||||
$config['selected-country'] = $config['selected-country'] ?? false;
|
$config['selected-country'] = $config['selected-country'] ?? false;
|
||||||
$config['selected-provider'] = $config['selected-provider'] ?? false;
|
$config['selected-provider'] = $config['selected-provider'] ?? false;
|
||||||
$config['has-input-mandatory'] = $config['has-input-mandatory'] ?? false;
|
$config['has-input-mandatory'] = $config['has-input-mandatory'] ?? false;
|
||||||
$this->job->configuration = $config;
|
$config['has-input-interactive'] = $config['has-input-interactive'] ?? true; // defaults to true.
|
||||||
|
$this->job->configuration = $config;
|
||||||
$this->job->save();
|
$this->job->save();
|
||||||
|
|
||||||
if ($config['selected-country'] && $config['selected-provider'] && $config['has-input-mandatory'] && false) {
|
if ($config['selected-country'] && $config['selected-provider'] && $config['has-input-mandatory'] && $config['has-input-interactive']) {
|
||||||
|
// give job another status
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Prerequisites;
|
namespace FireflyIII\Import\Prerequisites;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Services\Bunq\Id\DeviceServerId;
|
use FireflyIII\Services\Bunq\Id\DeviceServerId;
|
||||||
@@ -332,4 +332,4 @@ class BunqPrerequisites implements PrerequisitesInterface
|
|||||||
|
|
||||||
return $deviceServerId;
|
return $deviceServerId;
|
||||||
}
|
}
|
||||||
}
|
}
|
96
app/Import/Prerequisites/FilePrerequisites.php
Normal file
96
app/Import/Prerequisites/FilePrerequisites.php
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* FilePrerequisites.php
|
||||||
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Import\Prerequisites;
|
||||||
|
|
||||||
|
use FireflyIII\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains all the routines necessary to import from a file. Hint: there are none.
|
||||||
|
*/
|
||||||
|
class FilePrerequisites implements PrerequisitesInterface
|
||||||
|
{
|
||||||
|
/** @var User */
|
||||||
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns view name that allows user to fill in prerequisites. Currently asks for the API key.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getView(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns any values required for the prerequisites-view.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getViewParameters(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if this import method has any special prerequisites such as config
|
||||||
|
* variables or other things. The only thing we verify is the presence of the API key. Everything else
|
||||||
|
* tumbles into place: no installation token? Will be requested. No device server? Will be created. Etc.
|
||||||
|
*
|
||||||
|
* True if prerequisites. False if not.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasPrerequisites(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the user for this Prerequisites-routine. Class is expected to implement and save this.
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
*/
|
||||||
|
public function setUser(User $user): void
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method responds to the user's submission of an API key. It tries to register this instance as a new Firefly III device.
|
||||||
|
* If this fails, the error is returned in a message bag and the user is notified (this is fairly friendly).
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return MessageBag
|
||||||
|
*/
|
||||||
|
public function storePrerequisites(Request $request): MessageBag
|
||||||
|
{
|
||||||
|
return new MessageBag;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Prerequisites;
|
namespace FireflyIII\Import\Prerequisites;
|
||||||
|
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Prerequisites;
|
namespace FireflyIII\Import\Prerequisites;
|
||||||
|
|
||||||
use FireflyIII\Jobs\GetSpectreProviders;
|
use FireflyIII\Jobs\GetSpectreProviders;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
@@ -42,20 +42,16 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
|||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $fileType
|
* @param string $type
|
||||||
*
|
*
|
||||||
* @return ImportJob
|
* @return ImportJob
|
||||||
*
|
*
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function create(string $fileType): ImportJob
|
public function create(string $type): ImportJob
|
||||||
{
|
{
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$fileType = strtolower($fileType);
|
$type = strtolower($type);
|
||||||
$keys = array_keys(config('firefly.import_formats'));
|
|
||||||
if (!in_array($fileType, $keys)) {
|
|
||||||
throw new FireflyException(sprintf('Cannot use type "%s" for import job.', $fileType));
|
|
||||||
}
|
|
||||||
|
|
||||||
while ($count < 30) {
|
while ($count < 30) {
|
||||||
$key = Str::random(12);
|
$key = Str::random(12);
|
||||||
@@ -63,10 +59,10 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
|||||||
if (null === $existing->id) {
|
if (null === $existing->id) {
|
||||||
$importJob = new ImportJob;
|
$importJob = new ImportJob;
|
||||||
$importJob->user()->associate($this->user);
|
$importJob->user()->associate($this->user);
|
||||||
$importJob->file_type = $fileType;
|
$importJob->file_type = $type;
|
||||||
$importJob->key = Str::random(12);
|
$importJob->key = Str::random(12);
|
||||||
$importJob->status = 'new';
|
$importJob->status = 'new';
|
||||||
$importJob->configuration = [];
|
$importJob->configuration = config(sprintf('import.default_config.%s', $type)) ?? [];
|
||||||
$importJob->extended_status = [
|
$importJob->extended_status = [
|
||||||
'steps' => 0,
|
'steps' => 0,
|
||||||
'done' => 0,
|
'done' => 0,
|
||||||
@@ -80,8 +76,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
|||||||
}
|
}
|
||||||
++$count;
|
++$count;
|
||||||
}
|
}
|
||||||
|
throw new FireflyException('Could not create an import job with a unique key after 30 tries.');
|
||||||
return new ImportJob;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -32,11 +32,11 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
|
|||||||
interface ImportJobRepositoryInterface
|
interface ImportJobRepositoryInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param string $fileType
|
* @param string $type
|
||||||
*
|
*
|
||||||
* @return ImportJob
|
* @return ImportJob
|
||||||
*/
|
*/
|
||||||
public function create(string $fileType): ImportJob;
|
public function create(string $type): ImportJob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key
|
* @param string $key
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\Csv;
|
namespace FireflyIII\Support\Import\Configuration\File;
|
||||||
|
|
||||||
use ExpandedForm;
|
use ExpandedForm;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\Csv;
|
namespace FireflyIII\Support\Import\Configuration\File;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Import\Mapper\MapperInterface;
|
use FireflyIII\Import\Mapper\MapperInterface;
|
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Import\Configuration\Csv;
|
namespace FireflyIII\Support\Import\Configuration\File;
|
||||||
|
|
||||||
use FireflyIII\Import\Specifics\SpecificInterface;
|
use FireflyIII\Import\Specifics\SpecificInterface;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
89
app/Support/Import/Configuration/File/Upload.php
Normal file
89
app/Support/Import/Configuration/File/Upload.php
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Upload.php
|
||||||
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III.
|
||||||
|
*
|
||||||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Firefly III is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace FireflyIII\Support\Import\Configuration\File;
|
||||||
|
|
||||||
|
use FireflyIII\Import\Specifics\SpecificInterface;
|
||||||
|
use FireflyIII\Models\ImportJob;
|
||||||
|
use FireflyIII\Support\Import\Configuration\ConfigurationInterface;
|
||||||
|
use League\Csv\Reader;
|
||||||
|
use League\Csv\Statement;
|
||||||
|
use Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Upload.
|
||||||
|
*/
|
||||||
|
class Upload implements ConfigurationInterface
|
||||||
|
{
|
||||||
|
/** @var ImportJob */
|
||||||
|
private $job;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
private $warning = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data necessary to show the configuration screen.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getData(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return possible warning to user.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getWarningMessage(): string
|
||||||
|
{
|
||||||
|
return $this->warning;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ImportJob $job
|
||||||
|
*
|
||||||
|
* @return ConfigurationInterface
|
||||||
|
*/
|
||||||
|
public function setJob(ImportJob $job): ConfigurationInterface
|
||||||
|
{
|
||||||
|
$this->job = $job;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store the result.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function storeConfiguration(array $data): bool
|
||||||
|
{
|
||||||
|
echo 'do something with data.';
|
||||||
|
exit;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -44,18 +44,9 @@ return [
|
|||||||
'csv' => 'FireflyIII\Import\Configurator\CsvConfigurator',
|
'csv' => 'FireflyIII\Import\Configurator\CsvConfigurator',
|
||||||
'spectre' => '',
|
'spectre' => '',
|
||||||
],
|
],
|
||||||
'import_configurators' => [
|
|
||||||
'csv' => 'FireflyIII\Import\Configurator\CsvConfigurator',
|
|
||||||
'spectre' => 'FireflyIII\Import\Configurator\SpectreConfigurator',
|
|
||||||
],
|
|
||||||
'import_processors' => [
|
'import_processors' => [
|
||||||
'csv' => 'FireflyIII\Import\FileProcessor\CsvProcessor',
|
'csv' => 'FireflyIII\Import\FileProcessor\CsvProcessor',
|
||||||
],
|
],
|
||||||
'import_pre' => [
|
|
||||||
'bunq' => 'FireflyIII\Support\Import\Prerequisites\BunqPrerequisites',
|
|
||||||
'spectre' => 'FireflyIII\Support\Import\Prerequisites\SpectrePrerequisites',
|
|
||||||
'plaid' => 'FireflyIII\Support\Import\Prerequisites\PlaidPrerequisites',
|
|
||||||
],
|
|
||||||
'import_info' => [
|
'import_info' => [
|
||||||
'bunq' => 'FireflyIII\Support\Import\Information\BunqInformation',
|
'bunq' => 'FireflyIII\Support\Import\Information\BunqInformation',
|
||||||
'spectre' => 'FireflyIII\Support\Import\Information\SpectreInformation',
|
'spectre' => 'FireflyIII\Support\Import\Information\SpectreInformation',
|
||||||
|
42
config/import.php
Normal file
42
config/import.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'enabled' => [
|
||||||
|
'file' => true,
|
||||||
|
'bunq' => true,
|
||||||
|
'spectre' => true,
|
||||||
|
'plaid' => true,
|
||||||
|
],
|
||||||
|
'prerequisites' => [
|
||||||
|
'file' => 'FireflyIII\Import\Prerequisites\FilePrerequisites',
|
||||||
|
'bunq' => 'FireflyIII\Import\Prerequisites\BunqPrerequisites',
|
||||||
|
'spectre' => 'FireflyIII\Import\Prerequisites\SpectrePrerequisites',
|
||||||
|
'plaid' => 'FireflyIII\Import\Prerequisites\PlaidPrerequisites',
|
||||||
|
|
||||||
|
],
|
||||||
|
'configuration' => [
|
||||||
|
'file' => 'FireflyIII\Import\Configuration\FileConfigurator',
|
||||||
|
'bunq' => 'FireflyIII\Import\Configuration\BunqConfigurator',
|
||||||
|
'spectre' => 'FireflyIII\Import\Configuration\SpectreConfigurator',
|
||||||
|
'plaid' => 'FireflyIII\Import\Configuration\PlaidConfigurator',
|
||||||
|
],
|
||||||
|
'default_config' => [
|
||||||
|
'file' => [
|
||||||
|
'has-config-file' => true,
|
||||||
|
'auto-start' => false,
|
||||||
|
],
|
||||||
|
'bunq' => [
|
||||||
|
'has-config-file' => false,
|
||||||
|
'auto-start' => true,
|
||||||
|
],
|
||||||
|
'spectre' => [
|
||||||
|
'has-config-file' => false,
|
||||||
|
'auto-start' => true,
|
||||||
|
],
|
||||||
|
'plaid' => [
|
||||||
|
'has-config-file' => false,
|
||||||
|
'auto-start' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
BIN
public/images/logos/file.png
Normal file
BIN
public/images/logos/file.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
3
public/js/ff/import/status.js
vendored
3
public/js/ff/import/status.js
vendored
@@ -36,6 +36,9 @@ $(function () {
|
|||||||
"use strict";
|
"use strict";
|
||||||
timeOutId = setTimeout(checkImportStatus, startInterval);
|
timeOutId = setTimeout(checkImportStatus, startInterval);
|
||||||
$('.start-job').click(startJob);
|
$('.start-job').click(startJob);
|
||||||
|
if(autoStart) {
|
||||||
|
startJob();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1079,7 +1079,7 @@ return [
|
|||||||
'import_index_title' => 'Import data into Firefly III',
|
'import_index_title' => 'Import data into Firefly III',
|
||||||
'import_index_sub_title' => 'Index',
|
'import_index_sub_title' => 'Index',
|
||||||
'import_general_index_intro' => 'Welcome to Firefly\'s import routine. There are a few ways of importing data into Firefly III, displayed here as buttons.',
|
'import_general_index_intro' => 'Welcome to Firefly\'s import routine. There are a few ways of importing data into Firefly III, displayed here as buttons.',
|
||||||
'import_general_index_csv_file' => 'Import a (CSV) file',
|
'import_general_index_file' => 'Import a file',
|
||||||
'import_index_intro' => 'This routine will help you import files from your bank into Firefly III. Please check out the help pages in the top right corner.',
|
'import_index_intro' => 'This routine will help you import files from your bank into Firefly III. Please check out the help pages in the top right corner.',
|
||||||
'import_index_file' => 'Select your file',
|
'import_index_file' => 'Select your file',
|
||||||
'import_index_config' => 'If you have previously imported data into Firefly III, you may have a configuration file, which will pre-set configuration values for you. For some banks, other users have kindly provided their <a href="https://github.com/firefly-iii/import-configurations/wiki">configuration file</a>.',
|
'import_index_config' => 'If you have previously imported data into Firefly III, you may have a configuration file, which will pre-set configuration values for you. For some banks, other users have kindly provided their <a href="https://github.com/firefly-iii/import-configurations/wiki">configuration file</a>.',
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form class="form-horizontal" action="{{ route('import.file.process-configuration', job.key) }}" method="post" enctype="multipart/form-data">
|
<form class="form-horizontal" action="{{ route('import.configure.post', job.key) }}" method="post" enctype="multipart/form-data">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form action="{{ route('import.file.process-configuration', job.key) }}" method="post">
|
<form action="{{ route('import.configure.post', job.key) }}" method="post">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
|
|
||||||
{% for field in data %}
|
{% for field in data %}
|
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form action="{{ route('import.file.process-configuration', job.key) }}" method="post">
|
<form action="{{ route('import.configure.post', job.key) }}" method="post">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
<input type="hidden" name="settings" value="roles"/>
|
<input type="hidden" name="settings" value="roles"/>
|
||||||
|
|
@@ -53,12 +53,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<p>
|
<p>
|
||||||
{{ 'import_status_ready_text'|_ }}
|
{% if job.configuration['has-config-file'] == false %}
|
||||||
|
This should only be visible momentarily.
|
||||||
|
{% else %}
|
||||||
|
{{ 'import_status_ready_text'|_ }}
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<code>php artisan firefly:start-import {{ job.key }}</code>
|
<code>php artisan firefly:start-import {{ job.key }}</code>
|
||||||
</p>
|
</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
{% if job.configuration['has-config-file'] != false %}
|
||||||
<div class="col-lg-4">
|
<div class="col-lg-4">
|
||||||
<a href="{{ route('import.file.download', [job.key]) }}" class="btn btn-default"><i
|
<a href="{{ route('import.file.download', [job.key]) }}" class="btn btn-default"><i
|
||||||
class="fa fa-fw fa-download"></i> {{ 'import_status_ready_config'|_ }}</a>
|
class="fa fa-fw fa-download"></i> {{ 'import_status_ready_config'|_ }}</a>
|
||||||
@@ -66,13 +71,16 @@
|
|||||||
<div class="col-lg-4">
|
<div class="col-lg-4">
|
||||||
<button class="btn btn-success start-job"><i class="fa fa-fw fa-gears"></i> {{ 'import_status_ready_start'|_ }}</button>
|
<button class="btn btn-success start-job"><i class="fa fa-fw fa-gears"></i> {{ 'import_status_ready_start'|_ }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% if job.configuration['has-config-file'] != false %}
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<p class="text-info">
|
<p class="text-info">
|
||||||
{{ 'import_status_ready_share'|_ }}
|
{{ 'import_status_ready_share'|_ }}
|
||||||
</p>
|
</p>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -145,6 +153,11 @@
|
|||||||
var jobImportUrl = '{{ route('import.file.json', [job.key]) }}';
|
var jobImportUrl = '{{ route('import.file.json', [job.key]) }}';
|
||||||
var jobStartUrl = '{{ route('import.file.start', [job.key]) }}';
|
var jobStartUrl = '{{ route('import.file.start', [job.key]) }}';
|
||||||
var token = '{{ csrf_token() }}';
|
var token = '{{ csrf_token() }}';
|
||||||
|
{% if job.configuration['auto-start'] == true %}
|
||||||
|
var autoStart = true;
|
||||||
|
{% else %}
|
||||||
|
var autoStart = false;
|
||||||
|
{% endif %}
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="js/ff/import/status.js?v={{ FF_VERSION }}"></script>
|
<script type="text/javascript" src="js/ff/import/status.js?v={{ FF_VERSION }}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
53
resources/views/import/file/upload.twig
Normal file
53
resources/views/import/file/upload.twig
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
{% extends "./layout/default" %}
|
||||||
|
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
{{ Breadcrumbs.renderIfExists }}
|
||||||
|
{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<div class="box box-default">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">{{ 'import_index_title'|_ }}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-8">
|
||||||
|
<p>
|
||||||
|
{{ 'import_index_intro'|_ }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<form method="POST" action="{{ route('import.configure.post', job.key) }}" accept-charset="UTF-8" class="form-horizontal"
|
||||||
|
enctype="multipart/form-data">
|
||||||
|
|
||||||
|
<input name="_token" type="hidden" value="{{ csrf_token() }}">
|
||||||
|
|
||||||
|
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
|
||||||
|
|
||||||
|
{{ ExpandedForm.file('import_file', {helpText: 'import_index_file'|_}) }}
|
||||||
|
{{ ExpandedForm.file('configuration_file', {helpText: 'import_index_config'|_|raw}) }}
|
||||||
|
{{ ExpandedForm.select('import_file_type', importFileTypes, defaultImportType, {'helpText' : 'import_index_type'|_}) }}
|
||||||
|
|
||||||
|
<div class="form-group" id="import_file_holder">
|
||||||
|
<label for="ffInput_submit" class="col-sm-4 control-label"> </label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<button type="submit" class="btn pull-right btn-success">
|
||||||
|
{{ ('import_index_start')|_ }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
{% block scripts %}
|
||||||
|
{% endblock %}
|
||||||
|
{% block styles %}
|
||||||
|
{% endblock %}
|
@@ -21,39 +21,50 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{# file import #}
|
{# file import #}
|
||||||
<div class="col-lg-1 text-center">
|
{% if routines.file == true %}
|
||||||
<a href="{{ route('import.file.index') }}">
|
<div class="col-lg-1 text-center">
|
||||||
<img src="images/logos/csv.png" alt="bunq"/><br />
|
<a href="{{ route('import.prerequisites', ['file']) }}">
|
||||||
{{ 'import_general_index_csv_file'|_ }}
|
<img src="images/logos/file.png" alt="{{ 'import_general_index_file'|_ }}"/><br/>
|
||||||
|
{{ 'import_general_index_file'|_ }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{# bunq import #}
|
{# bunq import #}
|
||||||
<div class="col-lg-1 text-center">
|
{% if routines.bunq == true %}
|
||||||
<a href="{{ route('import.bank.prerequisites', ['bunq']) }}">
|
<div class="col-lg-1 text-center">
|
||||||
<img src="images/logos/bunq.png" alt="bunq"/><br />
|
<a href="{{ route('import.prerequisites', ['bunq']) }}">
|
||||||
|
<img src="images/logos/bunq.png" alt="{{ 'import_from_bunq'|_ }}"/><br/>
|
||||||
{{ 'import_from_bunq'|_ }}
|
{{ 'import_from_bunq'|_ }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{# import from Spectre #}
|
{# import from Spectre #}
|
||||||
<div class="col-lg-1 text-center">
|
{% if routines.spectre == true %}
|
||||||
<a href="{{ route('import.bank.prerequisites', ['spectre']) }}">
|
<div class="col-lg-1 text-center">
|
||||||
<img src="images/logos/spectre.png" alt="Spectre"/><br />
|
<a href="{{ route('import.prerequisites', ['spectre']) }}">
|
||||||
|
<img src="images/logos/spectre.png" alt="{{ 'import_using_spectre'|_ }}"/><br/>
|
||||||
{{ 'import_using_spectre'|_ }}
|
{{ 'import_using_spectre'|_ }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-1 text-center">
|
{% endif %}
|
||||||
{# import from Plaid #}
|
|
||||||
<a href="{{ route('import.bank.prerequisites', ['plaid']) }}">
|
{# import from Plaid #}
|
||||||
<img src="images/logos/plaid.png" alt="Plaid"/><br />
|
{% if routines.plaid == true %}
|
||||||
{{ 'import_using_plaid'|_ }}
|
<div class="col-lg-1 text-center">
|
||||||
</a>
|
<a href="{{ route('import.prerequisites', ['plaid']) }}">
|
||||||
</div>
|
<img src="images/logos/plaid.png" alt="{{ 'import_using_plaid'|_ }}"/><br/>
|
||||||
</div>
|
{{ 'import_using_plaid'|_ }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form class="form-horizontal" action="{{ route('import.file.process-configuration', job.key) }}" method="post">
|
<form class="form-horizontal" action="{{ route('import.configure.post', job.key) }}" method="post">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
<div class="box box-default">
|
<div class="box box-default">
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form class="form-horizontal" action="{{ route('import.file.process-configuration', job.key) }}" method="post">
|
<form class="form-horizontal" action="{{ route('import.configure.post', job.key) }}" method="post">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
<div class="box box-default">
|
<div class="box box-default">
|
||||||
|
@@ -5,12 +5,12 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form class="form-horizontal" action="{{ route('import.file.process-configuration', job.key) }}" method="post">
|
<form class="form-horizontal" action="{{ route('import.configure.post', job.key) }}" method="post">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
<div class="box box-default">
|
<div class="box box-default">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">{{ trans('bank.spectre_select_bank_title') }}</h3>
|
<h3 class="box-title">{{ trans('bank.spectre_select_provider_title') }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@@ -427,28 +427,30 @@ Route::group(
|
|||||||
Route::group(
|
Route::group(
|
||||||
['middleware' => 'user-full-auth', 'prefix' => 'import', 'as' => 'import.'], function () {
|
['middleware' => 'user-full-auth', 'prefix' => 'import', 'as' => 'import.'], function () {
|
||||||
|
|
||||||
Route::get('', ['uses' => 'ImportController@index', 'as' => 'index']);
|
Route::get('', ['uses' => 'Import\IndexController@index', 'as' => 'index']);
|
||||||
|
|
||||||
|
// import method prerequisites:
|
||||||
|
Route::get('prerequisites/{bank}', ['uses' => 'Import\PrerequisitesController@index', 'as' => 'prerequisites']);
|
||||||
|
Route::post('prerequisites/{bank}', ['uses' => 'Import\PrerequisitesController@post', 'as' => 'prerequisites.post']);
|
||||||
|
|
||||||
|
// create the job:
|
||||||
|
Route::get('create/{bank}', ['uses' => 'Import\IndexController@create', 'as' => 'create-job']);
|
||||||
|
|
||||||
|
// configure the job:
|
||||||
|
Route::get('configure/{importJob}', ['uses' => 'Import\ConfigurationController@index', 'as' => 'configure']);
|
||||||
|
Route::post('configure/{importJob}', ['uses' => 'Import\ConfigurationController@post', 'as' => 'configure.post']);
|
||||||
|
|
||||||
|
|
||||||
// file import
|
// file import
|
||||||
Route::get('file', ['uses' => 'Import\FileController@index', 'as' => 'file.index']);
|
// Route::get('file', ['uses' => 'Import\FileController@index', 'as' => 'file.index']);
|
||||||
Route::post('file/initialize', ['uses' => 'Import\FileController@initialize', 'as' => 'file.initialize']);
|
// Route::post('file/initialize', ['uses' => 'Import\FileController@initialize', 'as' => 'file.initialize']);
|
||||||
|
|
||||||
Route::get('file/configure/{importJob}', ['uses' => 'Import\FileController@configure', 'as' => 'file.configure']);
|
// Route::get('file/download/{importJob}', ['uses' => 'Import\FileController@download', 'as' => 'file.download']);
|
||||||
Route::post('file/configure/{importJob}', ['uses' => 'Import\FileController@postConfigure', 'as' => 'file.process-configuration']);
|
// Route::get('file/status/{importJob}', ['uses' => 'Import\FileController@status', 'as' => 'file.status']);
|
||||||
|
// Route::get('file/json/{importJob}', ['uses' => 'Import\FileController@json', 'as' => 'file.json']);
|
||||||
Route::get('file/download/{importJob}', ['uses' => 'Import\FileController@download', 'as' => 'file.download']);
|
// Route::any('file/start/{importJob}', ['uses' => 'Import\FileController@start', 'as' => 'file.start']);
|
||||||
Route::get('file/status/{importJob}', ['uses' => 'Import\FileController@status', 'as' => 'file.status']);
|
// Route:: get('bank/{bank}/configure/{importJob}', ['uses' => 'Import\BankController@configure', 'as' => 'bank.configure']);
|
||||||
Route::get('file/json/{importJob}', ['uses' => 'Import\FileController@json', 'as' => 'file.json']);
|
// Route::post('bank/{bank}/configure/{importJob}', ['uses' => 'Import\BankController@postConfigure', 'as' => 'bank.configure.post']);
|
||||||
Route::post('file/start/{importJob}', ['uses' => 'Import\FileController@start', 'as' => 'file.start']);
|
|
||||||
|
|
||||||
// banks:
|
|
||||||
Route::get('bank/{bank}/prerequisites', ['uses' => 'Import\BankController@prerequisites', 'as' => 'bank.prerequisites']);
|
|
||||||
Route::post('bank/{bank}/prerequisites', ['uses' => 'Import\BankController@postPrerequisites', 'as' => 'bank.prerequisites.post']);
|
|
||||||
|
|
||||||
Route::get('bank/{bank}/create', ['uses' => 'Import\BankController@createJob', 'as' => 'bank.create-job']);
|
|
||||||
Route:: get('bank/{bank}/configure/{importJob}', ['uses' => 'Import\BankController@configure', 'as' => 'bank.configure']);
|
|
||||||
Route::post('bank/{bank}/configure/{importJob}', ['uses' => 'Import\BankController@postConfigure', 'as' => 'bank.configure.post']);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user