Skip to content

Commit

Permalink
Merge pull request #22 from cromaLab/gmatute
Browse files Browse the repository at this point in the history
Enable tag selection, filtering and display
  • Loading branch information
G018 authored Feb 27, 2017
2 parents e0d4b03 + e4c7ac7 commit 62e11cb
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 32 deletions.
10 changes: 6 additions & 4 deletions lib/requests/controllers/recording_prompt.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function(app, _parent) {

function closePrompt() {
$timeout(function(){
_parent.toggle($scope.requestTitle);
_parent.toggle($scope.requestTitle, $scope.requestTags);
},0,false);
}

Expand All @@ -32,9 +32,11 @@ module.exports = function(app, _parent) {
decrementCounter()
}, 1000);
}

}

$scope.tags = ["Featured", "HW 3", "Exam 1"];
$scope.requestTags = [];

$scope.startRecording = function() {
$scope.COUNTDOWN = true;
$scope.TEXTMODE = false;
Expand All @@ -49,8 +51,8 @@ module.exports = function(app, _parent) {
decrementCounter();
},0,false);
})

};

// triggers text request box
$scope.textRecording = function() {
//hide h2, hide start recording button
Expand All @@ -61,7 +63,7 @@ module.exports = function(app, _parent) {
// submit text request
$scope.textRequestSubmittion = function (){

_parent.sendingTextDesc($scope.requestTitle,$scope.textRequestDescription);
_parent.sendingTextDesc($scope.requestTitle,$scope.textRequestDescription,$scope.requestTags);
//re-configure
$scope.requestTitle = "";
$scope.textRequestDescription = ""
Expand Down
12 changes: 6 additions & 6 deletions lib/requests/requestView.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,21 @@ function RequestView() {
});
};
// enable editor + voice recording
proto.enable = function(title) {
proto.enable = function(title, tags) {
if (!this.isRecording()) {

this._invoke(function(Recorder) {
Recorder.start(title);
Recorder.start(title, tags);
});
this.panel.show();
}
};

// send the title and the text description
proto.sendingTextDesc = function(title, request){
proto.sendingTextDesc = function(title, request, tags){
// console.log(title, request);
this._invoke(function(Recorder) {
Recorder.sendingTextRequest(title, request);
Recorder.sendingTextRequest(title, request, tags);
});
};

Expand Down Expand Up @@ -149,11 +149,11 @@ function RequestView() {
this.panel.destroy();
};
// send the title of the request
proto.toggle = function(title) {
proto.toggle = function(title, tags) {
if (this.isRecording()) {
this.disable();
} else {
this.enable(title);
this.enable(title, tags);
}
};

Expand Down
9 changes: 5 additions & 4 deletions lib/requests/services/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function(app) {
}
}
},
start: function(title) {
start: function(title, tags) {
debugger;
if (!this.isRecording()) {
this.setRecording(true);
Expand All @@ -41,6 +41,7 @@ module.exports = function(app) {
} else {
requestTitle = "No title for this request!"
}
requestTags = tags;
debugger;
EditorRecorder.start(uid, cwd);
VoiceRecorder.start(uid);
Expand All @@ -57,14 +58,14 @@ module.exports = function(app) {
scope.reqSideBarButton = true;
});
}, 0, false);
UploadRecording(uid, EditorRecorder, VoiceRecorder, FileRecorder, cwd, requestTitle);
UploadRecording(uid, EditorRecorder, VoiceRecorder, FileRecorder, cwd, requestTitle, requestTags);
}
},
sendingTextRequest: function(title, request){
sendingTextRequest: function(title, request, tags){
uid = guid();
debugger;
cwd = FileRecorder.start(uid);
UploadTextRequest(uid, cwd, title, request,FileRecorder);
UploadTextRequest(uid, cwd, title, request, tags, FileRecorder);
},
cancel: function() {
if (this.isRecording()) {
Expand Down
3 changes: 2 additions & 1 deletion lib/requests/services/upload_recording.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var _ = require('underscore')
module.exports = function(app) {
var changelog;
app.factory('UploadRecording', ['$q', '$rootScope', 'STORAGE_DIRECTORY', 'Slack', function($q, $rootScope, STORAGE_DIRECTORY, Slack) {
return function(uid, editorRecorder, voiceRecorder, workspaceSnapshot, cwd, requestTitle) {
return function(uid, editorRecorder, voiceRecorder, workspaceSnapshot, cwd, requestTitle, requestTags) {
var changelogPromise = editorRecorder.stop(uid);
var promises = voiceRecorder.stop(uid),
wavPromise = promises;
Expand All @@ -29,6 +29,7 @@ module.exports = function(app) {
var recordingInfo = {
contact: skype,
title: requestTitle,
tags: requestTags,
question_id: uid,
editor_id: prefs.getEditorID(),
transcript: "worked",
Expand Down
5 changes: 3 additions & 2 deletions lib/requests/services/upload_textrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ var _ = require('underscore')

module.exports = function(app){
app.factory('UploadTextRequest', ['STORAGE_DIRECTORY','EditorRecorder','Slack', function(STORAGE_DIRECTORY, EditorRecorder, Slack){
return function(uid, cwd, title, request, workspaceSnapshot){
console.log(uid, cwd, title,request);
return function(uid, cwd, title, request, tags, workspaceSnapshot){
console.log(uid, cwd, title, request, tags);
var folder = path.join(STORAGE_DIRECTORY, uid);
var filename = 'recording.json',
fullFilename = path.join(folder, filename);
Expand All @@ -17,6 +17,7 @@ module.exports = function(app){
var recordingInfo = {
title: title,
request_description: request,
tags: tags,
question_id: uid,
editor_id: prefs.getEditorID(),
transcript: "worked",
Expand Down
1 change: 1 addition & 0 deletions lib/requests/views/recording_prompt.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ <h2 ng-show='TEXTMODE' >Describe your request in the text box below. Click 'Subm
<textarea ng-show='TEXTMODE' ng-model='textRequestDescription' id="request-text" class="form-control native-key-bindings" rows="5" tabIndex=-1 placeholder="(e.g. type your request here ... )">{{requestText}}</textarea>

<div ng-hide="COUNTDOWN" class="prompt_buttons">
<select ng-model="requestTags" ng-options="tag for tag in tags" multiple></select>
<button id='textRecording' ng-hide='TEXTMODE' type='button' class='btn btn-default icon settings h3_size' ng-click='textRecording()'>Text</button>
<button id='startRecording' ng-hide='TEXTMODE' type='button' class='btn btn-default icon icon-primitive-dot settings h3_size' ng-click='startRecording()'>Start Recording</button>
<button id='requestTextSubmittion' ng-show='TEXTMODE' type='button' class='btn btn-default icon settings h3_size' ng-click='textRequestSubmittion()'>Submit</button>
Expand Down
40 changes: 30 additions & 10 deletions lib/response/controllers/response_panel.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = function(app) {
editedRequest: "",
editedTitle: ""
};

$scope.search = {
query: { title: "" },
active: false,
Expand All @@ -32,17 +33,35 @@ module.exports = function(app) {
this.active = !this.active;
}
}
$scope.tags = {
all: [
{ name: "All", filter: "" },
{ name: "Featured", filter: "" },
{ name: "Recent", filter: "" }
],
update: function(newTag) {
this.active = newTag;
}

baseTags = [
{ name:'All', filter: "" },
{ name:'Pending', filter: function(r) { return r.status.responses.length == 0 } }
]

$scope.tags = baseTags;
$scope.activeTag = $scope.tags[0];
$scope.updateTag = function(tag) { $scope.activeTag = tag; }

updateTagList = function() {
reqTags = new Set();
// Collect tags from requests
$scope.$root.requests.forEach(function(request) {
reqTags = new Set([...reqTags, ...request.tags]);
});
// Process tags from request
reqTags = Array.from(reqTags).map(function(tag) {
return {
name: tag,
filter: function (r) {
return r.tags.indexOf(tag) != -1;
}
}
});
// Update tags
$scope.tags = baseTags.concat(reqTags);
}
$scope.tags.active = $scope.tags.all[0];
$scope.$root.$watch('requests', updateTagList);

var parent = atom.views.getView(atom.workspace).querySelector('.vertical');
parent.appendChild(element.el);
Expand Down Expand Up @@ -145,6 +164,7 @@ module.exports = function(app) {
$scope.selectedObj = obj;
$scope.search.active = false;
$scope.search.query = "";
$scope.activeTag = $scope.tags[0];

//call helperCode
if (obj.status.responses.length > 0) {
Expand Down
17 changes: 12 additions & 5 deletions lib/response/views/response_panel.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ <h2>Search</h2>
</div>
</div>
<div class="col-sm-11">
<span class="label" ng-repeat="tag in tags.all" ng-class="tags.active == tag ?'label-success':'label-default'">
<a href="" ng-click="tags.update(tag)">{{tag.name}}</a>
<span class="label" ng-repeat="tag in tags" ng-class="activeTag == tag ?'label-success':'label-default'">
<a href="" ng-click="updateTag(tag)">{{tag.name}}</a>
</span>
</div>
<div class="col-sm-11">
Expand All @@ -32,8 +32,13 @@ <h2>Search</h2>
</div>
<!-- requests list -->
<div ng-show="resList" class="request-list">
<div ng-hide='request.remove' ng-class='request.status.state' class="request-item" ng-class-odd="'odd'" ng-repeat="request in requests | filter:tags.active.filter | filter:search.query track by $index" id="{{request.id}}" ng-click="clickRequest(request)" ng-style="setColor($index)">
<h3><b>R{{$root.requests.length-$index}}</b> {{request.title | limitTo:45}}{{request.title.length > 45 ? '...' : ''}}</h3>
<div ng-hide='request.remove' ng-class='request.status.state' class="request-item" ng-class-odd="'odd'" ng-repeat="request in requests | filter:activeTag.filter | filter:search.query track by $index" id="{{request.id}}" ng-click="clickRequest(request)" ng-style="setColor($index)">
<h3>
<b>R{{$root.requests.length-$index}}</b> {{request.title | limitTo:45}}{{request.title.length > 45 ? '...' : ''}}
</h3>
<div>
<span class="label label-default" ng-repeat="tag in request.tags">{{tag}}</span>
</div>
<h3 ng-show='request.request_description'>Q: {{request.request_description}}</h3>
File:{{request.changelog[1].title}}
<div ng-hide='request.request_description' class="request-buttons">
Expand Down Expand Up @@ -69,7 +74,9 @@ <h3 ng-show='request.request_description'>Q: {{request.request_description}}</h3
<div style="margin-left: 10px; margin-right: 10px; ">
<div class="annotation_bubble_upper">
<h3 style="font-size: 18px;">{{selectedObj.title | limitTo:35}}{{selectedObj.title.length > 30 ? '...' : ''}} </h3>

<div>
<span class="label label-default" ng-repeat="tag in selectedObj.tags">{{tag}}</span>
</div>
<h3 ng-show='selectedObj.request_description'>Q: {{selectedObj.request_description}}</h3>
File:{{selectedObj.changelog[1].title}}

Expand Down

0 comments on commit 62e11cb

Please sign in to comment.