|
|
|
@ -22,6 +22,11 @@ function initDB() {
|
|
|
|
autoIncrement: true,
|
|
|
|
autoIncrement: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const settingsT = db.createObjectStore('settings', {
|
|
|
|
|
|
|
|
keyPath: 'id',
|
|
|
|
|
|
|
|
autoIncrement: true,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Spalten definieren
|
|
|
|
// Spalten definieren
|
|
|
|
store.createIndex('createdate', 'createdate', { unique: false });
|
|
|
|
store.createIndex('createdate', 'createdate', { unique: false });
|
|
|
|
store.createIndex('date', 'date', { unique: false });
|
|
|
|
store.createIndex('date', 'date', { unique: false });
|
|
|
|
@ -29,6 +34,9 @@ function initDB() {
|
|
|
|
store.createIndex('type', 'type', { unique: false });
|
|
|
|
store.createIndex('type', 'type', { unique: false });
|
|
|
|
store.createIndex('status', 'status', { unique: false });
|
|
|
|
store.createIndex('status', 'status', { unique: false });
|
|
|
|
store.createIndex('sondertext', 'sondertext', { unique: false });
|
|
|
|
store.createIndex('sondertext', 'sondertext', { unique: false });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
settingsT.createIndex('SettingsID', 'SettingsID', { unique: false });
|
|
|
|
|
|
|
|
settingsT.createIndex('SettingsValue', 'SettingsValue', { unique: false });
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
request.onsuccess = function (event) {
|
|
|
|
request.onsuccess = function (event) {
|
|
|
|
@ -44,10 +52,10 @@ function initDB() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Neuer Eintrag in die IndexedDB
|
|
|
|
// Neuer Eintrag in die IndexedDB
|
|
|
|
function addEntry(data) {
|
|
|
|
function addEntry(data, table) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const transaction = db.transaction(['hours'], 'readwrite');
|
|
|
|
const transaction = db.transaction([table], 'readwrite');
|
|
|
|
const store = transaction.objectStore('hours');
|
|
|
|
const store = transaction.objectStore(table);
|
|
|
|
|
|
|
|
|
|
|
|
data.createdate = new Date();
|
|
|
|
data.createdate = new Date();
|
|
|
|
const request = store.add(data);
|
|
|
|
const request = store.add(data);
|
|
|
|
@ -63,10 +71,10 @@ function addEntry(data) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Eintrag aktualisieren
|
|
|
|
// Eintrag aktualisieren
|
|
|
|
function updateEntry(id, updatedData) {
|
|
|
|
function updateEntry(id, table, updatedData) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const transaction = db.transaction(['hours'], 'readwrite');
|
|
|
|
const transaction = db.transaction([table], 'readwrite');
|
|
|
|
const store = transaction.objectStore('hours');
|
|
|
|
const store = transaction.objectStore(table);
|
|
|
|
|
|
|
|
|
|
|
|
const getRequest = store.get(id);
|
|
|
|
const getRequest = store.get(id);
|
|
|
|
|
|
|
|
|
|
|
|
@ -111,10 +119,10 @@ function deleteEntry(id) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Einträge abrufen
|
|
|
|
// Einträge abrufen
|
|
|
|
function getAllEntries() {
|
|
|
|
function getAllEntries(table) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const transaction = db.transaction(['hours'], 'readonly');
|
|
|
|
const transaction = db.transaction([table], 'readonly');
|
|
|
|
const store = transaction.objectStore('hours');
|
|
|
|
const store = transaction.objectStore(table);
|
|
|
|
|
|
|
|
|
|
|
|
const request = store.getAll();
|
|
|
|
const request = store.getAll();
|
|
|
|
|
|
|
|
|
|
|
|
|