* Refactor view and browse of store.

This commit is contained in:
zhaoke
2023-08-03 14:04:05 +08:00
parent 669d4f3b02
commit ba8cd0be5c
21 changed files with 188 additions and 52 deletions
+4 -2
View File
@@ -70,6 +70,7 @@ class store extends control
}
$pagedApps = $this->store->searchApps($sortType, $keyword, $postCategories, $pageID, $recPerPage);
$this->app->loadClass('pager', true);
$pager = pager::init($pagedApps->total, $recPerPage, $pageID);
@@ -81,6 +82,7 @@ class store extends control
$this->view->title = $this->lang->store->common;
$this->view->position[] = $this->lang->store->common;
$this->view->cloudApps = $pagedApps->apps;
$this->view->installedApps = $this->storeZen->getInstalledApps();
$this->view->categories = $categories;
$this->view->postCategories = $postCategories;
$this->view->keyword = $keyword;
@@ -95,7 +97,7 @@ class store extends control
*
* @param int $id
* @access public
* @return viod
* @return void
*/
public function appView($id, $pageID = 1, $recPerPage = 20)
{
@@ -116,7 +118,7 @@ class store extends control
$this->app->loadClass('pager', true);
$pager = pager::init($totalArticle, $recPerPage, $pageID);
$this->view->dynamicPager = $pager;
$this->view->pager = $pager;
$this->view->title = $appInfo->alias;
$this->view->position[] = $appInfo->alias;
+15
View File
@@ -31,6 +31,21 @@ window.treeClick = function(info)
*/
window.installApp = function()
{
var confirm = $(this).data('confirm');
console.log(confirm);
if(confirm)
{
zui.Modal.confirm(confirm).then(result =>
{
if(!result) return;
zui.Modal.open({
url: $(this).data('url'),
id: 'installModal'
});
});
return;
}
zui.Modal.open({
url: $(this).data('url'),
id: 'installModal'
+27
View File
@@ -0,0 +1,27 @@
<?php
$lang->store->appType = 'Type';
$lang->store->appVersion = 'Version';
$lang->store->releaseDate = 'Publish Time';
$lang->store->author = 'Author';
$lang->store->empty = 'Empty';
$lang->store->install = 'Install';
$lang->store->customInstall = 'Custom Install';
$lang->store->searchApp = 'Search';
$lang->store->testChannel = 'Test Version';
$lang->store->stableChannel = 'Stable Version';
$lang->store->appBasicInfo = 'Basic Info';
$lang->store->screenshots = 'Screenshots';
$lang->store->appDynamic = 'Dynamic';
$lang->store->noDynamicArticle = 'Empty';
$lang->store->noScreenshot = 'Empty';
$lang->store->cloudStore = 'APP Store';
$lang->store->support = 'Support';
$lang->store->gitUrl = 'Git';
$lang->store->dockerfileUrl = 'Dockerfile';
$lang->store->forumUrl = 'Forum';
$lang->store->alreadyInstalled = 'The application has been installed on the platform, Are you sure you want to continue with the installation?';
$lang->store->featureBar['browse']['id'] = 'Default';
$lang->store->featureBar['browse']['create_time'] = 'Newest';
$lang->store->featureBar['browse']['update_time'] = 'Recently updated';
+1
View File
@@ -20,6 +20,7 @@ $lang->store->support = '支持';
$lang->store->gitUrl = '应用源码';
$lang->store->dockerfileUrl = 'Dockerfile';
$lang->store->forumUrl = '论坛';
$lang->store->alreadyInstalled = '平台已安装过该应用,确定要继续安装么?';
$lang->store->featureBar['browse']['id'] = '默认';
$lang->store->featureBar['browse']['create_time'] = '最新上架';
+18 -1
View File
@@ -101,6 +101,23 @@ class storeModel extends model
return $result->data;
}
/**
* Get app version pairs by id.
*
* @param int $id
* @access public
* @return array
*/
public function getVersionPairs(int $id): array
{
$pairs = array();
$versions = $this->appVersionList($id);
foreach($versions as $version) $pairs[$version->version] = $version->app_version . '-' . $version->version;
return $pairs;
}
/**
* Get app version list to install.
*
@@ -125,7 +142,7 @@ class storeModel extends model
$apiUrl = $this->config->cloud->api->host;
$apiUrl .= '/api/market/app/version';
$result = commonModel::apiGet($apiUrl, $apiParams, $this->config->cloud->api->headers);
if(!isset($result->code) || $result->code != 200) return null;
if(!isset($result->code) || $result->code != 200) return array();
return array_combine(array_column($result->data, 'version'), $result->data);
}
+5 -14
View File
@@ -13,8 +13,7 @@ declare(strict_types=1);
namespace zin;
$setting = usePager('dynamicPager');
$screenshots = array_filter($cloudApp->screenshot_urls);
$screenshots = array_filter($cloudApp->screenshot_urls);
if(!empty($screenshots) && count($screenshots)%3) $screenshots = array_merge($screenshots, array_fill(0, count($screenshots)%3, ''));
$screenshotsWg = array();
foreach($screenshots as $screenshot)
@@ -22,12 +21,12 @@ foreach($screenshots as $screenshot)
$screenshotsWg[] = div
(
setClass('flex-1 img-thumbnail'),
!$screenshot ? '' : img
$screenshot ? img
(
set::src($screenshot),
setClass('state'),
on::click('window.open("' . $screenshot . '")')
)
) : null,
);
}
@@ -72,7 +71,7 @@ detailHeader(
backBtn
(
$lang->store->install,
setClass('primary btn size-sm install-btn'),
setClass('primary btn install-btn w-20'),
set::type('primary'),
set::url($this->createLink('instance', 'install', "id={$cloudApp->id}")),
setData('toggle', 'modal'),
@@ -141,15 +140,7 @@ detailBody
setClass('table borderless table-hover mb-3'),
...$dynamicArticlesWd,
),
pager(
setID('dynamicPager'),
set::page($setting['page']),
set::recTotal($setting['recTotal']),
set::recPerPage($setting['recPerPage']),
set::linkCreator($setting['linkCreator']),
set::items($setting['items']),
set::gap($setting['gap']),
),
pager(setID('dynamicPager')),
)
)
)
+2 -1
View File
@@ -49,7 +49,7 @@ foreach ($cloudApps as $group)
div
(
setStyle('height', '100px'),
setClass('flex border-b border-light'),
setClass('flex border-b border-lighter'),
img(set::src($cloudApp->logo), setStyle(array('width' => '80px', 'height' => '80px'))),
div
(
@@ -72,6 +72,7 @@ foreach ($cloudApps as $group)
setClass('primary btn size-sm install-btn'),
setData('prevent', true),
setData('toggle', 'modal'),
in_array($cloudApp->id, $installedApps) ? setData('confirm', $lang->store->alreadyInstalled) : null,
setData('url', $this->createLink('space', 'createApplication', "id={$cloudApp->id}")),
on::click('installApp', array('stop' => true)),
)
+33
View File
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
/**
* The zen file of store module of ZenTaoPMS.
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Ke Zhao<zhaoke@easycorp.ltd>
* @package store
* @link https://www.zentao.net
*/
class storeZen extends store
{
/**
* 获取已安装的所有应用。
* Get all installed apps.
*
* @param form $formData
* @param bool $isPipelineServer
* @access protected
* @return object|false
*/
protected function getInstalledApps(): array
{
$installedApps = array();
$space = $this->loadModel('space')->defaultSpace($this->app->user->account);
$instances = $this->space->getSpaceInstances($space->id, 'all');
foreach($instances as $instance) $installedApps[] = $instance->appID;
return $installedApps;
}
}