-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13a8d8a
commit 876a5d3
Showing
8 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
seed/static/seed/js/controllers/system_meter_readings_upload_modal_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* SEED Platform (TM), Copyright (c) Alliance for Sustainable Energy, LLC, and other contributors. | ||
* See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md | ||
*/ | ||
angular.module('SEED.controller.system_meter_readings_upload_modal', []).controller('system_meter_readings_upload_modal_controller', [ | ||
'$scope', | ||
'$stateParams', | ||
'$uibModalInstance', | ||
'inventory_group_service', | ||
'inventory_service', | ||
'meter_service', | ||
'uploader_service', | ||
'spinner_utility', | ||
'organization', | ||
'meter', | ||
'datasets', | ||
'filler_cycle', | ||
'refresh_meters_and_readings', | ||
// eslint-disable-next-line func-names | ||
function ( | ||
$scope, | ||
$stateParams, | ||
$uibModalInstance, | ||
inventory_group_service, | ||
inventory_service, | ||
meter_service, | ||
uploader_service, | ||
spinner_utility, | ||
organization, | ||
meter, | ||
datasets, | ||
filler_cycle, | ||
refresh_meters_and_readings | ||
) { | ||
$scope.state = "upload"; | ||
$scope.meter = meter; | ||
$scope.organization = organization; | ||
$scope.organization_id = organization.id; | ||
$scope.datasets = datasets; | ||
$scope.selectedDataset = datasets[0]; | ||
$scope.selectedCycle = filler_cycle; | ||
|
||
|
||
$scope.uploader = { | ||
invalid_file_contents: false, | ||
invalid_csv_extension_alert: false, | ||
invalid_xlsx_extension_alert: false, | ||
progress: 0, | ||
status_message: '' | ||
}; | ||
|
||
$scope.uploaderfunc = (event_message, file /* , progress */) => { | ||
switch (event_message) { | ||
case 'invalid_extension': | ||
$scope.$apply(() => { | ||
$scope.uploader.invalid_csv_extension_alert = true; | ||
$scope.uploader.invalid_xlsx_extension_alert = true; | ||
$scope.uploader.invalid_file_contents = false; | ||
}); | ||
break; | ||
|
||
case 'upload_complete': | ||
$scope.state = "processing"; | ||
uploader_service | ||
.system_meter_upload(file.file_id, $scope.organization.org_id, meter.id) | ||
.then((data) => { | ||
console.log(data) | ||
$scope.state = "confirmation"; | ||
$scope.confirmation_message = data.message | ||
|
||
}) | ||
.catch((err) => present_meter_import_error(err)); | ||
break; | ||
} | ||
}; | ||
|
||
$scope.dismiss = () => { | ||
refresh_meters_and_readings(); | ||
spinner_utility.show(); | ||
$uibModalInstance.dismiss('cancel'); | ||
}; | ||
} | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
seed/static/seed/partials/system_meter_readings_upload_modal.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<div class="modal-header"> | ||
<h4>Add readings to {$ meter.alias $}</h4> | ||
</div> | ||
|
||
<div ng-switch="state"> | ||
<div class="modal-body" ng-switch-when="upload"> | ||
<div class="data_upload_steps container-fluid"> | ||
<div class="alert alert-danger" ng-show="uploader.invalid_csv_extension_alert" style="margin-bottom: 18px" | ||
translate="INVALID_CSV_EXTENSION_ALERT"></div> | ||
<div class="alert alert-danger" ng-show="uploader.invalid_file_contents" style="margin-bottom: 18px" translate> | ||
An error occurred while processing the file. Please ensure that your file meets the required specifications. | ||
</div> | ||
</div> | ||
|
||
<div class="row text-center"> | ||
<button type="button" class="btn btn-primary col-sm-6 center-block" sd-uploader organization-id="organization_id" | ||
sourcetype="MetersReadings" sourceprog="" sourcever="" importrecord="selectedDataset.id" | ||
eventfunc="uploaderfunc(message, file, progress)"> | ||
<span translate>UPLOAD_FILE</span> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div class="modal-body" ng-switch-when="processing"> | ||
<uib-progressbar class="progress-striped active" value="100" type="info"></uib-progressbar> | ||
</div> | ||
|
||
<div class="modal-body" ng-switch-when="confirmation"> | ||
{$ confirmation_message $} | ||
<button type="button" class="btn btn-default" ng-click="dismiss()" translate>Dismiss</button> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters