Skip to content

Commit d3f4dec

Browse files
[spalenque] - #13388 * new passport page and sangria admin (#113)
[spalenque] - #13388 * WIP done admin WIP react passport page WIP map WIP map working WIP google map public cloud passport template WIP change map react component WIP google maps WIP done WIP done 2
1 parent 968be41 commit d3f4dec

50 files changed

Lines changed: 2823 additions & 12 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

marketplace/_config/injector.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ Injector:
1414
constructor:
1515
0: '%$PoweredOpenStackServicesRepository'
1616
1: '%$PoweredOpenStackImplementationManager'
17+
PublicCloudPassportRepository:
18+
class: SapphirePublicCloudPassportRepository
19+
PublicCloudPassportManager:
20+
constructor:
21+
0: '%$SapphirePublicCloudPassportRepository'
22+
1: '%$TransactionManager'
23+
PublicCloudPassportResfullApi:
24+
constructor:
25+
0: '%$PublicCloudPassportRepository'
26+
1: '%$PublicCloudPassportManager'
1727
MarketPlaceOpenStackPoweredExpireServicesDigestTask:
1828
constructor:
1929
0: '%$ExpiredPoweredOpenStackImplementationEmailMessageSender'

marketplace/_config/routes.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ Director:
2020
'api/v1/marketplace/consultants': 'ConsultantsCrudApi'
2121
'api/v1/marketplace/reviews': 'ReviewCrudApi'
2222
'api/v1/marketplace/books': 'BooksCrudApi'
23-
'api/v1/marketplace/drivers': 'DriverRestfullApi'
23+
'api/v1/marketplace/drivers': 'DriverRestfullApi'
24+
'api/v1/marketplace/public-cloud-passports': 'PublicCloudPassportResfullApi'
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Copyright 2017 Openstack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
/**
15+
* Class PublicCloudPassport
16+
*/
17+
final class PublicCloudPassport
18+
extends DataObject implements IPublicCloudPassport {
19+
20+
static $db = [
21+
'LearnMore' => 'Varchar(255)',
22+
'Active' => 'Boolean(1)'
23+
];
24+
25+
static $has_one = [
26+
'PublicCloud' => 'PublicCloudService',
27+
];
28+
29+
30+
/**
31+
* @return int
32+
*/
33+
public function getIdentifier()
34+
{
35+
return (int)$this->getField('ID');
36+
}
37+
38+
/**
39+
* @return string
40+
*/
41+
public function getLearnMoreLink()
42+
{
43+
return $this->getField('LearnMore');
44+
}
45+
46+
/**
47+
* @param string $link
48+
* @return void
49+
*/
50+
public function setLearnMoreLink($link)
51+
{
52+
$this->setField('LearnMore',$link);
53+
}
54+
55+
56+
57+
58+
}

marketplace/code/infrastructure/active_records/clouds/PublicCloudService.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ final class PublicCloudService
1818
extends CloudService
1919
implements IPublicCloudService {
2020

21+
static $belongs_to = array(
22+
'PublicCloudPassport' => 'PublicCloudPassport.PublicCloud'
23+
);
24+
2125
}
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2017 OpenStack Foundation
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
**/
15+
final class SapphirePublicCloudPassportRepository
16+
extends SapphireRepository
17+
implements IPublicCloudPassportRepository
18+
{
19+
20+
public function __construct()
21+
{
22+
parent::__construct(null);
23+
}
24+
25+
/**
26+
* @param int $page
27+
* @param int $page_size
28+
* @param string $order
29+
* @param null $search_term
30+
* @return array
31+
*/
32+
function getAllCloudsByPage
33+
(
34+
$page = 1,
35+
$page_size = 10,
36+
$order = null,
37+
$search_term = null
38+
)
39+
{
40+
$offset = ($page - 1 ) * $page_size;
41+
$order_by = ' CompanyService.Name ASC ';
42+
if(!empty($order)){
43+
if(strstr($order, 'name') !== false)
44+
$order_by = ' CompanyService.Name '. (strstr($order, '+') !== false ? 'ASC' : 'DESC');
45+
}
46+
47+
$order_by = ' ORDER BY '.$order_by;
48+
$where = '';
49+
50+
if(!empty($search_term)){
51+
if(!empty($where)) $where .= ' AND ';
52+
$where .= " (Company.Name LIKE '%{$search_term}%' OR CompanyService.Name LIKE '%{$search_term}%') ";
53+
}
54+
55+
if(!empty($where)) $where = ' WHERE '.$where;
56+
$query = <<<SQL
57+
SELECT
58+
CompanyService.ID AS CloudID,
59+
CompanyService.Name AS CloudName,
60+
CompanyService.Slug AS CloudSlug,
61+
Company.Name AS CompanyName,
62+
Company.URLSegment AS CompanySlug,
63+
Passport.ID AS PassportID,
64+
Passport.LearnMore,
65+
Passport.Active
66+
FROM PublicCloudService
67+
INNER JOIN CompanyService ON CompanyService.ID = PublicCloudService.ID
68+
INNER JOIN Company ON Company.ID = CompanyService.CompanyID
69+
LEFT JOIN PublicCloudPassport AS Passport ON Passport.PublicCloudID = CompanyService.ID
70+
{$where}
71+
{$order_by}
72+
SQL;
73+
74+
$count = DB::query($query)->numRecords();
75+
76+
$query .= <<<SQL
77+
LIMIT {$offset},{$page_size};
78+
SQL;
79+
80+
$list = new ArrayList();
81+
foreach(DB::query($query) as $row)
82+
{
83+
$list->push(new ArrayData($row));
84+
}
85+
86+
return [$list, $count];
87+
}
88+
89+
/**
90+
* @param int $start
91+
* @param int $limit
92+
* @param string $order
93+
* @param null $search_term
94+
* @return array
95+
*/
96+
function getAllPassports
97+
(
98+
$start = 1,
99+
$limit = 10,
100+
$order = null,
101+
$search_term = null
102+
)
103+
{
104+
$order_by = ' CompanyService.Name ASC ';
105+
if(!empty($order)){
106+
if(strstr($order, 'name') !== false)
107+
$order_by = ' CompanyService.Name '. (strstr($order, '+') !== false ? 'ASC' : 'DESC');
108+
}
109+
110+
$order_by = ' ORDER BY '.$order_by;
111+
$where = ' WHERE Passport.Active = 1 ';
112+
113+
if(!empty($search_term)){
114+
$where .= " AND (Company.Name LIKE '%{$search_term}%' OR CompanyService.Name LIKE '%{$search_term}%') ";
115+
}
116+
117+
$query = <<<SQL
118+
SELECT
119+
CompanyService.ID AS CloudID,
120+
CompanyService.Name AS CloudName,
121+
CompanyService.Slug AS CloudSlug,
122+
CompanyService.Overview AS CloudOverview,
123+
CompanyService.LastEdited AS LastEdited,
124+
Company.Name AS CompanyName,
125+
Company.URLSegment AS CompanySlug,
126+
F.Filename AS Logo,
127+
Passport.ID AS PassportID,
128+
Passport.LearnMore,
129+
Passport.Active,
130+
GROUP_CONCAT(Loc.Lat SEPARATOR ',') AS Lat,
131+
GROUP_CONCAT(Loc.Lng SEPARATOR ',') AS Lng,
132+
GROUP_CONCAT(CONCAT(Loc.City, '(', Loc.Country, ')') SEPARATOR ', ') AS Locations
133+
FROM PublicCloudService
134+
INNER JOIN CompanyService ON CompanyService.ID = PublicCloudService.ID
135+
INNER JOIN Company ON Company.ID = CompanyService.CompanyID
136+
INNER JOIN PublicCloudPassport AS Passport ON Passport.PublicCloudID = CompanyService.ID
137+
LEFT JOIN DataCenterLocation AS Loc ON Loc.CloudServiceID = CompanyService.ID
138+
LEFT JOIN File AS F ON F.ID = Company.LogoID
139+
{$where} GROUP BY CloudID
140+
{$order_by}
141+
SQL;
142+
143+
$count = DB::query($query)->numRecords();
144+
145+
$query .= <<<SQL
146+
LIMIT {$start},{$limit};
147+
SQL;
148+
149+
$list = new ArrayList();
150+
foreach(DB::query($query) as $row)
151+
{
152+
$list->push(new ArrayData($row));
153+
}
154+
155+
return [$list, $count];
156+
}
157+
158+
}

0 commit comments

Comments
 (0)