Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for #78 added option to enable libraries #158

Merged
merged 1 commit into from
Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drawio/controller/editorcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public function index($fileId, $shareToken = NULL, $filePath = NULL) {
"drawioOfflineMode" => $offlineMode,
"drawioFilePath" => rawurlencode($relativePath),
"drawioAutosave" =>$this->config->GetAutosave(),
"drawioLibraries" =>$this->config->GetLibraries(),
"fileId" => $fileId,
"filePath" => $filePath,
"shareToken" => $shareToken
Expand Down
4 changes: 4 additions & 0 deletions drawio/controller/settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function index() {
"drawioTheme" => $this->config->GetTheme(),
"drawioLang" => $this->config->GetLang(),
"drawioAutosave" => $this->config->GetAutosave()
"drawioLibraries" => $this->config->GetLibraries()
];
return new TemplateResponse($this->appName, "settings", $data, "blank");
}
Expand All @@ -78,12 +79,14 @@ public function settings()
$theme = trim($_POST['theme']);
$lang = trim($_POST['lang']);
$autosave = trim($_POST['autosave']);
$libraries = trim($_POST['libraries']);

$this->config->SetDrawioUrl($drawio);
$this->config->SetOfflineMode($offlinemode);
$this->config->SetTheme($theme);
$this->config->SetLang($lang);
$this->config->SetAutosave($autosave);
$this->config->SetLibraries($libraries);

if (version_compare(implode(".", \OCP\Util::getVersion()), "13", ">=")) {
$checkmime = new \OCA\Drawio\Migration\CheckMimeType();
Expand All @@ -103,6 +106,7 @@ public function settings()
"theme" => $this->config->GetTheme(),
"lang" => $this->config->GetLang(),
"drawioAutosave" =>$this->config->GetAutosave()
"drawioLibraries" =>$this->config->GetLibraries()
];
}

Expand Down
1 change: 1 addition & 0 deletions drawio/controller/viewercontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function index($fileId, $shareToken = NULL, $filePath = NULL) {
"drawioOfflineMode" => $offlineMode,
//"drawioFilePath" => rawurlencode($relativePath), // info not needed for public view
"drawioAutosave" => $this->config->GetAutosave(),
"drawioLibraries" =>$this->config->GetLibraries(),
"fileId" => $fileId,
"filePath" => $filePath,
"shareToken" => $shareToken,
Expand Down
5 changes: 4 additions & 1 deletion drawio/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
var f_theme = $("#theme option:selected").val();
var f_lang = $("#lang").val().trim();
var f_autosave = $("#drawioAutosave option:selected").val();
var f_libraries = $("#drawioLibraries option:selected").val();

var saving = OC.Notification.show( t(OCA.Drawio.AppName, "Saving...") );

Expand All @@ -33,7 +34,8 @@
offlineMode: f_offlineMode,
theme: f_theme,
lang: f_lang,
autosave: f_autosave
autosave: f_autosave,
libraries: f_libraries
};


Expand All @@ -52,6 +54,7 @@
$("#theme").val(response.theme);
$("#lang").val(response.lang);
$("#drawioAutosave").val(response.drawioAutosave);
$("#drawioLibraries").val(response.libraries);

var message =
response.error
Expand Down
15 changes: 15 additions & 0 deletions drawio/lib/appconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AppConfig {
private $predefTheme = "kennedy"; //kennedy, minimal, atlas, dark
private $predefLang = "auto";
private $predefAutosave = "yes";
private $predefLibraries = "no";

private $appName;

Expand All @@ -35,6 +36,7 @@ class AppConfig {
private $_theme = "DrawioTheme";
private $_lang = "DrawioLang";
private $_autosave = "DrawioAutosave";
private $_libraries = "DrawioLibraries";

public function __construct($AppName)
{
Expand Down Expand Up @@ -115,6 +117,19 @@ public function GetAutosave()
return $val;
}

public function SetLibraries($libraries)
{
$this->logger->info("SetLibraries: " . $libraries, array("app" => $this->appName));
$this->config->setAppValue($this->appName, $this->_libraries, $libraries);
}

public function GetLibraries()
{
$val = $this->config->getAppValue($this->appName, $this->_libraries);
if (empty($val)) $val = $this->predefLibraries;
return $val;
}

public function GetAppName()
{
return $this->appName;
Expand Down
4 changes: 4 additions & 0 deletions drawio/templates/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
$frame_params .= "&offline=1&stealth=1";
}
if ($_["drawioLibraries"] == "yes")
{
$frame_params .= "&libraries=1";
}
if (!empty($_["drawioTheme"])) $frame_params .= "&ui=".$_["drawioTheme"];
if (!empty($_["drawioLang"])) $frame_params .= "&lang=".$_["drawioLang"];
if (!empty($_["drawioUrlArgs"])) $frame_params .= "&".$_["drawioUrlArgs"];
Expand Down
8 changes: 8 additions & 0 deletions drawio/templates/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
</select>
</p>

<p class="drawio-header">
<label for='drawioLibraries'><?php p($l->t("Enable libraries?")) ?>
<select id="drawioLibraries">
<option value="yes"<?php if ($_["drawioLibraries"] === "yes") echo ' selected'; ?>><?php p($l->t("Yes")) ?></option>
<option value="no"<?php if ($_["drawioLibraries"] === "no") echo ' selected'; ?>><?php p($l->t("No")) ?></option>
</select>
</p>

<br />
<a id="drawioSave" class="button"><?php p($l->t("Save")) ?></a>
</div>
4 changes: 4 additions & 0 deletions drawio/templates/viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
{
$frame_params .= "&offline=1&stealth=1";
}
if ($_["drawioLibraries"] == "yes")
{
$frame_params .= "&libraries=1";
}
if (!empty($_["drawioTheme"])) $frame_params .= "&ui=".$_["drawioTheme"];
if (!empty($_["drawioLang"])) $frame_params .= "&lang=".$_["drawioLang"];
if (!empty($_["drawioUrlArgs"])) $frame_params .= "&".$_["drawioUrlArgs"];
Expand Down