summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/message.inc.php20
-rw-r--r--inc/property.inc.php4
-rw-r--r--modules/minilinux.inc.php19
-rw-r--r--templates/minilinux/filelist.html5
4 files changed, 39 insertions, 9 deletions
diff --git a/inc/message.inc.php b/inc/message.inc.php
index b62f234f..9405457d 100644
--- a/inc/message.inc.php
+++ b/inc/message.inc.php
@@ -108,6 +108,26 @@ class Message
}
/**
+ * Get all queued messages, flushing the queue.
+ * Useful in api/ajax mode.
+ */
+ public static function asString()
+ {
+ global $error_text;
+ $return = '';
+ foreach (self::$list as $item) {
+ $message = $error_text[$item['id']];
+ foreach ($item['params'] as $index => $text) {
+ $message = str_replace('{{' . $index . '}}', $text, $message);
+ }
+ $return .= '[' . $item['type'] . ']: ' . $message . "\n";
+ self::$alreadyDisplayed[] = $item;
+ }
+ self::$list = array();
+ return $return;
+ }
+
+ /**
* Deserialize any messages from the current HTTP request and
* place them in the message queue.
*/
diff --git a/inc/property.inc.php b/inc/property.inc.php
index 0aa1841e..d62bbcb9 100644
--- a/inc/property.inc.php
+++ b/inc/property.inc.php
@@ -111,7 +111,7 @@ class Property
'url' => CONFIG_REMOTE_ML . '/list.php'
));
if (!isset($task['id']))
- return false;
+ return 'Could not start list download (' . Message::asString() . ')';
if ($task['statusCode'] !== TASK_FINISHED) {
$task = Taskmanager::waitComplete($task['id']);
}
@@ -126,7 +126,7 @@ class Property
public static function setVersionCheckInformation($value)
{
- self::set('versioncheck-data', json_encode($value));
+ self::set('versioncheck-data', json_encode($value), 1);
}
public static function getVmStoreConfig()
diff --git a/modules/minilinux.inc.php b/modules/minilinux.inc.php
index 78535ba6..48f7c4f6 100644
--- a/modules/minilinux.inc.php
+++ b/modules/minilinux.inc.php
@@ -39,7 +39,13 @@ class Page_MiniLinux extends Page
$local = CONFIG_HTTP_DIR . '/' . $system['id'] . '/' . $file['name'];
if (!file_exists($local) || filesize($local) !== $file['size'] || md5_file($local) !== substr($file['md5'], 0, 32)) {
$file['changed'] = true;
- $file['taskid'] = Property::getDownloadTask($file['md5']);
+ }
+ $taskId = Property::getDownloadTask($file['md5']);
+ if ($taskId !== false) {
+ $file['download'] = Render::parse('minilinux/download', array(
+ 'task' => $taskId,
+ 'name' => $file['name']
+ ));
}
}
}
@@ -55,16 +61,16 @@ class Page_MiniLinux extends Page
echo "Invalid download request";
return;
}
- $found = false;
+ $file = false;
foreach ($data['systems'] as &$system) {
if ($system['id'] !== $id) continue;
- foreach ($system['files'] as &$file) {
- if ($file['name'] !== $name) continue;
- $found = true;
+ foreach ($system['files'] as &$f) {
+ if ($f['name'] !== $name) continue;
+ $file = $f;
break;
}
}
- if (!$found) {
+ if ($file === false) {
echo "Nonexistent system/file: $id / $name";
return;
}
@@ -76,6 +82,7 @@ class Page_MiniLinux extends Page
echo 'Error launching download task: ' . $task['statusCode'];
return;
}
+ Property::setDownloadTask($file['md5'], $task['id']);
echo Render::parse('minilinux/download', array(
'name' => $name,
'task' => $task['id']
diff --git a/templates/minilinux/filelist.html b/templates/minilinux/filelist.html
index abb28aad..fdc3f14e 100644
--- a/templates/minilinux/filelist.html
+++ b/templates/minilinux/filelist.html
@@ -10,7 +10,9 @@
{{#files}}
<li class="list-group-item" id="{{uid}}">
{{name}}
- {{#changed}}<span class="btn btn-primary btn-sm" onclick="slxUpdate('{{uid}}', '{{id}}', '{{name}}')">Aktualisieren</span>{{/changed}}
+ {{#changed}}<span class="btn btn-success btn-sm" onclick="slxUpdate('{{uid}}', '{{id}}', '{{name}}')">Aktualisieren</span>{{/changed}}
+ {{^changed}}<span class="btn btn-default btn-sm" onclick="slxUpdate('{{uid}}', '{{id}}', '{{name}}')">Erneut herunterladen</span>{{/changed}}
+ {{{download}}}
</li>
{{/files}}
</ul>
@@ -36,4 +38,5 @@ function slxUpdate(uid, id, name)
}
});
}
+tmInit();
</script> \ No newline at end of file