API Decouplng Part 2
removed all remaining API requests from the front end and removed the FipamoAdminAPI js file, changing it to ContentRequest as it now handles posting data to the system directly, authenticating it self by checking the embedded CSRF token that regulary rotates also renamed MaintenanceManager to Maintenance request and moved it to the same dir as ContentRequest as they are both libraries that connect to the backend
This commit is contained in:
parent
3d17771f76
commit
c5afbb9131
15 changed files with 176 additions and 132 deletions
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Interfaces\MemberRepositoryInterface;
|
use App\Interfaces\MemberRepositoryInterface;
|
||||||
|
use App\Services\Data\SettingsService;
|
||||||
|
|
||||||
class RouteGetController extends Controller
|
class RouteGetController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -11,6 +12,7 @@ class RouteGetController extends Controller
|
||||||
protected $theme;
|
protected $theme;
|
||||||
protected $front;
|
protected $front;
|
||||||
protected $member;
|
protected $member;
|
||||||
|
protected $settings;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
DashController $dashController,
|
DashController $dashController,
|
||||||
|
@ -18,12 +20,14 @@ class RouteGetController extends Controller
|
||||||
ThemeController $themeController,
|
ThemeController $themeController,
|
||||||
FrontController $frontController,
|
FrontController $frontController,
|
||||||
MemberRepositoryInterface $memberRepo,
|
MemberRepositoryInterface $memberRepo,
|
||||||
|
SettingsService $settingsService,
|
||||||
) {
|
) {
|
||||||
$this->dash = $dashController;
|
$this->dash = $dashController;
|
||||||
$this->gate = $authController;
|
$this->gate = $authController;
|
||||||
$this->theme = $themeController;
|
$this->theme = $themeController;
|
||||||
$this->front = $frontController;
|
$this->front = $frontController;
|
||||||
$this->member = $memberRepo;
|
$this->member = $memberRepo;
|
||||||
|
$this->settings = $settingsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleRequest($first = null, $second = null, $third = null, $fourth = null)
|
public function handleRequest($first = null, $second = null, $third = null, $fourth = null)
|
||||||
|
@ -52,9 +56,33 @@ class RouteGetController extends Controller
|
||||||
case 'archives':
|
case 'archives':
|
||||||
return $this->front->page($first, $second, $third);
|
return $this->front->page($first, $second, $third);
|
||||||
break;
|
break;
|
||||||
|
case 'backup':
|
||||||
|
return $this->downloadBackup($second);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return $this->front->index($first, $second, $third);
|
return $this->front->index($first, $second, $third);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function downloadBackup($type)
|
||||||
|
{
|
||||||
|
if ($this->member::status()) {
|
||||||
|
$latest = '';
|
||||||
|
$file = '';
|
||||||
|
if ($type == 'content-download') {
|
||||||
|
$latest = $this->settings->getGlobal()['last_content_backup'];
|
||||||
|
$file = 'backup-content-' . $latest . '.zip';
|
||||||
|
} else {
|
||||||
|
$latest = $this->settings->getGlobal()['last_files_backup'];
|
||||||
|
$file = 'backup-files-' . $latest . '.zip';
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->download(
|
||||||
|
'../content/backups/' . $file,
|
||||||
|
$file,
|
||||||
|
['Content-Type: application/zip']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,23 +6,51 @@ use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use App\Mail\SystemEmail;
|
use App\Mail\SystemEmail;
|
||||||
use App\Interfaces\PageRepositoryInterface;
|
use App\Interfaces\PageRepositoryInterface;
|
||||||
|
use App\Services\Upkeep\MaintenanceService;
|
||||||
|
use App\Services\Assets\FileUploadService;
|
||||||
|
use App\Interfaces\MemberRepositoryInterface;
|
||||||
|
use App\Services\Data\SettingsService;
|
||||||
|
use App\Services\UpKeep\InitService;
|
||||||
|
use App\Services\UpKeep\ResetService;
|
||||||
|
|
||||||
class RoutePostController extends Controller
|
class RoutePostController extends Controller
|
||||||
{
|
{
|
||||||
protected $page;
|
protected $page;
|
||||||
|
protected $gate;
|
||||||
|
protected $maintenance;
|
||||||
|
protected $upload;
|
||||||
|
protected $settings;
|
||||||
|
protected $member;
|
||||||
|
protected $init;
|
||||||
|
protected $reset;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
PageRepositoryInterface $pageRepo,
|
PageRepositoryInterface $pageRepo,
|
||||||
AuthController $authController,
|
AuthController $authController,
|
||||||
|
MaintenanceService $maintenanceService,
|
||||||
|
FileUploadService $fileUploadService,
|
||||||
|
SettingsService $settingsService,
|
||||||
|
MemberRepositoryInterface $memberRepo,
|
||||||
|
InitService $initService,
|
||||||
|
ResetService $resetService,
|
||||||
) {
|
) {
|
||||||
$this->page = $pageRepo;
|
$this->page = $pageRepo;
|
||||||
$this->gate = $authController;
|
$this->gate = $authController;
|
||||||
|
$this->maintenance = $maintenanceService;
|
||||||
|
$this->upload = $fileUploadService;
|
||||||
|
$this->settings = $settingsService;
|
||||||
|
$this->member = $memberRepo;
|
||||||
|
$this->init = $initService;
|
||||||
|
$this->reset = $resetService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleRequest(Request $request)
|
public function handleRequest(Request $request)
|
||||||
{
|
{
|
||||||
$path = explode('/', $request->path());
|
$path = explode('/', $request->path());
|
||||||
switch ($path[0]) {
|
switch ($path[0]) {
|
||||||
|
case 'init':
|
||||||
|
return $this->initTask($path[1], $request);
|
||||||
|
break;
|
||||||
case 'login':
|
case 'login':
|
||||||
return $this->gate->enter($request);
|
return $this->gate->enter($request);
|
||||||
break;
|
break;
|
||||||
|
@ -36,9 +64,44 @@ class RoutePostController extends Controller
|
||||||
return $this->sendNotify($request);
|
return $this->sendNotify($request);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'upload':
|
||||||
|
$type = null;
|
||||||
|
$result = $result = $this->upload->handleFile($request, $type);
|
||||||
|
//update configs for specfic uploads
|
||||||
|
switch ($request['source']) {
|
||||||
|
case 'avatar-upload':
|
||||||
|
$member = [];
|
||||||
|
$member = session('member');
|
||||||
|
$member['avatar'] = $result['filePath'];
|
||||||
|
$member = (object) $member;
|
||||||
|
$this->member->update($member);
|
||||||
|
break;
|
||||||
|
case 'background-upload':
|
||||||
|
$this->settings->updateGlobalData('background', $result['filePath']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function initTask($task, $request)
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
switch ($task) {
|
||||||
|
case 'fresh':
|
||||||
|
$result = $this->init->fresh(json_decode($request->getContent()));
|
||||||
|
break;
|
||||||
|
case 'restore':
|
||||||
|
$result = $this->init->restore($request);
|
||||||
|
break;
|
||||||
|
case 'reset':
|
||||||
|
$result = $this->reset->site($request);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return response()->json($result)->header('Content-Type', 'application/json');
|
||||||
|
}
|
||||||
|
|
||||||
private function sendNotify($request)
|
private function sendNotify($request)
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
|
@ -7,6 +7,7 @@ use App\Services\Assets\AssetService;
|
||||||
use App\Services\Assets\RenderService;
|
use App\Services\Assets\RenderService;
|
||||||
use App\Interfaces\MemberRepositoryInterface;
|
use App\Interfaces\MemberRepositoryInterface;
|
||||||
use App\Services\Data\SettingsService;
|
use App\Services\Data\SettingsService;
|
||||||
|
use App\Services\Upkeep\MaintenanceService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class RoutePutController extends Controller
|
class RoutePutController extends Controller
|
||||||
|
@ -16,6 +17,7 @@ class RoutePutController extends Controller
|
||||||
protected $render;
|
protected $render;
|
||||||
protected $settings;
|
protected $settings;
|
||||||
protected $member;
|
protected $member;
|
||||||
|
protected $maintenance;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
PageRepositoryInterface $pageRepo,
|
PageRepositoryInterface $pageRepo,
|
||||||
|
@ -23,12 +25,14 @@ class RoutePutController extends Controller
|
||||||
RenderService $renderService,
|
RenderService $renderService,
|
||||||
SettingsService $settingsService,
|
SettingsService $settingsService,
|
||||||
MemberRepositoryInterface $memberRepo,
|
MemberRepositoryInterface $memberRepo,
|
||||||
|
MaintenanceService $maintenanceService,
|
||||||
) {
|
) {
|
||||||
$this->page = $pageRepo;
|
$this->page = $pageRepo;
|
||||||
$this->assets = $assetService;
|
$this->assets = $assetService;
|
||||||
$this->render = $renderService;
|
$this->render = $renderService;
|
||||||
$this->settings = $settingsService;
|
$this->settings = $settingsService;
|
||||||
$this->member = $memberRepo;
|
$this->member = $memberRepo;
|
||||||
|
$this->maintenance = $maintenanceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleRequest(Request $request)
|
public function handleRequest(Request $request)
|
||||||
|
@ -43,6 +47,23 @@ class RoutePutController extends Controller
|
||||||
case 'settings':
|
case 'settings':
|
||||||
return $this->settingsTasks($request, $path[1]);
|
return $this->settingsTasks($request, $path[1]);
|
||||||
break;
|
break;
|
||||||
|
case 'backup':
|
||||||
|
return $this->createBackup($request);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createBackup($request)
|
||||||
|
{
|
||||||
|
$body = json_decode($request->getContent());
|
||||||
|
if ($body->task == 'content_backup') {
|
||||||
|
return response()->json(
|
||||||
|
$this->maintenance->createContentBackUp()
|
||||||
|
)->header('Content-Type', 'application/json');
|
||||||
|
} else {
|
||||||
|
return response()->json(
|
||||||
|
$this->maintenance->createFileBackUp()
|
||||||
|
)->header('Content-Type', 'application/json');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class MaintenanceService
|
||||||
public function createContentBackUp()
|
public function createContentBackUp()
|
||||||
{
|
{
|
||||||
//make sure back directory is there
|
//make sure back directory is there
|
||||||
$stamp = Carbon::now()->format("YmdGis");
|
$stamp = Carbon::now()->format("YmdHis");
|
||||||
if (!is_dir(env('FIPAMO_BACKUPS'))) {
|
if (!is_dir(env('FIPAMO_BACKUPS'))) {
|
||||||
mkdir(env('FIPAMO_BACKUPS'), 0755, true);
|
mkdir(env('FIPAMO_BACKUPS'), 0755, true);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ class MaintenanceService
|
||||||
|
|
||||||
public function createFileBackUp()
|
public function createFileBackUp()
|
||||||
{
|
{
|
||||||
$stamp = Carbon::now()->format("YmdGis");
|
$stamp = Carbon::now()->format("YmdHis");
|
||||||
$zip = new \ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$zip->open(
|
$zip->open(
|
||||||
env('FIPAMO_BACKUPS') . '/backup-files-' . $stamp . '.zip',
|
env('FIPAMO_BACKUPS') . '/backup-files-' . $stamp . '.zip',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import FipamoAdminAPI from '../../libraries/FipamoAdminAPI.js';
|
import ContentRequest from '../../libraries/ContentRequest.js';
|
||||||
import Notficaton from '../ui/Notifications.js';
|
import Notficaton from '../ui/Notifications.js';
|
||||||
const notify = new Notficaton();
|
const notify = new Notficaton();
|
||||||
export default class Mailer {
|
export default class Mailer {
|
||||||
|
@ -20,7 +20,7 @@ export default class Mailer {
|
||||||
content: text,
|
content: text,
|
||||||
mail_task: task
|
mail_task: task
|
||||||
};
|
};
|
||||||
let admin = new FipamoAdminAPI();
|
let admin = new ContentRequest();
|
||||||
admin
|
admin
|
||||||
.sendMail(mailData)
|
.sendMail(mailData)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
import PostIndex from './PostIndex';
|
|
||||||
import SettingsIndex from './SettingsIndex';
|
|
||||||
import NaviIndex from './NavIndex';
|
|
||||||
import Menu from '../ui/Menu';
|
|
||||||
|
|
||||||
export default class DashManager {
|
|
||||||
//--------------------------
|
|
||||||
// constructor
|
|
||||||
//--------------------------
|
|
||||||
constructor() {
|
|
||||||
this.currentDisplay = '';
|
|
||||||
this.urlPieces = document.URL.split('/');
|
|
||||||
this.chooseDisplay(this.urlPieces[4], this.urlPieces[5]);
|
|
||||||
//start main menu handler
|
|
||||||
new Menu();
|
|
||||||
}
|
|
||||||
//--------------------------
|
|
||||||
// methods
|
|
||||||
//--------------------------
|
|
||||||
start() {}
|
|
||||||
|
|
||||||
chooseDisplay(section, page) {
|
|
||||||
this.currentDisplay = '';
|
|
||||||
switch (section) {
|
|
||||||
case 'page':
|
|
||||||
this.currentDisplay = new PostIndex(page);
|
|
||||||
break;
|
|
||||||
case 'settings':
|
|
||||||
this.currentDisplay = new SettingsIndex();
|
|
||||||
break;
|
|
||||||
case 'navigation':
|
|
||||||
this.currentDisplay = new NaviIndex();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
//just chill
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.start();
|
|
||||||
}
|
|
||||||
//--------------------------
|
|
||||||
// event handlers
|
|
||||||
//--------------------------
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
import FipamoAdminAPI from '../../libraries/FipamoAdminAPI.js';
|
import ContentRequest from '../../libraries/ContentRequest.js';
|
||||||
import Maintenance from './MaintenanceManager.js';
|
import Maintenance from '../../libraries/MaintenanceRequest.js';
|
||||||
import DataUitls from '../utils/DataUtils.js';
|
import DataUitls from '../utils/DataUtils.js';
|
||||||
import * as DataEvent from '../events/DataEvent.js';
|
import * as DataEvent from '../events/DataEvent.js';
|
||||||
import Notfications from '../ui/Notifications.js';
|
import Notfications from '../ui/Notifications.js';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import FipamoAdminAPI, { TASK_SYNC_NAV } from '../../libraries/FipamoAdminAPI.js';
|
import ContentRequest, { TASK_SYNC_NAV } from '../../libraries/ContentRequest.js';
|
||||||
import NavActions from '../actions/NavActions.js';
|
import NavActions from '../actions/NavActions.js';
|
||||||
import * as DataEvent from '../events/DataEvent.js';
|
import * as DataEvent from '../events/DataEvent.js';
|
||||||
import Notifications from '../ui/Notifications.js';
|
import Notifications from '../ui/Notifications.js';
|
||||||
|
@ -11,7 +11,7 @@ export default class NavIndex {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {
|
constructor() {
|
||||||
this.processing = false;
|
this.processing = false;
|
||||||
this.admin = new FipamoAdminAPI(null);
|
this.cr = new ContentRequest(null);
|
||||||
this.start();
|
this.start();
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -24,7 +24,7 @@ export default class NavIndex {
|
||||||
onUpdate: () => {
|
onUpdate: () => {
|
||||||
new NavActions().syncMenu().then(data => {
|
new NavActions().syncMenu().then(data => {
|
||||||
notify.alert('Updating Menu', null);
|
notify.alert('Updating Menu', null);
|
||||||
self.admin.sync(TASK_SYNC_NAV, data).then(r => {
|
self.cr.sync(TASK_SYNC_NAV, data).then(r => {
|
||||||
if (r.type == DataEvent.MENU_UPDATED) {
|
if (r.type == DataEvent.MENU_UPDATED) {
|
||||||
notify.alert(r.message, true);
|
notify.alert(r.message, true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,7 +55,7 @@ export default class NavIndex {
|
||||||
data.remove = e.target.getAttribute('data-uuid');
|
data.remove = e.target.getAttribute('data-uuid');
|
||||||
notify.alert('Editing Menu', null);
|
notify.alert('Editing Menu', null);
|
||||||
self.processing = true;
|
self.processing = true;
|
||||||
self.admin.sync(TASK_SYNC_NAV, data).then(r => {
|
self.cr.sync(TASK_SYNC_NAV, data).then(r => {
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
if (r.type == DataEvent.MENU_UPDATED) {
|
if (r.type == DataEvent.MENU_UPDATED) {
|
||||||
notify.alert(r.message, true);
|
notify.alert(r.message, true);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
//TOOLS
|
//TOOLS
|
||||||
import FipamoAdminAPI, {
|
import ContentRequest, {
|
||||||
TASK_PAGE_CREATE,
|
TASK_PAGE_CREATE,
|
||||||
TASK_PAGE_EDIT,
|
TASK_PAGE_EDIT,
|
||||||
TASK_PAGE_DELETE
|
TASK_PAGE_DELETE
|
||||||
} from '../../libraries/FipamoAdminAPI.js';
|
} from '../../libraries/ContentRequest.js';
|
||||||
import Maintenance from './MaintenanceManager.js';
|
import Maintenance from '../../libraries/MaintenanceRequest.js';
|
||||||
import * as DataEvent from '../events/DataEvent.js';
|
import * as DataEvent from '../events/DataEvent.js';
|
||||||
import PageActions from '../actions/PageActions.js';
|
import PageActions from '../actions/PageActions.js';
|
||||||
import * as EditorEvent from '../events/EditorEvent.js';
|
import * as EditorEvent from '../events/EditorEvent.js';
|
||||||
|
@ -19,8 +19,8 @@ export default class PostEditor {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.processing = false;
|
this.processing = false;
|
||||||
let self = 'this';
|
let self = 'this';
|
||||||
this.admin = new FipamoAdminAPI(null, document.getElementById('notify-progress'));
|
this.cr = new ContentRequest(null, document.getElementById('notify-progress'));
|
||||||
this.mm = new Maintenance(null, null);
|
this.mr = new Maintenance(null, null);
|
||||||
this.urlPieces = document.URL.split('/');
|
this.urlPieces = document.URL.split('/');
|
||||||
this.post = [];
|
this.post = [];
|
||||||
this.postID = null;
|
this.postID = null;
|
||||||
|
@ -145,7 +145,7 @@ export default class PostEditor {
|
||||||
new PageActions().collectInfo(this.fm.getFileOrder()).then(page => {
|
new PageActions().collectInfo(this.fm.getFileOrder()).then(page => {
|
||||||
self.processing = true;
|
self.processing = true;
|
||||||
notify.alert('Writing down changes', null);
|
notify.alert('Writing down changes', null);
|
||||||
self.admin
|
self.cr
|
||||||
.pageActions(task, page)
|
.pageActions(task, page)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
|
@ -179,7 +179,7 @@ export default class PostEditor {
|
||||||
.collectInfo(this.fm.getFileOrder())
|
.collectInfo(this.fm.getFileOrder())
|
||||||
.then(page => {
|
.then(page => {
|
||||||
self.processing = true;
|
self.processing = true;
|
||||||
this.admin
|
this.cr
|
||||||
.pageActions(TASK_PAGE_DELETE, page)
|
.pageActions(TASK_PAGE_DELETE, page)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
|
@ -207,7 +207,7 @@ export default class PostEditor {
|
||||||
let upload = new FormData();
|
let upload = new FormData();
|
||||||
upload.enctype = 'multipart/form-data';
|
upload.enctype = 'multipart/form-data';
|
||||||
upload.append('upload_files[]', files[0], files[0].name);
|
upload.append('upload_files[]', files[0], files[0].name);
|
||||||
this.mm
|
this.mr
|
||||||
.filesUpload(files[0].type, upload)
|
.filesUpload(files[0].type, upload)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.message == 'File Uploaded. Great!') {
|
if (result.message == 'File Uploaded. Great!') {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import SettingsActions from '../actions/SettingsActions.js';
|
import SettingsActions from '../actions/SettingsActions.js';
|
||||||
import Maintenance from './MaintenanceManager.js';
|
import Maintenance from '../../libraries/MaintenanceRequest.js';
|
||||||
import FipamoAdminAPI, { TASK_SYNC_SETTNIGS } from '../../libraries/FipamoAdminAPI.js';
|
import ContentRequest, { TASK_SYNC_SETTNIGS } from '../../libraries/ContentRequest.js';
|
||||||
import * as DataEvent from '../../../dash/app/events/DataEvent.js';
|
import * as DataEvent from '../../../dash/app/events/DataEvent.js';
|
||||||
import Mailer from '../actions/Mailer.js';
|
import Mailer from '../actions/Mailer.js';
|
||||||
import Notifications from '../ui/Notifications.js';
|
import Notifications from '../ui/Notifications.js';
|
||||||
|
@ -12,8 +12,8 @@ export default class SettingsIndex {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.processing = false;
|
this.processing = false;
|
||||||
this.start();
|
this.start();
|
||||||
this.admin = new FipamoAdminAPI(null);
|
this.cr = new ContentRequest(null);
|
||||||
this.mm = new Maintenance(null, null);
|
this.mr = new Maintenance(null, null);
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// methods
|
// methods
|
||||||
|
@ -26,7 +26,7 @@ export default class SettingsIndex {
|
||||||
.getInfo()
|
.getInfo()
|
||||||
.then(data => {
|
.then(data => {
|
||||||
notify.alert('Saving Settings', null);
|
notify.alert('Saving Settings', null);
|
||||||
self.admin.sync(TASK_SYNC_SETTNIGS, data).then(r => {
|
self.cr.sync(TASK_SYNC_SETTNIGS, data).then(r => {
|
||||||
if (r.type == DataEvent.SETTINGS_UPDATED) {
|
if (r.type == DataEvent.SETTINGS_UPDATED) {
|
||||||
notify.alert(r.message, true);
|
notify.alert(r.message, true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -98,7 +98,7 @@ export default class SettingsIndex {
|
||||||
'This cannot be undone, so please confirm.'
|
'This cannot be undone, so please confirm.'
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
this.mm
|
this.mr
|
||||||
.reset()
|
.reset()
|
||||||
.then(r => {
|
.then(r => {
|
||||||
if (r.type == 'COOL') {
|
if (r.type == 'COOL') {
|
||||||
|
@ -223,7 +223,7 @@ export default class SettingsIndex {
|
||||||
upload.append('source', type);
|
upload.append('source', type);
|
||||||
upload.append('upload_files[]', files[0], files[0].name);
|
upload.append('upload_files[]', files[0], files[0].name);
|
||||||
|
|
||||||
this.mm
|
this.mr
|
||||||
.filesUpload(files[0].type, upload)
|
.filesUpload(files[0].type, upload)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
if (type == 'avatar-upload') {
|
if (type == 'avatar-upload') {
|
||||||
|
@ -248,7 +248,7 @@ export default class SettingsIndex {
|
||||||
let task = { task: 'PUBLISH_ALL' };
|
let task = { task: 'PUBLISH_ALL' };
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
notify.alert('Publishing site...', null);
|
notify.alert('Publishing site...', null);
|
||||||
this.admin
|
this.cr
|
||||||
.publish(task)
|
.publish(task)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
|
@ -274,7 +274,7 @@ export default class SettingsIndex {
|
||||||
notify.alert('Creating File Backup', null);
|
notify.alert('Creating File Backup', null);
|
||||||
type = { task: 'file_backup' };
|
type = { task: 'file_backup' };
|
||||||
}
|
}
|
||||||
this.mm
|
this.mr
|
||||||
.backup(type)
|
.backup(type)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
notify.alert(r.message, true);
|
notify.alert(r.message, true);
|
||||||
|
@ -292,7 +292,7 @@ export default class SettingsIndex {
|
||||||
let task = { task: 'cleanup pages indexes' };
|
let task = { task: 'cleanup pages indexes' };
|
||||||
this.processing = true;
|
this.processing = true;
|
||||||
notify.alert('Cleaning up page indexes', null);
|
notify.alert('Cleaning up page indexes', null);
|
||||||
this.admin
|
this.cr
|
||||||
.handleReindex(task)
|
.handleReindex(task)
|
||||||
.then(r => {
|
.then(r => {
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Sortable from '../vendor/sortable.core.esm.js';
|
||||||
import anime from '../vendor/anime.es.js';
|
import anime from '../vendor/anime.es.js';
|
||||||
import DataUtils from '../utils/DataUtils.js';
|
import DataUtils from '../utils/DataUtils.js';
|
||||||
import Notfications from './Notifications.js';
|
import Notfications from './Notifications.js';
|
||||||
import Maintenance from '../controllers/MaintenanceManager.js';
|
import Maintenance from '../../libraries/MaintenanceRequest.js';
|
||||||
const notify = new Notfications();
|
const notify = new Notfications();
|
||||||
|
|
||||||
export default class FileManager {
|
export default class FileManager {
|
||||||
|
@ -10,7 +10,7 @@ export default class FileManager {
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor(upload, input, imageList, fileList) {
|
constructor(upload, input, imageList, fileList) {
|
||||||
this.mm = new Maintenance(null, null, document.getElementById('notify-progress'));
|
this.mr = new Maintenance(null, null, document.getElementById('notify-progress'));
|
||||||
this.upload = upload;
|
this.upload = upload;
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.imageList = imageList;
|
this.imageList = imageList;
|
||||||
|
@ -115,7 +115,7 @@ export default class FileManager {
|
||||||
progress = document.getElementById(
|
progress = document.getElementById(
|
||||||
'pgs' + item.getAttribute('id')
|
'pgs' + item.getAttribute('id')
|
||||||
);
|
);
|
||||||
self.mm
|
self.mr
|
||||||
.filesUpload(theFile.type, upload, progress)
|
.filesUpload(theFile.type, upload, progress)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
item.setAttribute('data-id', result.filePath);
|
item.setAttribute('data-id', result.filePath);
|
||||||
|
@ -140,7 +140,7 @@ export default class FileManager {
|
||||||
progress = document.getElementById(
|
progress = document.getElementById(
|
||||||
'pgs' + item.getAttribute('id')
|
'pgs' + item.getAttribute('id')
|
||||||
);
|
);
|
||||||
self.mm
|
self.mr
|
||||||
.filesUpload(theFile.type, upload, progress)
|
.filesUpload(theFile.type, upload, progress)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
item.setAttribute('data-id', result.filePath);
|
item.setAttribute('data-id', result.filePath);
|
||||||
|
@ -166,7 +166,7 @@ export default class FileManager {
|
||||||
progress = document.getElementById(
|
progress = document.getElementById(
|
||||||
'pgs' + item.getAttribute('id')
|
'pgs' + item.getAttribute('id')
|
||||||
);
|
);
|
||||||
self.mm
|
self.mr
|
||||||
.filesUpload(theFile.type, upload, progress)
|
.filesUpload(theFile.type, upload, progress)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
item.setAttribute('data-id', result.filePath);
|
item.setAttribute('data-id', result.filePath);
|
||||||
|
@ -195,7 +195,7 @@ export default class FileManager {
|
||||||
progress = document.getElementById(
|
progress = document.getElementById(
|
||||||
'pgs' + item.getAttribute('id')
|
'pgs' + item.getAttribute('id')
|
||||||
);
|
);
|
||||||
self.mm
|
self.mr
|
||||||
.filesUpload(theFile.type, upload, progress)
|
.filesUpload(theFile.type, upload, progress)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
item.setAttribute('data-id', result.filePath);
|
item.setAttribute('data-id', result.filePath);
|
||||||
|
|
|
@ -41,7 +41,7 @@ export const API_ACCESS_BAD = 'apiUseNotAuthorized';
|
||||||
* A can of methods used to edit install settings, navigation pages and content pages
|
* A can of methods used to edit install settings, navigation pages and content pages
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class FipamoAdminAPI {
|
class ContentRequest {
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {string} baseURL - url of site; uses local when empty
|
* @param {string} baseURL - url of site; uses local when empty
|
||||||
|
@ -413,4 +413,4 @@ class FipamoAdminAPI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { FipamoAdminAPI as default };
|
export { ContentRequest as default };
|
|
@ -7,19 +7,16 @@ export const REQUEST_TYPE_DELETE = 'DELETE';
|
||||||
export const CONTENT_TYPE_JSON = 'json';
|
export const CONTENT_TYPE_JSON = 'json';
|
||||||
export const CONTENT_TYPE_FORM = 'x-www-form-urlencoded';
|
export const CONTENT_TYPE_FORM = 'x-www-form-urlencoded';
|
||||||
//** API URLS **//
|
//** API URLS **//
|
||||||
export const API_STATUS = '/api/v1/status';
|
export const API_INIT = '/init/fresh';
|
||||||
export const API_INIT = '/api/v1/init';
|
export const API_RESTORE = '/init/restore';
|
||||||
export const API_RESTORE = '/api/v1/restore';
|
export const API_RESET = '/init/reset';
|
||||||
export const API_RESET = '/api/v1/reset';
|
export const API_CREATE_BACKUP = '/backup/create';
|
||||||
export const API_GET_SECRET = '/api/v1/get-secret';
|
export const API_DOWNLOAD_BACKUP = '/backup/download';
|
||||||
export const API_RESET_PASS = '/api/v1/reset-password';
|
export const API_RESTORE_BACKUP = '/backup/restore';
|
||||||
export const API_CREATE_BACKUP = '/api/v1/backup/create';
|
export const API_FILES_UPLOAD = '/upload/files';
|
||||||
export const API_DOWNLOAD_BACKUP = '/api/v1/backup/download';
|
|
||||||
export const API_RESTORE_BACKUP = '/api/v1/backup/restore';
|
//export const API_RESET_PASS = '/api/v1/reset-password';
|
||||||
export const API_UPLOAD_AVATAR = '/api/v1/settings/add-avatar';
|
|
||||||
export const API_UPLOAD_BACKGROUND = '/api/v1/settings/add-feature-background';
|
|
||||||
export const API_IMAGE_UPLOAD = '/api/v1/page/add-entry-image';
|
|
||||||
export const API_FILES_UPLOAD = '/api/v1/files';
|
|
||||||
//** API TASKS **//
|
//** API TASKS **//
|
||||||
export const TASK_SITE_INIT = 'blogInit';
|
export const TASK_SITE_INIT = 'blogInit';
|
||||||
export const TASK_BACKUP_RESTORE = 'restoreBackup';
|
export const TASK_BACKUP_RESTORE = 'restoreBackup';
|
||||||
|
@ -58,19 +55,6 @@ class MaintenanceManager {
|
||||||
this.key = null;
|
this.key = null;
|
||||||
if (key) this.key = key;
|
if (key) this.key = key;
|
||||||
if (baseURL) this.baseURL = baseURL;
|
if (baseURL) this.baseURL = baseURL;
|
||||||
//if key is valid, checks to see if a session is active and returns
|
|
||||||
this._request(
|
|
||||||
this.baseURL
|
|
||||||
? this.baseURL + API_STATUS + '?key=' + this.key
|
|
||||||
: API_STATUS + '?key=' + this.key
|
|
||||||
).then(response => {
|
|
||||||
if (response.type === API_ACCESS_GOOD) {
|
|
||||||
this.token = response.token;
|
|
||||||
} else {
|
|
||||||
//don't set token
|
|
||||||
//console.log("NO TOKEN");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -271,6 +255,10 @@ class MaintenanceManager {
|
||||||
self.handleLoadProgress(e, progressBar)
|
self.handleLoadProgress(e, progressBar)
|
||||||
);
|
);
|
||||||
request.open(requestType, requestURL, true);
|
request.open(requestType, requestURL, true);
|
||||||
|
request.setRequestHeader(
|
||||||
|
'X-CSRF-TOKEN',
|
||||||
|
document.querySelector('meta[name="csrf-token"]').content
|
||||||
|
);
|
||||||
request.onload = () => {
|
request.onload = () => {
|
||||||
if (request.status == 200) {
|
if (request.status == 200) {
|
||||||
let response = JSON.parse(request['response']);
|
let response = JSON.parse(request['response']);
|
||||||
|
@ -281,14 +269,6 @@ class MaintenanceManager {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {
|
if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {
|
||||||
if (
|
|
||||||
eventType === TASK_UPLOAD_FILES ||
|
|
||||||
eventType === TASK_BACKUP_CREATE ||
|
|
||||||
eventType === TASK_SITE_INIT
|
|
||||||
) {
|
|
||||||
request.setRequestHeader('fipamo-access-token', self.token);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (contentType) {
|
switch (contentType) {
|
||||||
case CONTENT_TYPE_JSON:
|
case CONTENT_TYPE_JSON:
|
||||||
request.setRequestHeader(
|
request.setRequestHeader(
|
|
@ -100,7 +100,7 @@
|
||||||
<span>
|
<span>
|
||||||
@if($lastContentBackup != '')
|
@if($lastContentBackup != '')
|
||||||
MOST RECENT:
|
MOST RECENT:
|
||||||
<a href="/api/v1/backup/content-download">{{ $lastContentBackup }}</a><br/>
|
<a href="/backup/content-download">{{ $lastContentBackup }}</a><br/>
|
||||||
@else
|
@else
|
||||||
<span>span No back ups. Frowny face.</span>
|
<span>span No back ups. Frowny face.</span>
|
||||||
@endif
|
@endif
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
<span>
|
<span>
|
||||||
@if($lastFilesBackup != '')
|
@if($lastFilesBackup != '')
|
||||||
MOST RECENT:
|
MOST RECENT:
|
||||||
<a href="/api/v1/backup/files-download">{{ $lastFilesBackup }}</a><br/>
|
<a href="/backup/files-download">{{ $lastFilesBackup }}</a><br/>
|
||||||
@else
|
@else
|
||||||
<span>span No back ups. Frowny face.</span>
|
<span>span No back ups. Frowny face.</span>
|
||||||
@endif
|
@endif
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use App\Http\Controllers\API\AuthAPIController;
|
|
||||||
use App\Http\Controllers\API\PageAPIController;
|
use App\Http\Controllers\API\PageAPIController;
|
||||||
use App\Http\Controllers\API\FileUploadAPIController;
|
use App\Http\Controllers\API\FileUploadAPIController;
|
||||||
use App\Http\Controllers\API\SettingsAPIController;
|
use App\Http\Controllers\API\SettingsAPIController;
|
||||||
|
@ -19,9 +18,6 @@ use App\Http\Controllers\API\MailAPIController;
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//check if session is active
|
|
||||||
Route::get("/v1/status", [AuthAPIController::class, 'status']);
|
|
||||||
|
|
||||||
//site setup
|
//site setup
|
||||||
Route::post("/v1/init", [InitAPIController::class, 'setupFresh']);
|
Route::post("/v1/init", [InitAPIController::class, 'setupFresh']);
|
||||||
Route::post("/v1/restore", [InitAPIController::class, 'setupRestore']);
|
Route::post("/v1/restore", [InitAPIController::class, 'setupRestore']);
|
||||||
|
|
Loading…
Reference in a new issue