Allow triggering package search for DB from DBs page
This commit is contained in:
parent
54a7a84d11
commit
50ef7c26f3
|
@ -162,7 +162,7 @@ export function renderTimeSpan(startTimeStamp, endTimeStamp)
|
||||||
export function renderLink(value, row, handler, tooltip, href, middleClickHref)
|
export function renderLink(value, row, handler, tooltip, href, middleClickHref)
|
||||||
{
|
{
|
||||||
const linkElement = document.createElement('a');
|
const linkElement = document.createElement('a');
|
||||||
const linkText = typeof value === 'object' ? value : document.createTextNode(value);
|
const linkText = typeof value === 'object' ? value : renderNoneInGrey(value);
|
||||||
linkElement.appendChild(linkText);
|
linkElement.appendChild(linkText);
|
||||||
linkElement.href = middleClickHref || href || '#';
|
linkElement.href = middleClickHref || href || '#';
|
||||||
if (tooltip !== undefined) {
|
if (tooltip !== undefined) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import * as AjaxHelper from './ajaxhelper.js';
|
import * as AjaxHelper from './ajaxhelper.js';
|
||||||
import * as BuildActionsPage from './buildactionspage.js';
|
import * as BuildActionsPage from './buildactionspage.js';
|
||||||
|
import * as PackageSearchPage from './packagesearchpage.js';
|
||||||
import * as CustomRendering from './customrendering.js';
|
import * as CustomRendering from './customrendering.js';
|
||||||
import * as GenericRendering from './genericrendering.js';
|
import * as GenericRendering from './genericrendering.js';
|
||||||
import * as Utils from './utils.js';
|
import * as Utils from './utils.js';
|
||||||
|
@ -40,7 +41,7 @@ function handleGlobalStatusUpdate(ajaxRequest)
|
||||||
columnAccessors: ['arch', 'name', 'packageCount', 'lastUpdate', 'syncFromMirror'],
|
columnAccessors: ['arch', 'name', 'packageCount', 'lastUpdate', 'syncFromMirror'],
|
||||||
customRenderer: {
|
customRenderer: {
|
||||||
name: function (value, row) {
|
name: function (value, row) {
|
||||||
return GenericRendering.renderLink(value, row, showRepository);
|
return GenericRendering.renderLink(value, row, searchRepository, undefined, undefined, hashToSearchRepository(row));
|
||||||
},
|
},
|
||||||
lastUpdate: GenericRendering.renderShortTimeStamp,
|
lastUpdate: GenericRendering.renderShortTimeStamp,
|
||||||
note: function(rows) {
|
note: function(rows) {
|
||||||
|
@ -51,6 +52,9 @@ function handleGlobalStatusUpdate(ajaxRequest)
|
||||||
note.appendChild(CustomRendering.renderReloadButton(queryGlobalStatus));
|
note.appendChild(CustomRendering.renderReloadButton(queryGlobalStatus));
|
||||||
return note;
|
return note;
|
||||||
},
|
},
|
||||||
|
syncFromMirror: function (value, row) {
|
||||||
|
return GenericRendering.renderLink(value, row, showRepository);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
globalStatus.appendChild(dbTable);
|
globalStatus.appendChild(dbTable);
|
||||||
|
@ -227,16 +231,32 @@ function handleGlobalStatusUpdate(ajaxRequest)
|
||||||
BuildActionsPage.handleBuildActionPresetChange();
|
BuildActionsPage.handleBuildActionPresetChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showRepository(dbName, dbInfo)
|
function showRepository(value, dbInfo)
|
||||||
{
|
{
|
||||||
const mirror = dbInfo.mainMirror;
|
const mirror = dbInfo.mainMirror;
|
||||||
if (!mirror) {
|
if (!mirror) {
|
||||||
window.alert('No mirror configured for ' + dbName + '.');
|
window.alert('No mirror configured for ' + dbInfo.name + '.');
|
||||||
} else {
|
} else {
|
||||||
window.open(mirror);
|
window.open(mirror);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function searchRepository(value, dbInfo)
|
||||||
|
{
|
||||||
|
const form = PackageSearchPage.initSearchForm();
|
||||||
|
form.name.value = '';
|
||||||
|
form.db.value = Utils.makeRepoName(dbInfo.name, dbInfo.arch);
|
||||||
|
form.mode.value = 'name-contains';
|
||||||
|
PackageSearchPage.searchForPackages();
|
||||||
|
}
|
||||||
|
|
||||||
|
function hashToSearchRepository(dbInfo)
|
||||||
|
{
|
||||||
|
return '#package-search-section?'
|
||||||
|
+ encodeURIComponent('name=&mode=name-contains&db='
|
||||||
|
+ encodeURIComponent(Utils.makeRepoName(dbInfo.name, dbInfo.arch)));
|
||||||
|
}
|
||||||
|
|
||||||
window.globalInfo = undefined;
|
window.globalInfo = undefined;
|
||||||
window.functionsPostponedUntilGlobalInfo = [];
|
window.functionsPostponedUntilGlobalInfo = [];
|
||||||
window.hasGlobalStatus = false;
|
window.hasGlobalStatus = false;
|
||||||
|
|
|
@ -4,26 +4,33 @@ import * as PackageRendering from './packagerendering.js';
|
||||||
import * as SinglePageHelper from './singlepage.js';
|
import * as SinglePageHelper from './singlepage.js';
|
||||||
import * as Utils from './utils.js';
|
import * as Utils from './utils.js';
|
||||||
|
|
||||||
export function initPackageSearch(sectionElement, sectionData, newParams)
|
export function initSearchForm()
|
||||||
{
|
{
|
||||||
const searchForm = document.getElementById('package-search-form');
|
const searchForm = document.getElementById('package-search-form');
|
||||||
if (!searchForm.dataset.initialized) {
|
if (searchForm.dataset.initialized) {
|
||||||
searchForm.onsubmit = function() {
|
return searchForm;
|
||||||
searchForPackages();
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
const packageResultsFormElements = document.getElementById('package-results-form').elements;
|
|
||||||
packageResultsFormElements.selectall.onclick = function () {
|
|
||||||
Utils.alterFormSelection(this.form, 'check-all');
|
|
||||||
};
|
|
||||||
packageResultsFormElements.unselectall.onclick = function () {
|
|
||||||
Utils.alterFormSelection(this.form, 'uncheck-all');
|
|
||||||
};
|
|
||||||
packageResultsFormElements.startselected.onclick = function () {
|
|
||||||
fillBuildActionFromPackageSearch();
|
|
||||||
};
|
|
||||||
searchForm.dataset.initialized = true;
|
|
||||||
}
|
}
|
||||||
|
searchForm.onsubmit = function() {
|
||||||
|
searchForPackages();
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
const packageResultsFormElements = document.getElementById('package-results-form').elements;
|
||||||
|
packageResultsFormElements.selectall.onclick = function () {
|
||||||
|
Utils.alterFormSelection(this.form, 'check-all');
|
||||||
|
};
|
||||||
|
packageResultsFormElements.unselectall.onclick = function () {
|
||||||
|
Utils.alterFormSelection(this.form, 'uncheck-all');
|
||||||
|
};
|
||||||
|
packageResultsFormElements.startselected.onclick = function () {
|
||||||
|
fillBuildActionFromPackageSearch();
|
||||||
|
};
|
||||||
|
searchForm.dataset.initialized = true;
|
||||||
|
return searchForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initPackageSearch(sectionElement, sectionData, newParams)
|
||||||
|
{
|
||||||
|
initSearchForm();
|
||||||
let currentParams = sectionData.state.params;
|
let currentParams = sectionData.state.params;
|
||||||
if (currentParams && currentParams.startsWith('?')) {
|
if (currentParams && currentParams.startsWith('?')) {
|
||||||
currentParams = currentParams.substr(1);
|
currentParams = currentParams.substr(1);
|
||||||
|
@ -83,7 +90,7 @@ function searchForPackagesFromParams(searchParams)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchForPackages()
|
export function searchForPackages()
|
||||||
{
|
{
|
||||||
const res = AjaxHelper.startFormQueryEx('package-search-form', showPackageSearchResults);
|
const res = AjaxHelper.startFormQueryEx('package-search-form', showPackageSearchResults);
|
||||||
const params = SinglePageHelper.sections['package-search'].state.params = res.params.substr(1);
|
const params = SinglePageHelper.sections['package-search'].state.params = res.params.substr(1);
|
||||||
|
|
Loading…
Reference in New Issue