From 9c3ea0530575e7eec098f871527e2e99072d5f97 Mon Sep 17 00:00:00 2001
From: "Sakamoto, Kazunori"
Date: Tue, 25 Feb 2020 23:34:32 +0900
Subject: [PATCH 01/14] feat: load download counts via ajax
---
Controller/CabinetFilesController.php | 29 ++++++++++++++++++++++++-
View/CabinetFiles/index.ctp | 10 ++++++++-
View/Elements/CabinetFiles/file_row.ctp | 8 +++----
webroot/js/cabinets.js | 23 ++++++++++++++++++--
4 files changed, 61 insertions(+), 9 deletions(-)
diff --git a/Controller/CabinetFilesController.php b/Controller/CabinetFilesController.php
index ae9d80e..9e5c901 100644
--- a/Controller/CabinetFilesController.php
+++ b/Controller/CabinetFilesController.php
@@ -11,6 +11,7 @@
*
*
* @author Ryuji AMANO
+ * @author Kazunori Sakamoto
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @property NetCommonsWorkflow $NetCommonsWorkflow
@@ -100,7 +101,8 @@ public function beforeFilter() {
'view',
'folder_detail',
'download',
- 'download_folder'
+ 'download_folder',
+ 'get_download_counts'
);
parent::beforeFilter();
$this->_cabinet = $this->Cabinet->find('first', array(
@@ -331,6 +333,31 @@ public function download_folder() {
return $zipDownloader->download($cabinetFolder['CabinetFile']['filename'] . '.zip');
}
+
+/**
+ * ファイルのダウンロード数の取得
+ *
+ * @return void
+ */
+public function get_download_counts() {
+ $options = [
+ 'fields' => [
+ 'UploadFilesContent.content_id',
+ 'UploadFile.download_count',
+ ],
+ 'conditions' => [
+ 'UploadFilesContent.plugin_key' => 'cabinets',
+ 'UploadFilesContent.content_id' => explode(',', $this->request->query('file_ids')),
+ 'UploadFile.field_name' => 'file'
+ ]
+ ];
+ $UploadFilesContent = ClassRegistry::init('Files.UploadFilesContent');
+ $files = $UploadFilesContent->find('all', $options);
+
+ $this->set('_serialize', ['counts']);
+ $this->set('counts', $files);
+}
+
/**
* フォルダのZIPダウンロード前処理
*
diff --git a/View/CabinetFiles/index.ctp b/View/CabinetFiles/index.ctp
index 2c4226e..397a939 100644
--- a/View/CabinetFiles/index.ctp
+++ b/View/CabinetFiles/index.ctp
@@ -103,13 +103,21 @@
'key' => $currentFolder['CabinetFile']['key'],
'frame_id' => Current::read('Frame.id'),
));
+ $fileIds = array();
+ foreach ($cabinetFiles as $file) {
+ if (! $file['CabinetFile']['is_folder']) {
+ $fileIds[] = $file['CabinetFile']['id'];
+ }
+ }
+ $nonCacheable = $this->response->header()['Pragma'] === 'no-cache' ||
+ strncmp('origin-', $_SERVER['SERVER_NAME'], 7) !== 0;
?>
+ ng-init="init()">
diff --git a/View/Elements/CabinetFiles/file_row.ctp b/View/Elements/CabinetFiles/file_row.ctp
index 2e60f12..40a156c 100644
--- a/View/Elements/CabinetFiles/file_row.ctp
+++ b/View/Elements/CabinetFiles/file_row.ctp
@@ -44,11 +44,9 @@
'Password is required to download.'
) ?>">
-
-
-
+
+
+
Date: Thu, 27 Feb 2020 15:43:34 +0900
Subject: [PATCH 02/14] refactor: use CDNCacheHelper
---
View/CabinetFiles/index.ctp | 12 ++++++------
View/Elements/CabinetFiles/file_row.ctp | 2 +-
webroot/js/cabinets.js | 9 ++-------
3 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/View/CabinetFiles/index.ctp b/View/CabinetFiles/index.ctp
index 397a939..6f03e16 100644
--- a/View/CabinetFiles/index.ctp
+++ b/View/CabinetFiles/index.ctp
@@ -104,20 +104,20 @@
'frame_id' => Current::read('Frame.id'),
));
$fileIds = array();
- foreach ($cabinetFiles as $file) {
- if (! $file['CabinetFile']['is_folder']) {
- $fileIds[] = $file['CabinetFile']['id'];
+ if ($this->CDNCache->isCacheable()) {
+ foreach ($cabinetFiles as $file) {
+ if (! $file['CabinetFile']['is_folder']) {
+ $fileIds[] = $file['CabinetFile']['id'];
+ }
}
}
- $nonCacheable = $this->response->header()['Pragma'] === 'no-cache' ||
- strncmp('origin-', $_SERVER['SERVER_NAME'], 7) !== 0;
?>
+ ng-init="init()">
diff --git a/View/Elements/CabinetFiles/file_row.ctp b/View/Elements/CabinetFiles/file_row.ctp
index 40a156c..8403db6 100644
--- a/View/Elements/CabinetFiles/file_row.ctp
+++ b/View/Elements/CabinetFiles/file_row.ctp
@@ -45,7 +45,7 @@
) ?>">
-
+ CDNCache->isCacheable() ? '-' : $cabinetFile['UploadFile']['file']['total_download_count']; ?>
< fileIds.length; i++) {
- var $count = $(queryPrefix + fileIds[i] + '-count');
- $count.text('-');
- }
-
var params = '?frame_id=' + frameId + '&file_ids=' + fileIds.join(',');
$http.get(NC3_URL + '/cabinets/cabinet_files/get_download_counts.json' + params)
.then(
From f242cefdefcddcacfd8399e4cae7bbe9f60e6675 Mon Sep 17 00:00:00 2001
From: "Sakamoto, Kazunori"
Date: Sat, 29 Feb 2020 03:57:49 +0900
Subject: [PATCH 03/14] fix: refer to total_download_count instead of
download_count
---
Controller/CabinetFilesController.php | 11 ++++-------
View/CabinetFiles/index.ctp | 5 +++--
View/Elements/CabinetFiles/file_row.ctp | 2 +-
webroot/js/cabinets.js | 4 ++--
4 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/Controller/CabinetFilesController.php b/Controller/CabinetFilesController.php
index 9e5c901..4a48680 100644
--- a/Controller/CabinetFilesController.php
+++ b/Controller/CabinetFilesController.php
@@ -342,17 +342,14 @@ public function download_folder() {
public function get_download_counts() {
$options = [
'fields' => [
- 'UploadFilesContent.content_id',
- 'UploadFile.download_count',
+ 'UploadFile.total_download_count',
],
'conditions' => [
- 'UploadFilesContent.plugin_key' => 'cabinets',
- 'UploadFilesContent.content_id' => explode(',', $this->request->query('file_ids')),
- 'UploadFile.field_name' => 'file'
+ 'UploadFile.id' => explode(',', $this->request->query('upload_file_ids')),
]
];
- $UploadFilesContent = ClassRegistry::init('Files.UploadFilesContent');
- $files = $UploadFilesContent->find('all', $options);
+ $UploadFile = ClassRegistry::init('Files.UploadFile');
+ $files = $UploadFile->find('first', $options);
$this->set('_serialize', ['counts']);
$this->set('counts', $files);
diff --git a/View/CabinetFiles/index.ctp b/View/CabinetFiles/index.ctp
index 6f03e16..10ade1c 100644
--- a/View/CabinetFiles/index.ctp
+++ b/View/CabinetFiles/index.ctp
@@ -107,7 +107,7 @@
if ($this->CDNCache->isCacheable()) {
foreach ($cabinetFiles as $file) {
if (! $file['CabinetFile']['is_folder']) {
- $fileIds[] = $file['CabinetFile']['id'];
+ $fileIds[] = $file['UploadFile']['id'];
}
}
}
@@ -117,7 +117,8 @@
class="table table-hover cabinets__index__file-list"
style="table-layout: fixed"
ng-controller="CabinetFile.index"
- ng-init="init()">
+ ng-init="init()">
diff --git a/View/Elements/CabinetFiles/file_row.ctp b/View/Elements/CabinetFiles/file_row.ctp
index 8403db6..d76c500 100644
--- a/View/Elements/CabinetFiles/file_row.ctp
+++ b/View/Elements/CabinetFiles/file_row.ctp
@@ -44,7 +44,7 @@
'Password is required to download.'
) ?>">
-
+
CDNCache->isCacheable() ? '-' : $cabinetFile['UploadFile']['file']['total_download_count']; ?>
diff --git a/webroot/js/cabinets.js b/webroot/js/cabinets.js
index 5ab0982..7180c37 100644
--- a/webroot/js/cabinets.js
+++ b/webroot/js/cabinets.js
@@ -48,14 +48,14 @@ NetCommonsApp.controller('CabinetFile.index',
if (!fileIds || !fileIds.length) return;
var queryPrefix = '#' + frameId + '-';
- var params = '?frame_id=' + frameId + '&file_ids=' + fileIds.join(',');
+ var params = '?frame_id=' + frameId + '&upload_file_ids=' + fileIds.join(',');
$http.get(NC3_URL + '/cabinets/cabinet_files/get_download_counts.json' + params)
.then(
function(response) {
var counts = response.data.counts;
for (var i = 0; i < counts.length; i++) {
var $count = $(queryPrefix + counts[i]['UploadFilesContent']['content_id'] + '-count');
- $count.text(counts[i]['UploadFile']['download_count']);
+ $count.text(counts[i]['UploadFile']['total_download_count']);
}
},
function() {
From 2ddab1e32fd3c73e825dbbbf870b44deb3e8a7b6 Mon Sep 17 00:00:00 2001
From: "Sakamoto, Kazunori"
Date: Sat, 29 Feb 2020 12:50:25 +0900
Subject: [PATCH 04/14] fix: show download counts correctly
---
Controller/CabinetFilesController.php | 3 ++-
View/CabinetFiles/index.ctp | 2 +-
View/Elements/CabinetFiles/file_row.ctp | 2 +-
webroot/js/cabinets.js | 2 +-
4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Controller/CabinetFilesController.php b/Controller/CabinetFilesController.php
index 4a48680..a6a7e33 100644
--- a/Controller/CabinetFilesController.php
+++ b/Controller/CabinetFilesController.php
@@ -342,6 +342,7 @@ public function download_folder() {
public function get_download_counts() {
$options = [
'fields' => [
+ 'UploadFile.id',
'UploadFile.total_download_count',
],
'conditions' => [
@@ -349,7 +350,7 @@ public function get_download_counts() {
]
];
$UploadFile = ClassRegistry::init('Files.UploadFile');
- $files = $UploadFile->find('first', $options);
+ $files = $UploadFile->find('all', $options);
$this->set('_serialize', ['counts']);
$this->set('counts', $files);
diff --git a/View/CabinetFiles/index.ctp b/View/CabinetFiles/index.ctp
index 10ade1c..6a7dde8 100644
--- a/View/CabinetFiles/index.ctp
+++ b/View/CabinetFiles/index.ctp
@@ -107,7 +107,7 @@
if ($this->CDNCache->isCacheable()) {
foreach ($cabinetFiles as $file) {
if (! $file['CabinetFile']['is_folder']) {
- $fileIds[] = $file['UploadFile']['id'];
+ $fileIds[] = $file['UploadFile']['file']['id'];
}
}
}
diff --git a/View/Elements/CabinetFiles/file_row.ctp b/View/Elements/CabinetFiles/file_row.ctp
index d76c500..2d75197 100644
--- a/View/Elements/CabinetFiles/file_row.ctp
+++ b/View/Elements/CabinetFiles/file_row.ctp
@@ -44,7 +44,7 @@
'Password is required to download.'
) ?>">
-
+
CDNCache->isCacheable() ? '-' : $cabinetFile['UploadFile']['file']['total_download_count']; ?>
diff --git a/webroot/js/cabinets.js b/webroot/js/cabinets.js
index 7180c37..621bf0e 100644
--- a/webroot/js/cabinets.js
+++ b/webroot/js/cabinets.js
@@ -54,7 +54,7 @@ NetCommonsApp.controller('CabinetFile.index',
function(response) {
var counts = response.data.counts;
for (var i = 0; i < counts.length; i++) {
- var $count = $(queryPrefix + counts[i]['UploadFilesContent']['content_id'] + '-count');
+ var $count = $(queryPrefix + counts[i]['UploadFile']['id'] + '-count');
$count.text(counts[i]['UploadFile']['total_download_count']);
}
},
From 1b88518818774028bd2ecb69b65890076a027639 Mon Sep 17 00:00:00 2001
From: "Sakamoto, Kazunori"
Date: Sat, 29 Feb 2020 18:28:08 +0900
Subject: [PATCH 05/14] refactor: don't use jQuery
---
View/CabinetFiles/index.ctp | 17 +++++++++--------
View/Elements/CabinetFiles/file_row.ctp | 4 ++--
webroot/js/cabinets.js | 15 +++++++++++----
3 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/View/CabinetFiles/index.ctp b/View/CabinetFiles/index.ctp
index 6a7dde8..d6d49a6 100644
--- a/View/CabinetFiles/index.ctp
+++ b/View/CabinetFiles/index.ctp
@@ -1,6 +1,7 @@
element('NetCommons.javascript_alert'); ?>
NetCommonsHtml->css('/cabinets/css/cabinets.css'); ?>
@@ -103,12 +104,12 @@
'key' => $currentFolder['CabinetFile']['key'],
'frame_id' => Current::read('Frame.id'),
));
- $fileIds = array();
- if ($this->CDNCache->isCacheable()) {
- foreach ($cabinetFiles as $file) {
- if (! $file['CabinetFile']['is_folder']) {
- $fileIds[] = $file['UploadFile']['file']['id'];
- }
+ $initialValues = array();
+ $cacheable = $this->CDNCache->isCacheable();
+ foreach ($cabinetFiles as $file) {
+ if (! $file['CabinetFile']['is_folder']) {
+ $value = $cacheable ? null : $file['UploadFile']['file']['total_download_count'];
+ $initialValues[$file['UploadFile']['file']['id']] = $value;
}
}
?>
@@ -118,7 +119,7 @@
style="table-layout: fixed"
ng-controller="CabinetFile.index"
ng-init="init()">
+ . h(json_encode(Current::read('Frame.id'))) . ', ' . h(json_encode($initialValues)); ?>)">
diff --git a/View/Elements/CabinetFiles/file_row.ctp b/View/Elements/CabinetFiles/file_row.ctp
index 2d75197..565915f 100644
--- a/View/Elements/CabinetFiles/file_row.ctp
+++ b/View/Elements/CabinetFiles/file_row.ctp
@@ -44,8 +44,8 @@
'Password is required to download.'
) ?>">
-
- CDNCache->isCacheable() ? '-' : $cabinetFile['UploadFile']['file']['total_download_count']; ?>
+
+ {{downloadCounts[]}}
< fileIds.length; i++) {
+ initialValues[fileIds[i]] = '-';
+ }
+
var params = '?frame_id=' + frameId + '&upload_file_ids=' + fileIds.join(',');
$http.get(NC3_URL + '/cabinets/cabinet_files/get_download_counts.json' + params)
.then(
function(response) {
var counts = response.data.counts;
for (var i = 0; i < counts.length; i++) {
- var $count = $(queryPrefix + counts[i]['UploadFile']['id'] + '-count');
- $count.text(counts[i]['UploadFile']['total_download_count']);
+ var file = counts[i].UploadFile;
+ $scope.downloadCounts[file.id] = file.total_download_count;
}
},
function() {
From 54bba674f59f56de74578d053b2ab62545ca0005 Mon Sep 17 00:00:00 2001
From: "Sakamoto, Kazunori"
Date: Mon, 2 Mar 2020 09:15:27 +0900
Subject: [PATCH 06/14] fix: optimize get_download_counts
---
Controller/CabinetFilesController.php | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/Controller/CabinetFilesController.php b/Controller/CabinetFilesController.php
index a6a7e33..9732c93 100644
--- a/Controller/CabinetFilesController.php
+++ b/Controller/CabinetFilesController.php
@@ -340,17 +340,18 @@ public function download_folder() {
* @return void
*/
public function get_download_counts() {
- $options = [
+ $query = [
'fields' => [
'UploadFile.id',
'UploadFile.total_download_count',
],
'conditions' => [
'UploadFile.id' => explode(',', $this->request->query('upload_file_ids')),
- ]
+ ],
+ 'recursive' => -1
];
$UploadFile = ClassRegistry::init('Files.UploadFile');
- $files = $UploadFile->find('all', $options);
+ $files = $UploadFile->find('all', $query);
$this->set('_serialize', ['counts']);
$this->set('counts', $files);
From 5a396f64f9c036cde1825c00a813fec8772b507a Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 31 Jul 2020 13:42:51 +0900
Subject: [PATCH 07/14] =?UTF-8?q?change:=20test:=20traivs=E3=82=92?=
=?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=81=99=E3=82=8B=E9=9A=9B=E3=81=ABavailabil?=
=?UTF-8?q?ity=E3=81=AB=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 0e5f429..94f1131 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,7 +12,7 @@ dist: trusty
env:
matrix:
- - NETCOMMONS_VERSION=master DB=mysql
+ - NETCOMMONS_VERSION=availability DB=mysql
global:
- secure: "mF+LYvAgZauto0g3knD6wqd3wz3TEiIFEc1IhJDHWsqSjTr371xxk8n1RmrbqoRYpcRutxBtdItvp531SbLjyuo7WJ/yW4VG9k0vh8p1Vxa6x9OreqFmwibDCtO0qwewrqNJzsH4ktPlWracMv6tLNdIJyEhmp8zLQ7etzmoAJ+YGwI7Jtib7r2Mrrplfyf/AK7Vn59QNIKV33vZ7FhCPON6+N2gsuvDG2qS0ulrc/SKujXHyVfaVB7j3ZEQNpuaZC5ZANl5y3FbsgpjUWJPjAt+O9o4Xq+rFGzaoVGsB5IwRLIDiNQye4tgvFDKWzEruslGtfXxOFbOAeD9og+jSoACQ62/vzNwzp8J68+ppDtY0KPp9iOMjAivErv/niF0Ed7059tjR3Z5fyZBr1mxPXY6v3ZKlJ+1IKy+sJcSho/rGhBrfQW8UOMzi08O/ZrXyMMeCZuqByR8BGQtLmEmNZGt0fIGBV4L3NlGG6KaBHUJVpfru2rHkSjM6u1/+v5YUt5f79eyt+BnVNaaTx0Tn8HbE9tcouk2h4VeocGHpskO0oHx5kcxNRJ0Tj9oiJZ0zcRrU0K1ulpLaUAVvszqPTbV88U5UoaggJ987SAeM3xrhG0yBHvrG0gRQfJ5BUouVehadEVEWBgD37UIhKnd8rC2uISwXfxYxaoi2UiqJvM="
- GIT_COMMITTER_NAME=RyujiAMANO
From 5fe09424208cd65c1b63c4f3640f4d111eae9b0e Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 31 Jul 2020 14:16:16 +0900
Subject: [PATCH 08/14] =?UTF-8?q?change:=20test:=20traivs=E3=82=92?=
=?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=81=99=E3=82=8B=E9=9A=9B=E3=81=ABavailabil?=
=?UTF-8?q?ity=E3=81=AB=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 2072cd6..c09ab74 100644
--- a/composer.json
+++ b/composer.json
@@ -15,7 +15,7 @@
"netcommons/blocks": "@dev",
"netcommons/files": "@dev",
"netcommons/mails": "@dev",
- "netcommons/net-commons": "@dev",
+ "netcommons/net-commons": "dev-availability",
"netcommons/pages": "@dev",
"netcommons/plugin-manager": "@dev",
"netcommons/topics": "@dev",
From 9c07428e33a9784b39af6e4967eb32c151b5b589 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 31 Jul 2020 14:20:13 +0900
Subject: [PATCH 09/14] =?UTF-8?q?change:=20test:=20traivs=E3=82=92?=
=?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=81=99=E3=82=8B=E9=9A=9B=E3=81=ABavailabil?=
=?UTF-8?q?ity=E3=81=AB=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index c09ab74..2072cd6 100644
--- a/composer.json
+++ b/composer.json
@@ -15,7 +15,7 @@
"netcommons/blocks": "@dev",
"netcommons/files": "@dev",
"netcommons/mails": "@dev",
- "netcommons/net-commons": "dev-availability",
+ "netcommons/net-commons": "@dev",
"netcommons/pages": "@dev",
"netcommons/plugin-manager": "@dev",
"netcommons/topics": "@dev",
From e639dc69fad91fd85543d5460c715eadb5f15c28 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 31 Jul 2020 15:44:56 +0900
Subject: [PATCH 10/14] =?UTF-8?q?style:=20test:=20traivs=E3=82=A8=E3=83=A9?=
=?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Controller/CabinetFilesController.php | 33 +++++++++++++--------------
View/CabinetFiles/index.ctp | 8 +++----
webroot/js/cabinets.js | 18 +++++++--------
3 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/Controller/CabinetFilesController.php b/Controller/CabinetFilesController.php
index 0f22be6..4dcccf3 100644
--- a/Controller/CabinetFilesController.php
+++ b/Controller/CabinetFilesController.php
@@ -332,29 +332,28 @@ public function download_folder() {
return $zipDownloader->download($cabinetFolder['CabinetFile']['filename'] . '.zip');
}
-
/**
* ファイルのダウンロード数の取得
*
* @return void
*/
-public function get_download_counts() {
- $query = [
- 'fields' => [
- 'UploadFile.id',
- 'UploadFile.total_download_count',
- ],
- 'conditions' => [
- 'UploadFile.id' => explode(',', $this->request->query('upload_file_ids')),
- ],
- 'recursive' => -1
- ];
- $UploadFile = ClassRegistry::init('Files.UploadFile');
- $files = $UploadFile->find('all', $query);
+ public function get_download_counts() {
+ $query = [
+ 'fields' => [
+ 'UploadFile.id',
+ 'UploadFile.total_download_count',
+ ],
+ 'conditions' => [
+ 'UploadFile.id' => explode(',', $this->request->query('upload_file_ids')),
+ ],
+ 'recursive' => -1
+ ];
+ $UploadFile = ClassRegistry::init('Files.UploadFile');
+ $files = $UploadFile->find('all', $query);
- $this->set('_serialize', ['counts']);
- $this->set('counts', $files);
-}
+ $this->set('_serialize', ['counts']);
+ $this->set('counts', $files);
+ }
/**
* フォルダのZIPダウンロードができるか否かチェック
diff --git a/View/CabinetFiles/index.ctp b/View/CabinetFiles/index.ctp
index 36007f9..5a147cd 100644
--- a/View/CabinetFiles/index.ctp
+++ b/View/CabinetFiles/index.ctp
@@ -1,7 +1,7 @@
element('NetCommons.javascript_alert'); ?>
NetCommonsHtml->css('/cabinets/css/cabinets.css'); ?>
@@ -118,8 +118,8 @@
class="table table-hover cabinets__index__file-list"
style="table-layout: fixed"
ng-controller="CabinetFile.index"
- ng-init="init()">
+ ng-init="init()">
|
diff --git a/webroot/js/cabinets.js b/webroot/js/cabinets.js
index 99199ee..0190e36 100644
--- a/webroot/js/cabinets.js
+++ b/webroot/js/cabinets.js
@@ -58,15 +58,15 @@ NetCommonsApp.controller('CabinetFile.index',
var params = '?frame_id=' + frameId + '&upload_file_ids=' + fileIds.join(',');
$http.get(NC3_URL + '/cabinets/cabinet_files/get_download_counts.json' + params)
.then(
- function(response) {
- var counts = response.data.counts;
- for (var i = 0; i < counts.length; i++) {
- var file = counts[i].UploadFile;
- $scope.downloadCounts[file.id] = file.total_download_count;
- }
- },
- function() {
- });
+ function(response) {
+ var counts = response.data.counts;
+ for (var i = 0; i < counts.length; i++) {
+ var file = counts[i].UploadFile;
+ $scope.downloadCounts[file.id] = file.total_download_count;
+ }
+ },
+ function() {
+ });
};
$scope.moveFile = function(cabinetFileKey, isFolder, data) {
From 996198f6b9d8e459d06b27ab437d75dc8a6c1c87 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Sat, 1 Aug 2020 23:05:20 +0900
Subject: [PATCH 11/14] =?UTF-8?q?fix:=20=E3=82=AD=E3=83=A3=E3=83=93?=
=?UTF-8?q?=E3=83=8D=E3=83=83=E3=83=88=E3=81=AE=E5=9C=A7=E7=B8=AE=E3=83=80?=
=?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E3=82=92GET?=
=?UTF-8?q?=E3=81=8B=E3=82=89POST=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97?=
=?UTF-8?q?=E3=81=9F=E9=9A=9B=E3=81=AB=E3=82=A6=E3=82=A7=E3=83=96=E3=82=A2?=
=?UTF-8?q?=E3=82=AF=E3=82=BB=E3=83=A9=E3=83=AC=E3=83=BC=E3=82=BF=E3=82=92?=
=?UTF-8?q?=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=81=A8Token=E3=82=A8?=
=?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Controller/CabinetFilesController.php | 17 +++++++++-
View/CabinetFiles/folder_detail.ctp | 2 ++
View/CabinetFiles/index.ctp | 1 +
View/Helper/CabinetFileHelper.php | 48 +++++++++++++++++++++++++++
webroot/js/cabinets_zip_download.js | 22 ++++++++++++
5 files changed, 89 insertions(+), 1 deletion(-)
diff --git a/Controller/CabinetFilesController.php b/Controller/CabinetFilesController.php
index 4dcccf3..91538e3 100644
--- a/Controller/CabinetFilesController.php
+++ b/Controller/CabinetFilesController.php
@@ -17,6 +17,7 @@
* @property NetCommonsWorkflow $NetCommonsWorkflow
* @property PaginatorComponent $Paginator
* @property CabinetFile $CabinetFile
+ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class CabinetFilesController extends CabinetsAppController {
@@ -103,7 +104,8 @@ public function beforeFilter() {
'download',
'download_folder',
'get_download_counts',
- 'check_download_folder'
+ 'check_download_folder',
+ 'load_download_folder'
);
parent::beforeFilter();
$this->_cabinet = $this->Cabinet->find('first', array(
@@ -398,6 +400,19 @@ protected function _findCabinetFilesByFolderDownload($cabinetFolder) {
return $files;
}
+/**
+ * ファイルの圧縮ダウンロードのロード処理
+ *
+ * @return void
+ */
+ public function load_download_folder() {
+ $View = $this->_getViewObject();
+ $fileKeys = explode(',', $this->request->query('file_keys'));
+ foreach ($fileKeys as $fileKey) {
+ $View->CabinetFile->setZipDownloadToken($fileKey);
+ }
+ }
+
/**
* フォルダのZIPダウンロード前処理
*
diff --git a/View/CabinetFiles/folder_detail.ctp b/View/CabinetFiles/folder_detail.ctp
index 9e6348c..1c543ad 100644
--- a/View/CabinetFiles/folder_detail.ctp
+++ b/View/CabinetFiles/folder_detail.ctp
@@ -124,4 +124,6 @@ echo $this->Html->script(
?>
+
+ CabinetFile->loadZipDownload((string)Current::read('Frame.id')); ?>
diff --git a/View/CabinetFiles/index.ctp b/View/CabinetFiles/index.ctp
index 5a147cd..c372854 100644
--- a/View/CabinetFiles/index.ctp
+++ b/View/CabinetFiles/index.ctp
@@ -202,5 +202,6 @@
+ CabinetFile->loadZipDownload((string)Current::read('Frame.id')); ?>
diff --git a/View/Helper/CabinetFileHelper.php b/View/Helper/CabinetFileHelper.php
index f6cd631..3930dc3 100644
--- a/View/Helper/CabinetFileHelper.php
+++ b/View/Helper/CabinetFileHelper.php
@@ -23,6 +23,13 @@ class CabinetFileHelper extends AppHelper {
'NetCommons.Token',
];
+/**
+ * 圧縮ダウンロードのキー
+ *
+ * var array
+ */
+ private $__zipDolowdKeys = [];
+
/**
* Before render callback. beforeRender is called before the view file is rendered.
*
@@ -112,7 +119,48 @@ public function zipDownload($cabinetFile, $label, $options) {
$attributes = $this->_parseAttributes($options);
$html .= "" . h($label) . "";
+
+ $frameId = (string)Current::read('Frame.id');
+ if (! isset($this->__zipDolowdKeys[$frameId])) {
+ $this->__zipDolowdKeys[$frameId] = [];
+ }
+ $this->__zipDolowdKeys[$frameId][] = $cabinetFile['CabinetFile']['key'];
+
+ return $html;
+ }
+
+/**
+ * 圧縮ダウンロードリンクのロードタグ出力
+ *
+ * @param string $frameId フレームID
+ * @return string
+ */
+ public function loadZipDownload($frameId) {
+ $html = '';
+ if (! isset($this->__zipDolowdKeys[$frameId])) {
+ return $html;
+ }
+
+ $html .= '';
return $html;
}
+/**
+ * 圧縮ダウンロードのためのTokenセット
+ *
+ * @param string $cabinetFileKey ファイルキー
+ * @return void
+ */
+ public function setZipDownloadToken($cabinetFileKey) {
+ $cabinetFile = [
+ 'CabinetFile' => [
+ 'key' => $cabinetFileKey
+ ],
+ ];
+ $this->zipDownload($cabinetFile, '', []);
+ }
+
}
diff --git a/webroot/js/cabinets_zip_download.js b/webroot/js/cabinets_zip_download.js
index 5656039..b246fd0 100644
--- a/webroot/js/cabinets_zip_download.js
+++ b/webroot/js/cabinets_zip_download.js
@@ -110,3 +110,25 @@ NetCommonsApp.controller('CabinetFiles.zipDownload',
};
}]);
+
+
+NetCommonsApp.controller('CabinetFiles.loadZipDownload',
+ ['$scope', '$http', 'NC3_URL',
+ function($scope, $http, NC3_URL) {
+
+ /**
+ * イニシャライズ処理
+ *
+ * @return {void}
+ */
+ $scope.load = function(frameId, fileKeys) {
+ var params = '?frame_id=' + frameId + '&file_keys=' + fileKeys;
+ $http.get(NC3_URL + '/cabinets/cabinet_files/load_download_folder.json' + params)
+ .then(
+ function(response) {
+ },
+ function() {
+ });
+ };
+ }]
+);
From 2ecb082fada3b10ea10fc122076521d69d1f3f58 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Mon, 3 Aug 2020 06:32:05 +0900
Subject: [PATCH 12/14] =?UTF-8?q?fix:=20=E3=82=AD=E3=83=A3=E3=83=93?=
=?UTF-8?q?=E3=83=8D=E3=83=83=E3=83=88=E3=81=AE=E5=9C=A7=E7=B8=AE=E3=83=80?=
=?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E3=82=92GET?=
=?UTF-8?q?=E3=81=8B=E3=82=89POST=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97?=
=?UTF-8?q?=E3=81=9F=E9=9A=9B=E3=81=AB=E3=82=A6=E3=82=A7=E3=83=96=E3=82=A2?=
=?UTF-8?q?=E3=82=AF=E3=82=BB=E3=83=A9=E3=83=AC=E3=83=BC=E3=82=BF=E3=82=92?=
=?UTF-8?q?=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=81=A8Token=E3=82=A8?=
=?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Controller/CabinetFilesController.php | 4 ++++
View/Helper/CabinetFileHelper.php | 6 +++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/Controller/CabinetFilesController.php b/Controller/CabinetFilesController.php
index 91538e3..0e5c343 100644
--- a/Controller/CabinetFilesController.php
+++ b/Controller/CabinetFilesController.php
@@ -300,6 +300,7 @@ public function download() {
* @return CakeResponse|string|void
*/
public function download_folder() {
+ $this->response->header('Pragma', 'no-cache');
if (! $this->request->is('post')) {
return $this->throwBadRequest();
}
@@ -363,6 +364,7 @@ public function get_download_counts() {
* @return void
*/
public function check_download_folder() {
+ $this->response->header('Pragma', 'no-cache');
if (! $this->request->is('post') || ! $this->request->is('ajax')) {
return $this->throwBadRequest();
}
@@ -406,8 +408,10 @@ protected function _findCabinetFilesByFolderDownload($cabinetFolder) {
* @return void
*/
public function load_download_folder() {
+ $this->response->header('Pragma', 'no-cache');
$View = $this->_getViewObject();
$fileKeys = explode(',', $this->request->query('file_keys'));
+
foreach ($fileKeys as $fileKey) {
$View->CabinetFile->setZipDownloadToken($fileKey);
}
diff --git a/View/Helper/CabinetFileHelper.php b/View/Helper/CabinetFileHelper.php
index 3930dc3..0108c94 100644
--- a/View/Helper/CabinetFileHelper.php
+++ b/View/Helper/CabinetFileHelper.php
@@ -89,16 +89,16 @@ public function zipDownload($cabinetFile, $label, $options) {
$hiddenFields = array_keys($tokenFields);
// * チェック用のToken作成
$this->_View->request->data = $requestData;
+ $this->_View->request->data['CabinetFile']['_action'] = 'check';
$checkToken = $this->Token->getToken(
'CabinetFile', $checkUrl, $tokenFields, $hiddenFields
);
- $checkToken['_Token']['key'] = '';
// * ダウンロード用のToken作成
$this->_View->request->data = $requestData;
+ $this->_View->request->data['CabinetFile']['_action'] = 'download';
$downloadToken = $this->Token->getToken(
'CabinetFile', $downloadUrl, $tokenFields, $hiddenFields
);
- $downloadToken['_Token']['key'] = '';
// * $thisi->request->dataを元に戻す
$this->_View->request->data = $currentData;
@@ -106,11 +106,11 @@ public function zipDownload($cabinetFile, $label, $options) {
'action' => $checkUrl,
'token' => $checkToken['_Token'],
];
-
$requestData['Download'] = [
'action' => $downloadUrl,
'token' => $downloadToken['_Token'],
];
+
//アンカータグ生成
$options['ng-controller'] = 'CabinetFiles.zipDownload';
$options['ng-init'] = "initialize(" . json_encode($requestData) . ")";
From 2e4ad66480ecd0673439d630fae9320e915b76c6 Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Mon, 3 Aug 2020 13:05:46 +0900
Subject: [PATCH 13/14] =?UTF-8?q?fix:=20=E3=82=AD=E3=83=A3=E3=83=93?=
=?UTF-8?q?=E3=83=8D=E3=83=83=E3=83=88=E3=81=AE=E5=9C=A7=E7=B8=AE=E3=83=80?=
=?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E3=82=92GET?=
=?UTF-8?q?=E3=81=8B=E3=82=89POST=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97?=
=?UTF-8?q?=E3=81=9F=E9=9A=9B=E3=81=AB=E3=82=A6=E3=82=A7=E3=83=96=E3=82=A2?=
=?UTF-8?q?=E3=82=AF=E3=82=BB=E3=83=A9=E3=83=AC=E3=83=BC=E3=82=BF=E3=82=92?=
=?UTF-8?q?=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E3=81=A8Token=E3=82=A8?=
=?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
View/Helper/CabinetFileHelper.php | 28 +++++++++++++++++++---------
webroot/js/cabinets_zip_download.js | 4 ++--
2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/View/Helper/CabinetFileHelper.php b/View/Helper/CabinetFileHelper.php
index 0108c94..5f6b3e2 100644
--- a/View/Helper/CabinetFileHelper.php
+++ b/View/Helper/CabinetFileHelper.php
@@ -79,23 +79,31 @@ public function zipDownload($cabinetFile, $label, $options) {
$checkUrl = $this->NetCommonsHtml->url($action);
//POSTデータ生成
- $requestData = [
+ $currentData = $this->_View->request->data;
+
+ // * チェック用のToken作成
+ $checkRequest = [
'CabinetFile' => [
- 'key' => $cabinetFile['CabinetFile']['key']
+ 'key' => $cabinetFile['CabinetFile']['key'],
+ '_action' => 'check'
],
];
- $currentData = $this->_View->request->data;
- $tokenFields = Hash::flatten($requestData);
+ $tokenFields = Hash::flatten($checkRequest);
$hiddenFields = array_keys($tokenFields);
- // * チェック用のToken作成
- $this->_View->request->data = $requestData;
- $this->_View->request->data['CabinetFile']['_action'] = 'check';
+ $this->_View->request->data = $checkRequest;
$checkToken = $this->Token->getToken(
'CabinetFile', $checkUrl, $tokenFields, $hiddenFields
);
// * ダウンロード用のToken作成
- $this->_View->request->data = $requestData;
- $this->_View->request->data['CabinetFile']['_action'] = 'download';
+ $downloadRequest = [
+ 'CabinetFile' => [
+ 'key' => $cabinetFile['CabinetFile']['key'],
+ '_action' => 'download'
+ ],
+ ];
+ $tokenFields = Hash::flatten($downloadRequest);
+ $hiddenFields = array_keys($tokenFields);
+ $this->_View->request->data = $downloadRequest;
$downloadToken = $this->Token->getToken(
'CabinetFile', $downloadUrl, $tokenFields, $hiddenFields
);
@@ -104,10 +112,12 @@ public function zipDownload($cabinetFile, $label, $options) {
$requestData['Check'] = [
'action' => $checkUrl,
+ 'request' => $checkRequest['CabinetFile'],
'token' => $checkToken['_Token'],
];
$requestData['Download'] = [
'action' => $downloadUrl,
+ 'request' => $downloadRequest['CabinetFile'],
'token' => $downloadToken['_Token'],
];
diff --git a/webroot/js/cabinets_zip_download.js b/webroot/js/cabinets_zip_download.js
index b246fd0..0eee5e1 100644
--- a/webroot/js/cabinets_zip_download.js
+++ b/webroot/js/cabinets_zip_download.js
@@ -40,7 +40,7 @@ NetCommonsApp.controller('CabinetFiles.zipDownload',
$event.preventDefault();
var postData = {
- CabinetFile: $scope.postData['CabinetFile'],
+ CabinetFile: $scope.postData['Check']['request'],
_Token: $scope.postData['Check']['token']
};
ajaxSendPost('POST', $scope.postData['Check']['action'], postData)
@@ -97,7 +97,7 @@ NetCommonsApp.controller('CabinetFiles.zipDownload',
});
formElement.append(inputElement);
});
- angular.forEach($scope.postData['CabinetFile'], function(value, key) {
+ angular.forEach($scope.postData['Download']['request'], function(value, key) {
var inputElement = $('', {
type: 'hidden',
name: 'data[CabinetFile][' + key + ']',
From 02e43aaa2f78de743f16022a14c5d9114958e5da Mon Sep 17 00:00:00 2001
From: s-nakajima
Date: Fri, 10 Sep 2021 23:11:13 +0900
Subject: [PATCH 14/14] =?UTF-8?q?fix:=20test:=20phpunit=E3=82=A8=E3=83=A9?=
=?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.github/workflows/tests.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 1477ea2..694926c 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -38,7 +38,7 @@ jobs:
NC3_BUILD_DIR: "/opt/nc3"
NC3_DOCKER_DIR: "/opt/docker"
NC3_GIT_URL: "git://github.com/NetCommons3/NetCommons3.git"
- NC3_GIT_BRANCH: "master"
+ NC3_GIT_BRANCH: "availability"
PLUGIN_BUILD_DIR: ${{ github.workspace }}
PHP_VERSION: ${{ matrix.php }}
MYSQL_VERSION: ${{ matrix.mysql }}
| | | | |