Split old controllers into separate files, began working on dashboard

This commit is contained in:
Patrick McDonagh
2016-06-07 19:12:01 -05:00
parent 8add45cc1b
commit 2449fbe9b7
26 changed files with 1784 additions and 1756 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@
*/
var getValuesClosestTo = function(dtime){
};
module.exports = {
@@ -16,5 +16,12 @@ module.exports = {
res.send(latestCard);
});
},
dates: function(req, res){
var query = "SELECT DISTINCT(DATE(createdAt)) as date FROM card_history ORDER BY date DESC";
Card.query(query, function(err, results){
if (err) return res.serverError(err);
return res.ok(results);
});
}
};

View File

@@ -0,0 +1,132 @@
poconsole.controller('cardIDCtrl', function($scope, $http, $routeParams, json, Page) {
Page.setTitle('Card Data');
Page.setPage('cardData');
$scope.folder = $routeParams.date;
var getDateList = json.getDateList();
getDateList.then(function(data) {
$scope.dates = data.dates;
$scope.currentDate = $scope.dates[0];
});
$http.get('/json/byID/' + $routeParams.date + '/' + $routeParams.card_id).success(function(cData) {
$scope.cardData = cData.contents;
$scope.surface = [];
$scope.downhole = [];
$scope.surface = cData.s.map(function(a){
return {position:a[0], load:a[1]};
});
$scope.surface.push($scope.surface[0]);
$scope.downhole = cData.d.map(function(a){
return {position:a[0], load:a[1]};
});
$scope.downhole.push($scope.downhole[0]);
var limits = {
sMaxPos: $scope.surface.map(function(x){return x.position;}).reduce(function(y,z){return Math.max(y,z);})+ 20,
sMinPos: $scope.surface.map(function(x){return x.position;}).reduce(function(y,z){return Math.min(y,z);})- 20,
sMaxLoad: $scope.surface.map(function(x){return x.load;}).reduce(function(y,z){return Math.max(y,z);})+ 2000,
sMinLoad: $scope.surface.map(function(x){return x.load;}).reduce(function(y,z){return Math.min(y,z);})- 2000,
dMaxLoad: $scope.downhole.map(function(x){return x.load;}).reduce(function(y,z){return Math.max(y,z);})+ 2000,
dMinLoad: $scope.downhole.map(function(x){return x.load;}).reduce(function(y,z){return Math.min(y,z);})- 2000,
};
$scope.limits = limits;
$scope.surfaceOptions = {
axes: {
x: {
key: 'position',
labelFunction: function(value) {
return value;
},
type: 'linear',
min: limits.sMinPos,
max: limits.sMaxPos,
ticks: 7
},
y: {
type: 'linear',
min: limits.sMinLoad,
max: limits.sMaxLoad,
ticks: 5
}
},
series: [
{
y: 'load',
color: 'steelblue',
thickness: '2px',
type: 'area',
striped: true,
label: 'Surface Card'
}
],
lineMode: 'linear',
tension: 0.7,
tooltip: {
mode: 'scrubber',
formatter: function(x, y, series) {
return 'Position: ' + x + ' in., Load: ' + y + ' lb.';
}
},
drawLegend: true,
drawDots: true,
columnsHGap: 5
};
$scope.downholeOptions = {
axes: {
x: {
key: 'position',
labelFunction: function(value) {
return value;
},
type: 'linear',
min: limits.sMinPos,
max: limits.sMaxPos,
ticks: 7
},
y: {
type: 'linear',
min: limits.dMinLoad,
max: limits.dMaxLoad,
ticks: 5
}
},
series: [
{
y: 'load',
color: 'steelblue',
thickness: '2px',
type: 'area',
striped: true,
label: 'Downhole Card'
}
],
lineMode: 'linear',
tension: 0.7,
tooltip: {
mode: 'scrubber',
formatter: function(x, y, series) {
return 'Position: ' + x + ' in., Load: ' + y + ' lb.';
}
},
drawLegend: true,
drawDots: true,
columnsHGap: 5
};
$scope.surfaceData = $scope.surface;
$scope.downholeData = $scope.downhole;
switch (parseInt($scope.cardData.card_type)) {
case 0:
$scope.cardType = 'Normal';
break;
case 1:
$scope.cardType = 'Shutdown';
break;
case 2:
$scope.cardType = 'Alarm';
break;
default:
$scope.cardType = 'Unknown';
break;
}
$scope.cardData.dateTime = new Date($scope.cardData.utctime.replace(" ","T"));
});
});

View File

@@ -0,0 +1,141 @@
poconsole.controller('cardCompareCtrl', function($scope, $http, $routeParams, json, Page, multipleCards, $log) {
var ddTemp, i, j, sdTemp, series, x;
Page.setTitle('Card Data');
Page.setPage('cardData');
$scope.cards = multipleCards.retrieve();
$scope.cardData = [];
$scope.surface = [];
$scope.downhole = [];
$scope.surfacePos = [];
$scope.surfaceLoad = [];
$scope.downholePos = [];
$scope.downholeLoad = [];
$scope.limits = [];
$scope.cardType = [];
$scope.surfaceData = [];
$scope.downholeData = [];
var getDateList = json.getDateList();
getDateList.then(function(data) {
$scope.dates = data.dates;
});
$scope.surfaceOptions = {
axes: {
x: {
key: 'position',
labelFunction: function(value) {
return value;
},
type: 'linear',
ticks: 7
},
y: {
type: 'linear',
ticks: 5
}
},
series: [],
lineMode: 'linear',
tension: 0.7,
tooltip: {
mode: 'scrubber',
formatter: function(x, y, series) {
return 'Position: ' + x + ' in., Load: ' + y + ' lb.';
}
},
drawLegend: true,
drawDots: true,
columnsHGap: 5
};
$scope.downholeOptions = {
axes: {
x: {
key: 'position',
labelFunction: function(value) {
return value;
},
type: 'linear',
ticks: 7
},
y: {
type: 'linear',
ticks: 5
}
},
series: [],
lineMode: 'linear',
tension: 0.7,
tooltip: {
mode: 'scrubber',
formatter: function(x, y, series) {
return 'Position: ' + x + ' in., Load: ' + y + ' lb.';
}
},
drawLegend: true,
drawDots: true,
columnsHGap: 5
};
x = 0;
while (x < $scope.cards.length) {
$scope.cardData.push($scope.cards[x]);
// $scope.surface.push([]);
// $scope.downhole.push([]);
// $scope.surfacePos.push([]);
// $scope.surfaceLoad.push([]);
// $scope.downholePos.push([]);
// $scope.downholeLoad.push([]);
series = {
y: 'load' + x + '',
color: '#' + (0x1000000 + Math.random() * 0xffffff).toString(16).substr(1, 6),
striped: true,
thickness: '2px',
type: 'line',
axis: 'y',
label: $scope.cardData[x].Card_ID
};
$scope.surfaceOptions.series.push(series);
$scope.downholeOptions.series.push(series);
i = 0;
while (i < $scope.cards[x].Surface_Position.length) {
if (!isNaN($scope.cards[x].Surface_Position[i]) && !isNaN($scope.cards[x].Surface_Load[i])) {
// $scope.surfacePos[x].push($scope.cards[x].Surface_Position[i]);
// $scope.surfaceLoad[x].push($scope.cards[x].s[i][1]);
// $scope.surface[x].push({
// position: $scope.cards[x].Surface_Position[i],
// load: $scope.cards[x].Surface_Load[i]
// });
sdTemp = {};
sdTemp.position = $scope.cards[x].Surface_Position[i];
sdTemp['load' + x] = $scope.cards[x].Surface_Load[i];
$scope.surfaceData.push(sdTemp);
}
i++;
}
// $scope.surface[x].push({
// position: $scope.cards[x].s[0][0],
// load: $scope.cards[x].s[0][1]
// });
j = 0;
while (j < $scope.cards[x].Downhole_Position.length) {
if (!isNaN($scope.cards[x].Downhole_Position[j]) && !isNaN($scope.cards[x].Downhole_Position[j])) {
// $scope.downholePos[x].push($scope.cards[x].d[j][0]);
// $scope.downholeLoad[x].push($scope.cards[x].d[j][1]);
// $scope.downhole[x].push({
// position: $scope.cards[x].d[j][0],
// load: $scope.cards[x].d[j][1]
// });
ddTemp = {};
ddTemp.position = $scope.cards[x].Downhole_Position[j];
ddTemp['load' + x] = $scope.cards[x].Downhole_Load[j];
$scope.downholeData.push(ddTemp);
}
j++;
}
// $scope.downhole[x].push({
// position: $scope.cards[x].d[0][0],
// load: $scope.cards[x].d[0][1]
// });
x++;
}
});

View File

@@ -0,0 +1,49 @@
poconsole.controller('cardDataCtrl', function($scope, $http, $routeParams, json, Page, $log) {
$scope.loading = true;
Page.setTitle('Card Data');
Page.setPage('cardData');
$scope.id = $routeParams.id;
var getDateList = json.getDateList();
getDateList.then(function(data) {
$scope.dates = data.dates;
$scope.currentDate = $scope.dates[0];
});
var getCard = json.getCard($routeParams.id);
getCard.then(function(cData){
cData = cData.data;
$scope.cardData = cData.card_data;
$scope.cardData.Stroke_Time = new Date($scope.cardData.Stroke_Time);
//$scope.cardData.dateTime = new Date($scope.cardData.localtime.replace(" ","T"));
$scope.surface = cData.card_data.Surface_Position.map(function(a, i){
return {position:cData.card_data.Surface_Position[i], load:cData.card_data.Surface_Load[i]};
});
$scope.surface.push($scope.surface[0]);
$scope.downhole = cData.card_data.Downhole_Position.map(function(a, i){
return {position:cData.card_data.Downhole_Position[i], load:cData.card_data.Downhole_Load[i]};
});
$scope.downhole.push($scope.downhole[0]);
$scope.card_graph_data = {
surface: $scope.surface,
downhole: $scope.downhole
};
var graphOptions = getCardGraphOptions($scope.surface, $scope.downhole);
$scope.surfaceOptions = graphOptions.surf;
$scope.downholeOptions = graphOptions.down;
var getTagsAtTime = json.getTagsAtTime($scope.cardData.Stroke_Time.getTime() / 1000);
getTagsAtTime.then(function(d){
var data = d.data;
if (data.status == "OK"){
$scope.loading = false;
$scope.tagData = {};
for(var i=0; i < data.vals.length; i++){
$scope.tagData[data.vals[i].name] = data.vals[i];
}
}
});
});
});

View File

@@ -1,36 +1,102 @@
poconsole.controller('dashboardCtrl', function($scope, $route, $http, $sails, Page, $log, tags) {
Page.setTitle('Dashboard');
// poconsole.controller('dashboardCtrl', function($scope, $route, $http, $sails, Page, $log, tags) {
// Page.setTitle('Dashboard');
// Page.setPage('dashboard');
// $scope.loadDashboard = function(){
// $scope.loading = true;
// var getCurrentValues = tags.getCurrentValues();
// getCurrentValues.then(function(data) {
// $scope.loading = false;
// $scope.vals = data.vals;
// $log.info($scope.vals);
// });
// };
// $scope.loadDashboard();
//
// $sails.get("/tag_val").success(function(data, status, headers, jwr){
// $log.info(data);
// });
//
// var valHandler = $sails.on('tag_val', function(message){
// if (message.verb === "created"){
// $log.info(message.data);
// for(var i = 0; i < $scope.vals.length; i++){
// if(message.data.tagID == $scope.vals[i].t_id){
// $scope.vals[i].val = message.data.val;
// $scope.vals[i].dtime = message.data.createdAt;
// }
// }
// }
// });
//
// $scope.$on('$destroy', function() {
// $sails.off('tag_val', valHandler);
// });
//
//
// });
poconsole.controller('dashboardCtrl', function($scope, $route, $http, $sails, json, Page, $log, statusTimeline, card_graph) {
Page.setTitle('Dashboard');
Page.setPage('dashboard');
$scope.loadDashboard = function(){
$scope.loading = true;
var getCurrentValues = tags.getCurrentValues();
getCurrentValues.then(function(data) {
$scope.loading = false;
$scope.vals = data.vals;
$log.info($scope.vals);
});
};
$scope.loadDashboard();
$sails.get("/tag_val").success(function(data, status, headers, jwr){
$log.info(data);
$scope.dateListLoading = true;
var getDateList = json.getDateList();
getDateList.then(function(data) {
$scope.dateListLoading = false;
$scope.dates = data.dates;
$scope.currentDate = $scope.dates[0];
});
var valHandler = $sails.on('tag_val', function(message){
if (message.verb === "created"){
$log.info(message.data);
for(var i = 0; i < $scope.vals.length; i++){
if(message.data.tagID == $scope.vals[i].t_id){
$scope.vals[i].val = message.data.val;
$scope.vals[i].dtime = message.data.createdAt;
$scope.dashboard = function() {
var getCurrentTagValues = json.getCurrentTagValues();
getCurrentTagValues.then(function(d){
var data = d.data;
if (data.status == "OK"){
$scope.tagValues = {};
for(var i=0; i < data.vals.length; i++){
$scope.tagValues[data.vals[i].name] = data.vals[i];
}
}
}
});
});
$scope.$on('$destroy', function() {
$sails.off('tag_val', valHandler);
});
var now = Date.now() / 1000;
var earlier = now - (24 * 60 * 60);
var gettimelineData = statusTimeline.prepareTimelineData(earlier, now);
gettimelineData.then(function(tData){
console.log(tData);
$scope.timelineData = tData;
});
var getCurrentStatus = json.getCurrentStatus();
getCurrentStatus.then(function(s){
var sData = s.data;
sData.datetime = new Date(sData.datetime * 1000);
$scope.status = sData.run_status;
$scope.status_datetime = new Date(sData.datetime);
});
var getLatestCard = json.getLatestCard();
getLatestCard.then(function(cData){
cData = cData.data;
$scope.cardData = cData.card_data[0];
//$scope.cardData.dateTime = new Date($scope.cardData.localtime.replace(" ","T"));
$scope.surface = cData.card_data[0].Surface_Position.map(function(a, i){
return {position:cData.card_data[0].Surface_Position[i], load:cData.card_data[0].Surface_Load[i]};
});
$scope.surface.push($scope.surface[0]);
$scope.downhole = cData.card_data[0].Downhole_Position.map(function(a, i){
return {position:cData.card_data[0].Downhole_Position[i], load:cData.card_data[0].Downhole_Load[i]};
});
$scope.downhole.push($scope.downhole[0]);
$scope.card_graph_data = {
surface: $scope.surface,
downhole: $scope.downhole
};
var graphOptions = card_graph.getCardGraphOptions($scope.surface, $scope.downhole);
$scope.surfaceOptions = graphOptions.surf;
$scope.downholeOptions = graphOptions.down;
});
};
$scope.dashboard();
});

View File

@@ -0,0 +1,8 @@
poconsole.controller('eventsCtrl', function($scope, Page, json) {
Page.setTitle('Events');
Page.setPage('events');
var getEventsData = json.getEventsData();
getEventsData.then(function(data) {
$scope.eventsData = data.eventsData;
});
});

View File

@@ -0,0 +1,55 @@
poconsole.controller('fileListPreviousCtrl', function($scope, $http, $routeParams, json, Page, $log, multipleCards, $location) {
Page.setTitle('File List');
Page.setPage('fileList');
$scope.currentPage = 1;
$scope.numPerPage = 100;
$scope.maxSize = 9;
var paramDate = $routeParams.date;
$scope.currentDate = dateConversion(paramDate);
var getDateList = json.getDateList();
getDateList.then(function(data) {
$scope.dates = data.dates;
});
var getCardCount = json.getCardCount(paramDate);
getCardCount.then(function(cdata){
$scope.numCards = cdata.count;
$scope.numPages = Math.ceil(cdata.count / $scope.numPerPage);
});
$scope.switchPage = function(page){
$scope.currentPage = page;
$scope.pageLoading = true;
var getFileList = json.getFilePage(paramDate, page, $scope.numPerPage);
getFileList.then(function(data) {
data.files = data.files.map(function(x){
x.Stroke_Time = new Date(x.Stroke_Time);
return x;
});
$scope.filteredFiles = data.files;
$scope.pageLoading = false;
});
};
$scope.switchPage(1);
$scope.$watch('currentPage', function() {
$scope.switchPage($scope.currentPage);
});
$scope.selectFiles = function() {
var ids = $scope.filteredFiles.filter(function(x){
return x.selected;
}).map(function(y){
return y.id;
});
$http.post('/json/cards', {
ids: ids
}).success(function(data, status, headers, config) {
multipleCards.store(data.cards);
$location.path('/card/compare');
}).error(function(data, status, headers, config) {
$log.info('Data', data);
$log.info('Status', status);
$log.info('Headers', headers);
$log.info('Config', config);
});
};
});

View File

@@ -0,0 +1,56 @@
poconsole.controller('fileListTodayCtrl', function($scope, $http, $routeParams, json, Page, $log, multipleCards, $location) {
Page.setTitle('File List');
Page.setPage('fileList');
$scope.currentPage = 1;
$scope.numPerPage = 100;
$scope.maxSize = 9;
var getDateList = json.getDateList();
getDateList.then(function(data) {
$scope.dates = data.dates;
$scope.currentDate = $scope.dates[0];
$log.info($scope.currentDate);
var getCardCount = json.getCardCount($scope.currentDate.unconv);
getCardCount.then(function(cdata){
$scope.numCards = cdata.count;
$scope.numPages = Math.ceil(cdata.count / $scope.numPerPage);
});
$scope.switchPage(1);
});
$scope.switchPage = function(page){
$scope.currentPage = page;
$scope.pageLoading = true;
var getFileList = json.getFilePage($scope.currentDate.unconv, page, $scope.numPerPage);
getFileList.then(function(data) {
data.files = data.files.map(function(x){
x.Stroke_Time = new Date(x.Stroke_Time);
return x;
});
$scope.filteredFiles = data.files;
$scope.pageLoading = false;
});
};
$scope.$watch('currentPage', function() {
$scope.switchPage($scope.currentPage);
});
$scope.selectFiles = function() {
var ids = $scope.filteredFiles.filter(function(x){
return x.selected;
}).map(function(y){
return y.id;
});
$http.post('/json/cards', {
ids: ids
}).success(function(data, status, headers, config) {
multipleCards.store(data.cards);
$location.path('/card/compare');
}).error(function(data, status, headers, config) {
$log.info('Data', data);
$log.info('Status', status);
$log.info('Headers', headers);
$log.info('Config', config);
});
};
});

View File

@@ -0,0 +1,121 @@
poconsole.controller('fluidShotCtrl', function($scope, json, Page, $log){
Page.setTitle('Fluid Shot');
Page.setPage('fluidshot');
$scope.showDeletedShots = false;
var getFluidShots = function(){
$scope.newShot = {
shot_datetime:null,
pump_intake_pressure:null,
fluid_gradient:null,
friction:null,
taken_by:null
};
var getFluidShots = json.getFluidShots();
getFluidShots.then(function(data){
$scope.fluidShots = data.fluid_shots;
});
};
/*
CREATE TABLE `WellData`.`fluid_shot` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`shot_datetime` datetime DEFAULT NULL,
`pump_intake_pressure` float DEFAULT NULL,
`fluid_gradient` float DEFAULT NULL,
`friction` float DEFAULT NULL,
`taken_by` varchar(128) DEFAULT NULL,
`deleted` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
)
*/
$scope.message = null;
$scope.newShot = {
shot_datetime:null,
pump_intake_pressure:null,
fluid_gradient:null,
friction:null,
taken_by:null
};
$scope.addFluidShot = function(){
if(!$scope.newShot.shot_datetime){
$scope.message = "No Date/Time provided.";
} else if(!$scope.newShot.pump_intake_pressure){
$scope.message = "No Pump Intake Pressure provided.";
} else if(!$scope.newShot.taken_by){
$scope.message = "No Taken By provided.";
} else {
$scope.message = json.pushFluidShot($scope.newShot.shot_datetime, $scope.newShot.pump_intake_pressure, $scope.newShot.fluid_gradient, $scope.newShot.friction, $scope.newShot.taken_by);
getFluidShots();
}
};
$scope.deleteFluidShot = function(id){
json.deleteFluidShot(id);
getFluidShots();
if ($scope.showDeletedFluidShots){
getDeletedFluidShots();
}
};
$scope.undeleteFluidShot = function(id){
json.undeleteFluidShot(id);
getFluidShots();
if ($scope.showDeletedFluidShots){
getDeletedFluidShots();
}
};
$scope.toggleDeleted = function(){
if ($scope.showDeletedFluidShots){
$scope.showDeletedFluidShots = false;
} else {
$scope.showDeletedFluidShots = true;
getDeletedFluidShots();
}
};
var getDeletedFluidShots = function(){
$scope.showDeletedFluidShots = true;
var getDeletedFluidShots = json.getDeletedFluidShots();
getDeletedFluidShots.then(function(data){
$scope.deletedFluidShots = data.fluid_shots;
});
};
$scope.startEditFluidShot = function(id){
$scope.message = null;
var editShotTarget = $scope.fluidShots.filter(function(x){
return (x.id == id);
})[0];
$scope.editShot = {
id:editShotTarget.id,
shot_datetime:editShotTarget.shot_datetime,
pump_intake_pressure:editShotTarget.pump_intake_pressure,
fluid_gradient:editShotTarget.fluid_gradient,
friction:editShotTarget.friction,
taken_by:editShotTarget.taken_by
};
};
$scope.submitEditedShot = function(){
if(!$scope.editShot.shot_datetime){
$scope.message = "No Date/Time provided.";
} else if(!$scope.editShot.pump_intake_pressure){
$scope.message = "No Pump Intake Pressure provided.";
} else if(!$scope.editShot.taken_by){
$scope.message = "No Taken By provided.";
} else {
$scope.message = json.updateFluidShot($scope.editShot.id, $scope.editShot.shot_datetime, $scope.editShot.pump_intake_pressure, $scope.editShot.fluid_gradient, $scope.editShot.friction, $scope.editShot.taken_by);
getFluidShots();
}
};
getFluidShots();
});

View File

@@ -0,0 +1,48 @@
poconsole.controller('gaugeOffCtrl', function($scope, Page, json) {
Page.setTitle('Gauge Off');
Page.setPage('gaugeOff');
var getGaugeOffData = json.getGaugeOffData();
getGaugeOffData.then(function(data) {
var i;
$scope.gaugeOffData = data.gaugeOffData;
i = 0;
while (i < $scope.gaugeOffData.length - 1) {
$scope.gaugeOffData[i].delta = {};
$scope.gaugeOffData[i].delta.percent_run = ((parseFloat($scope.gaugeOffData[i].percent_run) - parseFloat($scope.gaugeOffData[i + 1].percent_run)) / parseFloat($scope.gaugeOffData[i + 1].percent_run) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.kWh = ((parseFloat($scope.gaugeOffData[i].kWh) - parseFloat($scope.gaugeOffData[i + 1].kWh)) / parseFloat($scope.gaugeOffData[i + 1].kWh) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.kWh_regen = ((parseFloat($scope.gaugeOffData[i].kWh_regen) - parseFloat($scope.gaugeOffData[i + 1].kWh_regen)) / parseFloat($scope.gaugeOffData[i + 1].kWh_regen) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.electricity_cost = ((parseFloat($scope.gaugeOffData[i].electricity_cost) - parseFloat($scope.gaugeOffData[i + 1].electricity_cost)) / parseFloat($scope.gaugeOffData[i + 1].electricity_cost) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.peak_load = ((parseFloat($scope.gaugeOffData[i].peak_load) - parseFloat($scope.gaugeOffData[i + 1].peak_load)) / parseFloat($scope.gaugeOffData[i + 1].peak_load) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.min_load = ((parseFloat($scope.gaugeOffData[i].min_load) - parseFloat($scope.gaugeOffData[i + 1].min_load)) / parseFloat($scope.gaugeOffData[i + 1].min_load) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.average_SPM = ((parseFloat($scope.gaugeOffData[i].average_SPM) - parseFloat($scope.gaugeOffData[i + 1].average_SPM)) / parseFloat($scope.gaugeOffData[i + 1].average_SPM) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.production_calculated = ((parseFloat($scope.gaugeOffData[i].production_calculated) - parseFloat($scope.gaugeOffData[i + 1].production_calculated)) / parseFloat($scope.gaugeOffData[i + 1].production_calculated) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.polished_rod_HP = ((parseFloat($scope.gaugeOffData[i].polished_rod_HP) - parseFloat($scope.gaugeOffData[i + 1].polished_rod_HP)) / parseFloat($scope.gaugeOffData[i + 1].polished_rod_HP) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.lifting_cost = ((parseFloat($scope.gaugeOffData[i].lifting_cost) - parseFloat($scope.gaugeOffData[i + 1].lifting_cost)) / parseFloat($scope.gaugeOffData[i + 1].lifting_cost) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.full_card_production = ((parseFloat($scope.gaugeOffData[i].full_card_production) - parseFloat($scope.gaugeOffData[i + 1].full_card_production)) / parseFloat($scope.gaugeOffData[i + 1].full_card_production) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.fluid_above_pump = ((parseFloat($scope.gaugeOffData[i].fluid_above_pump) - parseFloat($scope.gaugeOffData[i + 1].fluid_above_pump)) / parseFloat($scope.gaugeOffData[i + 1].fluid_above_pump) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.pump_intake_pressure = ((parseFloat($scope.gaugeOffData[i].pump_intake_pressure) - parseFloat($scope.gaugeOffData[i + 1].pump_intake_pressure)) / parseFloat($scope.gaugeOffData[i + 1].pump_intake_pressure) * 100).toFixed(2);
$scope.gaugeOffData[i].delta.inflow_rate = ((parseFloat($scope.gaugeOffData[i].inflow_rate) - parseFloat($scope.gaugeOffData[i + 1].inflow_Rate)) / parseFloat($scope.gaugeOffData[i + 1].inflow_rate) * 100).toFixed(2);
i++;
}
});
$scope.show = {
PctRun: true,
kWh: true,
kWhRegen: false,
CostToOperate: true,
LiftingCost: false,
PeakLoad: false,
MinLoad: false,
AvgSPM: true,
CalcProduction: true,
ProjProduction: false,
PolishedRodHP: false,
FluidLevel: true,
PumpIntakePressure: false,
InflowRate: false
};
});

View File

@@ -1,5 +1,4 @@
var poconsole = angular.module('poconsole', ['ngJustGage', 'n3-line-chart', "ngQuickDate", "ngSails"]);
var poconsole = angular.module('poconsole', ['ngJustGage', 'n3-line-chart', "ngQuickDate", "ngSails", 'ui.bootstrap', 'ngAnimate', 'googlechart']);
poconsole.config(function(ngQuickDateDefaultsProvider) {
// Configure with icons from font-awesome
@@ -16,12 +15,18 @@ poconsole.config(function(ngQuickDateDefaultsProvider) {
});
});
poconsole.value('googleChartApiConfig', {
version: '1.1',
optionalSettings: {
packages: ['timeline'],
language: 'en'
}
});
poconsole.controller('mainCtrl', function($scope, Page) {
$scope.Page = Page;
});
//*---- FILTERS -----*//
poconsole.filter('dString', function myDateFormat($filter){
return function(text){
@@ -30,7 +35,6 @@ poconsole.filter('dString', function myDateFormat($filter){
};
});
poconsole.filter('sqlite_to_local', function sqliteformat($filter){
return function(text){
var utcdate= new Date(text + " UTC");

View File

@@ -0,0 +1,110 @@
poconsole.controller('notesCtrl', function($scope, json, Page, $log){
Page.setTitle('Notes');
Page.setPage('notes');
$scope.showDeletedNotes = false;
var getNotes = function(){
$scope.newNote.author = null;
$scope.newNote.note = null;
$scope.newNote.stroke_associated = null;
$scope.newNote.type = null;
var getNotes = json.getNotes();
getNotes.then(function(data){
$scope.notes = data.notes;
});
var getNoteTypes = json.getNoteTypes();
getNoteTypes.then(function(data){
$scope.noteTypes = data.types;
});
};
$scope.message = null;
$scope.newNote = {};
$scope.newNote.author = null;
$scope.newNote.note = null;
$scope.newNote.stroke_associated = null;
$scope.newNote.type = null;
$scope.addNote = function(){
if(!$scope.newNote.author){
$scope.message = "No author provided.";
} else if(!$scope.newNote.note){
$scope.message = "No note provided.";
} else if(!$scope.newNote.type){
$scope.message = "No type selected.";
} else {
$scope.message = json.pushNote($scope.newNote.author, $scope.newNote.note, $scope.newNote.type, $scope.newNote.stroke_associated);
getNotes();
}
};
$scope.deleteNote = function(id){
json.deleteNote(id);
getNotes();
if ($scope.showDeletedNotes){
getDeletedNotes();
}
};
$scope.undeleteNote = function(id){
json.undeleteNote(id);
getNotes();
if ($scope.showDeletedNotes){
getDeletedNotes();
}
};
$scope.toggleDeleted = function(){
if ($scope.showDeletedNotes){
$scope.showDeletedNotes = false;
} else {
$scope.showDeletedNotes = true;
getDeletedNotes();
}
};
var getDeletedNotes = function(){
$scope.showDeletedNotes = true;
var getDeletedNotes = json.getDeletedNotes();
getDeletedNotes.then(function(data){
$scope.deletedNotes = data.notes;
});
};
$scope.startEditNote = function(id){
$scope.message = null;
var editNoteTarget = $scope.notes.filter(function(x){
return (x.id == id);
})[0];
$scope.editNote = {
id: editNoteTarget.id,
author: editNoteTarget.author,
type: editNoteTarget.ntypeval,
date_time: editNoteTarget.date_time,
stroke_associated: editNoteTarget.stroke,
note: editNoteTarget.note
};
};
$scope.submitEditedNote = function(){
if(!$scope.editNote.author){
$scope.message = "No author provided.";
} else if(!$scope.editNote.note){
$scope.message = "No note provided.";
} else if(!$scope.editNote.type){
$scope.message = "No type selected.";
} else {
$scope.message = json.updateNote($scope.editNote.id, $scope.editNote.author, $scope.editNote.note, $scope.editNote.type, $scope.editNote.stroke_associated);
}
getNotes();
};
getNotes();
});

View File

@@ -0,0 +1,32 @@
poconsole.controller('totalsCtrl', function($scope, json, Page, $log){
Page.setTitle('Totals');
Page.setPage('dashboard');
// $scope.currentPage = 1;
// $scope.numPerPage = 10;
// $scope.maxSize = 9;
$scope.dateListLoading = true;
$scope.totalsLoading = true;
var getDateList = json.getDateList();
getDateList.then(function(data) {
$scope.dateListLoading = false;
$scope.dates = data.dates;
$scope.currentDate = $scope.dates[0];
// $scope.numPages = function() {
// return Math.ceil($scope.dates.length / $scope.numPerPage);
// };
// $scope.$watch('currentPage + numPerPage', function() {
// var begin = ($scope.currentPage - 1) * $scope.numPerPage;
// var end = begin + $scope.numPerPage;
// $scope.filteredDates = $scope.dates.slice(begin, end);
// });
});
$scope.refresh = function(){
var getTotals = json.getTotals();
getTotals.then(function(tdata){
$scope.totals = tdata.totals;
$scope.totalsLoading = false;
});
};
$scope.refresh();
});

View File

@@ -0,0 +1,106 @@
poconsole.controller('wellTestCtrl', function($scope, json, Page, $log){
Page.setTitle('Well Test');
Page.setPage('well_Test');
var getWellTests = function(){
$scope.newTest = {
shot_datetime:null,
pump_intake_pressure:null,
fluid_gradient:null,
friction:null,
taken_by:null
};
var getWellTests = json.getWellTests();
getWellTests.then(function(data){
$scope.wellTests = data.well_tests;
});
};
$scope.message = null;
$scope.newTest = {
shot_datetime:null,
pump_intake_pressure:null,
fluid_gradient:null,
friction:null,
taken_by:null
};
$scope.addWellTest = function(){
if(!$scope.newTest.shot_datetime){
$scope.message = "No Date/Time provided.";
} else if(!$scope.newTest.pump_intake_pressure){
$scope.message = "No Pump Intake Pressure provided.";
} else if(!$scope.newTest.taken_by){
$scope.message = "No Taken By provided.";
} else {
$scope.message = json.pushFluidShot($scope.newTest.shot_datetime, $scope.newTest.pump_intake_pressure, $scope.newTest.fluid_gradient, $scope.newTest.friction, $scope.newTest.taken_by);
getWellTests();
}
};
$scope.deleteWellTest = function(id){
json.deleteWellTest(id);
getWellTests();
if ($scope.ShowDeletedTests){
getDeletedWellTests();
}
};
$scope.undeleteFluidShot = function(id){
json.undeleteFluidShot(id);
getFluidShots();
if ($scope.showDeletedFluidShots){
getDeletedFluidShots();
}
};
$scope.toggleDeleted = function(){
if ($scope.showDeletedFluidShots){
$scope.showDeletedFluidShots = false;
} else {
$scope.showDeletedFluidShots = true;
getDeletedFluidShots();
}
};
var getDeletedFluidShots = function(){
$scope.showDeletedFluidShots = true;
var getDeletedFluidShots = json.getDeletedFluidShots();
getDeletedFluidShots.then(function(data){
$scope.deletedFluidShots = data.fluid_shots;
});
};
$scope.startEditFluidShot = function(id){
$scope.message = null;
var editShotTarget = $scope.fluidShots.filter(function(x){
return (x.id == id);
})[0];
$scope.editShot = {
id:editShotTarget.id,
shot_datetime:editShotTarget.shot_datetime,
pump_intake_pressure:editShotTarget.pump_intake_pressure,
fluid_gradient:editShotTarget.fluid_gradient,
friction:editShotTarget.friction,
taken_by:editShotTarget.taken_by
};
};
$scope.submitEditedShot = function(){
if(!$scope.editShot.shot_datetime){
$scope.message = "No Date/Time provided.";
} else if(!$scope.editShot.pump_intake_pressure){
$scope.message = "No Pump Intake Pressure provided.";
} else if(!$scope.editShot.taken_by){
$scope.message = "No Taken By provided.";
} else {
$scope.message = json.updateFluidShot($scope.editShot.id, $scope.editShot.shot_datetime, $scope.editShot.pump_intake_pressure, $scope.editShot.fluid_gradient, $scope.editShot.friction, $scope.editShot.taken_by);
getFluidShots();
}
};
getWellTests();
});

View File

@@ -0,0 +1,88 @@
poconsole.factory('card_graph',function($q, $http, $log){
var getCardGraphOptions = function(surface, downhole){
var limits = {
sMaxPos: surface.map(function(x){return x.position;}).reduce(function(y,z){return Math.max(y,z);})+ 20,
sMinPos: surface.map(function(x){return x.position;}).reduce(function(y,z){return Math.min(y,z);})- 20,
sMaxLoad: surface.map(function(x){return x.load;}).reduce(function(y,z){return Math.max(y,z);})+ 2000,
sMinLoad: surface.map(function(x){return x.load;}).reduce(function(y,z){return Math.min(y,z);})- 2000,
dMaxLoad: downhole.map(function(x){return x.load;}).reduce(function(y,z){return Math.max(y,z);})+ 2000,
dMinLoad: downhole.map(function(x){return x.load;}).reduce(function(y,z){return Math.min(y,z);})- 2000,
};
var surfaceOptions = {
axes: {
x: {
key: 'position',
labelFunction: function(value) {
return value;
},
type: 'linear',
min: limits.sMinPos,
max: limits.sMaxPos,
ticks: 7
},
y: {
type: 'linear',
min: limits.sMinLoad,
max: limits.sMaxLoad,
ticks: 5
}
},
series: [
{
axis:"y",
key: 'load',
dataset: 'surface',
color: 'steelblue',
type: ['line', 'area'],
striped: true,
label: 'Surface Card',
id: "surfaceCard"
}
],
grid: {
x: true,
y: true
}
};
var downholeOptions = {
axes: {
x: {
key: 'position',
labelFunction: function(value) {
return value;
},
type: 'linear',
min: limits.sMinPos,
max: limits.sMaxPos,
ticks: 7
},
y: {
type: 'linear',
min: limits.dMinLoad,
max: limits.dMaxLoad,
ticks: 5
}
},
series: [
{
axis:"y",
key: 'load',
dataset: 'downhole',
color: 'steelblue',
type: ['line', 'area'],
label: 'Downhole Card',
id: "downholeCard",
}
],
grid: {
x: true,
y: true
}
};
return({surf: surfaceOptions, down: downholeOptions});
};
return({getCardGraphOptions: getCardGraphOptions});
});

View File

@@ -0,0 +1,14 @@
poconsole.factory('multipleCards', function() {
var mCardData, retrieve, store;
mCardData = {};
store = function(data) {
mCardData = data;
};
retrieve = function() {
return mCardData;
};
return {
store: store,
retrieve: retrieve
};
});

View File

@@ -0,0 +1,79 @@
poconsole.factory('statusTimeline', function($q, $http){
var getStatusBetween = function(sDateTime, eDateTime){
var deferred = $q.defer();
$http.get('/json/status/' + sDateTime + "/" + eDateTime).success(function(data) {
if (data.status == "OK"){
if (data.run_status.length > 1){
var run_statuses = data.run_status;
var uniqueRunStatuses = [run_statuses[0]];
for (var i = 1; i < run_statuses.length; i++){
if (uniqueRunStatuses.slice(-1)[0].status != run_statuses[i].status){
uniqueRunStatuses.push(run_statuses[i]);
}
}
for (var j = 0; j < uniqueRunStatuses.length - 1; j++){
uniqueRunStatuses[j].end_dtime = uniqueRunStatuses[j+1].dtime;
}
deferred.resolve(uniqueRunStatuses);
}
}
});
return deferred.promise;
};
var prepareTimelineData = function(sDateTime, eDateTime){
var deferred = $q.defer();
var getData = getStatusBetween(sDateTime, eDateTime);
getData.then(function(d){
var statusData = d;
var timelineData = {
"cssStyle" : "height:300px;width:100%;",
"type": "Timeline",
"data": {
"cols": [
{type: 'string', id: 'Run Status'},
{type: 'string', id: 'Bar Label'},
// {type: 'string', role: 'tooltip', p: {'html': true}},
{type: 'date', id: 'Start'},
{type: 'date', id: 'End'}
],
"rows": [],
},
"options" : {
timeline: {
//singleColor: '#00f',
colorByRowLabel: false,
groupByRowLabel: true,
// rowLabelStyle: {fontName: 'Helvetica', fontSize: 14, color: '#442' },
// barLabelStyle: { fontName: 'Garamond', fontSize: 14 }
},
backgroundColor: '#ffffff',
tooltip: {
isHtml: true
}
}
};
if (statusData.length > 0){
statusData.slice(-1)[0].end_dtime = eDateTime;
for (var i=0; i < statusData.length; i++){
timelineData.data.rows.push({
c:[
{"v": statusData[i].status},
{"v": statusData[i].status},
// {"v": "<strong>" + statusData[i].status +"</strong>"},
{"v": new Date(statusData[i].dtime * 1000)},
{"v": new Date(statusData[i].end_dtime * 1000)}
]
});
}
deferred.resolve(timelineData);
}
});
return deferred.promise;
};
return {
prepareTimelineData: prepareTimelineData
};
});

View File

@@ -17,6 +17,48 @@ tagserver.config([
}).when('/docs', {
templateUrl: '/templates/docs.html',
controller: 'docsCtrl'
}).when('/totals', {
templateUrl: '/templates/totals.html',
controller: 'totalsCtrl'
}).when('/card/compare', {
templateUrl: '/templates/cardCompare.html',
controller: 'cardCompareCtrl'
}).when('/card/:id/overview', {
templateUrl: '/templates/cardOverview.html',
controller: 'cardDataCtrl'
}).when('/card/:id/data', {
templateUrl: '/templates/cardData.html',
controller: 'cardDataCtrl'
}).when('/card/:id/cards', {
templateUrl: '/templates/cardCards.html',
controller: 'cardDataCtrl'
}).when('/card/:id', {
templateUrl: '/templates/cardOverview.html',
controller: 'cardDataCtrl'
}).when('/files/:date', {
templateUrl: '/templates/fileList.html',
controller: 'fileListPreviousCtrl'
}).when('/files', {
templateUrl: '/templates/fileList.html',
controller: 'fileListTodayCtrl'
}).when('/gaugeOff', {
templateUrl: '/templates/gaugeOff.html',
controller: 'gaugeOffCtrl'
}).when('/wellTest', {
templateUrl: '/templates/wellTest.html',
controller: 'wellTestCtrl'
}).when('/events', {
templateUrl: '/templates/eventList.html',
controller: 'eventsCtrl'
}).when('/setup', {
templateUrl: '/templates/setup.html',
controller: 'setupCtrl'
}).when('/notes', {
templateUrl: '/templates/notes.html',
controller: 'notesCtrl'
}).when('/fluid_shot', {
templateUrl: '/templates/fluid_shot.html',
controller: 'fluidShotCtrl'
}).when('/', {
templateUrl: '/templates/dashboard.html',
controller: 'dashboardCtrl'

View File

@@ -0,0 +1,420 @@
poconsole.factory('json',function($q, $http, $log){
var getDateList = function() {
var deferred = $q.defer();
$http.get('/card/dates').success(function(data) {
var dateList = data;
var dates = dateList.map(function(x){return new Date(x.date);});
deferred.resolve({
dates: dates
});
});
return deferred.promise;
};
var getCurrentStatus = function(){
var deferred = $q.defer();
var params = {sort: 'createdAt DESC', limit: 1};
$http.get('/run_status', params).success(function(data) {
deferred.resolve({
data: data
});
});
return deferred.promise;
};
var getStatusAtTime = function(unixTS){
var deferred = $q.defer();
var params = {where: {createdAt}};
$http.get('/json/status/' + unixTS).success(function(data) {
deferred.resolve({
data: data
});
});
return deferred.promise;
};
// OLD FUNCTIONS
var getGaugeOffData = function() {
var deferred = $q.defer();
$http.get('/json/history/all').success(function(data) {
deferred.resolve({
gaugeOffData: data.hist
});
});
return deferred.promise;
};
var getWellTestData = function() {
var deferred = $q.defer();
$http.get('/json/well_test/all').success(function(data) {
deferred.resolve({
wellTestData: data.wellTest
});
});
return deferred.promise;
};
var getEventsData = function() {
var deferred = $q.defer();
$http.get('/json/event_list').success(function(data) {
deferred.resolve({
eventsData: data.events
});
});
return deferred.promise;
};
var getSetup = function() {
var deferred = $q.defer();
$http.get('/json/setup').success(function(data) {
deferred.resolve({
setup: data.setup
});
});
return deferred.promise;
};
var getPythonStatus = function() {
var deferred = $q.defer();
$http.get('/json/pythonStatus').success(function(data) {
deferred.resolve({
status: data.status
});
});
return deferred.promise;
};
var restartPythonScripts = function() {
var deferred = $q.defer();
$http.get('/json/pythonRestart').success(function(data) {
deferred.resolve({
success: data.success
});
});
return deferred.promise;
};
var getFilePage = function(date, pageNumber, numPerPage){
var deferred = $q.defer();
$http.get('/json/page/'+date+"/"+pageNumber+"/"+numPerPage).success(function(data) {
deferred.resolve({
files:data.cards
});
});
return deferred.promise;
};
var getCardCount = function(date){
var deferred = $q.defer();
$http.get('/json/count/'+date).success(function(data) {
deferred.resolve({
count:data.count
});
});
return deferred.promise;
};
var getFileList = function(date) {
var deferred = $q.defer();
$http.get('/json/all/' + date).success(function(data) {
deferred.resolve({
files: data.cards
});
});
return deferred.promise;
};
var getLatestCard = function() {
var deferred = $q.defer();
$http.get('/json/latestcard/').success(function(data) {
deferred.resolve({
data: data
});
});
return deferred.promise;
};
var getCard = function(id) {
var deferred = $q.defer();
$http.get('/json/card/'+ id.toString()).success(function(data) {
deferred.resolve({
data: data
});
});
return deferred.promise;
};
var getTotals = function() {
var deferred = $q.defer();
$http.get('/json/totals').success(function(data) {
var totalRet = {};
var vals = data.totals;
i=0;
while (i < vals.length){
totalRet[vals[i].name] = vals[i].value;
i++;
}
deferred.resolve({
totals: totalRet
});
});
return deferred.promise;
};
var getNotes = function(){
var deferred = $q.defer();
$http.get('/json/notes/get').success(function(data) {
deferred.resolve({
notes: data.notes
});
});
return deferred.promise;
};
var getNoteTypes = function(){
var deferred = $q.defer();
$http.get('/json/notes/get/types').success(function(data) {
deferred.resolve({
types: data.types
});
});
return deferred.promise;
};
var pushNote = function(author, note, type, stroke_associated){
$http.post('/json/notes/post', {
author:author,
note:note,
type:type,
stroke_associated:stroke_associated
}).success(function(data){
return data;
});
};
var deleteNote = function(noteID){
$http.post('/json/notes/delete', {id:noteID}).success(function(data){
return data;
});
};
var undeleteNote = function(noteID){
$http.post('/json/notes/undelete', {id:noteID}).success(function(data){
return data;
});
};
var updateNote = function(id,author, note, type, stroke_associated){
$http.post('/json/notes/update', {
id:id,
author:author,
note:note,
type:type,
stroke_associated:stroke_associated
}).success(function(data){
return data;
});
};
var getDeletedNotes = function(){
var deferred = $q.defer();
$http.get('/json/notes/get/deleted').success(function(data) {
deferred.resolve({
notes: data.notes
});
});
return deferred.promise;
};
var getFluidShots = function(){
var deferred = $q.defer();
$http.get('/json/fluid_shot/get').success(function(data) {
deferred.resolve({
fluid_shots: data.fluid_shots
});
});
return deferred.promise;
};
var pushFluidShot = function(shot_datetime, pump_intake_pressure, fluid_gradient, friction, taken_by){
$http.post('/json/fluid_shot/post', {
shot_datetime:shot_datetime,
pump_intake_pressure:pump_intake_pressure,
fluid_gradient:fluid_gradient,
friction:friction,
taken_by:taken_by
}).success(function(data){
return data;
});
};
var deleteFluidShot = function(shotID){
$http.post('/json/fluid_shot/delete', {id:shotID}).success(function(data){
return data;
});
};
var undeleteFluidShot = function(shotID){
$http.post('/json/fluid_shot/undelete', {id:shotID}).success(function(data){
return data;
});
};
var updateFluidShot = function(id, shot_datetime, pump_intake_pressure, fluid_gradient, friction, taken_by){
$http.post('/json/fluid_shot/update', {
id:id,
shot_datetime:shot_datetime,
pump_intake_pressure:pump_intake_pressure,
fluid_gradient:fluid_gradient,
friction:friction,
taken_by:taken_by
}).success(function(data){
return data;
});
};
var getDeletedFluidShots = function(){
var deferred = $q.defer();
$http.get('/json/fluid_shot/get/deleted').success(function(data) {
deferred.resolve({
fluid_shots: data.fluid_shots
});
});
return deferred.promise;
};
//Well Test Functions
var getWellTests = function(){
var deferred = $q.defer();
$http.get('/json/well_test/get').success(function(data) {
deferred.resolve({
well_tests: data.well_tests
});
});
return deferred.promise;
};
var pushWellTest = function(shot_datetime, pump_intake_pressure, fluid_gradient, friction, taken_by){
$http.post('/json/well_test/post', {
shot_datetime:shot_datetime,
pump_intake_pressure:pump_intake_pressure,
fluid_gradient:fluid_gradient,
friction:friction,
taken_by:taken_by
}).success(function(data){
return data;
});
};
var deleteWellTest = function(shotID){
$http.post('/json/well_test/delete', {id:testID}).success(function(data){
return data;
});
};
var undeleteWellTest = function(shotID){
$http.post('/json/well_test/undelete', {id:testID}).success(function(data){
return data;
});
};
var updateWellTest = function(id, shot_datetime, pump_intake_pressure, fluid_gradient, friction, taken_by){
$http.post('/json/well_test/update', {
id:id,
shot_datetime:shot_datetime,
pump_intake_pressure:pump_intake_pressure,
fluid_gradient:fluid_gradient,
friction:friction,
taken_by:taken_by
}).success(function(data){
return data;
});
};
var getDeletedWellTests = function(){
var deferred = $q.defer();
$http.get('/json/well_test/get/deleted').success(function(data) {
deferred.resolve({
well_tests: data.well_tests
});
});
return deferred.promise;
};
var getCurrentTagValues = function(){
var deferred = $q.defer();
$http.get('/json/tagvalues').success(function(data) {
deferred.resolve({
data: data
});
});
return deferred.promise;
};
var getTagsAtTime = function(unixTS){
var deferred = $q.defer();
$http.get('/json/tagvalues/' + unixTS).success(function(data) {
deferred.resolve({
data: data
});
});
return deferred.promise;
};
return {
getDateList: getDateList,
getGaugeOffData: getGaugeOffData,
getWellTestData: getWellTestData,
getEventsData: getEventsData,
getSetup: getSetup,
getPythonStatus: getPythonStatus,
restartPythonScripts: restartPythonScripts,
getFileList: getFileList,
getLatestCard: getLatestCard,
getCard: getCard,
getFilePage: getFilePage,
getCardCount: getCardCount,
getTotals: getTotals,
// Notes Functions
getNotes: getNotes,
getNoteTypes: getNoteTypes,
pushNote: pushNote,
deleteNote: deleteNote,
undeleteNote: undeleteNote,
updateNote: updateNote,
getDeletedNotes: getDeletedNotes,
// Fluit Shot Functions
getFluidShots: getFluidShots,
pushFluidShot: pushFluidShot,
deleteFluidShot: deleteFluidShot,
undeleteFluidShot: undeleteFluidShot,
updateFluidShot: updateFluidShot,
getDeletedFluidShots: getDeletedFluidShots,
// Well Test Functions
getWellTests: getWellTests,
pushWellTest: pushWellTest,
deleteWellTest: deleteWellTest,
undeleteWellTest: undeleteWellTest,
updateWellTest: updateWellTest,
getDeletedWellTests: getDeletedWellTests,
// Tag Data Functions
getCurrentTagValues: getCurrentTagValues,
getTagsAtTime: getTagsAtTime,
getCurrentStatus: getCurrentStatus,
getStatusAtTime: getStatusAtTime
};
});

View File

@@ -0,0 +1,30 @@
poconsole.controller('setupCtrl', function($scope, Page, json, $log) {
Page.setTitle('Setup');
Page.setPage('setup');
$scope.getPythonStatus = function() {
$scope.gettingStatus = true;
var getPythonStatus = json.getPythonStatus();
getPythonStatus.then(function(pyData) {
$scope.gettingStatus = false;
if (pyData.status.alarmLogger === true && pyData.status.dataLogger === true){
$scope.pythonStatus = 'OK';
} else {
$scope.pythonStatus = 'NOT OK';
}
$log.info(pyData);
});
};
var getSetup = json.getSetup();
getSetup.then(function(data) {
$scope.setup = data.setup;
$scope.getPythonStatus();
});
$scope.restartPython = function() {
$scope.resetting = true;
var restartPython = json.restartPythonScripts();
restartPython.then(function(response) {
$scope.resetting = false;
$scope.getPythonStatus();
});
};
});

View File

@@ -1,33 +1,123 @@
<div ng-if="loading" class="container">
<div class="container">
<div class="row">
<div class="col-md-12 well" style="text-align:center;">
<h1>Loading Dashboard...</h1>
<img class="img-responsive" src="/images/loading.gif" style="margin:0 auto;"/>
</div>
<div google-chart chart="timelineData"></div>
</div>
</div>
<div ng-if="!loading">
<div ng-if="error" class="container">
<div class="row">
<div class="col-md=12">
<h1>Error Caught!</h1>
<pre>{{message}}</pre>
<button ng-click="loadDashboard()" class="btn btn-large btn-danger"><i class="fa fa-refresh"></i> Reload Dashboard</button>
<div class="row">
<div class="col-sm-2">
<div ng-if="dateListLoading" class="well"><img src="/img/loading.gif" /></div>
<div ng-if="!dateListLoading">
<!-- <pagination total-items="totalFiles" ng-model="currentPage" max-size="maxSize" items-per-page="numPerPage" class="pagination-sm" boundary-links="false" rotate="false" num-pages="numPages"></pagination> -->
<ul class="list-group">
<li class="list-group-item active animate">Dashboard</li>
<li class="list-group-item animate" ng-repeat="date in dates">
<a href="/#/files/{{date | date: 'yyyy-MM-dd'}}">{{date | date: 'mediumDate'}}</a>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-10">
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="/">Last Stroke</a></li>
<li><a href="/#/totals">Today's Totals</a></li>
</ul>
<div ng-if="!error" class="container">
<div class="row">
<button ng-click="loadDashboard()" class="btn btn-large btn-success"><i class="fa fa-refresh"></i> Reload Dashboard</button>
<a href="/csv/all" class="btn btn-large btn-primary"><i class="fa fa-download"></i> Download All Data</a>
<div ng-repeat="val in vals">
<div class="col-md-4" style="height:200px; margin-bottom:40px;">
<just-gage id="{{val.name}}" min='val.minExpected' max='val.maxExpected' value='val.val' options="{label:val.units,title:val.name, decimals:2, refreshAnimationType:'bounce', startAnimationType:'bounce'}"></just-gage>
<div style="text-align:center">
<h5>{{ val.dtime | date: 'medium'}}</h5>
<a href="/#/tag/{{val.t_id}}" class="btn btn-large btn-primary"><i class="fa fa-line-chart"></i> View Data</a>
<h1 style="text-align:center;">Dashboard - Stroke {{cardData.Card_ID}}</h1>
<div style="text-align:center;"><button class="btn btn-primary active" id="refreshButton" ng-click="dashboard()">Refresh Data</button></div>
<div class="row">
<div class="col-sm-4">
<div id="Status" class="gauge well" style="width:95%; text-align:center; margin:10px;"><h4>Status: {{status}}</h4><h6>Last Changed: {{status_datetime | date: "medium"}}</h6></div>
</div>
<div class="col-sm-4">
<div id="FillageGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
<h4>Pump Fillage:</h4>
<h5>{{tagValues.fillage_percent.val | number:3}} %</h5>
</div>
</div>
<div class="col-sm-4">
<div id="FAPGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
<h4>Fluid Above Pump:</h4>
<h5>{{tagValues.fluid_level.val | number:3}} ft.</h5>
</div>
</div>
<div class="col-sm-4">
<div id="PRHPGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
<h4>Polished Rod HP:</h4>
<h5>{{tagValues.polished_rod_hp.val | number:3}} HP</h5>
</div>
</div>
<div class="col-sm-4">
<div id="PMPHPGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
<h4>Pump HP:</h4>
<h5>{{tagValues.pump_hp.val | number:3}} HP</h5>
</div>
</div>
<div class="col-sm-4">
<div id="SpeedGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
<h4>Speed:</h4>
<h5>{{tagValues.spm.val | number:3}} SPM</h5>
</div>
</div>
<div class="col-sm-4">
<div id="FluidLoadGauge" class="gauge well" style="width:95%; text-align:center; margin:10px;">
<h4>Fluid Load:</h4>
<h5>{{tagValues.downhole_fluid_load.val | number:3}} lbs.</h5>
</div>
</div>
<div class="col-sm-4">
<div id="LastUpdated" class="gauge well" style="width:95%; text-align:center; margin:10px;">
<h4>Current Stroke:</h4>
<h5>{{cardData.Stroke_Time | date: "medium"}}</h5>
<!--<h5>{{cardData.time_month}}/{{cardData.time_day}}/{{cardData.time_year}} {{cardData.time_hour}}:{{cardData.time_minute}}:{{cardData.time_second}}</h5>-->
</div>
</div>
<div class="col-sm-4">
<div id="cardButton" class="well" style="width:95%; text-align:center; margin:10px">
<a href="/#/files/{{folder}}" class="btn btn-primary active" style="width:40%;">View<br/>Cards</a>
<a href="/#/gaugeOff" class="btn btn-primary active" style="margin-left:10px; width:40%;">Gauge<br/>Off</a>
</div>
</div>
<div class="col-sm-12">
<div class="progress" style="margin:10px;">
<div class="progress-bar progress-bar-striped active" id="surface_stroke_length" role="progressbar" aria-valuenow="{{ tagValues.surface_stroke_length.val }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ tagValues.surface_stroke_length.val }}%;">
Surface Stroke Length: {{ tagValues.surface_stroke_length.val }} in.
</div>
</div>
<div class="progress" style="margin:10px;">
<div class="progress-bar progress-bar-striped active" id="downhole_gross_stroke" role="progressbar" aria-valuenow="{{ tagValues.donwhole_gross_stroke.val }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ tagValues.downhole_gross_stroke.val }}%;">
Downhole Gross Stroke: {{ tagValues.downhole_gross_stroke.val }} in.
</div>
</div>
<div class="progress" style="margin:10px;">
<div class="progress-bar progress-bar-striped active" id="downhole_adjusted_gross_stroke" role="progressbar" aria-valuenow="{{ tagValues.downhole_adjusted_gross_stroke.val }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ tagValues.downhole_adjusted_gross_stroke.val }}%;">
Downhole Adjusted Gross Stroke: {{ tagValues.downhole_adjusted_gross_stroke.val }} in.
</div>
</div>
<div class="progress" style="margin:10px;">
<div class="progress-bar progress-bar-striped active" id="downhole_net_stroke" role="progressbar" aria-valuenow="{{ tagValues.downhole_net_stroke.val }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ tagValues.downhole_net_stroke.val }}%;">
Downhole Net Stroke: {{ tagValues.downhole_net_stroke.val }} in.
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h1>Surface Card</h1>
<div class="surfaceCard" style="height:500px">
<linechart data="card_graph_data" options="surfaceOptions"></linechart>
</div>
</div>
<div class="col-sm-12">
<h1>Downhole Card</h1>
<div class="downholeCard" style="height:500px">
<linechart data="card_graph_data" options="downholeOptions"></linechart>
</div>
</div>
</div>

View File

@@ -23,7 +23,10 @@
"angular-route": "~1.4.9",
"font-awesome": "~4.5.0",
"ngQuickDate": "^1.3.4",
"angular-sails": "^1.1.4"
"angular-sails": "^1.1.4",
"angular-bootstrap": "^1.3.3",
"angular-animate": "^1.5.6",
"angular-google-chart": "^0.1.0"
},
"resolutions": {
"angular": "~1.4.9"

View File

@@ -44,7 +44,8 @@ module.exports.routes = {
* for configuration options and examples. *
* *
***************************************************************************/
"card/latest": "CardController.latest",
"/card/latest": "CardController.latest",
"/card/dates": "CardController.dates",
"/tag_val/latest": "Tag_valController.latest",
"/tag_val/clear/all": "Tag_valController.clearAllTagData",
"/tag_val/clear/:id": "Tag_valController.clearSingleTagData",

View File

@@ -45,6 +45,9 @@ var jsFilesToInject = [
'js/LineChart.js',
'js/dist/sails.io.js',
'js/dist/angular-sails.js',
'js/ui-bootstrap-tpls.js',
'/js/ng-google-chart.js',
'/js/angular-animate.js',
'js/ng/router.js',
'js/ng/controller_main.js',
'js/ng/factory_dateConversion.js',

View File

@@ -111,19 +111,38 @@
<script src="/js/LineChart.js"></script>
<script src="/js/dist/sails.io.js"></script>
<script src="/js/dist/angular-sails.js"></script>
<script src="/js/ui-bootstrap-tpls.js"></script>
<script src="/js/ng-google-chart.js"></script>
<script src="/js/angular-animate.js"></script>
<script src="/js/ng/router.js"></script>
<script src="/js/ng/controller_main.js"></script>
<script src="/js/ng/factory_dateConversion.js"></script>
<script src="/js/ng/factory_cardgraph.js"></script>
<script src="/js/ng/factory_config.js"></script>
<script src="/js/ng/factory_devices.js"></script>
<script src="/js/ng/factory_docs.js"></script>
<script src="/js/ng/factory_multiplecards.js"></script>
<script src="/js/ng/factory_page.js"></script>
<script src="/js/ng/factory_statustimeline.js"></script>
<script src="/js/ng/factory_tags.js"></script>
<script src="/js/ng/controller_cardbyid.js"></script>
<script src="/js/ng/controller_cardcompare.js"></script>
<script src="/js/ng/controller_carddata.js"></script>
<script src="/js/ng/controller_config.js"></script>
<script src="/js/ng/controller_dashboard.js"></script>
<script src="/js/ng/controller_doc.js"></script>
<script src="/js/ng/controller_events.js"></script>
<script src="/js/ng/controller_filelistprevious.js"></script>
<script src="/js/ng/controller_filelisttoday.js"></script>
<script src="/js/ng/controller_fluidshot.js"></script>
<script src="/js/ng/controller_gaugeoff.js"></script>
<script src="/js/ng/controller_notes.js"></script>
<script src="/js/ng/controller_tagVals.js"></script>
<script src="/js/ng/controller_tags.js"></script>
<script src="/js/ng/controller_totals.js"></script>
<script src="/js/ng/controller_welltest.js"></script>
<script src="/js/ng/temp_controller_json.js"></script>
<script src="/js/ng/temp_controller_setup.js"></script>
<!--SCRIPTS END-->
</body>
</html>