How to use GeneralSettings method in argos

Best JavaScript code snippet using argos

generalsettings.component.ts

Source:generalsettings.component.ts Github

copy

Full Screen

1/*2 * SpurtCommerce3 * version 3.04 * http://www.spurtcommerce.com5 *6 * Copyright (c) 2019 PICCOSOFT7 * Author piccosoft <support@spurtcommerce.com>8 * Licensed under the MIT license.9 */10import {11 ChangeDetectorRef,12 Component,13 ElementRef,14 OnInit,15 ViewChild16} from '@angular/core';17import { Subscription } from 'rxjs/index';18import {19 FormBuilder,20 FormControl,21 FormGroup,22 Validators23} from '@angular/forms';24import { CountrySandbox } from '../../../../../../../core/admin/settings/localizations/country/country.sandbox';25import { ZoneSandbox } from '../../../../../../../core/admin/settings/localizations/zone/zone.sandbox';26import { GeneralSettingSandbox } from '../../../../../../../core/admin/settings/generalsetting/generalsetting.sandbox';27import { Router } from '@angular/router';28import { ConfigService } from '../../../../../../../core/admin/service/config.service';29@Component({30 selector: 'app-spurt-genearlsettingsadd',31 templateUrl: './generalsettings.component.html',32 styleUrls: ['./generalsettings.component.css']33})34export class GeneralSettingComponent implements OnInit {35 // Variable36 @ViewChild('filePath') filePath: ElementRef;37 public postImageUrl: any;38 public defaultImageUrl: any;39 public imageUrl: any;40 private keyword = '';41 public pageSize = '10';42 private offset = 0;43 // Form Group44 public generalSettings: FormGroup;45 public storeName: FormControl;46 public storeOwner: FormControl;47 public address: FormControl;48 public email: FormControl;49 public phonenumber: FormControl;50 public country: FormControl;51 public zone: FormControl;52 public language: FormControl;53 public currency: FormControl;54 public maintenanceMode: FormControl;55 public submitted: any;56 // Language57 constructor(58 private changeDetectRef: ChangeDetectorRef,59 private router: Router,60 public fb: FormBuilder,61 public countrysandbox: CountrySandbox,62 public zonesandbox: ZoneSandbox,63 public generalsettingsandbox: GeneralSettingSandbox,64 private configService: ConfigService65 ) {}66 private subscriptions: Array<Subscription> = [];67 // initially calls initForm,dropdownlist,getGeneralSetting68 ngOnInit() {69 this.pageSize = localStorage.getItem('itemsPerPage')70 ? localStorage.getItem('itemsPerPage')71 : this.pageSize;72 this.defaultImageUrl = '';73 this.imageUrl = this.configService.getImageUrl();74 this.postImageUrl = './assets/upload-banner/upload.png';75 this.initForm();76 this.dropdownlist();77 this.getGeneralSetting();78 }79 /**80 * Handles form 'list' event. Calls sandbox GeneralSetting generalsetting get data function .81 */82 getGeneralSetting() {83 this.generalsettingsandbox.getGeneralSetting();84 }85 dropdownlist() {86 this.countrylist(this.offset, this.keyword);87 this.zonesList(this.offset);88 this.subscribe();89 }90 /**91 * Handles form 'submit' event. Calls sandbox GeneralSetting createGeneralSetting function if form is valid.92 *93 * @param params storing entire value94 */95 onSubmit() {96 this.submitted = true;97 if (this.generalSettings.invalid) {98 return;99 }100 const params: any = {};101 params.storename = this.generalSettings.value.storeName;102 params.storeowner = this.generalSettings.value.storeOwner;103 params.address = this.generalSettings.value.address;104 params.email = this.generalSettings.value.email;105 params.phonenumber = this.generalSettings.value.phonenumber;106 params.country = this.generalSettings.value.country;107 params.zone = this.generalSettings.value.zone;108 if (this.generalSettings.value.maintenanceMode === 'Yes') {109 params.maintenanceMode = 1;110 } else {111 params.maintenanceMode = 0;112 }113 if (this.defaultImageUrl) {114 params.image = this.postImageUrl;115 }116 this.generalsettingsandbox.createGeneralSetting(params);117 }118 // VALIDATION119 get f() {120 return this.generalSettings.controls;121 }122 // Form Group123 initForm() {124 this.generalSettings = this.fb.group({125 storeName: [null],126 storeOwner: [null],127 address: [null],128 email: [null],129 phonenumber: [null],130 country: [null],131 zone: [null],132 maintenanceMode: [null]133 });134 }135 /**136 * Handles form 'list' event. Calls sandbox country countrylist function .137 *138 * @param params storing entire value139 */140 countrylist(offset: number = 0, keyword) {141 const params: any = {};142 params.limit = this.pageSize;143 params.offset = offset;144 params.keyword = this.keyword;145 this.countrysandbox.getcountrieslist(params);146 }147 /**148 * Handles form 'list' event. Calls sandbox Zone getZoneList function .149 *150 * @param params storing entire value151 */152 zonesList(offset: number = 0) {153 const params: any = {};154 params.limit = this.pageSize;155 params.offset = offset;156 params.keyword = this.keyword;157 this.zonesandbox.getZoneList(params);158 }159 // Image Upload160 uploadButtonClick() {161 const el: HTMLElement = this.filePath.nativeElement as HTMLElement;162 el.click();163 }164 /**165 * Handles 'uploadChange' event. calls convertBase64 function166 *167 * @param $event .168 */169 uploadChange($event): void {170 this.convertBase64($event.target);171 }172 /**173 * Handles 'convertBase64' event. finally store the data in postImageUrl174 *175 * @param inputValue .176 */177 convertBase64(inputValue: any): void {178 const file: File = inputValue.files[0];179 const myReader: FileReader = new FileReader();180 myReader.onloadend = e => {181 this.postImageUrl = myReader.result;182 this.defaultImageUrl = myReader.result;183 this.changeDetectRef.detectChanges();184 };185 myReader.readAsDataURL(file);186 }187 // Subscribe general settings data bind form control values188 subscribe() {189 this.subscriptions.push(190 this.generalsettingsandbox.getGeneralSettings$.subscribe(data => {191 if (data && data[0]) {192 this.generalSettings.controls['storeName'].setValue(193 data[0].storeName194 );195 this.generalSettings.controls['storeOwner'].setValue(196 data[0].storeOwner197 );198 this.generalSettings.controls['address'].setValue(199 data[0].storeAddress200 );201 this.generalSettings.controls['country'].setValue(data[0].countryId);202 this.generalSettings.controls['zone'].setValue(data[0].zoneId);203 this.generalSettings.controls['email'].setValue(data[0].storeEmail);204 this.generalSettings.controls['phonenumber'].setValue(205 data[0].storeTelephone206 );207 if (data[0].maintenanceMode === 1) {208 this.generalSettings.patchValue({209 maintenanceMode: 'Yes',210 tc: true211 });212 } else if (data[0].maintenanceMode === 0) {213 this.generalSettings.patchValue({214 maintenanceMode: 'No',215 tc: true216 });217 }218 if (data[0].storeLogoPath && data[0].storeLogo) {219 this.postImageUrl =220 this.imageUrl + '?path=' +221 `${data[0].storeLogoPath}` + '&name=' +222 `${data[0].storeLogo}` +223 '&width=160&height=150';224 this.changeDetectRef.detectChanges();225 }226 }227 })228 );229 }230 // Cancle Navigate to Dashboard231 generalsettingcancel() {232 this.router.navigate(['/dashboard']);233 }...

Full Screen

Full Screen

edit.js

Source:edit.js Github

copy

Full Screen

1(function( $, JetEngineQueryConfig ) {2 'use strict';3 var JetEngineQuery = new Vue( {4 el: '#jet_query_form',5 template: '#jet-query-form',6 data: {7 generalSettings: {},8 postTypes: JetEngineQueryConfig.post_types,9 queryTypes: JetEngineQueryConfig.query_types,10 buttonLabel: JetEngineQueryConfig.edit_button_label,11 isEdit: JetEngineQueryConfig.item_id,12 helpLinks: JetEngineQueryConfig.help_links,13 typesComponents: JetEngineQueryConfig.types_components,14 showDeleteDialog: false,15 saving: false,16 suggestions: [],17 updatingPreview: false,18 previewCount: 0,19 previewBody: null,20 errors: {21 name: false,22 },23 errorNotices: [],24 },25 created: function() {26 this.updatePreview = _.debounce( this.updatePreviewCallback, 500 );27 },28 mounted: function() {29 var self = this;30 if ( JetEngineQueryConfig.item_id ) {31 wp.apiFetch( {32 method: 'get',33 path: JetEngineQueryConfig.api_path_get + JetEngineQueryConfig.item_id,34 } ).then( function( response ) {35 if ( response.success && response.data ) {36 for ( const property in response.data ) {37 self.$set( self.generalSettings, property, response.data[ property ] );38 }39 self.updatePreview();40 } else {41 if ( response.notices.length ) {42 response.notices.forEach( function( notice ) {43 self.$CXNotice.add( {44 message: notice.message,45 type: 'error',46 duration: 15000,47 } );48 //self.errorNotices.push( notice.message );49 } );50 }51 }52 } ).catch( function( e ) {53 console.log( e );54 } );55 } else {56 setTimeout( function() {57 self.$set( self.generalSettings, 'query_type', 'posts' );58 }, 1000 );59 }60 },61 methods: {62 switchPreview: function( value ) {63 this.$set( this.generalSettings, 'show_preview', value );64 this.updatePreview();65 },66 updatePreviewCallback: function() {67 var self = this;68 if ( ! self.generalSettings.show_preview ) {69 return;70 }71 self.updatingPreview = true;72 var preview = {},73 query = {},74 dynamic_query = {};75 if ( self.generalSettings.preview_page ) {76 preview.page = self.generalSettings.preview_page;77 }78 if ( self.generalSettings.preview_query_string ) {79 preview.query_string = self.generalSettings.preview_query_string;80 }81 query = self.generalSettings[ self.generalSettings.query_type ];82 dynamic_query = self.generalSettings[ '__dynamic_' + self.generalSettings.query_type ];83 wp.apiFetch( {84 method: 'post',85 path: JetEngineQueryConfig.api_path_update_preview,86 data: {87 preview: preview,88 query_id: JetEngineQueryConfig.item_id,89 query_type: self.generalSettings.query_type,90 query: query,91 dynamic_query: dynamic_query,92 }93 } ).then( function( response ) {94 if ( response.success ) {95 self.previewCount = response.count;96 self.previewBody = response.data;97 }98 self.updatingPreview = false;99 } ).catch( function( response ) {100 self.updatingPreview = false;101 self.$CXNotice.add( {102 message: response.message,103 type: 'error',104 duration: 7000,105 } );106 } );107 },108 searchPreviewPage: function( value ) {109 var self = this;110 if ( ! value ) {111 self.$set( self.generalSettings, 'preview_page', null );112 self.$set( self.generalSettings, 'preview_page_title', '' );113 self.updatePreview();114 return;115 }116 if ( 2 > value.length ) {117 return;118 }119 wp.apiFetch( {120 method: 'get',121 path: JetEngineQueryConfig.api_path_search_preview + '?_s=' + value,122 } ).then( function( response ) {123 self.suggestions = response.data;124 } ).catch( function( response ) {125 //self.errorNotices.push( response.message );126 self.$CXNotice.add( {127 message: response.message,128 type: 'error',129 duration: 7000,130 } );131 } );132 },133 applySuggestion: function( suggestion ) {134 this.$set( this.generalSettings, 'preview_page_title', suggestion.text );135 this.$set( this.generalSettings, 'preview_page', suggestion.id );136 this.suggestions = [];137 this.updatePreview();138 },139 ensureQueryType: function() {140 if ( this.generalSettings.query_type && ! this.generalSettings[ this.generalSettings.query_type ] ) {141 this.$set( this.generalSettings, this.generalSettings.query_type, {} );142 }143 if ( this.generalSettings.query_type && ! this.generalSettings[ '__dynamic_' + this.generalSettings.query_type ] ) {144 this.$set( this.generalSettings, '__dynamic_' + this.generalSettings.query_type, {} );145 }146 },147 handleFocus: function( where ) {148 if ( this.errors[ where ] ) {149 this.$set( this.errors, where, false );150 this.$CXNotice.close( where );151 //this.errorNotices.splice( 0, this.errorNotices.length );152 }153 },154 setDynamicQuery: function( prop, value ) {155 this.$set( this.generalSettings, prop, value );156 this.updatePreview();157 },158 save: function() {159 var self = this,160 hasErrors = false,161 path = JetEngineQueryConfig.api_path_edit;162 if ( JetEngineQueryConfig.item_id ) {163 path += JetEngineQueryConfig.item_id;164 }165 for ( var errKey in this.errors ) {166 if ( ! self.generalSettings[ errKey ] ) {167 self.$set( this.errors, errKey, true );168 self.$CXNotice.add( {169 message: JetEngineQueryConfig.notices[ errKey ],170 type: 'error',171 duration: 7000,172 }, 'name' );173 //self.errorNotices.push( JetEngineCCTConfig.notices.name );174 hasErrors = true;175 }176 }177 if ( hasErrors ) {178 return;179 }180 self.saving = true;181 wp.apiFetch( {182 method: 'post',183 path: path,184 data: {185 general_settings: self.generalSettings,186 meta_fields: self.metaFields,187 }188 } ).then( function( response ) {189 if ( response.success ) {190 if ( JetEngineQueryConfig.redirect ) {191 window.location = JetEngineQueryConfig.redirect.replace( /%id%/, response.item_id );192 } else {193 self.$CXNotice.add( {194 message: JetEngineQueryConfig.notices.success,195 type: 'success',196 } );197 self.saving = false;198 }199 } else {200 if ( response.notices.length ) {201 response.notices.forEach( function( notice ) {202 self.$CXNotice.add( {203 message: notice.message,204 type: 'error',205 duration: 7000,206 } );207 } );208 self.saving = false;209 }210 }211 } ).catch( function( response ) {212 //self.errorNotices.push( response.message );213 self.$CXNotice.add( {214 message: response.message,215 type: 'error',216 duration: 7000,217 } );218 self.saving = false;219 } );220 },221 }222 } );...

Full Screen

Full Screen

general-settings.service.ts

Source:general-settings.service.ts Github

copy

Full Screen

1import { Injectable } from '@angular/core';2import { Pricing } from './pricing';3import { GeneralSettings } from './general-settings';4import { BehaviorSubject } from 'rxjs/BehaviorSubject';5@Injectable()6export class GeneralSettingsService {7 private generalSettingsObservable: BehaviorSubject<GeneralSettings>;8 /**9 * Returns general settings observable10 * @returns {BehaviorSubject<GeneralSettings>}11 */12 public generalSettings(): BehaviorSubject<GeneralSettings> {13 if(!this.generalSettingsObservable) {14 const { ipcRenderer } = window.electron;15 const initialSettings = GeneralSettings.fromObject(ipcRenderer.sendSync('getGeneralSettings'));16 this.generalSettingsObservable = new BehaviorSubject(initialSettings);17 ipcRenderer.on('generalSettings', (e, settings) => {18 const generalSettings = GeneralSettings.fromObject(settings);19 this.generalSettingsObservable.next(generalSettings);20 });21 }22 return this.generalSettingsObservable;23 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1define('Mobile/Sample/Views/Test', [2], function(3) {4 var resource = window.localizationSettings;5 var __class = declare('Mobile.Sample.Views.Test', [Detail, _Templated], {6 formatSearchQuery: function(searchQuery) {7 return string.substitute('upper(AccountName) like "${0}%"', [this.escapeSearchQuery(searchQuery.toUpperCase())]);8 },9 createToolLayout: function() {10 return this.tools || (this.tools = {11 'tbar': [{12 security: App.getViewSecurity(this.editView, 'update')13 }, {14 security: App.getViewSecurity(this.editView, 'update')15 }, {16 security: App.getViewSecurity(this.editView, 'delete')17 }]18 });19 },20 createLayout: function() {21 return this.layout || (this.layout = [{

Full Screen

Using AI Code Generation

copy

Full Screen

1define('crm/Views/MyView', [2], function(3) {4 var resource = window.localizationSettings;5 var dtFormatResource = window.dateFormatResource;6 var __class = declare('crm.Views.MyView', [View], {

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful