summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE-common/client/app/services/scheduler
diff options
context:
space:
mode:
authorst782s <statta@research.att.com>2018-01-30 17:29:36 -0500
committerst782s <statta@research.att.com>2018-02-01 15:10:02 -0500
commit21a8761f684745bb300e075c7e98ad897ace9eed (patch)
tree6d585c3fe39fbb42a314941dbc8646e6ccf188cf /ecomp-portal-FE-common/client/app/services/scheduler
parent3af8af1310d5a27cb58be29505573f0bbdc1717c (diff)
Security/ Package Name changes
Issue-ID: PORTAL-174, PORTAL-157, PORTAL-156, PORTAL-148, PORTAL-145, PORTAL-140, PORTAL-133, PORTAL-121, PORTAL-111, PORTAL-88 Includes security fixes, Role Centralization, replace certain ECOMP occurrences etc Change-Id: I3c8b706709c6b92e646e3cbe50c2d660e8a46ef4 Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-portal-FE-common/client/app/services/scheduler')
-rw-r--r--ecomp-portal-FE-common/client/app/services/scheduler/scheduler.service.js217
1 files changed, 217 insertions, 0 deletions
diff --git a/ecomp-portal-FE-common/client/app/services/scheduler/scheduler.service.js b/ecomp-portal-FE-common/client/app/services/scheduler/scheduler.service.js
new file mode 100644
index 00000000..8d7d5c63
--- /dev/null
+++ b/ecomp-portal-FE-common/client/app/services/scheduler/scheduler.service.js
@@ -0,0 +1,217 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+'use strict';
+
+(function () {
+ class SchedulerService {
+ constructor($q, $log, $http, conf, uuid, utilsService,$modal) {
+ this.$q = $q;
+ this.$log = $log;
+ this.$http = $http;
+ this.conf = conf;
+ this.uuid = uuid;
+ this.utilsService = utilsService;
+ this.$modal = $modal;
+ this.widgetInfo={
+ id:'',
+ data:'',
+ param:''
+ }
+ }
+
+ /** get scheduler uuID **/
+ getStatusSchedulerId(schedulerInfo) {
+ let deferred = this.$q.defer();
+ var url = this.conf.api.getSchedulerId
+ this.$http({
+ url: url+'?r='+ Math.random(),
+ method: 'POST',
+ cache: false,
+ timeout: 60000,
+ data:schedulerInfo,
+ headers: {
+ 'X-ECOMP-RequestID':this.uuid.generate()
+ }
+ }).then(res => {
+ if (res == null || res.data == null || this.utilsService.isValidJSON(res.data)== false) {
+ deferred.reject('SchedulerService::getStatusSchedulerId Failed');
+ } else {
+ deferred.resolve(res.data);
+ }
+ }).catch(status => {
+ deferred.reject(status);
+ });
+ return deferred.promise;
+ }
+
+ /** get time slots for Range scheduler **/
+ getTimeslotsForScheduler(schedulerID) {
+ let deferred = this.$q.defer();
+ var url = this.conf.api.getTimeslotsForScheduler + '/' + schedulerID + '?r=' + Math.random();
+ this.$http({
+ url: url,
+ method: 'GET',
+ timeout: 60000,
+ cache: false,
+ headers: {
+ 'X-ECOMP-RequestID':this.uuid.generate()
+ },
+ }).then(res => {
+ this.$log.debug('SchedulerService:: this.conf.api.portalAdmin: ' + JSON.stringify(res));
+ if (res == null || res.data == null || this.utilsService.isValidJSON(res.data)== false) {
+ deferred.reject('SchedulerService::getTimeslotsForScheduler Failed');
+ } else {
+ deferred.resolve(res.data);
+ }
+ }).catch(errRes => {
+ deferred.reject(errRes);
+ });
+ return deferred.promise;
+ }
+
+
+ postSubmitForApprovedTimeslots(approvedTimeSlotsObj) {
+ let deferred = this.$q.defer();
+ let url = this.conf.api.postSubmitForApprovedTimeslots + '?r='+ Math.random();
+ this.$http({
+ url: url,
+ method: 'POST',
+ timeout: 60000,
+ cache: false,
+ data: approvedTimeSlotsObj,
+ headers: {
+ 'X-ECOMP-RequestID':this.uuid.generate()
+ }
+ }).then(res => {
+ if (res == null || res.data == null || this.utilsService.isValidJSON(res.data)== false) {
+ deferred.reject('SchedulerService::postSubmitForapprovedTimeslots');
+ } else {
+ deferred.resolve(res.data);
+ }
+ }).catch(errRes => {
+ deferred.reject(errRes);
+ });
+
+ return deferred.promise;
+ }
+
+ /** Get policy information from BE **/
+ getPolicyInfo() {
+ let deferred = this.$q.defer();
+ let url = this.conf.api.getPolicy + '?r=' + Math.random();
+ this.$http({
+ url: url,
+ method: 'GET',
+ timeout: 60000,
+ cache: false,
+ headers: {
+ 'X-ECOMP-RequestID':this.uuid.generate()
+ }
+ }).then(res => {
+ if (res == null || res.data == null || this.utilsService.isValidJSON(res.data)== false) {
+ deferred.reject('SchedulerService::getPolicyInfo');
+ } else {
+ deferred.resolve(res.data);
+ }
+ }).catch(errRes => {
+ deferred.reject(errRes);
+ });
+
+ return deferred.promise;
+ }
+
+ /** get Scheduler UI constants from BE **/
+ getSchedulerConstants() {
+ let deferred = this.$q.defer();
+ let url = this.conf.api.getSchedulerConstants;
+ this.$http({
+ url: url,
+ method: 'GET',
+ timeout: 60000,
+ cache: false,
+ headers: {
+ 'X-ECOMP-RequestID':this.uuid.generate()
+ }
+ }).then(res => {
+ if (res == null || res.data == null || this.utilsService.isValidJSON(res.data)== false) {
+ deferred.reject('SchedulerService::getSchedulerConstant');
+ } else {
+ deferred.resolve(res.data);
+ }
+ }).catch(errRes => {
+ deferred.reject(errRes);
+ });
+ return deferred.promise;
+ }
+
+
+ /**Opens up the popup for Scheduler UI**/
+ showWidget(widgetId,widgetData,widgetParam) {
+ let deferred = this.$q.defer();
+ this.widgetInfo.id = widgetId;
+ this.widgetInfo.data = widgetData;
+ this.widgetInfo.param = widgetParam;
+ var modalInstance = this.$modal.open({
+ templateUrl: 'app/views/scheduler/scheduler.tpl.html',
+ controller: 'SchedulerCtrl',
+ sizeClass:'modal-large',
+ windowClass:"modal-docked",
+ resolve: {
+ message: function message() {
+ var message = {
+ id: widgetId,
+ data: widgetData,
+ param: widgetParam
+ };
+ return message;
+ }
+ }
+ });
+ modalInstance.result.then(function () {
+ deferred.resolve();
+ });
+ return deferred.promise;
+ };
+
+ getWidgetData(){
+ return this.widgetInfo;
+ }
+ }
+ SchedulerService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4', 'utilsService', '$modal'];
+ angular.module('ecompApp').service('schedulerService', SchedulerService)
+})();