Skip to content

Commit

Permalink
project management app with sfchecks report
Browse files Browse the repository at this point in the history
This change moves the "archive project" feature from the projects list to the projectmanagement app.

The sfchecks report available is called the "user engagement report".  The projectmanagement app currently has two tabs: archive and reports.  Reports could probably be moved to its own app or better place in the future
  • Loading branch information
megahirt committed Apr 20, 2015
1 parent eb6d28e commit a5afa4a
Show file tree
Hide file tree
Showing 36 changed files with 680 additions and 142 deletions.
6 changes: 1 addition & 5 deletions .buildpath
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
<buildpathentry excluding="build/|docs/|lib/|lib/CodeIgniter_2.1.3|lib/CodeIgniter_2.1.3/|output/|src/vendor/|test/lib/|test/lib/|test/lib/simpletest|test/lib/simpletest/|.git/|node_modules/|src/vendor/" kind="src" path=""/>
<buildpathentry excluding="simpletest/" kind="src" path="test/lib"/>
<buildpathentry kind="src" path="lib/CodeIgniter_2.1.3"/>
<buildpathentry excluding="test/|docs/|extensions/" kind="src" path="test/lib/simpletest"/>
<buildpathentry excluding="phpunit/" kind="src" path="src/vendor"/>
<buildpathentry excluding=".git/|build/|docs/|lib/|node_modules/|output/|src/vendor/" kind="src" path=""/>
</buildpath>
22 changes: 22 additions & 0 deletions src/angular-app/bellows/apps/projectmanagement/js/services.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

angular.module('projectManagement.services', ['jsonRpc'])

.service('projectManagementService', ['jsonRpc',
function(jsonRpc) {
jsonRpc.connect('/api/sf');

this.getDto = function getDto(callback) {
jsonRpc.call('project_management_dto', [], callback);
};

this.archiveProjectAsOwner = function archiveProjectAsOwner(callback) {
jsonRpc.call('project_archive_asOwner', [], callback);
};

this.runReport = function runReport(reportName, params, callback) {
params = params || [];
jsonRpc.call('project_management_report_' + reportName, params, callback);
};

}]);
36 changes: 36 additions & 0 deletions src/angular-app/bellows/apps/projectmanagement/ng-app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<div class="content container" data-ng-cloak data-ng-controller="ProjectManagementCtrl">
<div id="sfchecks-hmenu" class="hdrnav">
<ul class="topNav">
<li class="here"><a href="/app/projects">My Projects</a></li>
<li><a href="/app/activity">Activity</a></li>
</ul>
<br />
</div>
<div style="padding-top:10px">
<sil-notices></sil-notices>

<a class="btn" ng-href="{{project.appLink}}" data-tooltip="Back to the project"
data-tooltip-placement="right">
<i class="icon-reply"></i>Back
</a>
<h2 style="font-weight:normal">{{project.projectName}} Project Management</h2>
<tabset ng-show="dtoLoaded">
<tab heading="Reports">
<div ng-show="reports.length > 0">
<div>
<select data-ng-model="report.currentId" data-ng-options="report.id as report.name for report in reports"><option value="">Select a Report...</option></select>
<button style="position:relative; top:-5px" ng-show="report.output" class="btn" ng-click="runReport()">Run Again</button>
</div>
<pre ng-show="report.output" data-ng-bind="report.output"></pre>
</div>
<div ng-hide="reports.length > 0">
No reports are available at this time.
</div>
</tab>
<tab heading="Archive">
<button class="btn" data-ng-disabled="actionInProgress" ng-click="archiveProject()">Archive this project</button>
<div class="text-error">Warning: This action can only be undone by a site administrator (at this point)</div>
</tab>
</tabset>
</div>
</div>
72 changes: 72 additions & 0 deletions src/angular-app/bellows/apps/projectmanagement/ng-app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use strict';

angular.module('projectmanagement', ['projectManagement.services', 'bellows.services', 'palaso.ui.listview', 'ui.bootstrap', 'palaso.ui.notice', 'palaso.ui.utils', 'wc.Directives'])
.controller('ProjectManagementCtrl', ['$scope', 'projectService', 'projectManagementService', 'sessionService', 'silNoticeService', 'modalService', '$window',
function($scope, projectService, appService, ss, notice, modalService, $window) {

$scope.project = ss.session.project;
$scope.actionInProgress = false;
$scope.report = {
output: '',
currentId: ''
};
$scope.reportOutput = '';

$scope.loadDto = function loadDto() {
appService.getDto(function(result) {
if (result.ok) {
$scope.reports = result.data.reports;
$scope.dtoLoaded = true;
}
});
};
$scope.loadDto();

$scope.$watch('report.currentId', function(reportId) {
$scope.runReport();
});

$scope.runReport = function runReport() {
if ($scope.report.currentId) {
$scope.report.output = 'Running Report...';
appService.runReport($scope.report.currentId, [], function(result) {
if (result.ok) {
$scope.report.output = result.data.output.replace(/\\n/g,"\n");
}
});
} else {
$scope.report.output = '';
}
};

// Archive the project
$scope.archiveProject = function() {
var message = "Are you sure you want to archive this project?";
var modalOptions = {
closeButtonText: 'Cancel',
actionButtonText: 'Archive',
headerText: 'Archive Project?',
bodyText: message
};
modalService.showModal({}, modalOptions).then(function (result) {
$scope.actionInProgress = true;
var archiveFunction;
if (ss.hasSiteRight(ss.domain.PROJECTS, ss.operation.ARCHIVE)) {
archiveFunction = projectService.archiveAsAdmin;
} else {
archiveFunction = appService.archiveProjectAsOwner;
}
archiveFunction(function(result) {
if (result.ok) {
notice.push(notice.SUCCESS, "The project was archived successfully");
$window.location.href = '/app/projects';
} else {
$scope.actionInProgress = false;
}
});
});
};


}])
;
1 change: 0 additions & 1 deletion src/angular-app/bellows/apps/projects/ng-app.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ <h2 style="font-weight:normal">My Projects</h2>
<listview hide-if-empty="true" search="queryProjectsForUser()" items="projects" visible-items="visibleProjects" select="">
<div data-ng-repeat="project in visibleProjects" class="details-row">
<ul class="inline" data-ng-class="{active: isSelected(project)}">
<li data-ng-show="rights.archive"><input type="checkbox" data-ng-checked="isSelected(project)" data-ng-click="updateSelection($event, project)" /></li>
<li style="width: 70%">
<a data-ng-show="isInProject(project)" href="/app/{{project.appName}}/{{project.id}}/">
<span class="larger-text">{{project.projectName}}</span>
Expand Down
5 changes: 3 additions & 2 deletions src/angular-app/bellows/apps/projects/ng-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ angular.module('projects', ['bellows.services', 'palaso.ui.listview', 'ui.bootst
// Rights
$scope.rights = {};
$scope.rights.edit = ss.hasSiteRight(ss.domain.PROJECTS, ss.operation.EDIT);
$scope.rights.archive = ss.hasSiteRight(ss.domain.PROJECTS, ss.operation.ARCHIVE);
$scope.rights.create = ss.hasSiteRight(ss.domain.PROJECTS, ss.operation.CREATE);
$scope.rights.showControlBar = $scope.rights.archive || $scope.rights.create;
$scope.rights.showControlBar = $scope.rights.create;

$scope.siteName = ss.baseSite();

Expand Down Expand Up @@ -43,6 +42,7 @@ angular.module('projects', ['bellows.services', 'palaso.ui.listview', 'ui.bootst
};

// Archive projects
/*
$scope.archiveProjects = function() {
var projectIds = [];
var message = '';
Expand Down Expand Up @@ -74,6 +74,7 @@ angular.module('projects', ['bellows.services', 'palaso.ui.listview', 'ui.bootst
});
});
};
*/

$scope.isInProject = function(project) {
if (project.role != 'none') {
Expand Down
4 changes: 2 additions & 2 deletions src/angular-app/bellows/js/bellows.services.project.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ angular.module('bellows.services')
this.createSwitchSession = function(projectName, projectCode, appName, callback) {
jsonRpc.call('project_create_switchSession', [projectName, projectCode, appName], callback);
};
this.archive = function(projectIds, callback) {
jsonRpc.call('project_archive', [projectIds], callback);
this.archiveAsAdmin = function(callback) {
jsonRpc.call('project_archive_asAdmin', [], callback);
};
this.archivedList = function(callback) {
jsonRpc.call('project_archivedList', [], callback);
Expand Down
3 changes: 2 additions & 1 deletion src/angular-app/bellows/js/bellows.services.session.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ angular.module('bellows.services')
VIEW_OWN: function() { return 6;},
EDIT_OWN: function() { return 7;},
DELETE_OWN: function() { return 8;},
ARCHIVE: function() { return 9;}
ARCHIVE: function() { return 9;},
ARCHIVE_OWN: function() { return 10;}
};

this.hasSiteRight = function(domain, operation) {
Expand Down
1 change: 1 addition & 0 deletions src/angular-app/languageforge/lexicon/ng-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ angular.module('lexicon',
// we tell offline.js to NOT store and remake requests while the connection is down
Offline.options.requests = false;
Offline.options.checkOnLoad = true;
Offline.options.checks.xhr.url = '/offlineCheck.txt';

var offlineMessageId;
Offline.on('up', function() {
Expand Down
166 changes: 89 additions & 77 deletions src/angular-app/scriptureforge/sfchecks/partials/project.html
Original file line number Diff line number Diff line change
@@ -1,86 +1,98 @@
<div data-ng-show="finishedLoading">
<h2 style="font-weight:normal">{{project.name}} Dashboard</h2>
<div class="notices">
<alert data-ng-repeat="message in messages" type="info" close="markMessageRead(message.id)"><b>{{message.subject}}</b><br /><span data-ng-bind-html="message.content"></span></alert>
</div>
<form data-ng-show="rights.showControlBar" class="control-bar form-inline">
<a id="projectSettingsButton" data-ng-show="rights.edit" class="btn pull-right" href="{{project.url}}/settings"><i class="icon-cog icon-large" data-tooltip="Project Settings"></i></a>
<button data-ng-disabled="selected.length == 0" data-ng-show="rights.archive" class="btn" data-ng-click="archiveTexts()"><i class="icon-archive icon-large" style="color:black"></i>Archive Texts</button>
<button data-ng-show="rights.create" class="btn" data-ng-click="newTextCollapsed = !newTextCollapsed"><i class="icon-plus"></i>Add New Text</button>
</form>
<div class="new-item" data-collapse="newTextCollapsed">
<form class="well" name="newTextForm">
<fieldset class="span4">
<table class="tableform">
<tr>
<td>
<label>Title</label>
<input required data-ng-model="title" type="text" placeholder="Title"/>
</td>
</tr>
<tr>
<td>
<label>Text</label>
<textarea textdrop data-ng-model="content" rows="4" placeholder="Paste the USX text here"></textarea>
</td>
</tr>
<tr>
<td>
<a data-ng-click="toggleRangeSelector()">Select limited verse range</a>
</td>
</tr>
<h2 style="font-weight:normal">{{project.name}} Dashboard</h2>
<div class="notices">
<alert data-ng-repeat="message in messages" type="info" close="markMessageRead(message.id)"><b>{{message.subject}}</b><br /><span data-ng-bind-html="message.content"></span></alert>
</div>
<div class="btn-group pull-right" data-ng-show="rights.edit">
<a class="btn dropdown-toggle"
data-toggle="dropdown"
data-tooltip-placement="right"
data-tooltip="Settings" href="#">
<i class="icon-cog icon-large"></i>
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#/settings">Project Settings</a></li>
<li><a href="/app/projectmanagement/{{project.id}}">Manage Project</a></li>
<!-- <li><a ng-href="/app/usermanagement/{{project.id}}" translate="User Management"></a></li> -->
</ul>
</div>
<form data-ng-show="rights.showControlBar" class="control-bar form-inline">
<button data-ng-disabled="selected.length == 0" data-ng-show="rights.archive" class="btn" data-ng-click="archiveTexts()"><i class="icon-archive icon-large" style="color:black"></i>Archive Texts</button>
<button data-ng-show="rights.create" class="btn" data-ng-click="newTextCollapsed = !newTextCollapsed"><i class="icon-plus"></i>Add New Text</button>
</form>
<div class="new-item" data-collapse="newTextCollapsed">
<form class="well" name="newTextForm">
<fieldset class="span4">
<table class="tableform">
<tr>
<td>
<label>Title</label>
<input required data-ng-model="title" type="text" placeholder="Title"/>
</td>
</tr>
<tr>
<td>
<label>Text</label>
<textarea textdrop data-ng-model="content" rows="4" placeholder="Paste the USX text here"></textarea>
</td>
</tr>
<tr>
<td>
<a data-ng-click="toggleRangeSelector()">Select limited verse range</a>
</td>
</tr>
<tr>
<td>
<span class="text-info"><a href="/sfchecks_usersguide#exportusx" target="_blank">How can I export a USX file from ParaTExt?</a></span>
</td>
</tr>
</table>
<div data-collapse="rangeSelectorCollapsed">
<table>
<tr>
<td>From</td>
<td><input type="number" data-ng-model="startCh" min="1" placeholder="Chap." style="width: 4em; text-align: right"></input>&nbsp;:&nbsp;<input type="number" data-ng-model="startVs" min="1" placeholder="Verse" style="width: 4em"></input></td>
<td><a data-ng-click="startCh = ''; startVs = ''" class="btn-link">reset</a></td>
</tr>
<tr>
<td>To</td>
<td><input type="number" data-ng-model="endCh" min="1" placeholder="Chap." style="width: 4em; text-align: right"></input>&nbsp;:&nbsp;<input type="number" data-ng-model="endVs" min="1" placeholder="Verse" style="width: 4em"></input></td>
<td><a data-ng-click="endCh = ''; endVs = ''" class="btn-link">reset</a></td>
</tr>
</table>
</div>
<button type="submit" class="btn" data-ng-disabled="newTextForm.$invalid" data-ng-click="addText(); newTextCollapsed = true"><i class="icon-ok"></i>Save</button>
</fieldset>
<fieldset class="span4">
<div class="drop-box" data-ng-file-drop="onUsxFile($files)" data-ng-file-drop-available="dropSupported=true">
<h4>Or drop a USX file here</h4>
<br/>
<p>or if you prefer...</p>
<input type="button" class="btn" value="Browse..." onclick="javascript:document.getElementById('usxfile').click();">
<input id="usxfile" type="file" style="display:none;" data-ng-file-select="onUsxFile($files)">
</div>
<div data-ng-show="!dropSupported">HTML5 Drop File is not supported on this browser</div>
</fieldset>
<div style="clear: left"></div>
</form>
</div>
<hr />
<listview hide-if-empty="true" items="texts" visible-items="visibleTexts" select="">
<div data-ng-repeat="text in visibleTexts" class="details-row">
<ul class="inline" data-ng-class="{active: isSelected(text)}">
<li data-ng-show="rights.archive" ><input type="checkbox" data-ng-checked="isSelected(text)" data-ng-click="updateSelection($event, text)" /></li>
<li>
<a class="span5" href="{{text.url}}"><span class="larger-text">{{text.title}}</span></a>
</li>
<li><a href="{{text.url}}">
<div class="attention-block">
<span class="subtitle">{{text.questionCount}} questions</span>
</table>
<div data-collapse="rangeSelectorCollapsed">
<table>
<tr>
<td>From</td>
<td><input type="number" data-ng-model="startCh" min="1" placeholder="Chap." style="width: 4em; text-align: right"></input>&nbsp;:&nbsp;<input type="number" data-ng-model="startVs" min="1" placeholder="Verse" style="width: 4em"></input></td>
<td><a data-ng-click="startCh = ''; startVs = ''" class="btn-link">reset</a></td>
</tr>
<tr>
<td>To</td>
<td><input type="number" data-ng-model="endCh" min="1" placeholder="Chap." style="width: 4em; text-align: right"></input>&nbsp;:&nbsp;<input type="number" data-ng-model="endVs" min="1" placeholder="Verse" style="width: 4em"></input></td>
<td><a data-ng-click="endCh = ''; endVs = ''" class="btn-link">reset</a></td>
</tr>
</table>
</div>
</a></li>
<li><span class="span2">{{text.responseCount}} responses</span></li>
<li class="muted"><small>Added {{text.dateCreated | relativetime}}</small></li>
</ul>
<hr />
<button type="submit" class="btn" data-ng-disabled="newTextForm.$invalid" data-ng-click="addText(); newTextCollapsed = true"><i class="icon-ok"></i>Save</button>
</fieldset>
<fieldset class="span4">
<div class="drop-box" data-ng-file-drop="onUsxFile($files)" data-ng-file-drop-available="dropSupported=true">
<h4>Or drop a USX file here</h4>
<br/>
<p>or if you prefer...</p>
<input type="button" class="btn" value="Browse..." onclick="javascript:document.getElementById('usxfile').click();">
<input id="usxfile" type="file" style="display:none;" data-ng-file-select="onUsxFile($files)">
</div>
<div data-ng-show="!dropSupported">HTML5 Drop File is not supported on this browser</div>
</fieldset>
<div style="clear: left"></div>
</form>
</div>
</listview>
<hr />
<listview hide-if-empty="true" items="texts" visible-items="visibleTexts" select="">
<div data-ng-repeat="text in visibleTexts" class="details-row">
<ul class="inline" data-ng-class="{active: isSelected(text)}">
<li data-ng-show="rights.archive" ><input type="checkbox" data-ng-checked="isSelected(text)" data-ng-click="updateSelection($event, text)" /></li>
<li>
<a class="span5" href="{{text.url}}"><span class="larger-text">{{text.title}}</span></a>
</li>
<li><a href="{{text.url}}">
<div class="attention-block">
<span class="subtitle">{{text.questionCount}} questions</span>
</div>
</a></li>
<li><span class="span2">{{text.responseCount}} responses</span></li>
<li class="muted"><small>Added {{text.dateCreated | relativetime}}</small></li>
</ul>
<hr />
</div>
</listview>
</div>
2 changes: 1 addition & 1 deletion src/controllers/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class api extends CI_Controller
public function service($api)
{
$serviceFileName = strtolower($api) . '.php';
$serviceClassName = str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $api)));
$serviceClassName = '\\service\\' . str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $api)));
$filePath = 'service/' . $serviceFileName;
if (!file_exists($filePath)) {
throw new Exception(sprintf("File not found '%s' for api '%s'", $filePath, $api));
Expand Down
File renamed without changes.
Binary file added src/images/scriptureforge/default/favicon.ico
Binary file not shown.
Binary file not shown.
Binary file added src/images/scriptureforge/simple/favicon.ico
Binary file not shown.
Loading

0 comments on commit a5afa4a

Please sign in to comment.