Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nengyuanzhang committed Jan 10, 2024
2 parents 0eee010 + 8cec0bc commit 0148b58
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ app.controller('EnergyStoragePowerStationController', function(
SweetAlert) {
$scope.cur_user = JSON.parse($window.localStorage.getItem("myems_admin_ui_current_user"));
$scope.exportdata = '';
$scope.importdata = '';

$scope.getAllCostCenters = function() {
let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
Expand Down Expand Up @@ -236,6 +237,46 @@ app.controller('EnergyStoragePowerStationController', function(
}
});
};


$scope.importEnergyStoragePowerStation = function() {
var modalInstance = $uibModal.open({
templateUrl: 'views/settings/energystoragepowerstation/energystoragepowerstation.import.html',
controller: 'ModalImportEnergyStoragePowerStationCtrl',
windowClass: "animated fadeIn",
resolve: {
params: function() {
return {
};
}
}
});
modalInstance.result.then(function(importdata) {
let headers = { "User-UUID": $scope.cur_user.uuid, "Token": $scope.cur_user.token };
EnergyStoragePowerStationService.importEnergyStoragePowerStation(importdata, headers, function(response) {
if (angular.isDefined(response.status) && response.status === 201) {
toaster.pop({
type: "success",
title: $translate.instant("TOASTER.SUCCESS_TITLE"),
body: $translate.instant("TOASTER.SUCCESS_ADD_BODY", {template: $translate.instant("COMMON.ENERGY_STORAGE_POWER_STATION")}),
showCloseButton: true,
});
$scope.$emit('handleEmitEnergyStoragePowerStationChanged');
} else {
toaster.pop({
type: "error",
title: $translate.instant("TOASTER.ERROR_ADD_BODY", { template: $translate.instant("COMMON.ENERGY_STORAGE_POWER_STATION") }),
body: $translate.instant(response.data.description),
showCloseButton: true,
});
}
});
}, function() {

});
$rootScope.modalInstance = modalInstance;
};

$scope.getAllEnergyStoragePowerStations();
$scope.getAllCostCenters();
$scope.getAllContacts();
Expand Down Expand Up @@ -295,3 +336,16 @@ app.controller('ModalExportEnergyStoragePowerStationCtrl', function($scope, $uib
$uibModalInstance.dismiss('cancel');
};
});


app.controller('ModalImportEnergyStoragePowerStationCtrl', function($scope, $uibModalInstance, params) {

$scope.operation = "SETTING.IMPORT_ENERGY_STORAGE_POWER_STATION";
$scope.ok = function() {
$uibModalInstance.close($scope.importdata);
};

$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ app.factory('EnergyStoragePowerStationService', function($http) {
callback(response);
});
},
importEnergyStoragePowerStation: function(jsonfile, headers, callback) {
$http.post(getAPI()+'energystoragepowerstations/import', {data:jsonfile}, {headers})
importEnergyStoragePowerStation: function(importdata, headers, callback) {
$http.post(getAPI()+'energystoragepowerstations/import', JSON.parse(importdata), {headers})
.then(function (response) {
callback(response);
}, function (response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<uib-tab heading="{{'COMMON.ENERGY_STORAGE_POWER_STATION' | translate}}">
<div class="panel-body" ng-controller="EnergyStoragePowerStationController">
<a ng-click="addEnergyStoragePowerStation()" class="btn btn-primary btn-rounded btn-outline" href=""><i class="fa fa-plus-circle"></i> {{'SETTING.ADD_ENERGY_STORAGE_POWER_STATION' | translate}}</a>
<a ng-click="importEnergyStoragePowerStation()" class="btn btn-primary btn-rounded btn-outline" href=""><i class="fa fa-plus-circle"></i> {{'SETTING.IMPORT' | translate}}</a>
<table class="footable table table-bordered table-hover" data-sort="true" data-page-size="15">
<thead>
<tr>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="inmodal">
<div class="modal-header">
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<form role="form" name="form_energystoragepowerstation" novalidate class="form-horizontal">
<div class="form-group">
<div class="col-sm-12">
<textarea ng-model="importdata" rows="22" cols="100" name="importdata" class="form-control" required="" placeholder=""></textarea>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" ng-click="cancel()">{{'SETTING.CANCEL' | translate}}</button>
<button type="button" ng-disabled="form_energystoragepowerstation.$invalid" class="btn btn-primary" ng-click="ok();">{{'SETTING.IMPORT' | translate}}</button>
</div>
</div>

0 comments on commit 0148b58

Please sign in to comment.