mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-06 16:36:59 +01:00
* [ADD] Added PDF files displaying
* [FIX] Minor bugfixes * [MOD] Code refactoring Signed-off-by: nuxsmin <nuxsmin@syspass.org>
This commit is contained in:
@@ -93,5 +93,6 @@ return [
|
||||
68 => __('Actualizado'),
|
||||
69 => __('Error al comprobar actualizaciones'),
|
||||
70 => __('Avisos de sysPass'),
|
||||
71 => __('Vaciar los tracks?')
|
||||
71 => __('Vaciar los tracks?'),
|
||||
72 => __('Archivo descargado')
|
||||
];
|
||||
@@ -218,6 +218,8 @@ final class AccountController extends ControllerBase implements CrudControllerIn
|
||||
|
||||
$this->view->assign('accountData', $accountData);
|
||||
|
||||
$clientAddress = $this->configData->isDemoEnabled() ? '***' : $this->request->getClientAddress(true);
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.account.link',
|
||||
new Event($this, EventMessage::factory()
|
||||
->addDescription(__u('Enlace visualizado'))
|
||||
@@ -225,11 +227,12 @@ final class AccountController extends ControllerBase implements CrudControllerIn
|
||||
->addDetail(__u('Cliente'), $accountData->getClientName())
|
||||
->addDetail(__u('Agente'), $this->router->request()->headers()->get('User-Agent'))
|
||||
->addDetail(__u('HTTPS'), $this->router->request()->isSecure() ? __u('ON') : __u('OFF'))
|
||||
->addDetail(__u('IP'), $clientAddress)
|
||||
->addData('userId', $publicLinkData->getUserId())
|
||||
->addData('notify', $publicLinkData->isNotify()))
|
||||
);
|
||||
} else {
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION, 'account-link');
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_PAGE_NO_PERMISSION, true, 'account-link');
|
||||
}
|
||||
|
||||
$this->view();
|
||||
|
||||
@@ -49,6 +49,8 @@ use SP\Util\Util;
|
||||
*/
|
||||
final class AccountFileController extends ControllerBase implements CrudControllerInterface
|
||||
{
|
||||
const EXTENSIONS_VIEW = ['TXT'];
|
||||
|
||||
use JsonTrait, ItemTrait;
|
||||
|
||||
/**
|
||||
@@ -89,7 +91,10 @@ final class AccountFileController extends ControllerBase implements CrudControll
|
||||
return $this->returnJsonResponseData(['html' => $this->render()]);
|
||||
}
|
||||
|
||||
if (mb_strtoupper($fileData->getExtension()) === 'TXT') {
|
||||
$extension = mb_strtoupper($fileData->getExtension());
|
||||
|
||||
if (in_array($extension, self::EXTENSIONS_VIEW)) {
|
||||
$this->view->assign('extension', $extension);
|
||||
$this->view->assign('data', htmlentities($fileData->getContent()));
|
||||
|
||||
$this->eventDispatcher->notifyEvent('show.accountFile',
|
||||
@@ -122,26 +127,38 @@ final class AccountFileController extends ControllerBase implements CrudControll
|
||||
try {
|
||||
$this->checkSecurityToken($this->previousSk, $this->request);
|
||||
|
||||
// Set the security toke to its previous value because we can't tell
|
||||
// the browser which will be the new security token (not so good...)
|
||||
$this->session->setSecurityKey($this->previousSk);
|
||||
|
||||
if (null === ($fileData = $this->accountFileService->getById($id))) {
|
||||
throw new SPException(__u('El archivo no existe'), SPException::INFO);
|
||||
}
|
||||
|
||||
// Enviamos el archivo al navegador
|
||||
header('Set-Cookie: fileDownload=true; path=/');
|
||||
header('Cache-Control: max-age=60, must-revalidate');
|
||||
header('Content-length: ' . $fileData->getSize());
|
||||
header('Content-type: ' . $fileData->getType());
|
||||
header('Content-Disposition: attachment; filename="' . $fileData->getName() . '"');
|
||||
header('Content-Description: PHP Generated Data');
|
||||
header('Content-transfer-encoding: binary');
|
||||
|
||||
$this->eventDispatcher->notifyEvent('download.accountFile',
|
||||
new Event($this, EventMessage::factory()
|
||||
->addDescription(__u('Archivo descargado'))
|
||||
->addDetail(__u('Archivo'), $fileData->getName()))
|
||||
);
|
||||
|
||||
return $fileData->getContent();
|
||||
$response = $this->router->response();
|
||||
$response->header('Cache-Control', 'max-age=60, must-revalidate');
|
||||
$response->header('Content-length', $fileData->getSize());
|
||||
$response->header('Content-type', $fileData->getType());
|
||||
$response->header('Content-Description', ' sysPass file');
|
||||
$response->header('Content-transfer-encoding', 'binary');
|
||||
|
||||
$extension = mb_strtoupper($fileData->getExtension());
|
||||
|
||||
if ($extension === 'PDF') {
|
||||
$response->header('Content-Disposition', 'inline; filename="' . $fileData->getName() . '"');
|
||||
} else {
|
||||
$response->header('Set-Cookie', 'fileDownload=true; path=/');
|
||||
$response->header('Content-Disposition', 'attachment; filename="' . $fileData->getName() . '"');
|
||||
}
|
||||
|
||||
$response->body($fileData->getContent());
|
||||
$response->send(true);
|
||||
} catch (\Exception $e) {
|
||||
processException($e);
|
||||
}
|
||||
@@ -413,7 +430,7 @@ final class AccountFileController extends ControllerBase implements CrudControll
|
||||
} catch (\Exception $e) {
|
||||
processException($e);
|
||||
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION);
|
||||
ErrorUtil::showErrorInView($this->view, ErrorUtil::ERR_EXCEPTION, true, 'files-list');
|
||||
}
|
||||
|
||||
$this->view();
|
||||
|
||||
@@ -67,7 +67,7 @@ final class UserPassResetController extends ControllerBase
|
||||
->getCustomLayout('request', strtolower($this->controllerName));
|
||||
|
||||
if (!$this->configData->isMailEnabled()) {
|
||||
ErrorUtil::showErrorInView($this->view, self::ERR_UNAVAILABLE, 'request');
|
||||
ErrorUtil::showErrorInView($this->view, self::ERR_UNAVAILABLE, true, 'request');
|
||||
}
|
||||
|
||||
$this->view();
|
||||
@@ -156,7 +156,7 @@ final class UserPassResetController extends ControllerBase
|
||||
if ($hash && $this->configData->isMailEnabled()) {
|
||||
$this->view->assign('hash', $hash);
|
||||
} else {
|
||||
ErrorUtil::showErrorInView($this->view, self::ERR_UNAVAILABLE, 'reset');
|
||||
ErrorUtil::showErrorInView($this->view, self::ERR_UNAVAILABLE, true, 'reset');
|
||||
}
|
||||
|
||||
$this->view();
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
<div id="files-wrap">
|
||||
<ul id="files-list " class="mdl-list">
|
||||
<?php foreach ($_getvar('files') as $file): ?>
|
||||
<?php foreach ($_getvar('files') as $file):
|
||||
$extension = mb_strtoupper($file->getExtension());
|
||||
?>
|
||||
<li class="mdl-list__item">
|
||||
<span class="mdl-list__item-primary-content" title="<?php echo $file->getName(); ?>">
|
||||
<i class="material-icons mdl-list__item-icon">attachment</i>
|
||||
@@ -40,15 +42,18 @@
|
||||
title="<?php echo __('Descargar Archivo'); ?>"
|
||||
data-item-id="<?php echo $file->getId(); ?>"
|
||||
data-action-route="<?php echo $_getvar('fileDownloadRoute'); ?>"
|
||||
data-item-type="<?php echo $extension; ?>"
|
||||
data-onclick="file/download">
|
||||
<?php echo $icons->getIconDownload()->getIcon(); ?></i>
|
||||
|
||||
<i class="material-icons btn-action mdl-list__item-icon <?php echo $icons->getIconView()->getClass(); ?>"
|
||||
title="<?php echo __('Ver Archivo'); ?>"
|
||||
data-item-id="<?php echo $file->getId(); ?>"
|
||||
data-action-route="<?php echo $_getvar('fileViewRoute'); ?>"
|
||||
data-onclick="file/view">
|
||||
<?php if ($extension !== 'PDF'): ?>
|
||||
<i class="material-icons btn-action mdl-list__item-icon <?php echo $icons->getIconView()->getClass(); ?>"
|
||||
title="<?php echo __('Ver Archivo'); ?>"
|
||||
data-item-id="<?php echo $file->getId(); ?>"
|
||||
data-action-route="<?php echo $_getvar('fileViewRoute'); ?>"
|
||||
data-onclick="file/view">
|
||||
<?php echo $icons->getIconView()->getIcon(); ?></i>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -150,7 +150,7 @@ final class NotificationHandler extends Provider implements EventReceiver
|
||||
$eventMessage = $event->getEventMessage();
|
||||
$data = $eventMessage->getData();
|
||||
|
||||
if ($data['notify'] === true) {
|
||||
if ($data['notify'][0] === true) {
|
||||
$notificationData = new NotificationData();
|
||||
$notificationData->setType(__('Notificación'));
|
||||
$notificationData->setComponent(__('Cuentas'));
|
||||
|
||||
@@ -28,6 +28,7 @@ use SP\Core\Exceptions\ConstraintException;
|
||||
use SP\Core\Exceptions\QueryException;
|
||||
use SP\DataModel\ItemSearchData;
|
||||
use SP\DataModel\NotificationData;
|
||||
use SP\Mvc\Model\QueryCondition;
|
||||
use SP\Repositories\Repository;
|
||||
use SP\Repositories\RepositoryItemInterface;
|
||||
use SP\Repositories\RepositoryItemTrait;
|
||||
@@ -386,19 +387,67 @@ final class NotificationRepository extends Repository implements RepositoryItemI
|
||||
$queryData->setFrom('Notification');
|
||||
$queryData->setOrder('`date` DESC');
|
||||
|
||||
$filterUser = '(userId = ? OR (userId = NULL AND onlyAdmin = 0) OR sticky = 1)';
|
||||
$queryCondition = new QueryCondition();
|
||||
$queryCondition->addFilter('userId = ?', [$userId]);
|
||||
$queryCondition->addFilter('(userId IS NULL AND onlyAdmin = 0)');
|
||||
$queryCondition->addFilter('sticky = 1');
|
||||
|
||||
if ($itemSearchData->getSeachString() !== '') {
|
||||
$queryData->setWhere('(type LIKE ? OR component LIKE ? OR description LIKE ?) AND ' . $filterUser);
|
||||
$queryData->setWhere(
|
||||
'(type LIKE ? OR component LIKE ? OR description LIKE ?) AND '
|
||||
. $queryCondition->getFilters(QueryCondition::CONDITION_OR)
|
||||
);
|
||||
|
||||
$search = '%' . $itemSearchData->getSeachString() . '%';
|
||||
$queryData->addParam($search);
|
||||
$queryData->addParam($search);
|
||||
$queryData->addParam($search);
|
||||
$queryData->addParam($userId);
|
||||
$queryData->setParams(array_merge([$search, $search, $search], $queryCondition->getParams()));
|
||||
} else {
|
||||
$queryData->setWhere($filterUser);
|
||||
$queryData->addParam($userId);
|
||||
$queryData->setWhere($queryCondition->getFilters(QueryCondition::CONDITION_OR));
|
||||
$queryData->setParams($queryCondition->getParams());
|
||||
}
|
||||
|
||||
$queryData->setLimit(
|
||||
'?,?',
|
||||
[$itemSearchData->getLimitStart(), $itemSearchData->getLimitCount()]
|
||||
);
|
||||
|
||||
return $this->db->doSelect($queryData, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches for items by a given filter
|
||||
*
|
||||
* @param ItemSearchData $itemSearchData
|
||||
* @param int $userId
|
||||
*
|
||||
* @return QueryResult
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function searchForAdmin(ItemSearchData $itemSearchData, $userId)
|
||||
{
|
||||
$queryData = new QueryData();
|
||||
$queryData->setMapClassName(NotificationData::class);
|
||||
$queryData->setSelect('id, type, component, description, `date`, checked, userId, sticky, onlyAdmin');
|
||||
$queryData->setFrom('Notification');
|
||||
$queryData->setOrder('`date` DESC');
|
||||
|
||||
$queryCondition = new QueryCondition();
|
||||
$queryCondition->addFilter('userId = ?', [$userId]);
|
||||
$queryCondition->addFilter('onlyAdmin = 1');
|
||||
$queryCondition->addFilter('sticky = 1');
|
||||
|
||||
if ($itemSearchData->getSeachString() !== '') {
|
||||
$queryData->setWhere(
|
||||
'(type LIKE ? OR component LIKE ? OR description LIKE ?) AND '
|
||||
. $queryCondition->getFilters(QueryCondition::CONDITION_OR)
|
||||
);
|
||||
|
||||
$search = '%' . $itemSearchData->getSeachString() . '%';
|
||||
|
||||
$queryData->setParams(array_merge([$search, $search, $search], $queryCondition->getParams()));
|
||||
} else {
|
||||
$queryData->setWhere($queryCondition->getFilters(QueryCondition::CONDITION_OR));
|
||||
$queryData->setParams($queryCondition->getParams());
|
||||
}
|
||||
|
||||
$queryData->setLimit(
|
||||
@@ -534,4 +583,37 @@ final class NotificationRepository extends Repository implements RepositoryItemI
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return QueryResult
|
||||
* @throws ConstraintException
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function getAllActiveForAdmin($id)
|
||||
{
|
||||
$query = /** @lang SQL */
|
||||
'SELECT id,
|
||||
type,
|
||||
component,
|
||||
description,
|
||||
`date`,
|
||||
userId,
|
||||
checked,
|
||||
sticky,
|
||||
onlyAdmin
|
||||
FROM Notification
|
||||
WHERE (userId = ? OR sticky = 1 OR userId IS NULL)
|
||||
AND checked = 0
|
||||
ORDER BY `date` DESC ';
|
||||
|
||||
$queryData = new QueryData();
|
||||
$queryData->setMapClassName(NotificationData::class);
|
||||
$queryData->setQuery($query);
|
||||
$queryData->addParam($id);
|
||||
$queryData->setOnErrorMessage(__u('Error al obtener las notificaciones'));
|
||||
|
||||
return $this->db->doSelect($queryData);
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ final class Installer extends Service
|
||||
*/
|
||||
const VERSION = [3, 0, 0];
|
||||
const VERSION_TEXT = '3.0-beta';
|
||||
const BUILD = 18102201;
|
||||
const BUILD = 18102401;
|
||||
|
||||
/**
|
||||
* @var DatabaseSetupInterface
|
||||
|
||||
@@ -247,6 +247,10 @@ final class NotificationService extends Service
|
||||
*/
|
||||
public function getAllActiveForUserId($id)
|
||||
{
|
||||
if ($this->context->getUserData()->getIsAdminApp()) {
|
||||
return $this->notificationRepository->getAllActiveForAdmin($id)->getDataAsArray();
|
||||
}
|
||||
|
||||
return $this->notificationRepository->getAllActiveForUserId($id)->getDataAsArray();
|
||||
}
|
||||
|
||||
@@ -264,7 +268,7 @@ final class NotificationService extends Service
|
||||
$userData = $this->context->getUserData();
|
||||
|
||||
if ($userData->getIsAdminApp()) {
|
||||
return $this->notificationRepository->search($itemSearchData);
|
||||
return $this->notificationRepository->searchForAdmin($itemSearchData, $userData->getId());
|
||||
}
|
||||
|
||||
return $this->notificationRepository->searchForUserId($itemSearchData, $userData->getId());
|
||||
|
||||
@@ -61,37 +61,18 @@ final class ErrorUtil
|
||||
$replace = null,
|
||||
$render = true)
|
||||
{
|
||||
if ($replace === null) {
|
||||
$view->resetTemplates();
|
||||
|
||||
if ($view->hashContentTemplates()) {
|
||||
$view->resetContentTemplates();
|
||||
$view->addContentTemplate('error', Template::PARTIALS_DIR);
|
||||
} else {
|
||||
$view->addTemplate('error', Template::PARTIALS_DIR);
|
||||
}
|
||||
} else {
|
||||
if ($view->hashContentTemplates()) {
|
||||
$view->removeContentTemplate($replace);
|
||||
$view->addContentTemplate('error', Template::PARTIALS_DIR);
|
||||
} else {
|
||||
$view->removeTemplate($replace);
|
||||
$view->addTemplate('error', Template::PARTIALS_DIR);
|
||||
}
|
||||
}
|
||||
|
||||
switch (get_class($e)) {
|
||||
case UpdatedMasterPassException::class:
|
||||
self::showErrorInView($view, self::ERR_UPDATE_MPASS, $render);
|
||||
self::showErrorInView($view, self::ERR_UPDATE_MPASS, $render, $replace);
|
||||
break;
|
||||
case UnauthorizedPageException::class:
|
||||
self::showErrorInView($view, self::ERR_PAGE_NO_PERMISSION, $render);
|
||||
self::showErrorInView($view, self::ERR_PAGE_NO_PERMISSION, $render, $replace);
|
||||
break;
|
||||
case AccountPermissionException::class:
|
||||
self::showErrorInView($view, self::ERR_ACCOUNT_NO_PERMISSION, $render);
|
||||
self::showErrorInView($view, self::ERR_ACCOUNT_NO_PERMISSION, $render, $replace);
|
||||
break;
|
||||
default;
|
||||
self::showErrorInView($view, self::ERR_EXCEPTION, $render);
|
||||
self::showErrorInView($view, self::ERR_EXCEPTION, $render, $replace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +82,12 @@ final class ErrorUtil
|
||||
* @param \SP\Mvc\View\Template $view
|
||||
* @param int $type int con el tipo de error
|
||||
* @param bool $render
|
||||
* @param null $replace
|
||||
*/
|
||||
public static function showErrorInView(Template $view, $type, $render = true)
|
||||
public static function showErrorInView(Template $view, $type, $render = true, $replace = null)
|
||||
{
|
||||
self::addErrorTemplate($view, $replace);
|
||||
|
||||
$error = self::getErrorTypes($type);
|
||||
|
||||
$view->append('errors',
|
||||
@@ -124,6 +108,32 @@ final class ErrorUtil
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Template $view
|
||||
* @param string|null $replace
|
||||
*/
|
||||
private static function addErrorTemplate(Template $view, string $replace = null)
|
||||
{
|
||||
if ($replace === null) {
|
||||
$view->resetTemplates();
|
||||
|
||||
if ($view->hashContentTemplates()) {
|
||||
$view->resetContentTemplates();
|
||||
$view->addContentTemplate('error', Template::PARTIALS_DIR);
|
||||
} else {
|
||||
$view->addTemplate('error', Template::PARTIALS_DIR);
|
||||
}
|
||||
} else {
|
||||
if ($view->hashContentTemplates()) {
|
||||
$view->removeContentTemplate($replace);
|
||||
$view->addContentTemplate('error', Template::PARTIALS_DIR);
|
||||
} else {
|
||||
$view->removeTemplate($replace);
|
||||
$view->addTemplate('error', Template::PARTIALS_DIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return error message by type
|
||||
*
|
||||
|
||||
@@ -37,10 +37,7 @@ use SP\DataModel\FileData;
|
||||
*/
|
||||
final class FileUtil
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $imageExtensions = ['JPG', 'PNG', 'GIF'];
|
||||
const IMAGE_EXTENSIONS = ['JPG', 'PNG', 'GIF'];
|
||||
|
||||
/**
|
||||
* Removes a directory in a recursive way
|
||||
@@ -74,6 +71,6 @@ final class FileUtil
|
||||
*/
|
||||
public static function isImage(FileData $fileData)
|
||||
{
|
||||
return in_array(mb_strtoupper($fileData->getExtension()), self::$imageExtensions, true);
|
||||
return in_array(mb_strtoupper($fileData->getExtension()), self::IMAGE_EXTENSIONS, true);
|
||||
}
|
||||
}
|
||||
@@ -45,11 +45,10 @@ sysPass.Actions = function (log) {
|
||||
data.sk = sysPassApp.sk.get();
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.type = "html";
|
||||
opts.addHistory = true;
|
||||
opts.data = data;
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, data);
|
||||
|
||||
return sysPassApp.requests.getActionCall(opts, function (response) {
|
||||
const $content = $("#content");
|
||||
@@ -168,17 +167,17 @@ sysPass.Actions = function (log) {
|
||||
view: function ($obj) {
|
||||
log.info("account:show");
|
||||
|
||||
getContent(sysPassApp.requests.getRouteForQuery($obj.data("action-route"), $obj.data("item-id")), "account");
|
||||
getContent({r: [$obj.data("action-route"), $obj.data("item-id")]}, "account");
|
||||
},
|
||||
viewHistory: function ($obj) {
|
||||
log.info("account:showHistory");
|
||||
|
||||
getContent(sysPassApp.requests.getRouteForQuery($obj.data("action-route"), $obj.val()), "account");
|
||||
getContent({r: [$obj.data("action-route"), $obj.val()]}, "account");
|
||||
},
|
||||
edit: function ($obj) {
|
||||
log.info("account:edit");
|
||||
|
||||
getContent(sysPassApp.requests.getRouteForQuery($obj.data("action-route"), $obj.data("item-id")), "account");
|
||||
getContent({r: [$obj.data("action-route"), $obj.data("item-id")]}, "account");
|
||||
},
|
||||
delete: function ($obj) {
|
||||
log.info("account:delete");
|
||||
@@ -224,13 +223,13 @@ sysPass.Actions = function (log) {
|
||||
const id = parentId === 0 ? $obj.data("item-id") : parentId;
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + id + "/" + parentId,
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), id, parentId],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
if (json.status !== 0) {
|
||||
@@ -270,14 +269,14 @@ sysPass.Actions = function (log) {
|
||||
const id = parentId === 0 ? $obj.data("item-id") : parentId;
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.async = false;
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + id,
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), id],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
return sysPassApp.requests.getActionCall(opts);
|
||||
},
|
||||
@@ -289,7 +288,7 @@ sysPass.Actions = function (log) {
|
||||
copy: function ($obj) {
|
||||
log.info("account:copy");
|
||||
|
||||
getContent(sysPassApp.requests.getRouteForQuery($obj.data("action-route"), $obj.data("item-id")), "account");
|
||||
getContent({r: [$obj.data("action-route"), $obj.data("item-id")]}, "account");
|
||||
},
|
||||
saveFavorite: function ($obj, callback) {
|
||||
log.info("account:saveFavorite");
|
||||
@@ -332,7 +331,7 @@ sysPass.Actions = function (log) {
|
||||
) {
|
||||
sysPassApp.sk.set(json.csrf);
|
||||
|
||||
getContent({r: json.data.nextAction['nextAction']}, "account");
|
||||
getContent({r: json.data.nextAction}, "account");
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -360,9 +359,7 @@ sysPass.Actions = function (log) {
|
||||
const parentId = $obj.data("parent-id");
|
||||
const itemId = parentId === undefined ? $obj.data("item-id") : parentId;
|
||||
|
||||
const route = sysPassApp.requests.getRouteForQuery($obj.data("action-route"), itemId);
|
||||
|
||||
getContent(route, "account");
|
||||
getContent({r: [$obj.data("action-route"), itemId]}, "account");
|
||||
},
|
||||
saveEditRestore: function ($obj) {
|
||||
log.info("account:restore");
|
||||
@@ -380,9 +377,7 @@ sysPass.Actions = function (log) {
|
||||
if (json.data.itemId !== undefined
|
||||
&& json.data.nextAction !== undefined
|
||||
) {
|
||||
const route = sysPassApp.requests.getRouteForQuery(json.data.nextAction, json.data.itemId);
|
||||
|
||||
getContent(route, "account");
|
||||
getContent({r: [json.data.nextAction, json.data.itemId]}, "account");
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -392,12 +387,12 @@ sysPass.Actions = function (log) {
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.method = "get";
|
||||
opts.type = "html";
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + $obj.data("item-id"),
|
||||
del: $obj.data("delete"),
|
||||
sk: sysPassApp.sk.get()
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
del: $obj.data("delete"),
|
||||
sk: sysPassApp.sk.get()
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (response) {
|
||||
$obj.html(response);
|
||||
@@ -417,8 +412,8 @@ sysPass.Actions = function (log) {
|
||||
}
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $frmSearch.data("action-route");
|
||||
opts.method = "get";
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: $obj.data("action-route")});
|
||||
opts.data = $frmSearch.serialize();
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
@@ -447,9 +442,7 @@ sysPass.Actions = function (log) {
|
||||
if (json.data.itemId !== undefined
|
||||
&& json.data.nextAction !== undefined
|
||||
) {
|
||||
const route = sysPassApp.requests.getRouteForQuery(json.data.nextAction, json.data.itemId);
|
||||
|
||||
getContent(route, "account");
|
||||
getContent({r: [json.data.nextAction, json.data.itemId]}, "account");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -468,12 +461,12 @@ sysPass.Actions = function (log) {
|
||||
$dst.clearOptions();
|
||||
$dst.load(function (callback) {
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + $obj.data("item-id"),
|
||||
sk: $obj.data("sk")
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get()
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
callback(json.data);
|
||||
@@ -494,12 +487,12 @@ sysPass.Actions = function (log) {
|
||||
$dst.clearOptions();
|
||||
$dst.load(function (callback) {
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("item-route"),
|
||||
sk: sysPassApp.sk.get()
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: $obj.data("action-route"),
|
||||
sk: sysPassApp.sk.get()
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
callback(json);
|
||||
@@ -529,12 +522,12 @@ sysPass.Actions = function (log) {
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.type = "html";
|
||||
opts.method = "get";
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + $obj.data("item-id"),
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (response) {
|
||||
if (response.length === 0) {
|
||||
@@ -576,7 +569,7 @@ sysPass.Actions = function (log) {
|
||||
log.info("main:login");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("route");
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: $obj.data("route")});
|
||||
opts.method = "get";
|
||||
opts.data = $obj.serialize();
|
||||
|
||||
@@ -664,7 +657,7 @@ sysPass.Actions = function (log) {
|
||||
}
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data('action-route');
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: $obj.data('action-route')});
|
||||
opts.method = "get";
|
||||
opts.useFullLoading = !!taskId;
|
||||
opts.data = $obj.serialize();
|
||||
@@ -692,11 +685,10 @@ sysPass.Actions = function (log) {
|
||||
log.info("main:getUpdates");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint + "?r=status/checkRelease";
|
||||
opts.method = "get";
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: "status/checkRelease", isAjax: 1});
|
||||
opts.timeout = 10000;
|
||||
opts.useLoading = false;
|
||||
opts.data = {isAjax: 1};
|
||||
|
||||
const $updates = $("#updates");
|
||||
|
||||
@@ -730,8 +722,12 @@ sysPass.Actions = function (log) {
|
||||
log.info("main:getNotices");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint + "?r=status/checkNotices";
|
||||
opts.method = "get";
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: "status/checkNotices",
|
||||
isAjax: 1
|
||||
});
|
||||
opts.timeout = 10000;
|
||||
opts.useLoading = false;
|
||||
opts.data = {isAjax: 1};
|
||||
@@ -879,11 +875,13 @@ sysPass.Actions = function (log) {
|
||||
log.info("config:import");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route");
|
||||
opts.data = {
|
||||
sk: $obj.data("sk"),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.method = "get";
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: $obj.data("action-route"),
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
sysPassApp.msg.out(json);
|
||||
@@ -911,12 +909,12 @@ sysPass.Actions = function (log) {
|
||||
log.info("file:view");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + $obj.data("item-id"),
|
||||
sk: sysPassApp.sk.get()
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get()
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (response) {
|
||||
if (response.status !== 0) {
|
||||
@@ -929,12 +927,26 @@ sysPass.Actions = function (log) {
|
||||
download: function ($obj) {
|
||||
log.info("file:download");
|
||||
|
||||
const data = {
|
||||
r: $obj.data("action-route") + "/" + $obj.data("item-id"),
|
||||
sk: sysPassApp.sk.get()
|
||||
};
|
||||
const fileType = $obj.data("item-type");
|
||||
const url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get()
|
||||
});
|
||||
|
||||
$.fileDownload(ajaxUrl.entrypoint, {"httpMethod": "GET", "data": data});
|
||||
if (fileType === 'PDF') {
|
||||
window.open(url, '_blank');
|
||||
return;
|
||||
}
|
||||
|
||||
$.fileDownload(url,
|
||||
{
|
||||
httpMethod: "GET",
|
||||
successCallback: function (url) {
|
||||
sysPassApp.msg.ok(sysPassApp.config.LANG[72]);
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
delete: function ($obj) {
|
||||
log.info("file:delete");
|
||||
@@ -955,12 +967,12 @@ sysPass.Actions = function (log) {
|
||||
title: sysPassApp.config.LANG[43],
|
||||
onClick: function (e) {
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + $obj.data("item-id"),
|
||||
sk: sysPassApp.sk.get()
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get(),
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
sysPassApp.msg.out(json);
|
||||
@@ -986,19 +998,31 @@ sysPass.Actions = function (log) {
|
||||
const accountId = $obj.data("account-id");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.method = "get";
|
||||
|
||||
if (accountId) {
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route") + "/" + accountId + "/" + notify;
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), accountId, notify],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
} else {
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route");
|
||||
opts.data = $obj.serialize() + "&sk=" + sysPassApp.sk.get();
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: $obj.data("action-route"),
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
opts.data = $obj.serialize();
|
||||
}
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
sysPassApp.msg.out(json);
|
||||
|
||||
if (json.status === 0) {
|
||||
getContent({r: $obj.data("action-next") + "/" + accountId});
|
||||
getContent({r: [$obj.data("action-next"), accountId]});
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1045,16 +1069,20 @@ sysPass.Actions = function (log) {
|
||||
onClick: function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
const itemId = $obj.data("item-id");
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route") + "/" + itemId;
|
||||
opts.method = "get";
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
sysPassApp.msg.out(json);
|
||||
|
||||
if (json.status === 0) {
|
||||
getContent({r: $obj.data("action-next") + "/" + $obj.data("account-id")});
|
||||
getContent({r: [$obj.data("action-next"), $obj.data("account-id")]});
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1066,16 +1094,14 @@ sysPass.Actions = function (log) {
|
||||
|
||||
tabs.state.update($obj);
|
||||
|
||||
const itemId = $obj.data("item-id");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + itemId,
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
sysPassApp.msg.out(json);
|
||||
@@ -1084,9 +1110,7 @@ sysPass.Actions = function (log) {
|
||||
const actionNext = $obj.data("action-next");
|
||||
|
||||
if (actionNext) {
|
||||
getContent({
|
||||
r: actionNext + "/" + $obj.data("account-id")
|
||||
});
|
||||
getContent({r: [actionNext, $obj.data("account-id")]});
|
||||
} else {
|
||||
getContent({
|
||||
r: tabs.state.tab.route,
|
||||
@@ -1182,7 +1206,6 @@ sysPass.Actions = function (log) {
|
||||
tabs.state.update($obj);
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
|
||||
const items = grid.getSelection($obj);
|
||||
@@ -1191,12 +1214,13 @@ sysPass.Actions = function (log) {
|
||||
return;
|
||||
}
|
||||
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + (items.length === 0 ? "/" + $obj.data("item-id") : ''),
|
||||
items: items,
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), (items.length === 0 ? $obj.data("item-id") : null)],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
opts.data = {items: items};
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
if (json.status !== 0) {
|
||||
@@ -1226,14 +1250,14 @@ sysPass.Actions = function (log) {
|
||||
|
||||
grid.delete($obj, function (items) {
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + (items.length === 0 ? "/" + $obj.data("item-id") : ''),
|
||||
items: items,
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), (items.length === 0 ? $obj.data("item-id") : null)],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
opts.data = {items: items};
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
sysPassApp.msg.out(json);
|
||||
@@ -1305,14 +1329,15 @@ sysPass.Actions = function (log) {
|
||||
log.info("wiki:show");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
pageName: $obj.data("pagename"),
|
||||
actionId: $obj.data("action-id"),
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: $obj.data("action-route"),
|
||||
pageName: $obj.data("pagename"),
|
||||
actionId: $obj.data("action-id"),
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
if (json.status !== 0) {
|
||||
@@ -1333,16 +1358,14 @@ sysPass.Actions = function (log) {
|
||||
|
||||
tabs.state.update($obj);
|
||||
|
||||
const itemId = $obj.data("item-id");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + itemId,
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
sysPassApp.msg.out(json);
|
||||
@@ -1422,13 +1445,13 @@ sysPass.Actions = function (log) {
|
||||
log.info("notification:check");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + $obj.data("item-id"),
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
if (json.status === 0) {
|
||||
@@ -1472,19 +1495,21 @@ sysPass.Actions = function (log) {
|
||||
|
||||
grid.delete($obj, function (items) {
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + (items.length === 0 ? "/" + $obj.data("item-id") : ''),
|
||||
items: items,
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), (items.length === 0 ? $obj.data("item-id") : null)],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
opts.data = {items: items};
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
sysPassApp.msg.out(json);
|
||||
|
||||
getContent({r: $obj.data("action-next")});
|
||||
getContent({r: $obj.data("action-next")}).then(function () {
|
||||
notification.getActive();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -1492,13 +1517,13 @@ sysPass.Actions = function (log) {
|
||||
log.info("notification:getActive");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: "items/notifications",
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: "items/notifications",
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
const $badge = $(".notifications-badge");
|
||||
@@ -1544,8 +1569,8 @@ sysPass.Actions = function (log) {
|
||||
|
||||
const $target = $($obj.data("target"));
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint + "?r=" + $obj.data("action-route");
|
||||
opts.method = "get";
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: $obj.data("action-route"),});
|
||||
opts.data = $obj.serialize();
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
@@ -1691,13 +1716,13 @@ sysPass.Actions = function (log) {
|
||||
const itemId = $obj.data("item-id");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + itemId,
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
sysPassApp.msg.out(json);
|
||||
@@ -1706,9 +1731,7 @@ sysPass.Actions = function (log) {
|
||||
const actionNext = $obj.data("action-next");
|
||||
|
||||
if (actionNext) {
|
||||
getContent({
|
||||
r: actionNext + "/" + itemId
|
||||
});
|
||||
getContent({r: [actionNext, itemId]});
|
||||
} else {
|
||||
getContent({
|
||||
r: tabs.state.tab.route,
|
||||
@@ -1727,7 +1750,7 @@ sysPass.Actions = function (log) {
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.method = "get";
|
||||
opts.url = ajaxUrl.entrypoint + "?r=task/runTask/" + taskId;
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint, {r: ["task/runTask", taskId],});
|
||||
|
||||
return sysPassApp.requests.getActionEvent(opts, function (result) {
|
||||
let text = result.task + " - " + result.message + " - " + result.time + " - " + result.progress + "%";
|
||||
@@ -1742,13 +1765,13 @@ sysPass.Actions = function (log) {
|
||||
log.info("track:unlock");
|
||||
|
||||
const opts = sysPassApp.requests.getRequestOpts();
|
||||
opts.url = ajaxUrl.entrypoint;
|
||||
opts.method = "get";
|
||||
opts.data = {
|
||||
r: $obj.data("action-route") + "/" + $obj.data("item-id"),
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
};
|
||||
opts.url = sysPassApp.util.getUrl(ajaxUrl.entrypoint,
|
||||
{
|
||||
r: [$obj.data("action-route"), $obj.data("item-id")],
|
||||
sk: sysPassApp.sk.get(),
|
||||
isAjax: 1
|
||||
});
|
||||
|
||||
sysPassApp.requests.getActionCall(opts, function (json) {
|
||||
sysPassApp.msg.out(json);
|
||||
|
||||
109
public/js/app-actions.min.js
vendored
109
public/js/app-actions.min.js
vendored
@@ -1,56 +1,57 @@
|
||||
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(d,l,e){d instanceof String&&(d=String(d));for(var f=d.length,h=0;h<f;h++){var p=d[h];if(l.call(e,p,h,d))return{i:h,v:p}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(d,l,e){d!=Array.prototype&&d!=Object.prototype&&(d[l]=e.value)};
|
||||
$jscomp.getGlobal=function(d){return"undefined"!=typeof window&&window===d?d:"undefined"!=typeof global&&null!=global?global:d};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(d,l,e,f){if(l){e=$jscomp.global;d=d.split(".");for(f=0;f<d.length-1;f++){var h=d[f];h in e||(e[h]={});e=e[h]}d=d[d.length-1];f=e[d];l=l(f);l!=f&&null!=l&&$jscomp.defineProperty(e,d,{configurable:!0,writable:!0,value:l})}};
|
||||
$jscomp.polyfill("Array.prototype.find",function(d){return d?d:function(d,e){return $jscomp.findInternal(this,d,e).v}},"es6","es3");
|
||||
sysPass.Actions=function(d){var l=0,e={entrypoint:"/index.php"};Object.freeze(e);var f=function(a,b){d.info("getContent");a.isAjax=1;a.sk=sysPassApp.sk.get();var c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint;c.method="get";c.type="html";c.addHistory=!0;c.data=a;return sysPassApp.requests.getActionCall(c,function(a){var c=$("#content");c.empty().html(a);a=sysPassApp.triggers.views;a.common(c);if(void 0!==b&&"function"===typeof a[b])a[b]();c=$(".mdl-layout__content");0<c.scrollTop()&&c.animate({scrollTop:0},
|
||||
1E3)})},h=function(a,b){$.magnificPopup.open({items:{src:a||"",type:"inline"},callbacks:{open:function(){var a=$("#box-popup");sysPassApp.triggers.views.common(a);void 0!==b&&"function"===typeof b.open&&b.open();a.find("form input:visible:first").focus()},close:function(){void 0!==b&&"function"===typeof b.close&&b.close()}},showCloseBtn:!1})},p=function(a,b){var c=$('<div id="box-popup" class="image">'+b+"</div>"),k=c.find("img");if(0===k.length)return h(b);k.hide();$.magnificPopup.open({items:{src:c,
|
||||
type:"inline"},callbacks:{open:function(){var a=this;k.on("click",function(){a.close()});setTimeout(function(){var a=sysPassApp.util.resizeImage(k);c.css({backgroundColor:"#fff",width:a.width,height:"auto"});k.show("slow")},500)}}})},q=function(){$.magnificPopup.close()},n={view:function(a){d.info("account:show");f(sysPassApp.requests.getRouteForQuery(a.data("action-route"),a.data("item-id")),"account")},viewHistory:function(a){d.info("account:showHistory");f(sysPassApp.requests.getRouteForQuery(a.data("action-route"),
|
||||
a.val()),"account")},edit:function(a){d.info("account:edit");f(sysPassApp.requests.getRouteForQuery(a.data("action-route"),a.data("item-id")),"account")},delete:function(a){d.info("account:delete");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[3]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(c){c=
|
||||
sysPassApp.requests.getRequestOpts();c.url=e.entrypoint;c.data={r:"account/saveDelete/"+a.data("item-id"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(c,function(c){sysPassApp.msg.out(c);sysPassApp.sk.set(c.csrf);n.search(a)})}}})},viewPass:function(a){d.info("account:viewPass");var b=a.data("parent-id")||0,c=0===b?a.data("item-id"):b,k=sysPassApp.requests.getRequestOpts();k.url=e.entrypoint;k.method="get";k.data={r:a.data("action-route")+"/"+c+"/"+b,sk:sysPassApp.sk.get(),isAjax:1};
|
||||
sysPassApp.requests.getActionCall(k,function(a){0!==a.status?sysPassApp.msg.out(a):(a=$(a.data.html),h(a),l=setTimeout(function(){q()},3E4),a.on("mouseleave",function(){clearTimeout(l);l=setTimeout(function(){q()},3E4)}).on("mouseenter",function(){0!==l&&clearTimeout(l)}))})},viewPassHistory:function(a){d.info("account:viewPassHistory");n.viewPass(a)},copyPass:function(a){d.info("account:copyPass");var b=a.data("parent-id");b=0===b?a.data("item-id"):b;var c=sysPassApp.requests.getRequestOpts();c.url=
|
||||
e.entrypoint;c.method="get";c.async=!1;c.data={r:a.data("action-route")+"/"+b,sk:sysPassApp.sk.get(),isAjax:1};return sysPassApp.requests.getActionCall(c)},copyPassHistory:function(a){d.info("account:copyPassHistory");n.copyPassHistory(a)},copy:function(a){d.info("account:copy");f(sysPassApp.requests.getRouteForQuery(a.data("action-route"),a.data("item-id")),"account")},saveFavorite:function(a,b){d.info("account:saveFavorite");var c="on"===a.data("status"),k=c?a.data("action-route-off"):a.data("action-route-on"),
|
||||
r=sysPassApp.requests.getRequestOpts();r.url=e.entrypoint;r.data={r:k+"/"+a.data("item-id"),sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(r,function(k){sysPassApp.msg.out(k);0===k.status&&(a.data("status",c?"off":"on"),"function"===typeof b&&b())})},request:function(a){d.info("account:request");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route")+"/"+a.data("item-id");b.data=a.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,
|
||||
function(a){sysPassApp.msg.out(a);0===a.status&&void 0!==a.data.nextAction&&(sysPassApp.sk.set(a.csrf),f({r:a.data.nextAction.nextAction},"account"))})},menu:function(a){a.hide();a.parent().children(".actions-optional").show(250)},sort:function(a){d.info("account:sort");var b=$("#frmSearch");b.find('input[name="skey"]').val(a.data("key"));b.find('input[name="sorder"]').val(a.data("dir"));b.find('input[name="start"]').val(a.data("start"));n.search()},editPass:function(a){d.info("account:editpass");
|
||||
var b=a.data("parent-id");b=void 0===b?a.data("item-id"):b;a=sysPassApp.requests.getRouteForQuery(a.data("action-route"),b);f(a,"account")},saveEditRestore:function(a){d.info("account:restore");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.data={r:a.data("action-route")+"/"+a.data("history-id")+"/"+a.data("item-id"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);void 0!==a.data.itemId&&void 0!==a.data.nextAction&&(a=sysPassApp.requests.getRouteForQuery(a.data.nextAction,
|
||||
a.data.itemId),f(a,"account"))})},listFiles:function(a){d.info("account:getfiles");var b=sysPassApp.requests.getRequestOpts();b.method="get";b.type="html";b.url=e.entrypoint;b.data={r:a.data("action-route")+"/"+a.data("item-id"),del:a.data("delete"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(b,function(c){a.html(c)})},search:function(a){d.info("account:search");var b=$("#frmSearch");b.find("input[name='sk']").val(sysPassApp.sk.get());b.find("input[name='skey']").val();b.find("input[name='sorder']").val();
|
||||
void 0!==a&&b.find("input[name='start']").val(0);a=sysPassApp.requests.getRequestOpts();a.url=e.entrypoint+"?r="+b.data("action-route");a.method="get";a.data=b.serialize();sysPassApp.requests.getActionCall(a,function(a){10===a.status&&sysPassApp.msg.out(a);$("#res-content").empty().html(a.data.html)})},save:function(a){d.info("account:save");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route")+"/"+a.data("item-id");b.data=a.serialize();$("select.select-box-tags[data-hash][data-updated=true]").each(function(a,
|
||||
k){b.data+="&"+k.getAttribute("id")+"_update=1"});sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);void 0!==a.data.itemId&&void 0!==a.data.nextAction&&(a=sysPassApp.requests.getRouteForQuery(a.data.nextAction,a.data.itemId),f(a,"account"))})}},w={logout:function(){sysPassApp.util.redirect("index.php?r=login/logout")},login:function(a){d.info("main:login");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("route");b.method="get";b.data=a.serialize();sysPassApp.requests.getActionCall(b,
|
||||
function(b){var c=$(".extra-hidden");switch(b.status){case 0:sysPassApp.util.redirect(b.data.url);break;case 2:sysPassApp.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:visible:first").focus();0<c.length&&c.hide();$("#mpass").prop("disabled",!1).val("");$("#smpass").show();break;case 5:sysPassApp.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:visible:first").focus();0<c.length&&c.hide();$("#oldpass").prop("disabled",!1).val("");
|
||||
$("#soldpass").show();break;default:sysPassApp.msg.out(b),a.find("input[type='text'],input[type='password']").val(""),a.find("input:visible:first").focus()}})},install:function(a){d.info("main:install");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("route");b.data=a.serialize();sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);0===a.status&&setTimeout(function(){sysPassApp.util.redirect("index.php?r=login/index")},1E3)})},upgrade:function(a){d.info("main:upgrade");
|
||||
var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[59]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){var c;(b=a.find("input[name='taskId']").val())&&(c=v(b));var d=sysPassApp.requests.getRequestOpts();d.url=e.entrypoint+"?r="+a.data("action-route");d.method="get";d.useFullLoading=!!b;d.data=a.serialize();
|
||||
sysPassApp.requests.getActionCall(d,function(b){sysPassApp.msg.out(b);0!==b.status?a.find(":input[name=key]").val(""):(void 0!==c&&c.close(),setTimeout(function(){sysPassApp.util.redirect("index.php")},5E3))})}}})},getUpdates:function(){d.info("main:getUpdates");var a=sysPassApp.requests.getRequestOpts();a.url=e.entrypoint+"?r=status/checkRelease";a.method="get";a.timeout=1E4;a.useLoading=!1;a.data={isAjax:1};var b=$("#updates");sysPassApp.requests.getActionCall(a,function(a){0===a.status?0<a.data.length?
|
||||
b.html('<a id="link-updates" href="'+a.data.url+'" target="_blank">'+a.data.title+'\n <div id="help-hasupdates" class="icon material-icons mdl-color-text--indigo-200">cloud_download</div>\n </a>\n <span for="link-updates" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+a.data.description+"</span>"):b.html('<div id="updates-info" class="icon material-icons mdl-color-text--teal-200">check_circle</div>\n <span for="updates-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+
|
||||
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(c,k,e){c instanceof String&&(c=String(c));for(var f=c.length,h=0;h<f;h++){var p=c[h];if(k.call(e,p,h,c))return{i:h,v:p}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(c,k,e){c!=Array.prototype&&c!=Object.prototype&&(c[k]=e.value)};
|
||||
$jscomp.getGlobal=function(c){return"undefined"!=typeof window&&window===c?c:"undefined"!=typeof global&&null!=global?global:c};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(c,k,e,f){if(k){e=$jscomp.global;c=c.split(".");for(f=0;f<c.length-1;f++){var h=c[f];h in e||(e[h]={});e=e[h]}c=c[c.length-1];f=e[c];k=k(f);k!=f&&null!=k&&$jscomp.defineProperty(e,c,{configurable:!0,writable:!0,value:k})}};
|
||||
$jscomp.polyfill("Array.prototype.find",function(c){return c?c:function(c,e){return $jscomp.findInternal(this,c,e).v}},"es6","es3");
|
||||
sysPass.Actions=function(c){var k=0,e={entrypoint:"/index.php"};Object.freeze(e);var f=function(a,b){c.info("getContent");a.isAjax=1;a.sk=sysPassApp.sk.get();var d=sysPassApp.requests.getRequestOpts();d.method="get";d.type="html";d.addHistory=!0;d.url=sysPassApp.util.getUrl(e.entrypoint,a);return sysPassApp.requests.getActionCall(d,function(a){var d=$("#content");d.empty().html(a);a=sysPassApp.triggers.views;a.common(d);if(void 0!==b&&"function"===typeof a[b])a[b]();d=$(".mdl-layout__content");0<
|
||||
d.scrollTop()&&d.animate({scrollTop:0},1E3)})},h=function(a,b){$.magnificPopup.open({items:{src:a||"",type:"inline"},callbacks:{open:function(){var a=$("#box-popup");sysPassApp.triggers.views.common(a);void 0!==b&&"function"===typeof b.open&&b.open();a.find("form input:visible:first").focus()},close:function(){void 0!==b&&"function"===typeof b.close&&b.close()}},showCloseBtn:!1})},p=function(a,b){var d=$('<div id="box-popup" class="image">'+b+"</div>"),l=d.find("img");if(0===l.length)return h(b);
|
||||
l.hide();$.magnificPopup.open({items:{src:d,type:"inline"},callbacks:{open:function(){var a=this;l.on("click",function(){a.close()});setTimeout(function(){var a=sysPassApp.util.resizeImage(l);d.css({backgroundColor:"#fff",width:a.width,height:"auto"});l.show("slow")},500)}}})},q=function(){$.magnificPopup.close()},n={view:function(a){c.info("account:show");f({r:[a.data("action-route"),a.data("item-id")]},"account")},viewHistory:function(a){c.info("account:showHistory");f({r:[a.data("action-route"),
|
||||
a.val()]},"account")},edit:function(a){c.info("account:edit");f({r:[a.data("action-route"),a.data("item-id")]},"account")},delete:function(a){c.info("account:delete");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[3]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(d){d=sysPassApp.requests.getRequestOpts();
|
||||
d.url=e.entrypoint;d.data={r:"account/saveDelete/"+a.data("item-id"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(d,function(d){sysPassApp.msg.out(d);sysPassApp.sk.set(d.csrf);n.search(a)})}}})},viewPass:function(a){c.info("account:viewPass");var b=a.data("parent-id")||0,d=0===b?a.data("item-id"):b,l=sysPassApp.requests.getRequestOpts();l.method="get";l.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),d,b],sk:sysPassApp.sk.get(),isAjax:1});sysPassApp.requests.getActionCall(l,
|
||||
function(a){0!==a.status?sysPassApp.msg.out(a):(a=$(a.data.html),h(a),k=setTimeout(function(){q()},3E4),a.on("mouseleave",function(){clearTimeout(k);k=setTimeout(function(){q()},3E4)}).on("mouseenter",function(){0!==k&&clearTimeout(k)}))})},viewPassHistory:function(a){c.info("account:viewPassHistory");n.viewPass(a)},copyPass:function(a){c.info("account:copyPass");var b=a.data("parent-id");b=0===b?a.data("item-id"):b;var d=sysPassApp.requests.getRequestOpts();d.method="get";d.async=!1;d.url=sysPassApp.util.getUrl(e.entrypoint,
|
||||
{r:[a.data("action-route"),b],sk:sysPassApp.sk.get(),isAjax:1});return sysPassApp.requests.getActionCall(d)},copyPassHistory:function(a){c.info("account:copyPassHistory");n.copyPassHistory(a)},copy:function(a){c.info("account:copy");f({r:[a.data("action-route"),a.data("item-id")]},"account")},saveFavorite:function(a,b){c.info("account:saveFavorite");var d="on"===a.data("status"),l=d?a.data("action-route-off"):a.data("action-route-on"),t=sysPassApp.requests.getRequestOpts();t.url=e.entrypoint;t.data=
|
||||
{r:l+"/"+a.data("item-id"),sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(t,function(c){sysPassApp.msg.out(c);0===c.status&&(a.data("status",d?"off":"on"),"function"===typeof b&&b())})},request:function(a){c.info("account:request");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route")+"/"+a.data("item-id");b.data=a.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);0===a.status&&void 0!==
|
||||
a.data.nextAction&&(sysPassApp.sk.set(a.csrf),f({r:a.data.nextAction},"account"))})},menu:function(a){a.hide();a.parent().children(".actions-optional").show(250)},sort:function(a){c.info("account:sort");var b=$("#frmSearch");b.find('input[name="skey"]').val(a.data("key"));b.find('input[name="sorder"]').val(a.data("dir"));b.find('input[name="start"]').val(a.data("start"));n.search()},editPass:function(a){c.info("account:editpass");var b=a.data("parent-id");b=void 0===b?a.data("item-id"):b;f({r:[a.data("action-route"),
|
||||
b]},"account")},saveEditRestore:function(a){c.info("account:restore");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.data={r:a.data("action-route")+"/"+a.data("history-id")+"/"+a.data("item-id"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);void 0!==a.data.itemId&&void 0!==a.data.nextAction&&f({r:[a.data.nextAction,a.data.itemId]},"account")})},listFiles:function(a){c.info("account:getfiles");var b=sysPassApp.requests.getRequestOpts();
|
||||
b.method="get";b.type="html";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],del:a.data("delete"),sk:sysPassApp.sk.get()});sysPassApp.requests.getActionCall(b,function(d){a.html(d)})},search:function(a){c.info("account:search");var b=$("#frmSearch");b.find("input[name='sk']").val(sysPassApp.sk.get());b.find("input[name='skey']").val();b.find("input[name='sorder']").val();void 0!==a&&b.find("input[name='start']").val(0);var d=sysPassApp.requests.getRequestOpts();
|
||||
d.method="get";d.url=sysPassApp.util.getUrl(e.entrypoint,{r:a.data("action-route")});d.data=b.serialize();sysPassApp.requests.getActionCall(d,function(a){10===a.status&&sysPassApp.msg.out(a);$("#res-content").empty().html(a.data.html)})},save:function(a){c.info("account:save");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route")+"/"+a.data("item-id");b.data=a.serialize();$("select.select-box-tags[data-hash][data-updated=true]").each(function(a,c){b.data+="&"+
|
||||
c.getAttribute("id")+"_update=1"});sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);void 0!==a.data.itemId&&void 0!==a.data.nextAction&&f({r:[a.data.nextAction,a.data.itemId]},"account")})}},w={logout:function(){sysPassApp.util.redirect("index.php?r=login/logout")},login:function(a){c.info("main:login");var b=sysPassApp.requests.getRequestOpts();b.url=sysPassApp.util.getUrl(e.entrypoint,{r:a.data("route")});b.method="get";b.data=a.serialize();sysPassApp.requests.getActionCall(b,
|
||||
function(b){var d=$(".extra-hidden");switch(b.status){case 0:sysPassApp.util.redirect(b.data.url);break;case 2:sysPassApp.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:visible:first").focus();0<d.length&&d.hide();$("#mpass").prop("disabled",!1).val("");$("#smpass").show();break;case 5:sysPassApp.msg.out(b);a.find("input[type='text'],input[type='password']").val("");a.find("input:visible:first").focus();0<d.length&&d.hide();$("#oldpass").prop("disabled",!1).val("");
|
||||
$("#soldpass").show();break;default:sysPassApp.msg.out(b),a.find("input[type='text'],input[type='password']").val(""),a.find("input:visible:first").focus()}})},install:function(a){c.info("main:install");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("route");b.data=a.serialize();sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);0===a.status&&setTimeout(function(){sysPassApp.util.redirect("index.php?r=login/index")},1E3)})},upgrade:function(a){c.info("main:upgrade");
|
||||
var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[59]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){var d;(b=a.find("input[name='taskId']").val())&&(d=v(b));var c=sysPassApp.requests.getRequestOpts();c.url=sysPassApp.util.getUrl(e.entrypoint,{r:a.data("action-route")});c.method="get";c.useFullLoading=
|
||||
!!b;c.data=a.serialize();sysPassApp.requests.getActionCall(c,function(b){sysPassApp.msg.out(b);0!==b.status?a.find(":input[name=key]").val(""):(void 0!==d&&d.close(),setTimeout(function(){sysPassApp.util.redirect("index.php")},5E3))})}}})},getUpdates:function(){c.info("main:getUpdates");var a=sysPassApp.requests.getRequestOpts();a.method="get";a.url=sysPassApp.util.getUrl(e.entrypoint,{r:"status/checkRelease",isAjax:1});a.timeout=1E4;a.useLoading=!1;var b=$("#updates");sysPassApp.requests.getActionCall(a,
|
||||
function(a){0===a.status?0<a.data.length?b.html('<a id="link-updates" href="'+a.data.url+'" target="_blank">'+a.data.title+'\n <div id="help-hasupdates" class="icon material-icons mdl-color-text--indigo-200">cloud_download</div>\n </a>\n <span for="link-updates" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+a.data.description+"</span>"):b.html('<div id="updates-info" class="icon material-icons mdl-color-text--teal-200">check_circle</div>\n <span for="updates-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+
|
||||
sysPassApp.config.LANG[68]+"</span>"):b.html('<div id="updates-info" class="icon material-icons mdl-color-text--amber-200">warning</div>\n <span for="updates-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+sysPassApp.config.LANG[69]+"</span>");sysPassApp.theme.update()},function(){b.html('<div id="updates-info" class="icon material-icons mdl-color-text--amber-200">warning</div>\n <span for="updates-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">'+
|
||||
sysPassApp.config.LANG[69]+"</span>")})},getNotices:function(){d.info("main:getNotices");var a=sysPassApp.requests.getRequestOpts();a.url=e.entrypoint+"?r=status/checkNotices";a.method="get";a.timeout=1E4;a.useLoading=!1;a.data={isAjax:1};var b=$("#notices");sysPassApp.requests.getActionCall(a,function(a){0===a.status&&0<a.data.length&&b.html('<a href="https://github.com/nuxsmin/sysPass/labels/Notices" target="_blank">\n <div id="notices-info" \n class="material-icons mdl-badge mdl-badge--overlap mdl-color-text--amber-200" \n data-badge="'+
|
||||
sysPassApp.config.LANG[69]+"</span>")})},getNotices:function(){c.info("main:getNotices");var a=sysPassApp.requests.getRequestOpts();a.method="get";a.url=sysPassApp.util.getUrl(e.entrypoint,{r:"status/checkNotices",isAjax:1});a.timeout=1E4;a.useLoading=!1;a.data={isAjax:1};var b=$("#notices");sysPassApp.requests.getActionCall(a,function(a){0===a.status&&0<a.data.length&&b.html('<a href="https://github.com/nuxsmin/sysPass/labels/Notices" target="_blank">\n <div id="notices-info" \n class="material-icons mdl-badge mdl-badge--overlap mdl-color-text--amber-200" \n data-badge="'+
|
||||
a.data.length+'">feedback</div>\n </a>\n <span for="notices-info" class="mdl-tooltip mdl-tooltip--top mdl-tooltip--large">\n <div class="notices-title">'+sysPassApp.config.LANG[70]+"</div>"+a.data.map(function(a){return a.title}).join("<br>")+"\n </span>");sysPassApp.theme.update()})}},g={state:{tab:{index:0,refresh:!0,route:""},itemId:0,update:function(a){var b=$("#content").find("[id^='tabs-'].is-active");
|
||||
0<b.length&&(g.state.tab.refresh=!a.data("item-dst"),g.state.tab.index=b.data("tab-index"),g.state.tab.route=b.data("tab-route"),g.state.itemId=a.data("item-id"))}},save:function(a,b){d.info("tabs:save");g.state.update(a);var c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint+"?r="+a.data("action-route");c.method=a.data("action-method")||"post";c.data=a.serialize();c.data+="&sk="+sysPassApp.sk.get();$("select.select-box-tags[data-hash][data-updated=true]").each(function(a,b){c.data+="&"+b.getAttribute("id")+
|
||||
"_update=1"});sysPassApp.requests.getActionCall(c,function(c){sysPassApp.msg.out(c);0===c.status&&("function"===typeof b&&b(),void 0!==a.data("reload")?(d.info("reload"),setTimeout(function(){sysPassApp.util.redirect("index.php")},2E3)):!0===g.state.tab.refresh&&(d.info("refresh"),f({r:g.state.tab.route,tabIndex:g.state.tab.index})))})},refresh:function(a){this.state.update(a);f({r:this.state.tab.route,tabIndex:this.state.tab.index})}},t={show:function(a){d.info("appMgmt:show");g.state.update(a);
|
||||
var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.method="get";var c=m.getSelection(a);!1!==c&&(b.data={r:a.data("action-route")+(0===c.length?"/"+a.data("item-id"):""),items:c,sk:sysPassApp.sk.get(),isAjax:1},sysPassApp.requests.getActionCall(b,function(b){if(0!==b.status)sysPassApp.msg.out(b);else{var d=a.data("item-dst");h(b.data.html,{open:function(){d&&(g.state.tab.refresh=!1)},close:function(){d&&c.update(a)}})}}))},delete:function(a){d.info("appMgmt:delete");g.state.update(a);
|
||||
m.delete(a,function(b){var c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint;c.method="get";c.data={r:a.data("action-route")+(0===b.length?"/"+a.data("item-id"):""),items:b,sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(c,function(a){sysPassApp.msg.out(a);f({r:g.state.tab.route,tabIndex:g.state.tab.index})})})},save:function(a){d.info("appMgmt:save");g.save(a,function(){q()})},search:function(a){d.info("appMgmt:search");m.search(a)},nav:function(a){d.info("appMgmt:nav");
|
||||
m.nav(a)}},u={check:function(a){d.info("notification:check");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.method="get";b.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(b,function(b){0===b.status&&f({r:a.data("action-next")});u.getActive()})},search:function(a){d.info("notification:search");m.search(a)},show:function(a){d.info("notification:show");t.show(a)},save:function(a){d.info("notification:save");var b=
|
||||
sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("route");b.data=a.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,function(b){sysPassApp.msg.out(b);0===b.status&&($.magnificPopup.close(),f({r:a.data("action-next")}).then(function(){u.getActive()}))})},delete:function(a){d.info("notification:delete");m.delete(a,function(b){var c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint;c.method="get";c.data={r:a.data("action-route")+(0===b.length?"/"+a.data("item-id"):
|
||||
""),items:b,sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(c,function(b){sysPassApp.msg.out(b);f({r:a.data("action-next")})})})},getActive:function(){d.info("notification:getActive");var a=sysPassApp.requests.getRequestOpts();a.url=e.entrypoint;a.method="get";a.data={r:"items/notifications",sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(a,function(a){var b=$(".notifications-badge"),d=$(".notifications-tooltip");b.each(function(){var b=$(this);b.attr("data-badge",
|
||||
a.data.count);0===a.data.count?(b.removeClass(b.data("color-class")),d.empty().html(a.data.message)):(b.addClass(b.data("color-class")),d.empty().html(a.data.message_has))});0<a.data.count&&sysPassApp.util.sendNotification(a.data.message_has,a.data.notifications.join("\n"),a.data.hash)})},nav:function(a){d.info("eventlog:nav");m.nav(a)}},m={search:function(a){d.info("grid:search");var b=$(a.data("target")),c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint+"?r="+a.data("action-route");c.method=
|
||||
"get";c.data=a.serialize();sysPassApp.requests.getActionCall(c,function(a){0===a.status?b.html(a.data.html):b.html(sysPassApp.msg.html.error(a.description));sysPassApp.sk.set(a.csrf)})},nav:function(a,b){d.info("grid:nav");var c=$("#"+a.data("action-form"));c.find("[name='start']").val(a.data("start"));c.find("[name='count']").val(a.data("count"));c.find("[name='sk']").val(sysPassApp.sk.get());"function"===typeof b?b(c):m.search(c)},delete:function(a,b){var c='<div id="alert"><p id="alert-text">'+
|
||||
sysPassApp.config.LANG[12]+"</p></div>",d=m.getSelection(a);!1!==d&&mdlDialog().show({text:c,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(a){a.preventDefault();"function"===typeof b&&b(d)}}})},getSelection:function(a){a=a.data("selection");var b=[];return a&&($(a).find(".is-selected").each(function(){b.push($(this).data("item-id"))}),0===b.length)?!1:
|
||||
b}},v=function(a){var b=$("#taskStatus");b.empty().html(sysPassApp.config.LANG[62]);var c=sysPassApp.requests.getRequestOpts();c.method="get";c.url=e.entrypoint+"?r=task/runTask/"+a;return sysPassApp.requests.getActionEvent(c,function(a){a=a.task+" - "+a.message+" - "+a.time+" - "+a.progress+"%";a+="<br>"+sysPassApp.config.LANG[62];b.empty().html(a)})};return{getContent:f,showFloatingBox:h,closeFloatingBox:q,appMgmt:t,account:n,accountManager:{restore:function(a){d.info("accountManager:restore");
|
||||
g.state.update(a);var b=a.data("item-id"),c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint;c.method="get";c.data={r:a.data("action-route")+"/"+b,sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(c,function(c){sysPassApp.msg.out(c);0===c.status&&((c=a.data("action-next"))?f({r:c+"/"+b}):f({r:g.state.tab.route,tabIndex:g.state.tab.index}))})}},file:{view:function(a){d.info("file:view");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.method="get";b.data={r:a.data("action-route")+
|
||||
"/"+a.data("item-id"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(b,function(b){if(0!==b.status)return sysPassApp.msg.out(b);p(a,b.data.html)})},download:function(a){d.info("file:download");a={r:a.data("action-route")+"/"+a.data("item-id"),sk:sysPassApp.sk.get()};$.fileDownload(e.entrypoint,{httpMethod:"GET",data:a})},delete:function(a){d.info("file:delete");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[15]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],
|
||||
onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.method="get";b.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);0===a.status&&n.listFiles($("#list-account-files"))})}}})}},checks:{wiki:function(a){d.info("checks:wiki");a=$(a.data("src"));
|
||||
a.find("[name='sk']").val(sysPassApp.sk.get());var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.data=a.serialize();sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);0===a.status&&$("#dokuWikiResCheck").html(a.data)})}},config:{save:function(a){d.info("config:save");g.save(a)},masterpass:function(a){var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[59]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(b){b.preventDefault();
|
||||
sysPassApp.msg.error(sysPassApp.config.LANG[44]);a.find(":input[type=password]").val("")}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){var c;(b=a.find("input[name='taskId']").val())&&(c=v(b));var d=sysPassApp.requests.getRequestOpts();d.url=e.entrypoint;d.useFullLoading=!!b;d.data=a.serialize();sysPassApp.requests.getActionCall(d,function(b){sysPassApp.msg.out(b);a.find(":input[type=password]").val("");void 0!==c&&c.close()})}}})},backup:function(a){d.info("config:backup");g.state.update(a);
|
||||
var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route");b.useFullLoading=!0;b.data=a.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);0===a.status&&f({r:g.state.tab.route,tabIndex:g.state.tab.index})})},export:function(a){d.info("config:export");g.save(a)},import:function(a){d.info("config:import");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route");b.data=a.serialize()+
|
||||
"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a)})},refreshMpass:function(a){d.info("config:import");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route");b.data={sk:a.data("sk"),isAjax:1};sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a)})},mailCheck:function(a){d.info("config:mailCheck");var b=$(a.data("src")),c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint+"?r="+a.data("action-route");
|
||||
c.data=b.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(c,function(a){sysPassApp.msg.out(a)})}},main:w,user:{showSettings:function(a){d.info("user:showSettings");f({r:a.data("action-route")},"userSettings")},saveSettings:function(a){d.info("user:saveSettings");g.save(a)},password:function(a){d.info("user:password");var b=sysPassApp.requests.getRequestOpts();b.type="html";b.method="get";b.url=e.entrypoint;b.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:sysPassApp.sk.get(),
|
||||
isAjax:1};sysPassApp.requests.getActionCall(b,function(a){0===a.length?w.logout():h(a)})},passreset:function(a){d.info("user:passreset");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"/?r="+a.data("action-route");b.data=a.serialize();sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);0===a.status&&setTimeout(function(){sysPassApp.util.redirect("index.php")},2E3)})}},link:{save:function(a){d.info("link:save");var b=function(b){var c=a.data("account-id"),d=sysPassApp.requests.getRequestOpts();
|
||||
c?d.url=e.entrypoint+"?r="+a.data("action-route")+"/"+c+"/"+b:(d.url=e.entrypoint+"?r="+a.data("action-route"),d.data=a.serialize()+"&sk="+sysPassApp.sk.get());sysPassApp.requests.getActionCall(d,function(b){sysPassApp.msg.out(b);0===b.status&&f({r:a.data("action-next")+"/"+c})})},c='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[48]+"</p></div>";mdlDialog().show({text:c,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();b(0)}},positive:{title:sysPassApp.config.LANG[43],
|
||||
onClick:function(a){a.preventDefault();b(1)}}})},delete:function(a){d.info("link:delete");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[12]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b.preventDefault();b=a.data("item-id");var c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint+"?r="+
|
||||
a.data("action-route")+"/"+b;sysPassApp.requests.getActionCall(c,function(b){sysPassApp.msg.out(b);0===b.status&&f({r:a.data("action-next")+"/"+a.data("account-id")})})}}})},refresh:function(a){d.info("link:refresh");g.state.update(a);var b=a.data("item-id"),c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint;c.method="get";c.data={r:a.data("action-route")+"/"+b,sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(c,function(b){sysPassApp.msg.out(b);0===b.status&&((b=a.data("action-next"))?
|
||||
f({r:b+"/"+a.data("account-id")}):f({r:g.state.tab.route,tabIndex:g.state.tab.index}))})}},eventlog:{clear:function(a){var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[20]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b.preventDefault();g.save(a)}}})}},ajaxUrl:e,plugin:{toggle:function(a){d.info("plugin:enable");
|
||||
g.state.update(a);var b=a.data("item-id"),c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint;c.method="get";c.data={r:a.data("action-route")+"/"+b,sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(c,function(a){sysPassApp.msg.out(a);0===a.status&&setTimeout(function(){sysPassApp.util.redirect("index.php")},2E3)})},reset:function(a){d.info("plugin:reset");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[58]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],
|
||||
onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b.preventDefault();g.save(a)}}})},search:function(a){d.info("plugin:search");m.search(a)},show:function(a){d.info("plugin:show");t.show(a)},save:function(a){d.info("plugin:save");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("route");b.data=a.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,function(b){sysPassApp.msg.out(b);
|
||||
0===b.status&&(f({r:a.data("action-next")}),$.magnificPopup.close())})},nav:function(a){d.info("plugin:nav");m.nav(a)}},notification:u,wiki:{show:function(a){d.info("wiki:show");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.method="get";b.data={pageName:a.data("pagename"),actionId:a.data("action-id"),sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(b,function(a){0!==a.status?sysPassApp.msg.out(a):h(a.data.html)})}},items:{get:function(a){d.info("items:get");var b=
|
||||
a[0].selectize;b.clearOptions();b.load(function(c){var d=sysPassApp.requests.getRequestOpts();d.url=e.entrypoint;d.method="get";d.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:a.data("sk")};sysPassApp.requests.getActionCall(d,function(d){c(d.data);b.setValue(a.data("selected-id"),!0);sysPassApp.triggers.updateFormHash()})})},update:function(a){d.info("items:update");var b=$("#"+a.data("item-dst"))[0].selectize,c=b.getValue();b.clearOptions();b.load(function(d){var f=sysPassApp.requests.getRequestOpts();
|
||||
f.url=e.entrypoint;f.method="get";f.data={r:a.data("item-route"),sk:sysPassApp.sk.get()};sysPassApp.requests.getActionCall(f,function(a){d(a);b.setValue(c,!0)})})}},ldap:{check:function(a){d.info("ldap:check");var b=$(a.data("src")),c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint+"?r="+a.data("action-route");c.data=b.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(c,function(a){sysPassApp.msg.out(a);0===a.status&&void 0!==a.data.template&&void 0!==a.data.items&&
|
||||
h(a.data.template,{open:function(){var b=$("#ldap-results").find(".list-wrap").empty();a.data.items.forEach(function(a){b.append(sysPassApp.theme.html.getList(a.items,a.icon))})}})})},import:function(a){d.info("ldap:import");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[57]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],
|
||||
onClick:function(b){b=$(a.data("src"));var c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint+"?r="+a.data("action-route");c.data=b.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(c,function(a){sysPassApp.msg.out(a)})}}})}},track:{unlock:function(a){d.info("track:unlock");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.method="get";b.data={r:a.data("action-route")+"/"+a.data("item-id"),sk:sysPassApp.sk.get(),isAjax:1};sysPassApp.requests.getActionCall(b,
|
||||
function(b){sysPassApp.msg.out(b);g.refresh(a)})},clear:function(a){d.info("track:clear");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[71]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b.preventDefault();g.save(a)}}})}}}};
|
||||
0<b.length&&(g.state.tab.refresh=!a.data("item-dst"),g.state.tab.index=b.data("tab-index"),g.state.tab.route=b.data("tab-route"),g.state.itemId=a.data("item-id"))}},save:function(a,b){c.info("tabs:save");g.state.update(a);var d=sysPassApp.requests.getRequestOpts();d.url=e.entrypoint+"?r="+a.data("action-route");d.method=a.data("action-method")||"post";d.data=a.serialize();d.data+="&sk="+sysPassApp.sk.get();$("select.select-box-tags[data-hash][data-updated=true]").each(function(a,b){d.data+="&"+b.getAttribute("id")+
|
||||
"_update=1"});sysPassApp.requests.getActionCall(d,function(d){sysPassApp.msg.out(d);0===d.status&&("function"===typeof b&&b(),void 0!==a.data("reload")?(c.info("reload"),setTimeout(function(){sysPassApp.util.redirect("index.php")},2E3)):!0===g.state.tab.refresh&&(c.info("refresh"),f({r:g.state.tab.route,tabIndex:g.state.tab.index})))})},refresh:function(a){this.state.update(a);f({r:this.state.tab.route,tabIndex:this.state.tab.index})}},u={show:function(a){c.info("appMgmt:show");g.state.update(a);
|
||||
var b=sysPassApp.requests.getRequestOpts();b.method="get";var d=m.getSelection(a);!1!==d&&(b.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),0===d.length?a.data("item-id"):null],sk:sysPassApp.sk.get(),isAjax:1}),b.data={items:d},sysPassApp.requests.getActionCall(b,function(b){if(0!==b.status)sysPassApp.msg.out(b);else{var c=a.data("item-dst");h(b.data.html,{open:function(){c&&(g.state.tab.refresh=!1)},close:function(){c&&d.update(a)}})}}))},delete:function(a){c.info("appMgmt:delete");
|
||||
g.state.update(a);m.delete(a,function(b){var d=sysPassApp.requests.getRequestOpts();d.method="get";d.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),0===b.length?a.data("item-id"):null],sk:sysPassApp.sk.get(),isAjax:1});d.data={items:b};sysPassApp.requests.getActionCall(d,function(a){sysPassApp.msg.out(a);f({r:g.state.tab.route,tabIndex:g.state.tab.index})})})},save:function(a){c.info("appMgmt:save");g.save(a,function(){q()})},search:function(a){c.info("appMgmt:search");m.search(a)},
|
||||
nav:function(a){c.info("appMgmt:nav");m.nav(a)}},r={check:function(a){c.info("notification:check");var b=sysPassApp.requests.getRequestOpts();b.method="get";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get(),isAjax:1});sysPassApp.requests.getActionCall(b,function(b){0===b.status&&f({r:a.data("action-next")});r.getActive()})},search:function(a){c.info("notification:search");m.search(a)},show:function(a){c.info("notification:show");u.show(a)},
|
||||
save:function(a){c.info("notification:save");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("route");b.data=a.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,function(b){sysPassApp.msg.out(b);0===b.status&&($.magnificPopup.close(),f({r:a.data("action-next")}).then(function(){r.getActive()}))})},delete:function(a){c.info("notification:delete");m.delete(a,function(b){var d=sysPassApp.requests.getRequestOpts();d.method="get";d.url=sysPassApp.util.getUrl(e.entrypoint,
|
||||
{r:[a.data("action-route"),0===b.length?a.data("item-id"):null],sk:sysPassApp.sk.get(),isAjax:1});d.data={items:b};sysPassApp.requests.getActionCall(d,function(b){sysPassApp.msg.out(b);f({r:a.data("action-next")}).then(function(){r.getActive()})})})},getActive:function(){c.info("notification:getActive");var a=sysPassApp.requests.getRequestOpts();a.method="get";a.url=sysPassApp.util.getUrl(e.entrypoint,{r:"items/notifications",sk:sysPassApp.sk.get(),isAjax:1});sysPassApp.requests.getActionCall(a,function(a){var b=
|
||||
$(".notifications-badge"),c=$(".notifications-tooltip");b.each(function(){var b=$(this);b.attr("data-badge",a.data.count);0===a.data.count?(b.removeClass(b.data("color-class")),c.empty().html(a.data.message)):(b.addClass(b.data("color-class")),c.empty().html(a.data.message_has))});0<a.data.count&&sysPassApp.util.sendNotification(a.data.message_has,a.data.notifications.join("\n"),a.data.hash)})},nav:function(a){c.info("eventlog:nav");m.nav(a)}},m={search:function(a){c.info("grid:search");var b=$(a.data("target")),
|
||||
d=sysPassApp.requests.getRequestOpts();d.method="get";d.url=sysPassApp.util.getUrl(e.entrypoint,{r:a.data("action-route")});d.data=a.serialize();sysPassApp.requests.getActionCall(d,function(a){0===a.status?b.html(a.data.html):b.html(sysPassApp.msg.html.error(a.description));sysPassApp.sk.set(a.csrf)})},nav:function(a,b){c.info("grid:nav");var d=$("#"+a.data("action-form"));d.find("[name='start']").val(a.data("start"));d.find("[name='count']").val(a.data("count"));d.find("[name='sk']").val(sysPassApp.sk.get());
|
||||
"function"===typeof b?b(d):m.search(d)},delete:function(a,b){var d='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[12]+"</p></div>",c=m.getSelection(a);!1!==c&&mdlDialog().show({text:d,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(a){a.preventDefault();"function"===typeof b&&b(c)}}})},getSelection:function(a){a=a.data("selection");var b=[];
|
||||
return a&&($(a).find(".is-selected").each(function(){b.push($(this).data("item-id"))}),0===b.length)?!1:b}},v=function(a){var b=$("#taskStatus");b.empty().html(sysPassApp.config.LANG[62]);var d=sysPassApp.requests.getRequestOpts();d.method="get";d.url=sysPassApp.util.getUrl(e.entrypoint,{r:["task/runTask",a]});return sysPassApp.requests.getActionEvent(d,function(a){a=a.task+" - "+a.message+" - "+a.time+" - "+a.progress+"%";a+="<br>"+sysPassApp.config.LANG[62];b.empty().html(a)})};return{getContent:f,
|
||||
showFloatingBox:h,closeFloatingBox:q,appMgmt:u,account:n,accountManager:{restore:function(a){c.info("accountManager:restore");g.state.update(a);var b=a.data("item-id"),d=sysPassApp.requests.getRequestOpts();d.method="get";d.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get(),isAjax:1});sysPassApp.requests.getActionCall(d,function(d){sysPassApp.msg.out(d);0===d.status&&((d=a.data("action-next"))?f({r:[d,b]}):f({r:g.state.tab.route,tabIndex:g.state.tab.index}))})}},
|
||||
file:{view:function(a){c.info("file:view");var b=sysPassApp.requests.getRequestOpts();b.method="get";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get()});sysPassApp.requests.getActionCall(b,function(b){if(0!==b.status)return sysPassApp.msg.out(b);p(a,b.data.html)})},download:function(a){c.info("file:download");var b=a.data("item-type");a=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get()});
|
||||
"PDF"===b?window.open(a,"_blank"):$.fileDownload(a,{httpMethod:"GET",successCallback:function(a){sysPassApp.msg.ok(sysPassApp.config.LANG[72])}})},delete:function(a){c.info("file:delete");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[15]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b=sysPassApp.requests.getRequestOpts();
|
||||
b.method="get";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get()});sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);0===a.status&&n.listFiles($("#list-account-files"))})}}})}},checks:{wiki:function(a){c.info("checks:wiki");a=$(a.data("src"));a.find("[name='sk']").val(sysPassApp.sk.get());var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint;b.data=a.serialize();sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);
|
||||
0===a.status&&$("#dokuWikiResCheck").html(a.data)})}},config:{save:function(a){c.info("config:save");g.save(a)},masterpass:function(a){var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[59]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(b){b.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44]);a.find(":input[type=password]").val("")}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){var d;(b=a.find("input[name='taskId']").val())&&
|
||||
(d=v(b));var c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint;c.useFullLoading=!!b;c.data=a.serialize();sysPassApp.requests.getActionCall(c,function(b){sysPassApp.msg.out(b);a.find(":input[type=password]").val("");void 0!==d&&d.close()})}}})},backup:function(a){c.info("config:backup");g.state.update(a);var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route");b.useFullLoading=!0;b.data=a.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,
|
||||
function(a){sysPassApp.msg.out(a);0===a.status&&f({r:g.state.tab.route,tabIndex:g.state.tab.index})})},export:function(a){c.info("config:export");g.save(a)},import:function(a){c.info("config:import");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("action-route");b.data=a.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a)})},refreshMpass:function(a){c.info("config:import");var b=sysPassApp.requests.getRequestOpts();
|
||||
b.method="get";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:a.data("action-route"),sk:sysPassApp.sk.get(),isAjax:1});sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a)})},mailCheck:function(a){c.info("config:mailCheck");var b=$(a.data("src")),d=sysPassApp.requests.getRequestOpts();d.url=e.entrypoint+"?r="+a.data("action-route");d.data=b.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(d,function(a){sysPassApp.msg.out(a)})}},main:w,user:{showSettings:function(a){c.info("user:showSettings");
|
||||
f({r:a.data("action-route")},"userSettings")},saveSettings:function(a){c.info("user:saveSettings");g.save(a)},password:function(a){c.info("user:password");var b=sysPassApp.requests.getRequestOpts();b.type="html";b.method="get";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get(),isAjax:1});sysPassApp.requests.getActionCall(b,function(a){0===a.length?w.logout():h(a)})},passreset:function(a){c.info("user:passreset");var b=sysPassApp.requests.getRequestOpts();
|
||||
b.url=e.entrypoint+"/?r="+a.data("action-route");b.data=a.serialize();sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);0===a.status&&setTimeout(function(){sysPassApp.util.redirect("index.php")},2E3)})}},link:{save:function(a){c.info("link:save");var b=function(b){var d=a.data("account-id"),c=sysPassApp.requests.getRequestOpts();c.method="get";d?c.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),d,b],sk:sysPassApp.sk.get(),isAjax:1}):(c.url=sysPassApp.util.getUrl(e.entrypoint,
|
||||
{r:a.data("action-route"),sk:sysPassApp.sk.get(),isAjax:1}),c.data=a.serialize());sysPassApp.requests.getActionCall(c,function(b){sysPassApp.msg.out(b);0===b.status&&f({r:[a.data("action-next"),d]})})},d='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[48]+"</p></div>";mdlDialog().show({text:d,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();b(0)}},positive:{title:sysPassApp.config.LANG[43],onClick:function(a){a.preventDefault();b(1)}}})},delete:function(a){c.info("link:delete");
|
||||
var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[12]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b.preventDefault();b=sysPassApp.requests.getRequestOpts();b.method="get";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get(),isAjax:1});sysPassApp.requests.getActionCall(b,
|
||||
function(b){sysPassApp.msg.out(b);0===b.status&&f({r:[a.data("action-next"),a.data("account-id")]})})}}})},refresh:function(a){c.info("link:refresh");g.state.update(a);var b=sysPassApp.requests.getRequestOpts();b.method="get";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get(),isAjax:1});sysPassApp.requests.getActionCall(b,function(b){sysPassApp.msg.out(b);0===b.status&&((b=a.data("action-next"))?f({r:[b,a.data("account-id")]}):f({r:g.state.tab.route,
|
||||
tabIndex:g.state.tab.index}))})}},eventlog:{clear:function(a){var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[20]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b.preventDefault();g.save(a)}}})}},ajaxUrl:e,plugin:{toggle:function(a){c.info("plugin:enable");g.state.update(a);var b=sysPassApp.requests.getRequestOpts();
|
||||
b.method="get";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get(),isAjax:1});sysPassApp.requests.getActionCall(b,function(a){sysPassApp.msg.out(a);0===a.status&&setTimeout(function(){sysPassApp.util.redirect("index.php")},2E3)})},reset:function(a){c.info("plugin:reset");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[58]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();
|
||||
sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b.preventDefault();g.save(a)}}})},search:function(a){c.info("plugin:search");m.search(a)},show:function(a){c.info("plugin:show");u.show(a)},save:function(a){c.info("plugin:save");var b=sysPassApp.requests.getRequestOpts();b.url=e.entrypoint+"?r="+a.data("route");b.data=a.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(b,function(b){sysPassApp.msg.out(b);0===b.status&&
|
||||
(f({r:a.data("action-next")}),$.magnificPopup.close())})},nav:function(a){c.info("plugin:nav");m.nav(a)}},notification:r,wiki:{show:function(a){c.info("wiki:show");var b=sysPassApp.requests.getRequestOpts();b.method="get";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:a.data("action-route"),pageName:a.data("pagename"),actionId:a.data("action-id"),sk:sysPassApp.sk.get(),isAjax:1});sysPassApp.requests.getActionCall(b,function(a){0!==a.status?sysPassApp.msg.out(a):h(a.data.html)})}},items:{get:function(a){c.info("items:get");
|
||||
var b=a[0].selectize;b.clearOptions();b.load(function(d){var c=sysPassApp.requests.getRequestOpts();c.method="get";c.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get()});sysPassApp.requests.getActionCall(c,function(c){d(c.data);b.setValue(a.data("selected-id"),!0);sysPassApp.triggers.updateFormHash()})})},update:function(a){c.info("items:update");var b=$("#"+a.data("item-dst"))[0].selectize,d=b.getValue();b.clearOptions();b.load(function(c){var f=
|
||||
sysPassApp.requests.getRequestOpts();f.method="get";f.url=sysPassApp.util.getUrl(e.entrypoint,{r:a.data("action-route"),sk:sysPassApp.sk.get()});sysPassApp.requests.getActionCall(f,function(a){c(a);b.setValue(d,!0)})})}},ldap:{check:function(a){c.info("ldap:check");var b=$(a.data("src")),d=sysPassApp.requests.getRequestOpts();d.url=e.entrypoint+"?r="+a.data("action-route");d.data=b.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(d,function(a){sysPassApp.msg.out(a);0===a.status&&
|
||||
void 0!==a.data.template&&void 0!==a.data.items&&h(a.data.template,{open:function(){var b=$("#ldap-results").find(".list-wrap").empty();a.data.items.forEach(function(a){b.append(sysPassApp.theme.html.getList(a.items,a.icon))})}})})},import:function(a){c.info("ldap:import");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[57]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},
|
||||
positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b=$(a.data("src"));var c=sysPassApp.requests.getRequestOpts();c.url=e.entrypoint+"?r="+a.data("action-route");c.data=b.serialize()+"&sk="+sysPassApp.sk.get();sysPassApp.requests.getActionCall(c,function(a){sysPassApp.msg.out(a)})}}})}},track:{unlock:function(a){c.info("track:unlock");var b=sysPassApp.requests.getRequestOpts();b.method="get";b.url=sysPassApp.util.getUrl(e.entrypoint,{r:[a.data("action-route"),a.data("item-id")],sk:sysPassApp.sk.get(),
|
||||
isAjax:1});sysPassApp.requests.getActionCall(b,function(b){sysPassApp.msg.out(b);g.refresh(a)})},clear:function(a){c.info("track:clear");var b='<div id="alert"><p id="alert-text">'+sysPassApp.config.LANG[71]+"</p></div>";mdlDialog().show({text:b,negative:{title:sysPassApp.config.LANG[44],onClick:function(a){a.preventDefault();sysPassApp.msg.error(sysPassApp.config.LANG[44])}},positive:{title:sysPassApp.config.LANG[43],onClick:function(b){b.preventDefault();g.save(a)}}})}}}};
|
||||
|
||||
@@ -236,26 +236,10 @@ sysPass.Requests = function (sysPassApp) {
|
||||
return source;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an object for a given route and query
|
||||
*
|
||||
* @param route
|
||||
* @param query
|
||||
* @returns {{r: string}}
|
||||
*/
|
||||
const getRouteForQuery = function (route, query) {
|
||||
if (typeof query === "object") {
|
||||
return {r: route + "/" + query.join("/")};
|
||||
}
|
||||
|
||||
return {r: route + "/" + query};
|
||||
};
|
||||
|
||||
return {
|
||||
getRequestOpts: getRequestOpts,
|
||||
getActionCall: getActionCall,
|
||||
getActionEvent: getActionEvent,
|
||||
getRouteForQuery: getRouteForQuery,
|
||||
history: history
|
||||
};
|
||||
};
|
||||
|
||||
8
public/js/app-requests.min.js
vendored
8
public/js/app-requests.min.js
vendored
@@ -1,5 +1,5 @@
|
||||
sysPass.Requests=function(c){var e=c.log,b=[],h={type:"json",url:"",method:"post",callback:"",async:!0,data:"",cache:!1,processData:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",timeout:0,addHistory:!1,hash:"",useLoading:!0,useFullLoading:!1};Object.seal(h);var k={get:function(){return b},add:function(a){var f=""===a.hash?c.util.hash.md5(JSON.stringify(a)):a.hash;if(0<b.length&&b[b.length-1].hash===f)return b;e.info("history:add");a.hash=f;b.push(a);15<=b.length&&b.splice(0,10);
|
||||
return b},del:function(){e.info("history:del");if("undefined"!==typeof b.pop())return b[b.length-1]},reset:function(){e.info("history:reset");b=[]},length:function(){return b.length}},l=function(a){return-1===a.indexOf("http")&&-1===a.indexOf("https")?c.config.APP_ROOT+a:a};return{getRequestOpts:function(){return Object.create(h)},getActionCall:function(a,b,m){e.info("getActionCall");return $.ajax({dataType:a.type,url:l(a.url),method:a.method,async:a.async,data:a.data,cache:a.cache,processData:a.processData,
|
||||
contentType:a.contentType,timeout:a.timeout,beforeSend:function(){!0===a.useLoading&&c.theme.loading.show(a.useFullLoading)},success:function(g){if("function"!==typeof b)return!0;!0===a.addHistory&&(a.callback=b,k.add(a));"json"===a.type&&void 0!==g.csrf&&""!==g.csrf&&c.sk.set(g.csrf);b(g)},error:function(b,d,f){"function"!==typeof m?(d=void 0!==c.config.LANG[1]?c.config.LANG[1]:"An error occurred",d+="<p>"+f+"</p><p>"+b.responseText+"</p>",e.error(d),"html"===a.type&&$("#content").html(c.msg.html.error(d)),
|
||||
sysPass.Requests=function(c){var e=c.log,b=[],g={type:"json",url:"",method:"post",callback:"",async:!0,data:"",cache:!1,processData:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",timeout:0,addHistory:!1,hash:"",useLoading:!0,useFullLoading:!1};Object.seal(g);var k={get:function(){return b},add:function(a){var h=""===a.hash?c.util.hash.md5(JSON.stringify(a)):a.hash;if(0<b.length&&b[b.length-1].hash===h)return b;e.info("history:add");a.hash=h;b.push(a);15<=b.length&&b.splice(0,10);
|
||||
return b},del:function(){e.info("history:del");if("undefined"!==typeof b.pop())return b[b.length-1]},reset:function(){e.info("history:reset");b=[]},length:function(){return b.length}},l=function(a){return-1===a.indexOf("http")&&-1===a.indexOf("https")?c.config.APP_ROOT+a:a};return{getRequestOpts:function(){return Object.create(g)},getActionCall:function(a,b,m){e.info("getActionCall");return $.ajax({dataType:a.type,url:l(a.url),method:a.method,async:a.async,data:a.data,cache:a.cache,processData:a.processData,
|
||||
contentType:a.contentType,timeout:a.timeout,beforeSend:function(){!0===a.useLoading&&c.theme.loading.show(a.useFullLoading)},success:function(f){if("function"!==typeof b)return!0;!0===a.addHistory&&(a.callback=b,k.add(a));"json"===a.type&&void 0!==f.csrf&&""!==f.csrf&&c.sk.set(f.csrf);b(f)},error:function(b,d,n){"function"!==typeof m?(d=void 0!==c.config.LANG[1]?c.config.LANG[1]:"An error occurred",d+="<p>"+n+"</p><p>"+b.responseText+"</p>",e.error(d),"html"===a.type&&$("#content").html(c.msg.html.error(d)),
|
||||
c.msg.error(d)):m()},complete:function(b){!0===a.useLoading&&c.theme.loading.hide();void 0!==c.theme&&c.theme.ajax.complete()}})},getActionEvent:function(a,b,c){var f=l(a.url);f+="?"+$.param(a.data);var d=new EventSource(f);d.addEventListener("message",function(a){a=JSON.parse(a.data);e.debug(a);1===a.end?(e.info("getActionEvent:Ending"),d.close(),"function"===typeof c&&c(a)):"function"===typeof b&&b(a)});d.addEventListener("error",function(a){e.error("getActionEvent:Error occured");d.close()});return d},
|
||||
getRouteForQuery:function(a,b){return"object"===typeof b?{r:a+"/"+b.join("/")}:{r:a+"/"+b}},history:k}};
|
||||
history:k}};
|
||||
|
||||
@@ -480,7 +480,7 @@ sysPass.Util = function (log) {
|
||||
*/
|
||||
const notifications = {
|
||||
state: {
|
||||
lastHash : ''
|
||||
lastHash: ''
|
||||
},
|
||||
send: function (title, message, id) {
|
||||
log.info("sendNotification");
|
||||
@@ -523,6 +523,22 @@ sysPass.Util = function (log) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a serialized URL for a GET request
|
||||
* @param base
|
||||
* @param parts
|
||||
* @returns {string}
|
||||
*/
|
||||
const getUrl = function (base, parts) {
|
||||
return base + "?" + Object.keys(parts).map(function (key) {
|
||||
if (Array.isArray(parts[key])) {
|
||||
return key + "=" + parts[key].join("/");
|
||||
}
|
||||
|
||||
return key + "=" + parts[key];
|
||||
}).join("&");
|
||||
};
|
||||
|
||||
return {
|
||||
decodeEntities: decodeEntities,
|
||||
resizeImage: resizeImage,
|
||||
@@ -531,6 +547,7 @@ sysPass.Util = function (log) {
|
||||
setContentSize: setContentSize,
|
||||
redirect: redirect,
|
||||
uniqueId: uniqueId,
|
||||
getUrl: getUrl,
|
||||
sendNotification: notifications.send,
|
||||
password: password,
|
||||
hash: hash
|
||||
|
||||
493
public/vendor/js/jquery.fileDownload.js
vendored
Normal file
493
public/vendor/js/jquery.fileDownload.js
vendored
Normal file
@@ -0,0 +1,493 @@
|
||||
/*
|
||||
* jQuery File Download Plugin v1.4.5
|
||||
*
|
||||
* http://www.johnculviner.com
|
||||
*
|
||||
* Copyright (c) 2013 - John Culviner
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* !!!!NOTE!!!!
|
||||
* You must also write a cookie in conjunction with using this plugin as mentioned in the orignal post:
|
||||
* http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/
|
||||
* !!!!NOTE!!!!
|
||||
*/
|
||||
|
||||
(function($, window){
|
||||
// i'll just put them here to get evaluated on script load
|
||||
var htmlSpecialCharsRegEx = /[<>&\r\n"']/gm;
|
||||
var htmlSpecialCharsPlaceHolders = {
|
||||
'<': 'lt;',
|
||||
'>': 'gt;',
|
||||
'&': 'amp;',
|
||||
'\r': "#13;",
|
||||
'\n': "#10;",
|
||||
'"': 'quot;',
|
||||
"'": '#39;' /*single quotes just to be safe, IE8 doesn't support ', so use ' instead */
|
||||
};
|
||||
|
||||
$.extend({
|
||||
//
|
||||
//$.fileDownload('/path/to/url/', options)
|
||||
// see directly below for possible 'options'
|
||||
fileDownload: function (fileUrl, options) {
|
||||
|
||||
//provide some reasonable defaults to any unspecified options below
|
||||
var settings = $.extend({
|
||||
|
||||
//
|
||||
//Requires jQuery UI: provide a message to display to the user when the file download is being prepared before the browser's dialog appears
|
||||
//
|
||||
preparingMessageHtml: null,
|
||||
|
||||
//
|
||||
//Requires jQuery UI: provide a message to display to the user when a file download fails
|
||||
//
|
||||
failMessageHtml: null,
|
||||
|
||||
//
|
||||
//the stock android browser straight up doesn't support file downloads initiated by a non GET: http://code.google.com/p/android/issues/detail?id=1780
|
||||
//specify a message here to display if a user tries with an android browser
|
||||
//if jQuery UI is installed this will be a dialog, otherwise it will be an alert
|
||||
//Set to null to disable the message and attempt to download anyway
|
||||
//
|
||||
androidPostUnsupportedMessageHtml: "Unfortunately your Android browser doesn't support this type of file download. Please try again with a different browser.",
|
||||
|
||||
//
|
||||
//Requires jQuery UI: options to pass into jQuery UI Dialog
|
||||
//
|
||||
dialogOptions: { modal: true },
|
||||
|
||||
//
|
||||
//a function to call while the dowload is being prepared before the browser's dialog appears
|
||||
//Args:
|
||||
// url - the original url attempted
|
||||
//
|
||||
prepareCallback: function (url) { },
|
||||
|
||||
//
|
||||
//a function to call after a file download successfully completed
|
||||
//Args:
|
||||
// url - the original url attempted
|
||||
//
|
||||
successCallback: function (url) { },
|
||||
|
||||
//
|
||||
//a function to call after a file download request was canceled
|
||||
//Args:
|
||||
// url - the original url attempted
|
||||
//
|
||||
abortCallback: function (url) { },
|
||||
|
||||
//
|
||||
//a function to call after a file download failed
|
||||
//Args:
|
||||
// responseHtml - the html that came back in response to the file download. this won't necessarily come back depending on the browser.
|
||||
// in less than IE9 a cross domain error occurs because 500+ errors cause a cross domain issue due to IE subbing out the
|
||||
// server's error message with a "helpful" IE built in message
|
||||
// url - the original url attempted
|
||||
// error - original error cautch from exception
|
||||
//
|
||||
failCallback: function (responseHtml, url, error) { },
|
||||
|
||||
//
|
||||
// the HTTP method to use. Defaults to "GET".
|
||||
//
|
||||
httpMethod: "GET",
|
||||
|
||||
//
|
||||
// if specified will perform a "httpMethod" request to the specified 'fileUrl' using the specified data.
|
||||
// data must be an object (which will be $.param serialized) or already a key=value param string
|
||||
//
|
||||
data: null,
|
||||
|
||||
//
|
||||
//a period in milliseconds to poll to determine if a successful file download has occured or not
|
||||
//
|
||||
checkInterval: 100,
|
||||
|
||||
//
|
||||
//the cookie name to indicate if a file download has occured
|
||||
//
|
||||
cookieName: "fileDownload",
|
||||
|
||||
//
|
||||
//the cookie value for the above name to indicate that a file download has occured
|
||||
//
|
||||
cookieValue: "true",
|
||||
|
||||
//
|
||||
//the cookie path for above name value pair
|
||||
//
|
||||
cookiePath: "/",
|
||||
|
||||
//
|
||||
//if specified it will be used when attempting to clear the above name value pair
|
||||
//useful for when downloads are being served on a subdomain (e.g. downloads.example.com)
|
||||
//
|
||||
cookieDomain: null,
|
||||
|
||||
//
|
||||
//the title for the popup second window as a download is processing in the case of a mobile browser
|
||||
//
|
||||
popupWindowTitle: "Initiating file download...",
|
||||
|
||||
//
|
||||
//Functionality to encode HTML entities for a POST, need this if data is an object with properties whose values contains strings with quotation marks.
|
||||
//HTML entity encoding is done by replacing all &,<,>,',",\r,\n characters.
|
||||
//Note that some browsers will POST the string htmlentity-encoded whilst others will decode it before POSTing.
|
||||
//It is recommended that on the server, htmlentity decoding is done irrespective.
|
||||
//
|
||||
encodeHTMLEntities: true
|
||||
|
||||
}, options);
|
||||
|
||||
var deferred = new $.Deferred();
|
||||
|
||||
//Setup mobile browser detection: Partial credit: http://detectmobilebrowser.com/
|
||||
var userAgent = (navigator.userAgent || navigator.vendor || window.opera).toLowerCase();
|
||||
|
||||
var isIos; //has full support of features in iOS 4.0+, uses a new window to accomplish this.
|
||||
var isAndroid; //has full support of GET features in 4.0+ by using a new window. Non-GET is completely unsupported by the browser. See above for specifying a message.
|
||||
var isOtherMobileBrowser; //there is no way to reliably guess here so all other mobile devices will GET and POST to the current window.
|
||||
|
||||
if (/ip(ad|hone|od)/.test(userAgent)) {
|
||||
|
||||
isIos = true;
|
||||
|
||||
} else if (userAgent.indexOf('android') !== -1) {
|
||||
|
||||
isAndroid = true;
|
||||
|
||||
} else {
|
||||
|
||||
isOtherMobileBrowser = /avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|playbook|silk|iemobile|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0, 4));
|
||||
|
||||
}
|
||||
|
||||
var httpMethodUpper = settings.httpMethod.toUpperCase();
|
||||
|
||||
if (isAndroid && httpMethodUpper !== "GET" && settings.androidPostUnsupportedMessageHtml) {
|
||||
//the stock android browser straight up doesn't support file downloads initiated by non GET requests: http://code.google.com/p/android/issues/detail?id=1780
|
||||
|
||||
if ($().dialog) {
|
||||
$("<div>").html(settings.androidPostUnsupportedMessageHtml).dialog(settings.dialogOptions);
|
||||
} else {
|
||||
alert(settings.androidPostUnsupportedMessageHtml);
|
||||
}
|
||||
|
||||
return deferred.reject();
|
||||
}
|
||||
|
||||
var $preparingDialog = null;
|
||||
|
||||
var internalCallbacks = {
|
||||
|
||||
onPrepare: function (url) {
|
||||
|
||||
//wire up a jquery dialog to display the preparing message if specified
|
||||
if (settings.preparingMessageHtml) {
|
||||
|
||||
$preparingDialog = $("<div>").html(settings.preparingMessageHtml).dialog(settings.dialogOptions);
|
||||
|
||||
} else if (settings.prepareCallback) {
|
||||
|
||||
settings.prepareCallback(url);
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
onSuccess: function (url) {
|
||||
|
||||
//remove the perparing message if it was specified
|
||||
if ($preparingDialog) {
|
||||
$preparingDialog.dialog('close');
|
||||
}
|
||||
|
||||
settings.successCallback(url);
|
||||
|
||||
deferred.resolve(url);
|
||||
},
|
||||
|
||||
onAbort: function (url) {
|
||||
|
||||
//remove the perparing message if it was specified
|
||||
if ($preparingDialog) {
|
||||
$preparingDialog.dialog('close');
|
||||
};
|
||||
|
||||
settings.abortCallback(url);
|
||||
|
||||
deferred.reject(url);
|
||||
},
|
||||
|
||||
onFail: function (responseHtml, url, error) {
|
||||
|
||||
//remove the perparing message if it was specified
|
||||
if ($preparingDialog) {
|
||||
$preparingDialog.dialog('close');
|
||||
}
|
||||
|
||||
//wire up a jquery dialog to display the fail message if specified
|
||||
if (settings.failMessageHtml) {
|
||||
$("<div>").html(settings.failMessageHtml).dialog(settings.dialogOptions);
|
||||
}
|
||||
|
||||
settings.failCallback(responseHtml, url, error);
|
||||
|
||||
deferred.reject(responseHtml, url);
|
||||
}
|
||||
};
|
||||
|
||||
internalCallbacks.onPrepare(fileUrl);
|
||||
|
||||
//make settings.data a param string if it exists and isn't already
|
||||
if (settings.data !== null && typeof settings.data !== "string") {
|
||||
settings.data = $.param(settings.data);
|
||||
}
|
||||
|
||||
|
||||
var $iframe,
|
||||
downloadWindow,
|
||||
formDoc,
|
||||
$form;
|
||||
|
||||
if (httpMethodUpper === "GET") {
|
||||
|
||||
if (settings.data !== null) {
|
||||
//need to merge any fileUrl params with the data object
|
||||
|
||||
var qsStart = fileUrl.indexOf('?');
|
||||
|
||||
if (qsStart !== -1) {
|
||||
//we have a querystring in the url
|
||||
|
||||
if (fileUrl.substring(fileUrl.length - 1) !== "&") {
|
||||
fileUrl = fileUrl + "&";
|
||||
}
|
||||
} else {
|
||||
|
||||
fileUrl = fileUrl + "?";
|
||||
}
|
||||
|
||||
fileUrl = fileUrl + settings.data;
|
||||
}
|
||||
|
||||
if (isIos || isAndroid) {
|
||||
|
||||
downloadWindow = window.open(fileUrl);
|
||||
downloadWindow.document.title = settings.popupWindowTitle;
|
||||
window.focus();
|
||||
|
||||
} else if (isOtherMobileBrowser) {
|
||||
|
||||
window.location(fileUrl);
|
||||
|
||||
} else {
|
||||
|
||||
//create a temporary iframe that is used to request the fileUrl as a GET request
|
||||
$iframe = $("<iframe>")
|
||||
.hide()
|
||||
.prop("src", fileUrl)
|
||||
.appendTo("body");
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
var formInnerHtml = "";
|
||||
|
||||
if (settings.data !== null) {
|
||||
|
||||
$.each(settings.data.replace(/\+/g, ' ').split("&"), function () {
|
||||
|
||||
var kvp = this.split("=");
|
||||
|
||||
//Issue: When value contains sign '=' then the kvp array does have more than 2 items. We have to join value back
|
||||
var k = kvp[0];
|
||||
kvp.shift();
|
||||
var v = kvp.join("=");
|
||||
kvp = [k, v];
|
||||
|
||||
var key = settings.encodeHTMLEntities ? htmlSpecialCharsEntityEncode(decodeURIComponent(kvp[0])) : decodeURIComponent(kvp[0]);
|
||||
if (key) {
|
||||
var value = settings.encodeHTMLEntities ? htmlSpecialCharsEntityEncode(decodeURIComponent(kvp[1])) : decodeURIComponent(kvp[1]);
|
||||
formInnerHtml += '<input type="hidden" name="' + key + '" value="' + value + '" />';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (isOtherMobileBrowser) {
|
||||
|
||||
$form = $("<form>").appendTo("body");
|
||||
$form.hide()
|
||||
.prop('method', settings.httpMethod)
|
||||
.prop('action', fileUrl)
|
||||
.html(formInnerHtml);
|
||||
|
||||
} else {
|
||||
|
||||
if (isIos) {
|
||||
|
||||
downloadWindow = window.open("about:blank");
|
||||
downloadWindow.document.title = settings.popupWindowTitle;
|
||||
formDoc = downloadWindow.document;
|
||||
window.focus();
|
||||
|
||||
} else {
|
||||
|
||||
$iframe = $("<iframe style='display: none' src='about:blank'></iframe>").appendTo("body");
|
||||
formDoc = getiframeDocument($iframe);
|
||||
}
|
||||
|
||||
formDoc.write("<html><head></head><body><form method='" + settings.httpMethod + "' action='" + fileUrl + "'>" + formInnerHtml + "</form>" + settings.popupWindowTitle + "</body></html>");
|
||||
$form = $(formDoc).find('form');
|
||||
}
|
||||
|
||||
$form.submit();
|
||||
}
|
||||
|
||||
|
||||
//check if the file download has completed every checkInterval ms
|
||||
setTimeout(checkFileDownloadComplete, settings.checkInterval);
|
||||
|
||||
|
||||
function checkFileDownloadComplete() {
|
||||
//has the cookie been written due to a file download occuring?
|
||||
|
||||
var cookieValue = settings.cookieValue;
|
||||
if(typeof cookieValue == 'string') {
|
||||
cookieValue = cookieValue.toLowerCase();
|
||||
}
|
||||
|
||||
var lowerCaseCookie = settings.cookieName.toLowerCase() + "=" + cookieValue;
|
||||
|
||||
if (document.cookie.toLowerCase().indexOf(lowerCaseCookie) > -1) {
|
||||
|
||||
//execute specified callback
|
||||
internalCallbacks.onSuccess(fileUrl);
|
||||
|
||||
//remove cookie
|
||||
var cookieData = settings.cookieName + "=; path=" + settings.cookiePath + "; expires=" + new Date(0).toUTCString() + ";";
|
||||
if (settings.cookieDomain) cookieData += " domain=" + settings.cookieDomain + ";";
|
||||
document.cookie = cookieData;
|
||||
|
||||
//remove iframe
|
||||
cleanUp(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//has an error occured?
|
||||
//if neither containers exist below then the file download is occuring on the current window
|
||||
if (downloadWindow || $iframe) {
|
||||
|
||||
//has an error occured?
|
||||
try {
|
||||
|
||||
var formDoc = downloadWindow ? downloadWindow.document : getiframeDocument($iframe);
|
||||
|
||||
if (formDoc && formDoc.body !== null && formDoc.body.innerHTML.length) {
|
||||
|
||||
var isFailure = true;
|
||||
|
||||
if ($form && $form.length) {
|
||||
var $contents = $(formDoc.body).contents().first();
|
||||
|
||||
try {
|
||||
if ($contents.length && $contents[0] === $form[0]) {
|
||||
isFailure = false;
|
||||
}
|
||||
} catch (e) {
|
||||
if (e && e.number == -2146828218) {
|
||||
// IE 8-10 throw a permission denied after the form reloads on the "$contents[0] === $form[0]" comparison
|
||||
isFailure = true;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isFailure) {
|
||||
// IE 8-10 don't always have the full content available right away, they need a litle bit to finish
|
||||
setTimeout(function () {
|
||||
internalCallbacks.onFail(formDoc.body.innerHTML, fileUrl);
|
||||
cleanUp(true);
|
||||
}, 100);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
//500 error less than IE9
|
||||
internalCallbacks.onFail('', fileUrl, err);
|
||||
|
||||
cleanUp(true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//keep checking...
|
||||
setTimeout(checkFileDownloadComplete, settings.checkInterval);
|
||||
}
|
||||
|
||||
//gets an iframes document in a cross browser compatible manner
|
||||
function getiframeDocument($iframe) {
|
||||
var iframeDoc = $iframe[0].contentWindow || $iframe[0].contentDocument;
|
||||
if (iframeDoc.document) {
|
||||
iframeDoc = iframeDoc.document;
|
||||
}
|
||||
return iframeDoc;
|
||||
}
|
||||
|
||||
function cleanUp(isFailure) {
|
||||
|
||||
setTimeout(function() {
|
||||
|
||||
if (downloadWindow) {
|
||||
|
||||
if (isAndroid) {
|
||||
downloadWindow.close();
|
||||
}
|
||||
|
||||
if (isIos) {
|
||||
if (downloadWindow.focus) {
|
||||
downloadWindow.focus(); //ios safari bug doesn't allow a window to be closed unless it is focused
|
||||
if (isFailure) {
|
||||
downloadWindow.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//iframe cleanup appears to randomly cause the download to fail
|
||||
//not doing it seems better than failure...
|
||||
//if ($iframe) {
|
||||
// $iframe.remove();
|
||||
//}
|
||||
|
||||
}, 0);
|
||||
}
|
||||
|
||||
|
||||
function htmlSpecialCharsEntityEncode(str) {
|
||||
return str.replace(htmlSpecialCharsRegEx, function(match) {
|
||||
return '&' + htmlSpecialCharsPlaceHolders[match];
|
||||
});
|
||||
}
|
||||
var promise = deferred.promise();
|
||||
promise.abort = function() {
|
||||
cleanUp();
|
||||
$iframe.attr('src', '').html('');
|
||||
internalCallbacks.onAbort(fileUrl);
|
||||
};
|
||||
return promise;
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery, this || window);
|
||||
13
public/vendor/js/jquery.fileDownload.min.js
vendored
13
public/vendor/js/jquery.fileDownload.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user