started restructuring of web interface

This commit is contained in:
Martchus 2015-09-12 20:37:04 +02:00
parent 6d06663791
commit 0d20332542
17 changed files with 213 additions and 195 deletions

View File

@ -38,10 +38,10 @@ using namespace Utilities;
*/
/*!
* \brief Constructs a new package instance for the specified ALPM \a package.
* \brief Constructs a new instance for the specified ALPM \a package.
*/
AlpmPackage::AlpmPackage(alpm_pkg_t *package, AlpmDatabase *source) :
Package(QString::fromLocal8Bit(alpm_pkg_get_name(package)), source),
AlpmPackage::AlpmPackage(alpm_pkg_t *package, AlpmDatabase *alpmDatabase) :
Package(QString::fromLocal8Bit(alpm_pkg_get_name(package)), alpmDatabase),
m_ptr(package)
{
m_origin = static_cast<PackageOrigin>(alpm_pkg_get_origin(package));

View File

@ -10,7 +10,8 @@ class AlpmDatabase;
class AlpmPackage : public Package
{
public:
AlpmPackage(alpm_pkg_t *package, AlpmDatabase *source = nullptr);
AlpmPackage(alpm_pkg_t *package, AlpmDatabase *alpmDatabase);
AlpmPackage(alpm_pkg_t *package);
// ALPM specific meta data
const alpm_pkg_t *ptr() const;
@ -24,6 +25,15 @@ protected:
alpm_pkg_t *m_ptr;
};
/*!
* \brief Constructs a new instance for the specified ALPM \a package.
* \remarks This method is only meant to be used for packages which do
* not belong to a database.
*/
inline AlpmPackage::AlpmPackage(alpm_pkg_t *package) :
AlpmPackage(package, nullptr)
{}
inline uint qHash(const AlpmPackage &key)
{
return qHash(key.ptr());

View File

@ -16,8 +16,8 @@ namespace RepoIndex {
/*!
* \brief Creates a new instance from the specified "AurJson value".
*/
AurPackage::AurPackage(const QJsonValue &aurJsonValue, UserRepository *source) :
Package(QString(), source)
AurPackage::AurPackage(const QJsonValue &aurJsonValue, UserRepository *repository) :
Package(QString(), repository)
{
m_origin = PackageOrigin::Aur;
QJsonObject obj = aurJsonValue.toObject();
@ -41,8 +41,8 @@ AurPackage::AurPackage(const QJsonValue &aurJsonValue, UserRepository *source) :
* \brief Creates a new, empty instance.
* \remarks The only purpose of this c'tor is to use it with restoreFromCacheStream().
*/
AurPackage::AurPackage(UserRepository *source) :
Package(QString(), source)
AurPackage::AurPackage(UserRepository *repository) :
Package(QString(), repository)
{}
} // namespace PackageManagement

View File

@ -10,8 +10,8 @@ class UserRepository;
class AurPackage : public Package
{
public:
AurPackage(const QJsonValue &aurJsonValue, UserRepository *source);
AurPackage(UserRepository *source);
AurPackage(const QJsonValue &aurJsonValue, UserRepository *repository);
AurPackage(UserRepository *repository);
};
} // namespace PackageManagement

View File

@ -29,9 +29,9 @@ namespace RepoIndex {
* Since it is intenced to use the Package class as base class only,
* this constructor is protected.
*/
Package::Package(const QString &name, Repository *source) :
Package::Package(const QString &name, Repository *repository) :
m_origin(PackageOrigin::Unknown),
m_source(source),
m_repository(repository),
m_hasGeneralInfo(false),
m_name(name),
m_requiredByComputed(false),
@ -295,8 +295,8 @@ QJsonObject Package::basicInfo(bool includeRepoAndName) const
{
QJsonObject info;
if(includeRepoAndName) {
if(source()) {
put(info, QStringLiteral("repo"), source()->name());
if(repository()) {
put(info, QStringLiteral("repo"), repository()->name());
}
put(info, QStringLiteral("name"), name());
}
@ -316,8 +316,8 @@ QJsonObject Package::fullInfo(bool includeRepoAndName) const
{
QJsonObject info;
if(includeRepoAndName) {
if(source()) {
put(info, QStringLiteral("repo"), source()->name());
if(repository()) {
put(info, QStringLiteral("repo"), repository()->name());
}
put(info, QStringLiteral("name"), name());
}

View File

@ -97,7 +97,7 @@ public:
// general package meta data
PackageOrigin origin() const;
Repository *source() const;
Repository *repository() const;
bool hasGeneralInfo() const;
const QString &name() const;
const QString &version() const;
@ -165,12 +165,12 @@ public:
void restoreFromCacheStream(QDataStream &in);
protected:
explicit Package(const QString &name, Repository *source);
explicit Package(const QString &name, Repository *repository);
virtual void writeSpecificCacheHeader(QDataStream &out);
virtual void restoreSpecificCacheHeader(QDataStream &in);
PackageOrigin m_origin;
Repository *m_source;
Repository *m_repository;
// general package meta data
bool m_hasGeneralInfo;
@ -234,12 +234,12 @@ inline PackageOrigin Package::origin() const
}
/*!
* \brief Returns the package source.
* \remarks Might be nullptr if no source is associated.
* \brief Returns the repository.
* \remarks Might be nullptr if no repository is associated.
*/
inline Repository *Package::source() const
inline Repository *Package::repository() const
{
return m_source;
return m_repository;
}
/*!

View File

@ -235,8 +235,8 @@ void UpgradeLookupJson::processFinished()
}
// add results to results QJsonObject
QJsonObject results;
results.insert(QStringLiteral("softwareUpdates"), m_softwareUpgradesArray);
results.insert(QStringLiteral("packageOnlyUpdates"), m_packageOnlyUpgradesArray);
results.insert(QStringLiteral("softwareUpgrades"), m_softwareUpgradesArray);
results.insert(QStringLiteral("packageOnlyUpgrades"), m_packageOnlyUpgradesArray);
results.insert(QStringLiteral("downgrades"), m_downgradesArray);
results.insert(QStringLiteral("orphanedPackages"), m_orphanedPackagesArray);
if(!m_warningsArray.isEmpty()) {

View File

@ -2,6 +2,7 @@
#include "../alpm/manager.h"
#include "../alpm/upgradelookup.h"
#include "../alpm/config.h"
#include <QJsonDocument>
#include <QJsonObject>
@ -9,6 +10,10 @@
#include <QWebSocket>
#include <QCoreApplication>
#include <iostream>
using namespace std;
namespace RepoIndex {
Connection::Connection(const Manager &alpmManager, QWebSocket *socket, QObject *parent) :
@ -78,7 +83,7 @@ void Connection::handleQuery(const QJsonObject &obj)
} else if(what == QLatin1String("groupinfo")) {
m_groupInfoUpdatesRequested = obj.value(QStringLiteral("updates")).toBool(m_groupInfoUpdatesRequested);
sendResults(what, id, m_manager.groupInfo());
} else if(what == QLatin1String("checkforupdates")) {
} else if(what == QLatin1String("upgradelookup")) {
connect(new UpgradeLookupJson(m_manager, obj), &UpgradeLookupJson::resultsAvailable, this, &Connection::sendResult);
} else if(what == QLatin1String("ping")) {
sendResult(what, id, QStringLiteral("pong"));
@ -93,6 +98,7 @@ void Connection::handleCmd(const QJsonObject &obj)
const auto id = obj.value(QStringLiteral("id"));
if(what == QLatin1String("stop")) {
if(m_socket->peerAddress().isLoopback()) {
cerr << shchar << "Info: Server stopped via web interface." << endl;
QCoreApplication::quit();
} else {
sendError(QStringLiteral("rejected"), id);

View File

@ -56,7 +56,6 @@ DISTFILES += \
README.md \
LICENSE \
web/index.html \
web/js/alpm.js \
web/js/pagination.js \
web/js/entrymanagement.js \
web/js/packagemanagement.js \
@ -67,7 +66,8 @@ DISTFILES += \
web/js/utils.js \
web/css/core.css \
web/css/dashboard.css \
repoindex.conf.js
repoindex.conf.js \
web/js/client.js
# defines
CONFIG(release, debug|release) {

View File

@ -91,10 +91,6 @@ span.glyphicon {
.navbar-fixed-top {
border-bottom: 5px solid #337ab7;
}
.navbar-form {
padding-left: 0px;
padding-right: 8px;
}
/*
* Package info

View File

@ -47,20 +47,15 @@
<li id="nav_settings"><a id="link_settings" href="#" aria-label="Settings" data-toggle="popover" data-placement="bottom" title="Settings" data-content="TODO"><span class="glyphicon glyphicon-wrench" aria-hidden="true"></span></a></li>
<li id="nav_about"><a id="link_settings" href="#" onclick="$('#dlg_about').modal('show'); return false;"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></a></li>
</ul>
<form class="navbar-form navbar-right">
<button class="btn btn-danger" onclick="repoindex.alpmClient.stopServer();">Stop server</button>
</form>
<form class="navbar-form navbar-right">
<button id="nav_connect" class="btn btn-danger" onclick="repoindex.alpmClient.init();"><span class="glyphicon glyphicon glyphicon-refresh" aria-hidden="true" id="connection_glyphicon"></span> <span id="connection_status">Disconnected</span></button>
</form>
<form class="navbar-form navbar-right" role="search" onsubmit="repoindex.pageManager.applySearchTerm(this.searchtermInput.value, this.searchtermExact.checked); return false;" style="width: 30%;">
<form class="navbar-form navbar-left" target="#" onsubmit="repoindex.pageManager.applySearchTerm(this.searchtermInput.value, this.searchtermExact.checked, true); return false;">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="searchtermInput" oninput="repoindex.pageManager.applySearchTerm(this.value, this.form.searchtermExact.checked);">
<span class="input-group-btn">
<button type="submit" class="btn btn-default btn-slim-glyphicon">
<span class="glyphicon glyphicon-search"></span><span class="sr-only"> Search</span>
</button>
<button type="button" class="btn btn-default btn-slim-glyphicon" aria-label="clear" onclick="repoindex.pageManager.applySearchTerm(this.form.searchtermInput.value = '');">
<button type="button" class="btn btn-default btn-slim-glyphicon" aria-label="clear" onclick="repoindex.pageManager.applySearchTerm(this.form.searchtermInput.value = '', false, true);">
<!-- button can't be reset because this would reset the "exact"-checkbox too -->
<span class="glyphicon glyphicon-remove-sign"></span><span class="sr-only"> Clear</span>
</button>
<button type="button" class="btn btn-default btn-slim dropdown-toggle" data-toggle="dropdown" data-placeholder="false" aria-haspopup="true" aria-expanded="false">
@ -68,11 +63,15 @@
<span class="sr-only">Toggle search-dropdown</span>
</button>
<ul class="dropdown-menu">
<li><input type="checkbox" name="searchtermExact" id="searchterm_exact" onchange="repoindex.pageManager.applySearchTerm(this.form.searchtermInput.value, this.checked);"><label for="searchterm_exact">Excact</label></li>
<li><input type="checkbox" name="searchtermExact" id="searchterm_exact" onchange="repoindex.pageManager.applySearchTerm(this.form.searchtermInput.value, this.checked, false);"><label for="searchterm_exact">Excact</label></li>
</ul>
</span>
</div>
</form>
<form class="navbar-form navbar-right">
<button id="nav_stop_server" class="btn btn-danger" onclick="repoindex.client.stopServer();">Stop server</button>
<button id="nav_connect" class="btn btn-danger" onclick="repoindex.client.init();"><span class="glyphicon glyphicon glyphicon-refresh" aria-hidden="true" id="connection_glyphicon"></span> <span id="connection_status">Disconnected</span></button>
</form>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
@ -97,8 +96,8 @@
</button>
<ul class="dropdown-menu" aria-labelledby="repo_buttons_settings_dropdown">
<li><input type="checkbox" name="reposButtonsExclusive" id="repos_buttons_exclusive"><label for="repos_buttons_exclusive">Exclusive selection</label></li>
<li><a href="#" onclick="repoindex.pageManager.repoManager.buttonContainerExclusiveButton.checked = false; repoindex.pageManager.repoManager.updateEnabledAll(true); return false;">Select all</a></li>
<li><a href="#" onclick="repoindex.pageManager.repoManager.updateEnabledAll(false); return false;">Remove selection</a></li>
<li><a href="#" onclick="repoindex.pageManager.repoManager.buttonContainerExclusiveButton.checked = false; repoindex.pageManager.repoManager.upgradeEnabledAll(true); return false;">Select all</a></li>
<li><a href="#" onclick="repoindex.pageManager.repoManager.upgradeEnabledAll(false); return false;">Remove selection</a></li>
</ul>
</span>
</form>
@ -238,7 +237,7 @@
<tr><th>Signature level</th><td id="repo_siglevel"></td></tr>
<tr><th>Source-only</th><td id="repo_source_only"></td></tr>
<tr><th>Upgrade sources</th><td id="repo_upgrade_sources"></td></tr>
<tr><th>Upgrades</th><td><span id="repo_checkforupdates"></span></td></tr>
<tr><th>Upgrades</th><td><span id="repo_checkforupgrades"></span></td></tr>
</tbody>
</table>
</div>
@ -315,7 +314,7 @@
<script src="js/pagination.js"></script>
<script src="js/packagemanagement.js"></script>
<script src="js/groupmanagement.js"></script>
<script src="js/alpm.js"></script>
<script src="js/client.js"></script>
<script src="js/pagemanagement.js"></script>
</body>
</html>

View File

@ -13,18 +13,25 @@
BasicPackageInfo: "basicpkginfo",
FullPackageInfo: "fullpkginfo",
GroupInfo: "groupinfo",
CheckForUpdates: "checkforupdates"
UpgradeLookup: "upgradelookup"
};
repoindex.isLoopback = function(domain) {
return domain === "localhost" || domain === "127.0.0.1" || domain === "::1";
};
// responsible for the connection to the server
var AlpmClient = function(uri) {
var Client = function(url) {
// basic initialization
this.uri = uri;
this.url = url;
this.socket = undefined;
this.hasBasicRepoInfo = false;
this.hasGroupInfo = false;
this.scheduledRequests = [];
this.sentRequests = [];
this.repos = {};
// define functions control the connections
this.resetReconnectTries = function(tries) {
@ -41,7 +48,7 @@
--this.remainingReconnectTries;
var reconnectTimer = window.setInterval(function() {
window.clearInterval(reconnectTimer);
repoindex.alpmClient.init();
repoindex.client.init();
}, 5000);
}
};
@ -58,7 +65,7 @@
this.socket.close();
return;
}
this.socket = new WebSocket(this.uri);
this.socket = new WebSocket(this.url);
this.socket.client = this;
this.socket.onopen = function(event) {
@ -127,19 +134,19 @@
switch(type) {
case repoindex.RequestType.BasicRepoInfo:
case repoindex.RequestType.GroupInfo:
// -> update existing reuquest in this case
// -> upgrade existing reuquest in this case
for(; i < this.scheduledRequests.length; ++i) {
if(this.scheduledRequests[i].params.class === "query" && this.scheduledRequests[i].params.what === type) {
// there is already such a request
this.scheduledRequests[i].callbacks.push(callback); // add callback
params.id = this.scheduledRequests[i].params.id; // keep the old ID
this.scheduledRequests[i].params = params; // update params
this.scheduledRequests[i].params = params; // upgrade params
break;
}
}
break;
default:
// -> other request types can't be updated
// -> other request types can't be upgraded
i = this.scheduledRequests.length;
}
if(i >= this.scheduledRequests.length) {
@ -192,7 +199,7 @@
case repoindex.RequestType.GroupInfo:
this.useGroupInfo(values);
break;
case repoindex.RequestType.CheckForUpdates:
case repoindex.RequestType.UpgradeLookup:
// the info is used via the registred callbacks only
break;
default:
@ -211,7 +218,7 @@
// define functions to perform several requests
this.requestBasicRepoInfo = function(callback) {
this.scheduleRequest(repoindex.RequestType.BasicRepoInfo, {updates: "true"}, callback);
this.scheduleRequest(repoindex.RequestType.BasicRepoInfo, {upgrades: "true"}, callback);
};
this.requestBasicPackagesInfo = function(packageSelection, callback) {
@ -223,25 +230,25 @@
};
this.requestGroupInfo = function(callback) {
this.scheduleRequest(repoindex.RequestType.GroupInfo, {updates: "true"}, callback);
this.scheduleRequest(repoindex.RequestType.GroupInfo, {upgrades: "true"}, callback);
};
this.stopServer = function() {
if(this.isOpen()) {
this.socket.send(JSON.stringify({class: "cmd", what: "stop"}));
} else {
window.alert("Not connected to a server.");
repoindex.pageManager.addError("Not connected to a server.");
}
};
this.checkForUpdates = function(dbName, syncdbNames, callback) {
this.checkForUpgrades = function(dbName, syncdbNames, callback) {
var params = {
db: dbName
};
if(syncdbNames) {
params.syncdbs = syncdbNames;
}
this.scheduleRequest(repoindex.RequestType.CheckForUpdates, params, callback);
this.scheduleRequest(repoindex.RequestType.UpgradeLookup, params, callback);
};
// define functions to use differend kinds of results
@ -250,12 +257,14 @@
repoindex.pageManager.addError("Server replied insufficiant basic repo info.");
return false;
}
// update repos and package list
// upgrade repos and package list
this.repos = {};
var repoMgr = repoindex.pageManager.repoManager;
var pkgMgr = repoindex.pageManager.packageManager;
repoMgr.removeEntries();
pkgMgr.removeEntries();
for(var i1 = 0; i1 < values.length; ++i1) {
this.repos[values[i1].name] = values[i1];
var repoEntry = repoMgr.addEntry(values[i1]);
var packages = repoEntry.info.packages;
for(var i2 = 0; i2 < packages.length; ++i2) {
@ -287,7 +296,11 @@
};
// create a global client used within the entire document
repoindex.alpmClient = new AlpmClient((window.location.protocol === "https:" ? "wss://" : "ws://") + document.domain + ":1234");
repoindex.client = new Client((window.location.protocol === "https:" ? "wss://" : "ws://") + document.domain + ":1234");
if(!repoindex.isLoopback(document.domain)) {
// hide stop button if server is not on loopback interface
document.getElementById("nav_stop_server").style.display = "none";
}
return repoindex;

View File

@ -1,9 +1,10 @@
var repoindex = (function(repoindex) {
repoindex.removeFilterButtonHtml = '<button type="button" class="close" onclick="repoindex.pageManager.applySearchTerm(null, false, true);" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
repoindex.removeFilterButtonHtml = '<button type="button" class="close" onclick="repoindex.pageManager.applySearchTerm(null, false, true, true);" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
repoindex.Entry = function(info, enabled) {
repoindex.Entry = function(name, info, enabled) {
// basic initialization
this.name = name;
this.info = info;
this.enabled = enabled;
@ -21,7 +22,7 @@
this.appendChild(cellElement);
};
this.initTableRow = function() {};
this.updateTableRow = function() {
this.upgradeTableRow = function() {
this.rowElement.wipeChildren();
this.initTableRow();
};
@ -42,7 +43,7 @@
this.rowElement.style.display = "table-row";
};
this.updateEnabled = function() {};
this.upgradeEnabled = function() {};
};
repoindex.EntryManager = function(EntryType, entryContainer, pagination) {
@ -51,7 +52,7 @@
this.entryContainer = entryContainer;
this.entries = [];
this.pageName = undefined;
this.updateRequired = false;
this.upgradeRequired = false;
// init pagination
if((this.pagination = pagination)) {
@ -82,7 +83,7 @@
&& (!this.filterRepos || this.filterRepos.contains(entry.info.repo));
};
// provide functions to apply filter and update UI
// provide functions to apply filter and upgrade UI
this.applyFilter = function() {
//if(this.customSelection) {
// this.filteredEntries = this.customSelection;
@ -93,9 +94,9 @@
this.filteredEntries = this.relevantEntries();
}
//}
// update pagination (the pageSelected method defined above will be invoked here automatically)
// upgrade pagination (the pageSelected method defined above will be invoked here automatically)
this.pagination.entryCount = this.filteredEntries.length;
this.pagination.update();
this.pagination.upgrade();
};
this.removeFilter = function() {
@ -107,15 +108,15 @@
this.refreshInfo = function() {};
this.invalidate = function() {
this.updateRequired = true;
this.update();
this.upgradeRequired = true;
this.upgrade();
};
this.update = function() {
if(this.updateRequired && (!this.pageName || this.pageName === repoindex.pageManager.currentPage)) {
this.upgrade = function() {
if(this.upgradeRequired && (!this.pageName || this.pageName === repoindex.pageManager.currentPage)) {
this.applyFilter();
this.infoBox.innerHTML = this.infoText();
this.updateRequired = false;
this.upgradeRequired = false;
}
};
@ -125,9 +126,9 @@
this.entryContainer.wipeChildren();
};
this.updateEnabledForAll = function(enabled) {
this.upgradeEnabledForAll = function(enabled) {
for(var i = 0; i < this.entries.length; ++i) {
this.entries[i].updateEnabled(enabled);
this.entries[i].upgradeEnabled(enabled);
}
};

View File

@ -30,7 +30,7 @@
this.initTableRow();
this.applyBasicInfo = function(info, noUpdate) {
this.applyBasicInfo = function(info, noUpgrade) {
if(info.repo) this.info.repo = info.repo;
if(info.name) this.info.name = info.name;
if(info.arch) this.info.arch = info.arch;
@ -39,12 +39,12 @@
if(info.bdate) this.info.bdate = info.bdate;
if(info.flagdate) this.info.flagdate = info.flagdate;
this.info.basic = true;
if(!noUpdate) {
this.updateTableRow();
if(!noUpgrade) {
this.upgradeTableRow();
}
};
this.applyFullInfo = function(info, noUpdate) {
this.applyFullInfo = function(info, noUpgrade) {
this.applyBasicInfo(info);
if(info.idate) this.info.idate = info.idate;
if(info.isize) this.info.isize = info.isize;
@ -65,8 +65,8 @@
if(info.file) this.info.file = info.file;
if(info.files) this.info.files = info.files;
this.info.full = true;
if(!noUpdate) {
this.updateTableRow();
if(!noUpgrade) {
this.upgradeTableRow();
}
};
};
@ -124,17 +124,21 @@
if(entriesRequired) {
var pkgEntries = repoindex.pageManager.packageManager.relevantEntries();
var useBasicPackageInfo = function(values) {
for(var i = 0; i < values.length; ++i) {
var info = values[i];
if(!info.error) {
if(info.index >= 0 && info.index < pkgEntries.length) {
var entry = pkgEntries[info.index];
entry.applyBasicInfo(info);
if(Array.isArray(values)) {
for(var i = 0; i < values.length; ++i) {
var info = values[i];
if(!info.error) {
if(info.index >= 0 && info.index < pkgEntries.length) {
var entry = pkgEntries[info.index];
entry.applyBasicInfo(info);
}
}
}
} else {
repoindex.pageManager.addError("Basic package info returned by the server is invalid.");
}
};
repoindex.alpmClient.requestBasicPackagesInfo(packageSelection, useBasicPackageInfo);
repoindex.client.requestBasicPackagesInfo(packageSelection, useBasicPackageInfo);
}
}
};
@ -153,12 +157,12 @@
}
};
// basic repo info available?
if(repoindex.alpmClient.hasBasicRepoInfo) {
if(repoindex.client.hasBasicRepoInfo) {
// yes -> can determine entry instantly
determineEntry();
} else {
// no -> request info, use callback to determine entry when info becomes available
repoindex.alpmClient.requestBasicRepoInfo(determineEntry);
repoindex.client.requestBasicRepoInfo(determineEntry);
}
};
@ -197,7 +201,7 @@
repoindex.setText("pkg_scri", repoindex.makeBool(i.scri));
repoindex.setText("pkg_sig", repoindex.makeArray(i.sig));
repoindex.setTree("pkg_files", repoindex.makeTree(i.files));
// -> update download buttons
// -> upgrade download buttons
var downloadPkgParams = {repo: i.repo, pkg: i.name, down: "pkg"};
repoindex.setDownloadButton("pkg_down", "package", repoindex.makeHash(repoindex.Pages.Packages, downloadPkgParams, true), function() {
repoindex.pageManager.denoteHash(repoindex.Pages.Packages, downloadPkgParams);
@ -215,9 +219,10 @@
var info = values[i];
if(!info.error) {
if(info.index >= 0 && info.index < pkgEntries.length) {
var entry = pkgEntries[info.index];
entry.applyFullInfo(info);
pkgEntries[info.index].applyFullInfo(info);
}
// set properties (again) to actually show applied info
setProperties();
} else {
var errorMsg;
switch(info.error) {
@ -230,16 +235,14 @@
repoindex.pageManager.addError("Error: " + errorMsg);
}
}
// set properties (again) to actually show applied info
setProperties();
};
if(!i.full) {
// don't have the full package info yet -> request full package info
var packageSelection = {};
packageSelection[i.repo] = [{index: entryIndex, name: i.name}];
repoindex.alpmClient.requestFullPackagesInfo(packageSelection, useFullPackageInfo);
repoindex.client.requestFullPackagesInfo(packageSelection, useFullPackageInfo);
}
// set currentInfo (the pageManager needs this value to update the hash)
// set currentInfo (the pageManager needs this value to upgrade the hash)
this.currentInfo = i;
// ensures, that the "Package Info" box (with the properties just set) is shown
repoindex.pageManager.showPackageInfo(true);
@ -263,10 +266,10 @@
showEntry();
} else {
// no -> request full info, use callback to show entry when info becomes available
//repoindex.alpmClient.requestFullPackagesInfo([{index: i.index, repo: i.repo, name: i.name}], showEntry());
//repoindex.client.requestFullPackagesInfo([{index: i.index, repo: i.repo, name: i.name}], showEntry());
var packageSelection = {};
packageSelection[i.repo] = [{index: entryIndex, name: i.name}];
repoindex.alpmClient.requestFullPackagesInfo(packageSelection, showEntry);
repoindex.client.requestFullPackagesInfo(packageSelection, showEntry);
}
} else {
// no -> show error
@ -274,12 +277,12 @@
}
};
// basic repo info available?
if(repoindex.alpmClient.hasBasicRepoInfo) {
if(repoindex.client.hasBasicRepoInfo) {
// yes -> can determine entry instantly
determineEntry();
} else {
// no -> request info, use callback to determine entry when info becomes available
repoindex.alpmClient.requestBasicRepoInfo(determineEntry);
repoindex.client.requestBasicRepoInfo(determineEntry);
}
};

View File

@ -120,13 +120,13 @@
// variables to store the current configuration
var currentRepo, currentPkg;
// basic repo info is required for all pages
if(!repoindex.alpmClient.hasBasicRepoInfo) {
repoindex.alpmClient.requestBasicRepoInfo();
if(!repoindex.client.hasBasicRepoInfo) {
repoindex.client.requestBasicRepoInfo();
}
switch(pageName) {
case repoindex.Pages.Packages:
this.repoManager.buttonRow.style.display = "block";
this.packageManager.update();
this.packageManager.upgrade();
if(params && params.repo && params.pkg) {
if(params.down) {
switch(params.down) {
@ -146,19 +146,19 @@
break;
case repoindex.Pages.Groups:
this.repoManager.buttonRow.style.display = "block";
if(!repoindex.alpmClient.hasGroupInfo) {
repoindex.alpmClient.requestGroupInfo();
if(!repoindex.client.hasGroupInfo) {
repoindex.client.requestGroupInfo();
}
this.groupManager.update();
this.groupManager.upgrade();
break;
case repoindex.Pages.Repositories:
this.repoManager.buttonRow.style.display = "none";
if(params && params.repo) {
this.repoManager.showRepoInfo(params.repo);
if(params.invoke) {
if(params.invoke === "updatelookup") {
if(params.invoke === "upgradelookup") {
// check for upgrades
this.repoManager.showAvailableUpdates(params.repo);
this.repoManager.showAvailableUpgrades(params.repo);
}
}
} else if(this.repoManager.currentInfo) {
@ -234,29 +234,15 @@
};
// provide a function to apply an entered search term
this.applySearchTerm = function(searchTerm, exact, reset) {
var mgr = undefined;
switch(this.currentPage) {
case repoindex.Pages.Packages:
mgr = this.packageManager;
break;
case repoindex.Pages.Groups:
mgr = this.groupManager;
break;
case repoindex.Pages.Repositories:
mgr = this.repoManager;
break;
default:
;
}
if(mgr) {
this.applySearchTerm = function(searchTerm, exact, explcit, reset) {
if(this.currentManager) {
if(reset) {
mgr.customSelection = undefined;
this.currentManager.customSelection = undefined;
}
mgr.filterName = searchTerm;
mgr.filterNameExact = exact;
mgr.filterDescr = searchTerm ? (exact ? "with the name" : "for the search term") : undefined;
mgr.invalidate(true);
this.currentManager.filterName = searchTerm;
this.currentManager.filterNameExact = exact;
this.currentManager.filterDescr = searchTerm ? (exact ? "with the name" : "for the search term") : undefined;
this.currentManager.invalidate(true);
}
};
@ -325,7 +311,7 @@
// create a page manager object used within the entire document
repoindex.pageManager = new PageManager();
repoindex.alpmClient.init();
repoindex.client.init();
repoindex.pageManager.gotoHash(false);
return repoindex;

View File

@ -93,9 +93,9 @@
// provide a select function for the page element (will be called when the page element
// is clicked)
pageElement.select = function() {
// update active/inactive status and visibility of all page elements
// upgrade active/inactive status and visibility of all page elements
var pagination = this.pagination;
var updateVisibility = function(index, visible) {
var upgradeVisibility = function(index, visible) {
var lowest = 0;
var highest = pagination.elements.length - 1;
var low = index - pagination.visibleElementsBeforeAfter;
@ -112,13 +112,13 @@
}
}
if(pagination.currentElement) {
updateVisibility(pagination.currentElement.pageIndex, false);
upgradeVisibility(pagination.currentElement.pageIndex, false);
pagination.currentElement.setActive(false);
}
updateVisibility(this.pageIndex, true);
upgradeVisibility(this.pageIndex, true);
this.setActive(true);
// update status of the containing pagination object
// upgrade status of the containing pagination object
pagination.currentElement = this;
pagination.previousElement.setEnabled(this !== pagination.elements.first());
pagination.nextElement.setEnabled(this !== pagination.elements.last());
@ -186,8 +186,8 @@
this.currentElement = undefined;
};
// provide a function to update the pagination (after properties such as the entryCount have been changed)
this.update = function() {
// provide a function to upgrade the pagination (after properties such as the entryCount have been changed)
this.upgrade = function() {
var requiredPages = Math.ceil(this.entryCount / this.entriesPerPage);
var currentPages = this.elements.length;
if(requiredPages < currentPages) {

View File

@ -3,11 +3,11 @@
var RepoEntry = {};
RepoEntry.prototype = new repoindex.Entry();
RepoEntry.prototype.constructor = RepoEntry;
RepoEntry = function(repoInfo, enabled) {
RepoEntry = function(repoName, repoInfo, enabled) {
if(enabled === undefined) {
enabled = !repoInfo.requestRequired;
}
repoindex.Entry.prototype.constructor.call(this, repoInfo, enabled);
repoindex.Entry.prototype.constructor.call(this, repoName, repoInfo, enabled);
this.info.currentServer = 0;
@ -31,7 +31,7 @@
this.link.repo = this;
this.link.onclick = function() {
if(repoindex.pageManager.repoManager.buttonContainerExclusiveButton.checked) {
repoindex.pageManager.repoManager.updateEnabledAll(false);
repoindex.pageManager.repoManager.upgradeEnabledAll(false);
}
this.repo.toggleEnabled();
return false;
@ -65,7 +65,7 @@
// provide a function to toggle enabled/disabled
this.updateEnabled = function(enabled) {
this.upgradeEnabled = function(enabled) {
if(this.enabled !== enabled) {
this.link.className = (this.enabled = enabled) ? "btn btn-primary" : "btn btn-default";
this.statusChanged(this);
@ -73,7 +73,7 @@
};
this.toggleEnabled = function() {
this.updateEnabled(!this.enabled);
this.upgradeEnabled(!this.enabled);
};
};
@ -125,9 +125,9 @@
this.baseRemoveEntries();
};
this.updateEnabledAll = function(enabled) {
this.upgradeEnabledAll = function(enabled) {
for(var i = 0; i < this.entries.length; ++i) {
this.entries[i].updateEnabled(enabled);
this.entries[i].upgradeEnabled(enabled);
}
};
@ -163,12 +163,12 @@
}
};
// basic repo info available?
if(repoindex.alpmClient.hasBasicRepoInfo) {
if(repoindex.client.hasBasicRepoInfo) {
// yes -> can determine entry instantly
determineEntry();
} else {
// no -> request info, use callback to determine entry when info becomes available
repoindex.alpmClient.requestBasicRepoInfo(determineEntry);
repoindex.client.requestBasicRepoInfo(determineEntry);
}
};
@ -183,12 +183,12 @@
repoindex.setText("repo_siglevel", repoindex.makeArray(i.sigLevel, ", "));
repoindex.setText("repo_source_only", repoindex.makeBool(i.srcOnly));
repoindex.setText("repo_upgrade_sources", repoindex.makeArray(i.upgradeSources, ", "));
var invokeUpdateLookupParams = {repo: i.name, invoke: "updatelookup"};
repoindex.setDownloadButton("repo_checkforupdates", "check for updates", repoindex.makeHash(repoindex.Pages.Repositories, invokeUpdateLookupParams, true), function() {
repoindex.pageManager.repoManager.showAvailableUpdates(i.name);
repoindex.pageManager.denoteHash(repoindex.Pages.Repositories, invokeUpdateLookupParams);
var invokeUpgradeLookupParams = {repo: i.name, invoke: "upgradelookup"};
repoindex.setDownloadButton("repo_checkforupgrades", "check for upgrades", repoindex.makeHash(repoindex.Pages.Repositories, invokeUpgradeLookupParams, true), function() {
repoindex.pageManager.repoManager.showAvailableUpgrades(i.name);
repoindex.pageManager.denoteHash(repoindex.Pages.Repositories, invokeUpgradeLookupParams);
}, "refresh");
// set currentInfo (the pageManager needs this value to update the hash)
// set currentInfo (the pageManager needs this value to upgrade the hash)
this.currentInfo = i;
// ensures, that the "Package Info" box (with the properties just set) is shown
repoindex.pageManager.showRepoInfo();
@ -202,83 +202,87 @@
true);
};
this.showAvailableUpdates = function(repo) {
var requestUpdates = function() {
var showUpdates = function(availableUpdates) {
this.showAvailableUpgrades = function(repo) {
var requestUpgrades = function() {
var showUpgrades = function(availableUpgrades) {
// check for errors
if(Array.isArray(availableUpdates.errors)) {
for(var i = 0; i < availableUpdates.errors.length; ++i) {
repoindex.pageManager.addError("Error: " + availableUpdates.errors[i]);
if(Array.isArray(availableUpgrades.errors)) {
for(var i = 0; i < availableUpgrades.errors.length; ++i) {
repoindex.pageManager.addError("Error: " + availableUpgrades.errors[i]);
}
} else {
// create package entries for the updates
var updateEntries = [];
var updates = [
// create package entries for the upgrades
var upgradeEntries = [];
var upgrades = [
{
name: "software upgrade",
namePlural: "software upgrades",
style: "background-color: " + repoindex.softwareUpgradeBackgroundColor,
color: repoindex.softwareUpgradeBackgroundColor,
entries: Array.isArray(availableUpdates.softwareUpdates) ? availableUpdates.softwareUpdates : [],
count: Array.isArray(availableUpdates.softwareUpdates) ? availableUpdates.softwareUpdates.length : 0
entries: Array.isArray(availableUpgrades.softwareUpgrades) ? availableUpgrades.softwareUpgrades : [],
count: Array.isArray(availableUpgrades.softwareUpgrades) ? availableUpgrades.softwareUpgrades.length : 0
}, {
name: "package-only upgrade",
namePlural: "package-only upgrades",
style: "background-color: " + repoindex.packageUpgradeBackgroundColor,
color: repoindex.packageUpgradeBackgroundColor,
entries: Array.isArray(availableUpdates.packageOnlyUpdates) ? availableUpdates.packageOnlyUpdates : [],
count: Array.isArray(availableUpdates.packageOnlyUpdates) ? availableUpdates.packageOnlyUpdates.length : 0
entries: Array.isArray(availableUpgrades.packageOnlyUpgrades) ? availableUpgrades.packageOnlyUpgrades : [],
count: Array.isArray(availableUpgrades.packageOnlyUpgrades) ? availableUpgrades.packageOnlyUpgrades.length : 0
}, {
name: "downgrade",
namePlural: "downgrades",
style: "background-color: " + repoindex.downgradesBackgroundColor,
color: repoindex.downgradesBackgroundColor,
entries: Array.isArray(availableUpdates.downgrades) ? availableUpdates.downgrades : [],
count: Array.isArray(availableUpdates.downgrades) ? availableUpdates.downgrades.length : 0
entries: Array.isArray(availableUpgrades.downgrades) ? availableUpgrades.downgrades : [],
count: Array.isArray(availableUpgrades.downgrades) ? availableUpgrades.downgrades.length : 0
}, {
name: "orphaned package",
namePlural: "orphaned packages",
style: "background-color: " + repoindex.orphanedPackageBackgroundColor,
color: repoindex.orphanedPackageBackgroundColor,
entries: Array.isArray(availableUpdates.orphanedPackages) ? availableUpdates.orphanedPackages : [],
count: Array.isArray(availableUpdates.orphanedPackages) ? availableUpdates.orphanedPackages.length : 0
entries: Array.isArray(availableUpgrades.orphanedPackages) ? availableUpgrades.orphanedPackages : [],
count: Array.isArray(availableUpgrades.orphanedPackages) ? availableUpgrades.orphanedPackages.length : 0
}
];
var pkgMgr = repoindex.pageManager.packageManager;
var repoMgr = repoindex.pageManager.repoManager;
for(var i1 = 0; i1 < updates.length; ++i1) {
for(var i2 = 0; i2 < updates[i1].entries.length; ++i2) {
var newEntry = pkgMgr.createCustomEntry(updates[i1].color);
newEntry.info.index = updateEntries.length;
if(updates[i1].entries[i2].pkg) {
newEntry.applyBasicInfo(updates[i1].entries[i2].pkg, true);
if(updates[i1].entries[i2].curVer) {
newEntry.info.ver = updates[i1].entries[i2].curVer + " → " + (newEntry.info.ver ? newEntry.info.ver : "?");
for(var i1 = 0; i1 < upgrades.length; ++i1) {
// iterate through all kinds of "upgrades" declared above
for(var i2 = 0; i2 < upgrades[i1].entries.length; ++i2) {
// iterate through all entries which have been assigned to the current upgrade type
var newEntry = pkgMgr.createCustomEntry(upgrades[i1].color);
newEntry.info.index = upgradeEntries.length;
if(upgrades[i1].entries[i2].pkg) {
newEntry.applyBasicInfo(upgrades[i1].entries[i2].pkg, true);
if(upgrades[i1].entries[i2].curVer) {
// add current version to upgrade version
newEntry.info.ver = upgrades[i1].entries[i2].curVer + " → " + (newEntry.info.ver ? newEntry.info.ver : "?");
}
// find associated repo entry
if((newEntry.repoEntry = repoMgr.entryByName(newEntry.info.repo))) {
newEntry.repoEntry.updateEnabled(true); // ensure repo is enabled
newEntry.repoEntry.upgradeEnabled(true); // ensure repo is enabled
}
newEntry.updateTableRow();
newEntry.upgradeTableRow();
} else {
newEntry.applyBasicInfo(updates[i1].entries[i2]);
newEntry.applyBasicInfo(upgrades[i1].entries[i2]);
}
updateEntries.push(newEntry);
upgradeEntries.push(newEntry);
}
}
if(Array.isArray(availableUpdates.warnings)) {
for(var i = 0; i < availableUpdates.warnings.length; ++i) {
repoindex.pageManager.addError("Warning: " + availableUpdates.warnings[i]);
// show warnings
if(Array.isArray(availableUpgrades.warnings)) {
for(var i = 0; i < availableUpgrades.warnings.length; ++i) {
repoindex.pageManager.addError("Warning: " + availableUpgrades.warnings[i]);
}
}
// show updates via package manager
// show upgrades via package manager
pkgMgr.filterName = undefined;
pkgMgr.customSelection = updateEntries;
pkgMgr.customSelection = upgradeEntries;
pkgMgr.customSelectionName = "upgrade";
pkgMgr.customSelectionNamePlural = "upgrades";
var quandityInfo = repoindex.makeQuandityInfo(updates);
var quandityInfo = repoindex.makeQuandityInfo(upgrades);
if(quandityInfo) {
pkgMgr.customSelectionInfoText = "Updates for the repository <i>"
pkgMgr.customSelectionInfoText = "Upgrades for the repository <i>"
+ repoindex.escapeHtml(repo)
+ "</i>: " + quandityInfo
+ repoindex.removeFilterButtonHtml;
@ -288,15 +292,15 @@
repoindex.pageManager.setPage(repoindex.Pages.Packages);
}
};
repoindex.alpmClient.checkForUpdates(repo, null, showUpdates);
repoindex.client.checkForUpgrades(repo, null, showUpgrades);
};
// basic repo info available?
if(repoindex.alpmClient.hasBasicRepoInfo) {
// yes -> request updates instantly
requestUpdates();
if(repoindex.client.hasBasicRepoInfo) {
// yes -> request upgrades instantly
requestUpgrades();
} else {
// no -> request info, use callback to go on requesting updates when repo info becomes available
repoindex.alpmClient.requestBasicRepoInfo(requestUpdates);
// no -> request info, use callback to go on requesting upgrades when repo info becomes available
repoindex.client.requestBasicRepoInfo(requestUpgrades);
}
};