|
|
[-]
[+]
|
Added |
_service:tar_git:install-history-0.10.0.tar.gz/qml/js/worker.js
^
|
@@ -0,0 +1,191 @@
+/*
+ *
+ * Copyright 2022,2023 Peter G. (nephros) <sailfish@nephros.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+.pragma library
+
+WorkerScript.onMessage = function(m){
+ if (m.action === "getHistory"){ loadHistory(m.parameter.model, m.parameter.fn, m.parameter.f) }
+
+ /* load zypper history log file
+ * @param fn url file to load from
+ * @param filter filter callback
+ */
+ function loadHistory(model, fn, filter) {
+ model.clear(); model.sync();
+ console.assert((typeof fn !== "undefined"), "Called without filename");
+ console.info("Loading history from " + fn);
+ console.time("File request took");
+ const query = "file://" + fn;
+ const r = new XMLHttpRequest()
+ r.open('GET', query);
+ r.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+ r.send();
+
+ r.onreadystatechange = function(event) {
+ if (r.readyState == XMLHttpRequest.DONE) {
+ console.timeEnd("File request took");
+ fillModel(model, r.response.split("\n").reverse(),filter);
+ }
+ }
+ }
+
+ /* populate ListModel from payload */
+ function fillModel(model, a, filter) {
+ console.time("List loaded in");
+ console.time("Filtering took");
+ const data = a.filter(filterData);
+ if (!filter)
+ const data = data.filter(filterLocal);
+ console.timeEnd("Filtering took");
+ console.debug("Filtered Lines: " + data.length + "/" + a.length);
+ // performance: compile regexp and define and loop variables
+ // outside the loop
+ // also, looks oldschool to declare all vars at the top.
+ const isOpenrepos = /^openrepos-/
+ //const jollarepos = /(adaptation0 adaptation1 aliendalvik apps customer-jolla jolla sailfish-eas store xt9)/
+ const line;
+ const dt;
+ const d;
+ const t;
+ const date;
+ const dateTime;
+ const repo;
+ const repotype = "other";
+ const reponame = null;
+ const element = {};
+ data.forEach(function(r){
+ line = r.split("|");
+
+ // zypper stores local time at the time of the event.
+ // see https://codeberg.org/nephros/install-history/issues/16
+ dt = line[0].split(" ");
+ d = dt[0].split("-"); t = dt[1].split(":");
+ // months are counted from 0-11, so do a d[1] - 1
+ date = new Date( d[0], d[1] - 1, d[2], 0, 0, 0, 0).toISOString();
+ dateTime = new Date( d[0], d[1] - 1, d[2], t[0], t[1], t[2], 0);
+
+ /* assign pretty names:
+ *
+ grep install /var/log/zypp/history |grep -v PK_TMP_DIR | awk -F\| '{print $7}'| sort -u | grep -v openrepos
+
+ adaptation0
+ adaptation1
+ aliendalvik
+ customer-jolla
+ harbour-storeman-obs
+ mentaljam-obs
+ sailfish-eas
+ sailfishos-chum
+ sailfishos-chum-testing
+ store
+ xt9
+ */
+ repo = line[6];
+ reponame = repo;
+
+ /*
+ * this may look like it should be a switch...case block, but actually no.
+ */
+
+ // local repo:
+ if ( (repo === "PK_TMP_DIR") || (repo === "_tmpRPMcache_") ) {
+ repo=qsTr("local", "short name for the 'local' repo");
+ reponame=qsTr("Local Installs", "name for the 'local' repo");
+ repotype="local";
+ // all the Jolla repos:
+ } else if (repo === "store") {
+ reponame=qsTr("Jolla Store", "name for the jolla store repo");
+ repotype="jolla";
+ } else if (repo === "jolla") {
+ reponame=qsTr("Jolla System", "name for the jolla jolla repo");
+ repotype="jolla";
+ } else if (repo === "aliendalvik") {
+ reponame=qsTr("Android App Support", "name for the android support repo");
+ repotype="jolla";
+ } else if (repo === "apps") {
+ reponame=qsTr("Jolla Applications", "name for the jolla apps repo");
+ repotype="jolla";
+ } else if (repo === "sailfish-eas") {
+ reponame=qsTr("Exchange Feature", "name for the jolla feature repo");
+ repotype="jolla";
+ } else if (repo === "xt9") {
+ reponame=qsTr("XT9 Feature", "name for the jolla feature repo");
+ repotype="jolla";
+ } else if (repo === "customer-jolla") {
+ reponame=qsTr("Jolla Feature", "name for the jolla customer repo");
+ repotype="jolla";
+ } else if (repo === "adaptation0") {
+ reponame=qsTr("Device Adaptation", "name for the jolla adaptation0 repo");
+ repotype="jolla";
+ } else if (repo === "adaptation1") {
+ reponame=qsTr("Device Adaptation", "name for the jolla adaptation1 repo");
+ repotype="jolla";
+ // Storeman:
+ } else if ( (repo === "mentaljam-obs") || (repo === "harbour-storeman-obs") ) {
+ reponame=qsTr("Storeman", "name for the storeman repo");
+ // Chum:
+ } else if (repo === "sailfishos-chum") {
+ reponame=qsTr("SailfishOS:Chum", "name for the chum repo");
+ repotype="chum";
+ } else if (repo === "sailfishos-chum-testing") {
+ reponame=qsTr("SailfishOS:Chum Testing", "name for the chum testing repo");
+ repotype="chum";
+ // MLS:
+ } else if (repo === "nubecula-mls-offline-repo") {
+ reponame=qsTr("MLS", "name for the Nubecula Offline MLS repo");
+ // OpenRepos:
+ } else if ( isOpenrepos.test(repo) ) {
+ reponame= qsTr("OpenRepos: %1", "prefix for a openrepos repo").arg(repo.replace("openrepos-", ""));
+ repotype="openrepos";
+ }
+ element = {
+ "date": date,
+ "dateTime": dateTime,
+ "action": line[1].trim(),
+ "appName": line[2],
+ "version": line[3],
+ "repo": repo,
+ "repoName": reponame,
+ "repoType": repotype,
+ }
+ model.append(element);
+ if ( (model.count % 200) === 0) { model.sync(); WorkerScript.sendMessage({ event: "progress", percent: Math.floor(model.count / data.length * 100) }) }
+ }); // foreach func end
+ console.timeEnd("List loaded in");
+ model.sync()
+ }
+ /* helper to reduce payload */
+ function filterData(data) {
+ // lines have the format:
+ // 20xx-mm-dd HH:MM:SS|install
+ // 20xx-mm-dd HH:MM:SS|remove
+ // ..................^17
+ // everything else is not interesting
+ const re = /^20.{17}(\|install|\|remove).*$/;
+ return (re.test(data)) ? true : false;
+ }
+ function filterLocal(data) {
+ //const re = /\|PK_TMP_DIR\|/ // pkcon
+ //const re = /\|_tmpRPMcache_\|/ // zypper
+ const re = /\|(PK_TMP_DIR|_tmpRPMcache_)\|/ // both
+ return (!re.test(data)) ? true : false;
+ }
+
+}
+
+// vim: ft=javascript expandtab ts=4 st=2 sw=2
|
[-]
[+]
|
Changed |
_service:tar_git:install-history-0.10.0.tar.gz/qml/pages/MainPage.qml
^
|
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2022 Peter G. (nephros) <sailfish@nephros.org>
+ * Copyright 2022,2023 Peter G. (nephros) <sailfish@nephros.org>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +32,8 @@
property bool showLocal: true
property string historyfile: "/var/log/zypp/history"
+ property int progress: 0
+
Connections {
onStatusChanged: {
if (pageStack.busy) {
@@ -49,12 +51,6 @@
}
}
- /*
- onStatusChanged: {
- if ( status === PageStatus.Active && !pageStack.busy && pageStack.nextPage() === null ) { pageStack.pushAttached(statsPage) }
- }
- */
-
Component { id: statsPage; StatsPage{ } }
DockedPanel { id: detailInfo
@@ -144,14 +140,12 @@
flickable: flick
MenuItem { text: qsTr("Refresh");
// refresh on delayedclick otherwise the bounce animation freezes while we reload
- //onClicked: { appHistoryModel.clear(); view.forceLayout(); }
- onClicked: { appHistoryModel.clear(); view.forceLayout(); view.model = null; }
- onDelayedClick: { getHistory(page.historyfile,showLocal); view.model = appHistoryModel }
+ onDelayedClick: { updateHistory(page.historyfile,showLocal); }
}
MenuItem { text: showLocal ? qsTr("Hide %1", "show/hide local menu option").arg(qsTr("Local Installs", "menu option parameter")) : qsTr("Show %1", "show/hide local menu option").arg(qsTr("Local Installs", "menu option parameter")) ;
// refresh on delayedclick otherwise the bounce animation freezes while we reload
- onClicked: { showLocal = !showLocal; appHistoryModel.clear(); view.forceLayout(); view.model = null; }
- onDelayedClick: { getHistory(page.historyfile,showLocal); view.model = appHistoryModel }
+ onClicked: { showLocal = !showLocal }
+ onDelayedClick: { updateHistory(page.historyfile,showLocal); }
}
MenuItem { text: page.unclutter ? qsTr("Verbose Display", "menu option") : qsTr("Reduced Display", "menu option") ;
onClicked: page.unclutter = !page.unclutter
@@ -172,7 +166,8 @@
SilicaFlickable { id: flick
anchors.fill: parent
- PageHeader { id: header ; title: qsTr("Install History") ; description: (appHistoryModel.count > 0) ? qsTr("%Ln event(s)", "very, very unlikely to have only one, still, plurals please!", appHistoryModel.count) : qsTr("Loading…")}
+ PageHeader { id: header ; title: qsTr("Install History") ; description: (appHistoryModel.count > 0) ? qsTr("%Ln event(s)", "very, very unlikely to have only one, still, plurals please!", appHistoryModel.count) : qsTr("Loading…")
+ }
Column {
id: searchBar
anchors.top: header.bottom
@@ -369,8 +364,6 @@
}
}
- ListModel { id: appHistoryModel; Component.onCompleted: { getHistory(page.historyfile,showLocal); } }
-
Component{ id: datePicker; DatePickerDialog {} }
Component { id: highlightBar
@@ -381,171 +374,25 @@
}
}
- /* ----- functions ----- */
+ ListModel { id: appHistoryModel }
- /* load zypper history log file
- * @param fn url file to load from
- * @param filter filter callback
- */
- function getHistory(fn,filter) {
- console.assert((typeof fn !== "undefined"), "Called without filename");
- console.info("Loading history from " + fn);
- console.time("File request took");
- const query = Qt.resolvedUrl("file://" + fn);
- var r = new XMLHttpRequest()
- r.open('GET', query);
- r.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
- r.send();
-
- r.onreadystatechange = function(event) {
- if (r.readyState == XMLHttpRequest.DONE) {
- fillModel(r.response.split("\n").reverse(),filter);
- console.timeEnd("File request took");
- }
- }
+ // handle data mangling in a worker script:
+ Component.onCompleted: getHistory(page.historyfile, showLocal)
+ function getHistory(fileName, filter) {
+ if (!worker.ready) { console.warn("worker not ready!") }
+ worker.sendMessage({ action: "getHistory", parameter: { model: appHistoryModel, fn: fileName, f: filter}})
}
- /* helper to reduce payload */
- function filterData(data) {
- // lines have the format:
- // 20xx-mm-dd HH:MM:SS|install
- // 20xx-mm-dd HH:MM:SS|remove
- // ..................^17
- // everything else is not interesting
- const re = /^20.{17}(\|install|\|remove).*$/;
- return (re.test(data)) ? true : false;
+ function updateHistory(fileName, filter) {
+ appHistoryModel.clear();
+ getHistory(fileName, filter);
}
- function filterLocal(data) {
- //const re = /\|PK_TMP_DIR\|/ // pkcon
- //const re = /\|_tmpRPMcache_\|/ // zypper
- const re = /\|(PK_TMP_DIR|_tmpRPMcache_)\|/ // both
- return (!re.test(data)) ? true : false;
- }
-
- /* populate ListModel from payload */
- function fillModel(a,filter) {
- console.time("List loaded in");
- console.time("Filtering took");
- const data = a.filter(filterData);
- if (!filter)
- const data = data.filter(filterLocal);
- console.timeEnd("Filtering took");
- console.debug("Filtered Lines: " + data.length + "/" + a.length);
- // performance: compile regexp and define and loop variables
- // outside the loop
- // also, looks oldschool to declare all vars at the top.
- const isOpenrepos = /^openrepos-/
- //const jollarepos = /(adaptation0 adaptation1 aliendalvik apps customer-jolla jolla sailfish-eas store xt9)/
- const line;
- const dt;
- const d;
- const t;
- const date;
- const dateTime;
- const repo;
- const repotype = "other";
- const reponame = null;
- const element = {};
- data.forEach(function(r){
- line = r.split("|");
-
- // zypper stores local time at the time of the event.
- // see https://codeberg.org/nephros/install-history/issues/16
- dt = line[0].split(" ");
- d = dt[0].split("-"); t = dt[1].split(":");
- // months are counted from 0-11, so do a d[1] - 1
- date = new Date( d[0], d[1] - 1, d[2], 0, 0, 0, 0).toISOString();
- dateTime = new Date( d[0], d[1] - 1, d[2], t[0], t[1], t[2], 0);
- /* assign pretty names:
- *
- grep install /var/log/zypp/history |grep -v PK_TMP_DIR | awk -F\| '{print $7}'| sort -u | grep -v openrepos
-
- adaptation0
- adaptation1
- aliendalvik
- customer-jolla
- harbour-storeman-obs
- mentaljam-obs
- sailfish-eas
- sailfishos-chum
- sailfishos-chum-testing
- store
- xt9
- */
- repo = line[6];
- reponame = repo;
-
- /*
- * this may look like it should be a switch...case block, but actually no.
- */
-
- // local repo:
- if ( (repo === "PK_TMP_DIR") || (repo === "_tmpRPMcache_") ) {
- repo=qsTr("local", "short name for the 'local' repo");
- reponame=qsTr("Local Installs", "name for the 'local' repo");
- repotype="local";
- // all the Jolla repos:
- } else if (repo === "store") {
- reponame=qsTr("Jolla Store", "name for the jolla store repo");
- repotype="jolla";
- } else if (repo === "jolla") {
- reponame=qsTr("Jolla System", "name for the jolla jolla repo");
- repotype="jolla";
- } else if (repo === "aliendalvik") {
- reponame=qsTr("Android App Support", "name for the android support repo");
- repotype="jolla";
- } else if (repo === "apps") {
- reponame=qsTr("Jolla Applications", "name for the jolla apps repo");
- repotype="jolla";
- } else if (repo === "sailfish-eas") {
- reponame=qsTr("Exchange Feature", "name for the jolla feature repo");
|
[-]
[+]
|
Added |
_service:tar_git:install-history-0.10.0.tar.gz/test.qml
^
|
@@ -0,0 +1,14 @@
+import QtQuick 2.6
+import Sailfish.Silica 1.0
+import "qml/pages"
+
+ApplicationWindow {
+ id: app
+
+ allowedOrientations: Orientation.All
+
+ initialPage: Component { MainPage{} }
+
+}
+
+// vim: ft=javascript expandtab ts=4 sw=4 st=4
|
@@ -1,9 +1,10 @@
Name: install-history
Summary: Shows when packages have been installed or uninstalled
-Version: 0.9.18
+Version: 0.10.0
Release: 1
Group: Applications
-License: Apache 2.0
+#License: Apache 2.0
+License: ASL 2.0
SCM: https://codeberg.org/nephros/install-history
URL: https://codeberg.org/nephros/install-history
Sources:
@@ -25,15 +26,15 @@
- Settings
- Utility
Custom:
- Repo: https://codeberg.org/nephros/install-history
+ Repo: %{url}
Icon: https://sailfishos.org/content/sailfishos-docs//sailfish-content-graphics-default/latest/images/icon-m-file-rpm.svg
Screenshots:
- - https://codeberg.org/nephros/install-history/raw/branch/master/Screenshot_001.png
- - https://codeberg.org/nephros/install-history/raw/branch/master/Screenshot_002.png
- - https://codeberg.org/nephros/install-history/raw/branch/master/Screenshot_003.png
+ - %{url}/raw/branch/master/Screenshot_001.png
+ - %{url}/raw/branch/master/Screenshot_002.png
+ - %{url}/raw/branch/master/Screenshot_003.png
Url:
Homepage: https://forum.sailfishos.org/t/10253
- Bugtracker: https://codeberg.org/nephros/install-history/issues
+ Bugtracker: %{url}/issues
%endif
SetupOptions: -q -n %{name}-%{version}
#Macros:
|