@@ -6,19 +6,24 @@ class Service implements JsonSerializable
66{
77 private $ id ;
88 private $ name ;
9+ private $ description ;
10+ private $ group_name ;
911 private $ status ;
1012
1113 /**
1214 * Constructs service from its data.
1315 * @param int $id service ID
1416 * @param String $name service name
17+ * @param String $descriotion service description for tooltip
1518 * @param int $status current service status
1619 */
17- function __construct ($ id , $ name , $ status =3 )
20+ function __construct ($ id , $ name , $ description = null , $ group_name = '' , $ status =3 )
1821 {
1922 //TODO: Maybe get data from ID?
2023 $ this ->id = $ id ;
2124 $ this ->name = $ name ;
25+ $ this ->description = $ description ;
26+ $ this ->group_name = $ group_name ;
2227 $ this ->status = $ status ;
2328 }
2429
@@ -49,6 +54,15 @@ public function get_name()
4954 return $ this ->name ;
5055 }
5156
57+ /**
58+ * Returns description of this service
59+ * @return String description
60+ */
61+ public function get_description ()
62+ {
63+ return $ this ->description ;
64+ }
65+
5266 /**
5367 * Processes submitted form and adds service unless problem is encountered,
5468 * calling this is possible only for admin or higher rank. Also checks requirements
@@ -192,24 +206,64 @@ public static function current_status($array){
192206
193207 /**
194208 * Renders this service.
209+ * @param $boolGroup set to true if the groups name is to be rendered
195210 * @return void
196211 */
197212 public function render (){
198213 global $ statuses ;
199214 global $ classes ;
200- ?>
201- <div class="item clearfix">
202- <div class="service"><?php echo $ this ->name ; ?> </div>
203- <?php if ($ this ->status !=-1 ){?> <div class="status <?php echo $ classes [$ this ->status ];?> "><?php echo _ ($ statuses [$ this ->status ]);?> </div><?php }?>
204- </div>
205- <?php
215+ static $ arrCompletedGroups = array ();
216+ //static $boolClosed;
217+ static $ boolOpened ;
218+
219+ // Check if previous ul has been opened, and if a empty/new group is being
220+ // render_header, close the UL first.
221+ if ( $ boolOpened ) {
222+ if ( empty ($ this ->group_name ) || !in_array ($ this ->group_name , $ arrCompletedGroups ) ) {
223+ echo '</ul> ' ;
224+ $ boolOpened = false ;
225+ }
226+ }
227+
228+ // If no group exist or group is new, start a new UL
229+ if ( !empty ($ this ->group_name ) && !in_array ($ this ->group_name , $ arrCompletedGroups )) {
230+ echo '<ul class="list-group components"> ' ;
231+ //echo '<ul class="platforms list-group mb-2">';
232+ // Render the group status if it exists
233+ echo '<li class="list-group-item list-group-item-success group-name"><span><i class="glyphicon glyphicon-plus"></i></span> ' . $ this ->group_name .'<div class="status ' . $ classes [$ this ->status ] .'"> ' . _ ($ statuses [$ this ->status ]).'</div></li> ' ;
234+ //echo '<li class="cist-group-item d-flex flex-row justify-content-between platform list-group-item-action py-0 expanded" role="button">' . $this->group_name .'<div class="status '. $classes[$this->status] .'"'. _($statuses[$this->status]).'</div></li>';
235+ $ arrCompletedGroups [] = $ this ->group_name ;
236+ $ boolOpened = true ;
237+ }
238+
239+ if ( empty ($ this ->group_name )) {
240+ echo '<ul class="list-group components"> ' ;
241+
242+ // echo '<ul class="platforms list-group mb-2">';
243+ $ boolFinish = true ;
244+ }
245+
246+ // Render the service status
247+ echo '<li class="list-group-item sub-component"><strong> ' . $ this ->name .'</strong> ' ;
248+ //echo '<li class="list-group-item d-flex flex-columns justify-content-between><span>+</span><h3 class="py-2 my-0 flex-fill expanded">' . $this->name . '</h3>';
249+ if (!empty ($ this ->description )) {
250+ echo '<a class="desc-tool-tip" data-toggle="tooltip" data-placement="top" title=" ' .$ this ->description .'"> <span><i class="glyphicon glyphicon-question-sign"></i></span></a> ' ;
251+ }
252+ if ($ this ->status !=-1 ){?> <div class="status pull-right <?php echo $ classes [$ this ->status ];?> "><?php echo _ ($ statuses [$ this ->status ]);?> </div>
253+ <?php
254+ }
255+ echo '</li> ' ;
256+ if ( isset ($ boolFinish ) && $ boolFinish ) {
257+ echo '</ul> ' ;
258+ }
206259 }
207260
208261 public function jsonSerialize () {
209262 global $ statuses ;
210263 return [
211264 "id " => $ this ->id ,
212265 "name " => $ this ->name ,
266+ "description " => $ this ->description ,
213267 "status " => $ this ->status ,
214268 "status_string " => $ statuses [$ this ->status ]
215269 ];
0 commit comments