Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable local overrides for header & footer on AngularJS pages #123

Merged
merged 3 commits into from Oct 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Expand Up @@ -11,6 +11,9 @@ trim_trailing_whitespace = true
[*.json]
indent_size = 2

[*.html]
indent_size = 2

[*.markdown]
trim_trailing_whitespace = false

Expand Down
5 changes: 2 additions & 3 deletions api/v1/viewSubProjects.php
Expand Up @@ -90,9 +90,8 @@ function echo_subprojects_dashboard_JSON($project_instance, $date)
$googletracker = htmlentities($Project->GoogleTracker);
$docurl = make_cdash_url(htmlentities($Project->DocumentationUrl));

// Main dashboard section
$projectname_encoded = urlencode($Project->Name);
$response = array();
// Main dashboard section
$projectname_encoded = urlencode($Project->Name);
$response['datetime'] = date("l, F d Y H:i:s T", time());
$response['date'] = $date;
$response['unixtimestamp'] = $currentstarttime;
Expand Down
21 changes: 17 additions & 4 deletions cdash/common.php
Expand Up @@ -477,7 +477,7 @@ function get_projects($onlyactive=true)
$dayssincelastsubmission = (time()-strtotime($project['last_build']))/86400;
}
$project['dayssincelastsubmission'] = $dayssincelastsubmission;

if ($project['last_build'] != 'NA' && $project['dayssincelastsubmission']<=$CDASH_ACTIVE_PROJECT_DAYS) {
// Get the number of builds in the past 7 days
$submittime_UTCDate = gmdate(FMT_DATETIME, time()-604800);
Expand All @@ -486,7 +486,7 @@ function get_projects($onlyactive=true)
$buildquery_array = pdo_fetch_array($buildquery);
$project['nbuilds'] = $buildquery_array[0];
}

/** Not showing the upload size for now for performance reasons */
//$Project = new Project;
//$Project->Id = $project['id'];
Expand Down Expand Up @@ -575,7 +575,7 @@ function get_server_URI($localhost=false)
if (!$CDASH_CURL_REQUEST_LOCALHOST && $CDASH_BASE_URL != '') {
return $CDASH_BASE_URL;
}

$currentPort="";
$httpprefix="http://";
if ($_SERVER['SERVER_PORT']!=80 && $_SERVER['SERVER_PORT']!=443) {
Expand Down Expand Up @@ -2061,7 +2061,7 @@ function __json_encode($data)

function begin_JSON_response()
{
global $CDASH_VERSION;
global $CDASH_VERSION, $CDASH_USE_LOCAL_DIRECTORY;

$response = array();
$response['version'] = $CDASH_VERSION;
Expand All @@ -2072,6 +2072,19 @@ function begin_JSON_response()
}
$response['userid'] = $userid;

// Check for local overrides of common view partials.
$files_to_check = array("header", "footer");
$base_dir = str_replace('\\', '/', dirname(dirname(__FILE__)));
foreach ($files_to_check as $file_to_check) {
$local_file = "local/views/$file_to_check.html";
if ($CDASH_USE_LOCAL_DIRECTORY == '1' &&
file_exists("$base_dir/$local_file")) {
$response[$file_to_check] = $local_file;
} else {
$response[$file_to_check] = "views/partials/$file_to_check.html";
}
}

return $response;
}

Expand Down
8 changes: 3 additions & 5 deletions views/index.html
Expand Up @@ -31,8 +31,7 @@

<div ng-if="cdash.requirelogin == 1" ng-include="'login.php'"></div>

<!-- TODO: use local header if it exists. -->
<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/header.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.header"></ng-include>

<div ng-if="cdash.future == 1">
CDash cannot predict the future (yet)...
Expand Down Expand Up @@ -371,7 +370,7 @@ <h3 id="{{buildgroup.linkname}}"><a href="#" class="grouptrigger">{{buildgroup.n

<td ng-if="buildgroup.hasupdatedata" align="center" ng-class="{'error': build.update.errors == 1, 'warning': build.update.warning == 1, 'normal': build.update.defined == 1}">
<div ng-if="build.numchildren == 0">
<img ng-if="build.userupdates > 0" src="images/yellowled.png" height="10px" alt="star" title="I checked in some code for this build!"/>
<img ng-if="build.userupdates > 0" src="images/yellowled.png" height="10px" alt="star" title="I checked in some code for this build!"/>
<a ng-href="viewUpdate.php?buildid={{build.id}}">
{{build.update.files}}
</a>
Expand Down Expand Up @@ -756,7 +755,6 @@ <h3><a href="#" class="grouptrigger">Dynamic Analysis</a></h3>
</table>
</div> <!-- end index content -->

<!-- FOOTER TODO: local override -->
<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/footer.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.footer"></ng-include>
</body>
</html>
4 changes: 2 additions & 2 deletions views/manageBuildGroup.html
Expand Up @@ -32,7 +32,7 @@
</head>
<body bgcolor="#ffffff" ng-controller="ManageBuildGroupController">
<div ng-if="cdash.requirelogin == 1" ng-include="'login.php'"></div>
<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/header.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.header"></ng-include>
<br/>

<div class="container" ng-if="cdash.requirelogin != 1 && !loading">
Expand Down Expand Up @@ -381,6 +381,6 @@

<!-- FOOTER -->
<br/>
<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/footer.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.footer"></ng-include>
</body>
</html>
4 changes: 2 additions & 2 deletions views/manageSubProject.html
Expand Up @@ -28,7 +28,7 @@

<body bgcolor="#ffffff" ng-controller="ManageSubProjectController">
<div ng-if="cdash.requirelogin == 1" ng-include="'login.php'"></div>
<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/header.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.header"></ng-include>
<br/>

<div class="container" ng-if="!loading && cdash.requirelogin != 1">
Expand Down Expand Up @@ -240,6 +240,6 @@

<!-- FOOTER -->
<br/>
<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/footer.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.footer"></ng-include>
</body>
</html>
4 changes: 2 additions & 2 deletions views/viewBuildError.html
Expand Up @@ -40,7 +40,7 @@
<body bgcolor="#ffffff" ng-controller="BuildErrorController">
<div ng-if="cdash.requirelogin == 1" ng-include="'login.php'"></div>

<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/header.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.header"></ng-include>
<br/>

<div ng-if="cdash.requirelogin != 1 && !loading">
Expand Down Expand Up @@ -224,6 +224,6 @@

<!-- FOOTER -->
<br/>
<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/footer.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.footer"></ng-include>
</body>
</html>
83 changes: 44 additions & 39 deletions views/viewNotes.html
Expand Up @@ -26,56 +26,61 @@
</head>

<body bgcolor="#ffffff" ng-controller="ViewNotesController">
<ng-include src="'views/partials/header.html'"></ng-include>
<br/>
<div ng-if="cdash.requirelogin == 1" ng-include="'login.php'"></div>

<table border="0">
<tr>
<td align="left">
<b>Site: </b>
<a href="viewSite.php?siteid={{cdash.build.siteid}}">{{cdash.build.site}}</a>
</td>
<tr>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.header"></ng-include>

<tr>
<td align="left">
<b>Build Name: </b>
<a href="buildSummary.php?buildid={{cdash.build.buildid}}">{{cdash.build.buildname}}</a>
</td>
</tr>
<div ng-if="cdash.requirelogin != 1">
<br/>

<table border="0">
<tr>
<td align="left">
<b>Site: </b>
<a href="viewSite.php?siteid={{cdash.build.siteid}}">{{cdash.build.site}}</a>
</td>
<tr>

<tr>
<td align="left">
<b>Stamp: </b>
{{cdash.build.stamp}}
</td>
<tr>
</table>
<tr>
<td align="left">
<b>Build Name: </b>
<a href="buildSummary.php?buildid={{cdash.build.buildid}}">{{cdash.build.buildname}}</a>
</td>
</tr>

<tr>
<td align="left">
<b>Stamp: </b>
{{cdash.build.stamp}}
</td>
<tr>
</table>

<br/>
<a href="" ng-repeat="note in cdash.notes" ng-click="gotoNote($index)">
<img src="images/document.png" alt="Notes" border="0" align="top"/>
{{note.time}} -- {{note.name}}
<br/>
</a>
<a href="" ng-repeat="note in cdash.notes" ng-click="gotoNote($index)">
<img src="images/document.png" alt="Notes" border="0" align="top"/>
{{note.time}} -- {{note.name}}
<br/>
</a>

<br/>
<br/>
<br/>
<br/>
<br/>
<br/>

<div ng-repeat="note in cdash.notes">
<div class="title-divider" id="note{{$index}}">
<b>{{note.time}} -- {{note.name}}</b>
<div ng-repeat="note in cdash.notes">
<div class="title-divider" id="note{{$index}}">
<b>{{note.time}} -- {{note.name}}</b>
</div>
<br/>
<pre>
{{note.text}}
</pre>
<br/>
</div>
<br/>
<pre>
{{note.text}}
</pre>
<br/>
</div>

<!-- FOOTER -->
<br/>
<ng-include src="'views/partials/footer.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.footer"></ng-include>
</body>
</html>
11 changes: 4 additions & 7 deletions views/viewSubProjects.html
Expand Up @@ -19,11 +19,8 @@
</head>

<body ng-controller="ViewSubProjectsController">
<ng-include src="'views/partials/header.html'"></ng-include>

<div ng-if="cdash.requirelogin == 1">
Please <a href="user.php">login</a> to view this page.
</div>
<div ng-if="cdash.requirelogin == 1" ng-include="'login.php'"></div>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.header"></ng-include>

<div id="content" ng-if="!loading && cdash.requirelogin != 1">
<table ng-show="cdash.banners.length > 0" border="0" width="100%">
Expand Down Expand Up @@ -160,8 +157,8 @@ <h3>Project</h3>
</div>

<br/>
<!-- FOOTER -->
<!-- FOOTER -->
<br/>
<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/footer.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.footer"></ng-include>
</body>
</html>
7 changes: 4 additions & 3 deletions views/viewTest.html
Expand Up @@ -26,11 +26,12 @@
</head>

<body bgcolor="#ffffff" ng-controller="ViewTestController">
<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/header.html'"></ng-include>
<br/>

<div ng-if="cdash.requirelogin == 1" ng-include="'login.php'"></div>

<ng-include ng-if="cdash.requirelogin != 1" src="cdash.header"></ng-include>
<br/>

<div ng-if="cdash.requirelogin != 1 && !loading">
<h3>Testing started on {{cdash.build.testtime}}</h3>

Expand Down Expand Up @@ -238,6 +239,6 @@ <h3 ng-switch-default>

<!-- FOOTER -->
<br/>
<ng-include ng-if="cdash.requirelogin != 1" src="'views/partials/footer.html'"></ng-include>
<ng-include ng-if="cdash.requirelogin != 1" src="cdash.footer"></ng-include>
</body>
</html>