Update 19.11.2022
This commit is contained in:
29
HTML/gcphone/src/store/index.js
Normal file
29
HTML/gcphone/src/store/index.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
import phone from './modules/phone'
|
||||
import contacts from './modules/contacts'
|
||||
import messages from './modules/messages'
|
||||
import appels from './modules/appels'
|
||||
import bank from './modules/bank'
|
||||
import notes from './modules/notes'
|
||||
import bourse from './modules/bourse'
|
||||
import tchat from './modules/tchat'
|
||||
import twitter from './modules/twitter'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
phone,
|
||||
contacts,
|
||||
messages,
|
||||
appels,
|
||||
bank,
|
||||
bourse,
|
||||
notes,
|
||||
tchat,
|
||||
twitter
|
||||
},
|
||||
strict: true
|
||||
})
|
||||
116
HTML/gcphone/src/store/modules/appels.js
Normal file
116
HTML/gcphone/src/store/modules/appels.js
Normal file
@@ -0,0 +1,116 @@
|
||||
import PhoneAPI from './../../PhoneAPI'
|
||||
|
||||
const state = {
|
||||
appelsHistorique: [],
|
||||
appelsInfo: null
|
||||
}
|
||||
|
||||
const getters = {
|
||||
appelsHistorique: ({ appelsHistorique }) => appelsHistorique,
|
||||
appelsInfo: ({ appelsInfo }) => appelsInfo,
|
||||
appelsDisplayName (state, getters) {
|
||||
if (state.appelsInfo === null) {
|
||||
return 'ERROR'
|
||||
}
|
||||
if (state.appelsInfo.hidden === true) {
|
||||
return getters.IntlString('APP_PHONE_NUMBER_HIDDEN')
|
||||
}
|
||||
const num = getters.appelsDisplayNumber
|
||||
const contact = getters.contacts.find(e => e.number === num) || {}
|
||||
return contact.display || getters.IntlString('APP_PHONE_NUMBER_UNKNOWN')
|
||||
},
|
||||
appelsDisplayNumber (state, getters) {
|
||||
if (state.appelsInfo === null) {
|
||||
return 'ERROR'
|
||||
}
|
||||
if (getters.isInitiatorCall === true) {
|
||||
return state.appelsInfo.receiver_num
|
||||
}
|
||||
if (state.appelsInfo.hidden === true) {
|
||||
return '###-####'
|
||||
}
|
||||
return state.appelsInfo.transmitter_num
|
||||
},
|
||||
isInitiatorCall (state, getters) {
|
||||
if (state.appelsInfo === null) {
|
||||
return false
|
||||
}
|
||||
return state.appelsInfo.initiator === true
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
startCall ({ commit }, { numero }) {
|
||||
PhoneAPI.startCall(numero)
|
||||
},
|
||||
acceptCall ({ state }) {
|
||||
PhoneAPI.acceptCall(state.appelsInfo)
|
||||
},
|
||||
rejectCall ({ state }) {
|
||||
PhoneAPI.rejectCall(state.appelsInfo)
|
||||
},
|
||||
ignoreCall ({ commit }) {
|
||||
commit('SET_APPELS_INFO', null)
|
||||
// PhoneAPI.ignoreCall(state.appelsInfo)
|
||||
},
|
||||
appelsDeleteHistorique ({ commit, state }, { numero }) {
|
||||
PhoneAPI.appelsDeleteHistorique(numero)
|
||||
commit('SET_APPELS_HISTORIQUE', state.appelsHistorique.filter(h => {
|
||||
return h.num !== numero
|
||||
}))
|
||||
},
|
||||
appelsDeleteAllHistorique ({ commit }) {
|
||||
PhoneAPI.appelsDeleteAllHistorique()
|
||||
commit('SET_APPELS_HISTORIQUE', [])
|
||||
},
|
||||
resetAppels ({ commit }) {
|
||||
commit('SET_APPELS_HISTORIQUE', [])
|
||||
commit('SET_APPELS_INFO', null)
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_APPELS_HISTORIQUE (state, appelsHistorique) {
|
||||
state.appelsHistorique = appelsHistorique
|
||||
},
|
||||
SET_APPELS_INFO_IF_EMPTY (state, appelsInfo) {
|
||||
if (state.appelsInfo === null) {
|
||||
state.appelsInfo = appelsInfo
|
||||
}
|
||||
},
|
||||
SET_APPELS_INFO (state, appelsInfo) {
|
||||
state.appelsInfo = appelsInfo
|
||||
},
|
||||
SET_APPELS_INFO_IS_ACCEPTS (state, isAccepts) {
|
||||
if (state.appelsInfo !== null) {
|
||||
state.appelsInfo = Object.assign({}, state.appelsInfo, {
|
||||
is_accepts: isAccepts
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line
|
||||
state.appelsHistorique = [{"id":1,"incoming":0,"num":"336-4557","owner":"336-4557","accepts":0,"time":1528374759000},{"id":2,"incoming":0,"num":"police","owner":"336-4557","accepts":1,"time":1528374787000},{"id":3,"incoming":1,"num":"555-5555","owner":"336-4557","accepts":1,"time":1528374566000},{"id":4,"incoming":1,"num":"555-5555","owner":"336-4557","accepts":0,"time":1528371227000}]
|
||||
state.appelsInfo = {
|
||||
initiator: false,
|
||||
id: 5,
|
||||
transmitter_src: 5,
|
||||
// transmitter_num: '###-####',
|
||||
transmitter_num: '336-4557',
|
||||
receiver_src: undefined,
|
||||
// receiver_num: '336-4557',
|
||||
receiver_num: '###-####',
|
||||
is_valid: 0,
|
||||
is_accepts: 0,
|
||||
hidden: 0
|
||||
}
|
||||
}
|
||||
29
HTML/gcphone/src/store/modules/bank.js
Normal file
29
HTML/gcphone/src/store/modules/bank.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import PhoneAPI from './../../PhoneAPI'
|
||||
|
||||
const state = {
|
||||
bankAmont: '0'
|
||||
}
|
||||
|
||||
const getters = {
|
||||
bankAmont: ({ bankAmont }) => bankAmont
|
||||
}
|
||||
|
||||
const actions = {
|
||||
sendpara ({ state }, { id, amount }) {
|
||||
PhoneAPI.callEvent('gcphone:bankTransfer', {id, amount})
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_BANK_AMONT (state, bankAmont) {
|
||||
state.bankAmont = bankAmont
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
|
||||
43
HTML/gcphone/src/store/modules/bourse.js
Normal file
43
HTML/gcphone/src/store/modules/bourse.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const state = {
|
||||
bourseInfo: []
|
||||
}
|
||||
|
||||
const getters = {
|
||||
bourseInfo: ({ bourseInfo }) => bourseInfo
|
||||
}
|
||||
|
||||
const actions = {
|
||||
resetBourse ({ commit }) {
|
||||
commit('SET_BOURSE_INFO', [])
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_BOURSE_INFO (state, bourseInfo) {
|
||||
state.bourseInfo = bourseInfo
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line
|
||||
state.bourseInfo = [{
|
||||
difference: 0,
|
||||
libelle: 'Diamante',
|
||||
price: 1540.2
|
||||
}, {
|
||||
difference: 20,
|
||||
libelle: 'Hierro',
|
||||
price: 54.2
|
||||
}, {
|
||||
difference: -20.5,
|
||||
libelle: 'Cobre',
|
||||
price: 254.2
|
||||
}]
|
||||
}
|
||||
55
HTML/gcphone/src/store/modules/contacts.js
Normal file
55
HTML/gcphone/src/store/modules/contacts.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import PhoneAPI from './../../PhoneAPI'
|
||||
|
||||
const state = {
|
||||
contacts: [],
|
||||
defaultContacts: []
|
||||
}
|
||||
|
||||
const getters = {
|
||||
contacts: ({ contacts, defaultContacts }) => [...contacts, ...defaultContacts]
|
||||
}
|
||||
|
||||
const actions = {
|
||||
updateContact (context, {id, display, number}) {
|
||||
PhoneAPI.updateContact(id, display, number)
|
||||
},
|
||||
addContact (context, {display, number}) {
|
||||
PhoneAPI.addContact(display, number)
|
||||
},
|
||||
deleteContact (context, {id}) {
|
||||
PhoneAPI.deleteContact(id)
|
||||
},
|
||||
resetContact ({ commit }) {
|
||||
commit('SET_CONTACTS', [])
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_CONTACTS (state, contacts) {
|
||||
state.contacts = contacts.sort((a, b) => a.display.localeCompare(b.display))
|
||||
},
|
||||
SET_DEFAULT_CONTACTS (state, contacts) {
|
||||
state.defaultContacts = contacts
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// eslint-disable-next-line
|
||||
state.contacts = [{
|
||||
id: 2,
|
||||
number: '336-4557',
|
||||
display: 'John doe'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
number: '336-4553',
|
||||
display: 'Nop user'
|
||||
}]
|
||||
}
|
||||
104
HTML/gcphone/src/store/modules/messages.js
Normal file
104
HTML/gcphone/src/store/modules/messages.js
Normal file
@@ -0,0 +1,104 @@
|
||||
import PhoneAPI from './../../PhoneAPI'
|
||||
|
||||
const state = {
|
||||
messages: []
|
||||
}
|
||||
|
||||
const getters = {
|
||||
messages: ({ messages }) => messages,
|
||||
nbMessagesUnread: ({ messages }) => {
|
||||
return messages.filter(e => e.isRead !== 1).length
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
setMessages ({ commit }, messages) {
|
||||
commit('SET_MESSAGES', messages)
|
||||
},
|
||||
sendMessage ({ commit }, {phoneNumber, message}) {
|
||||
PhoneAPI.sendMessage(phoneNumber, message)
|
||||
},
|
||||
deleteMessage ({ commit }, { id }) {
|
||||
PhoneAPI.deleteMessage(id)
|
||||
},
|
||||
deleteMessagesNumber ({ commit, state }, { num }) {
|
||||
PhoneAPI.deleteMessagesNumber(num)
|
||||
commit('SET_MESSAGES', state.messages.filter(mess => {
|
||||
return mess.transmitter !== num
|
||||
}))
|
||||
},
|
||||
deleteAllMessages ({ commit }) {
|
||||
PhoneAPI.deleteAllMessages()
|
||||
commit('SET_MESSAGES', [])
|
||||
},
|
||||
setMessageRead ({ commit }, num) {
|
||||
PhoneAPI.setMessageRead(num)
|
||||
commit('SET_MESSAGES_READ', { num })
|
||||
},
|
||||
resetMessage ({ commit }) {
|
||||
commit('SET_MESSAGES', [])
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_MESSAGES (state, messages) {
|
||||
state.messages = messages
|
||||
},
|
||||
ADD_MESSAGE (state, message) {
|
||||
state.messages.push(message)
|
||||
},
|
||||
SET_MESSAGES_READ (state, { num }) {
|
||||
for (let i = 0; i < state.messages.length; i += 1) {
|
||||
if (state.messages[i].transmitter === num && state.messages[i].isRead !== 1) {
|
||||
state.messages[i].isRead = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const time = new Date().getTime()
|
||||
const numRandom = '' + Math.floor(Math.random() * 10000000)
|
||||
state.messages = [
|
||||
{id: 0, transmitter: '0000', receiver: '06', time: time - 160, message: '#666-123', isRead: 1, owner: 0},
|
||||
{id: 1, transmitter: numRandom, receiver: '06', time: time - 160, message: 'Salut sa va ?!!!', isRead: 1, owner: 0},
|
||||
{id: 2, transmitter: numRandom, time, message: 'Tu fait quoi?', isRead: 1, owner: 0},
|
||||
{id: 3, transmitter: numRandom, time, message: 'Oui est toi ?', isRead: 1, owner: 1},
|
||||
{id: 4, transmitter: numRandom, time, message: 'GPS : 244 - 123', isRead: 1, owner: 0},
|
||||
{id: 2, transmitter: numRandom, time, message: 'Tu fait quoi?', isRead: 1, owner: 0},
|
||||
{id: 3, transmitter: numRandom, time, message: 'Oui est toi ?', isRead: 1, owner: 1},
|
||||
{id: 4, transmitter: numRandom, time, message: 'GPS : 244 - 123', isRead: 1, owner: 0},
|
||||
{id: 2, transmitter: numRandom, time, message: 'Tu fait quoi?', isRead: 1, owner: 0},
|
||||
{id: 3, transmitter: numRandom, time, message: 'Oui est toi ?', isRead: 1, owner: 1},
|
||||
{id: 4, transmitter: numRandom, time, message: 'GPS : 244 - 123', isRead: 1, owner: 0},
|
||||
{id: 2, transmitter: numRandom, time, message: 'Tu fait quoi?', isRead: 1, owner: 0},
|
||||
{id: 3, transmitter: numRandom, time, message: 'Oui est toi ?', isRead: 1, owner: 1},
|
||||
{id: 4, transmitter: numRandom, time, message: 'GPS : 244 - 123', isRead: 1, owner: 0},
|
||||
{id: 2, transmitter: numRandom, time, message: 'Tu fait quoi?', isRead: 1, owner: 0},
|
||||
{id: 3, transmitter: numRandom, time, message: 'Oui est toi ?', isRead: 1, owner: 1},
|
||||
{id: 4, transmitter: numRandom, time, message: 'GPS : 244 - 123', isRead: 1, owner: 0},
|
||||
{id: 2, transmitter: numRandom, time, message: 'Tu fait quoi?', isRead: 1, owner: 0},
|
||||
{id: 3, transmitter: numRandom, time, message: 'Oui est toi ?', isRead: 1, owner: 1},
|
||||
{id: 4, transmitter: numRandom, time, message: 'GPS : 244 - 123', isRead: 1, owner: 0},
|
||||
{id: 2, transmitter: numRandom, time, message: 'Tu fait quoi?', isRead: 1, owner: 0},
|
||||
{id: 3, transmitter: numRandom, time, message: 'Oui est toi ?', isRead: 1, owner: 1},
|
||||
{id: 4, transmitter: numRandom, time, message: 'GPS: 244.21, -123.15', isRead: 1, owner: 0},
|
||||
{id: 5, transmitter: 'police', time, message: 'Tu fait quoi?', isRead: 1, owner: 1},
|
||||
{id: 6, transmitter: 'ambulance', time, message: 'Oui est toi ?', isRead: 1, owner: 1},
|
||||
{id: 7, transmitter: '01', time, message: 'Salut sa va ?', isRead: 1, owner: 0},
|
||||
{id: 8, transmitter: '01', time, message: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', isRead: 0, owner: 1},
|
||||
{id: 9, transmitter: '01', time, message: 'GPS: -1034.5810546875, -2734.1027832031', isRead: 1, owner: 0},
|
||||
{id: 44, transmitter: '01', time, message: 'https://i.imgur.com/gthahbs.png', isRead: 1, owner: 0},
|
||||
{id: 10, transmitter: '02', time, message: 'Salut sa va ?', isRead: 1, owner: 0},
|
||||
{id: 11, transmitter: '04', time, message: 'Salut sa va ?', isRead: 1, owner: 0},
|
||||
{id: 12, transmitter: '04', time, message: 'Salut sa va ?', isRead: 1, owner: 0},
|
||||
{id: 13, transmitter: '09', time, message: 'Tu sais pas !', isRead: 1, owner: 0}
|
||||
]
|
||||
}
|
||||
116
HTML/gcphone/src/store/modules/notes.js
Normal file
116
HTML/gcphone/src/store/modules/notes.js
Normal file
@@ -0,0 +1,116 @@
|
||||
import PhoneAPI from './../../PhoneAPI'
|
||||
const LOCAL_NAME = 'gc_notes_channels'
|
||||
|
||||
let NotesAudio = null
|
||||
|
||||
const state = {
|
||||
channels: JSON.parse(localStorage[LOCAL_NAME] || null) || [],
|
||||
currentChannel: null,
|
||||
messagesChannel: []
|
||||
}
|
||||
|
||||
const getters = {
|
||||
notesChannels: ({ channels }) => channels,
|
||||
notesCurrentChannel: ({ currentChannel }) => currentChannel,
|
||||
notesMessages: ({ messagesChannel }) => messagesChannel
|
||||
}
|
||||
|
||||
const actions = {
|
||||
notesReset ({commit}) {
|
||||
commit('NOTES_SET_MESSAGES', { messages: [] })
|
||||
commit('NOTES_SET_CHANNEL', { channel: null })
|
||||
commit('NOTES_REMOVES_ALL_CHANNELS')
|
||||
},
|
||||
notesSetChannel ({ state, commit, dispatch }, { channel }) {
|
||||
if (state.currentChannel !== channel) {
|
||||
commit('NOTES_SET_MESSAGES', { messages: [] })
|
||||
commit('NOTES_SET_CHANNEL', { channel })
|
||||
dispatch('notesGetMessagesChannel', { channel })
|
||||
}
|
||||
},
|
||||
notesAddMessage ({ state, commit, getters }, { message }) {
|
||||
const channel = message.channel
|
||||
if (state.channels.find(e => e.channel === channel) !== undefined) {
|
||||
if (NotesAudio !== null) {
|
||||
NotesAudio.pause()
|
||||
NotesAudio = null
|
||||
}
|
||||
NotesAudio = new Audio('/html/static/sound/tchatNotification.ogg')
|
||||
NotesAudio.volume = getters.volume
|
||||
NotesAudio.play()
|
||||
}
|
||||
commit('NOTES_ADD_MESSAGES', { message })
|
||||
},
|
||||
notesAddChannel ({ commit }, { channel }) {
|
||||
commit('NOTES_ADD_CHANNELS', { channel })
|
||||
},
|
||||
notesRemoveChannel ({ commit }, { channel }) {
|
||||
commit('NOTES_REMOVES_CHANNELS', { channel })
|
||||
},
|
||||
notesGetMessagesChannel ({ commit }, { channel }) {
|
||||
PhoneAPI.notesGetMessagesChannel(channel)
|
||||
},
|
||||
notesSendMessage (state, { channel, message }) {
|
||||
PhoneAPI.notesSendMessage(channel, message)
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
NOTES_SET_CHANNEL (state, { channel }) {
|
||||
state.currentChannel = channel
|
||||
},
|
||||
NOTES_ADD_CHANNELS (state, { channel }) {
|
||||
state.channels.push({
|
||||
channel
|
||||
})
|
||||
localStorage[LOCAL_NAME] = JSON.stringify(state.channels)
|
||||
},
|
||||
NOTES_REMOVES_CHANNELS (state, { channel }) {
|
||||
state.channels = state.channels.filter(c => {
|
||||
return c.channel !== channel
|
||||
})
|
||||
localStorage[LOCAL_NAME] = JSON.stringify(state.channels)
|
||||
},
|
||||
NOTES_REMOVES_ALL_CHANNELS (state) {
|
||||
state.channels = []
|
||||
localStorage[LOCAL_NAME] = JSON.stringify(state.channels)
|
||||
},
|
||||
NOTES_ADD_MESSAGES (state, { message }) {
|
||||
if (message.channel === state.currentChannel) {
|
||||
state.messagesChannel.push(message)
|
||||
}
|
||||
},
|
||||
NOTES_SET_MESSAGES (state, { messages }) {
|
||||
state.messagesChannel = messages
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
state.currentChannel = 'debug'
|
||||
state.messagesChannel = JSON.parse('[{"channel":"teste","message":"teste","id":6,"time":1528671680000},{"channel":"teste","message":"Hop","id":5,"time":1528671153000}]')
|
||||
for (let i = 0; i < 200; i++) {
|
||||
state.messagesChannel.push(Object.assign({}, state.messagesChannel[0], { id: 100 + i, message: 'mess ' + i }))
|
||||
}
|
||||
state.messagesChannel.push({
|
||||
message: 'Message sur plusieur ligne car il faut bien !!! Ok !',
|
||||
id: 5000,
|
||||
time: new Date().getTime()
|
||||
})
|
||||
state.messagesChannel.push({
|
||||
message: 'Message sur plusieur ligne car il faut bien !!! Ok !',
|
||||
id: 5000,
|
||||
time: new Date().getTime()
|
||||
})
|
||||
state.messagesChannel.push({
|
||||
message: 'Message sur plusieur ligne car il faut bien !!! Ok !',
|
||||
id: 5000,
|
||||
time: new Date(4567845).getTime()
|
||||
})
|
||||
}
|
||||
229
HTML/gcphone/src/store/modules/phone.js
Normal file
229
HTML/gcphone/src/store/modules/phone.js
Normal file
@@ -0,0 +1,229 @@
|
||||
import Vue from 'vue'
|
||||
import PhoneAPI from './../../PhoneAPI'
|
||||
|
||||
const state = {
|
||||
show: process.env.NODE_ENV !== 'production',
|
||||
tempoHide: false,
|
||||
myPhoneNumber: '###-####',
|
||||
background: JSON.parse(window.localStorage['gc_background'] || null),
|
||||
coque: JSON.parse(window.localStorage['gc_coque'] || null),
|
||||
sonido: JSON.parse(window.localStorage['gc_sonido'] || null),
|
||||
zoom: window.localStorage['gc_zoom'] || '100%',
|
||||
volume: parseFloat(window.localStorage['gc_volume']) || 1,
|
||||
mouse: window.localStorage['gc_mouse'] === 'true',
|
||||
lang: window.localStorage['gc_language'],
|
||||
config: {
|
||||
reseau: 'ElBichop',
|
||||
useFormatNumberFrance: false,
|
||||
apps: [],
|
||||
themeColor: '#2A56C6',
|
||||
colors: ['#2A56C6'],
|
||||
language: {}
|
||||
}
|
||||
}
|
||||
|
||||
PhoneAPI.setUseMouse(state.mouse)
|
||||
|
||||
const getters = {
|
||||
show: ({ show }) => show,
|
||||
tempoHide: ({ tempoHide }) => tempoHide,
|
||||
myPhoneNumber: ({ myPhoneNumber }) => myPhoneNumber,
|
||||
volume: ({ volume }) => volume,
|
||||
enableTakePhoto: ({ config }) => config.enableTakePhoto === true,
|
||||
background: ({ background, config }) => {
|
||||
if (background === null) {
|
||||
if (config.background_default !== undefined) {
|
||||
return config.background_default
|
||||
}
|
||||
return {
|
||||
label: 'Default',
|
||||
value: 'default.jpg'
|
||||
}
|
||||
}
|
||||
return background
|
||||
},
|
||||
backgroundLabel: (state, getters) => getters.background.label,
|
||||
backgroundURL: (state, getters) => {
|
||||
if (getters.background.value.startsWith('http') === true) {
|
||||
return getters.background.value
|
||||
}
|
||||
return '/html/static/img/background/' + getters.background.value
|
||||
},
|
||||
coque: ({ coque, config }) => {
|
||||
if (coque === null) {
|
||||
if (config && config.coque_default !== undefined) {
|
||||
return config.coque_default
|
||||
}
|
||||
return {
|
||||
label: 'base',
|
||||
value: 'base.jpg'
|
||||
}
|
||||
}
|
||||
return coque
|
||||
},
|
||||
sonido: ({ sonido, config }) => {
|
||||
if (sonido === null) {
|
||||
if (config && config.sonido_default !== undefined) {
|
||||
return config.sonido_default
|
||||
}
|
||||
return {
|
||||
label: 'Panters',
|
||||
value: 'ring.ogg'
|
||||
}
|
||||
}
|
||||
return sonido
|
||||
},
|
||||
coqueLabel: (state, getters) => getters.coque.label,
|
||||
sonidoLabel: (state, getters) => getters.sonido.label,
|
||||
zoom: ({ zoom }) => zoom,
|
||||
useMouse: ({ mouse }) => mouse,
|
||||
config: ({ config }) => config,
|
||||
warningMessageCount: ({ config }) => config.warningMessageCount || 250,
|
||||
useFormatNumberFrance: ({ config }) => config.useFormatNumberFrance,
|
||||
themeColor: ({ config }) => config.themeColor,
|
||||
colors: ({ config }) => config.colors,
|
||||
Apps: ({ config, lang }, getters) => config.apps
|
||||
.filter(app => app.enabled !== false)
|
||||
.map(app => {
|
||||
if (app.puceRef !== undefined) {
|
||||
app.puce = getters[app.puceRef]
|
||||
}
|
||||
const keyName = `${lang}__name`
|
||||
app.intlName = app[keyName] || app.name
|
||||
return app
|
||||
}),
|
||||
AppsHome: (state, getters) => getters.Apps.filter(app => app.inHomePage === true),
|
||||
availableLanguages ({ config }) {
|
||||
const langKey = Object.keys(config.language)
|
||||
const AvailableLanguage = {}
|
||||
for (const key of langKey) {
|
||||
AvailableLanguage[config.language[key].NAME] = key
|
||||
}
|
||||
return AvailableLanguage
|
||||
},
|
||||
IntlString ({ config, lang }) {
|
||||
lang = lang || config.defaultLanguage
|
||||
if (config.language[lang] === undefined) {
|
||||
return (LABEL) => LABEL
|
||||
}
|
||||
return (LABEL, defaultValue) => {
|
||||
return config.language[lang][LABEL] || defaultValue || LABEL
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const actions = {
|
||||
async loadConfig ({ commit, state }) {
|
||||
const config = await PhoneAPI.getConfig()
|
||||
const keyLang = Object.keys(config.language)
|
||||
for (const key of keyLang) {
|
||||
const timeAgoConf = config.language[key].TIMEAGO
|
||||
if (timeAgoConf !== undefined) {
|
||||
Vue.prototype.$timeago.addLocale(key, timeAgoConf)
|
||||
}
|
||||
}
|
||||
Vue.prototype.$timeago.setCurrentLocale(state.lang)
|
||||
if (config.defaultContacts !== undefined) {
|
||||
commit('SET_DEFAULT_CONTACTS', config.defaultContacts)
|
||||
}
|
||||
commit('SET_CONFIG', config)
|
||||
},
|
||||
setEnableApp ({ commit, state }, { appName, enable = true }) {
|
||||
commit('SET_APP_ENABLE', { appName, enable })
|
||||
},
|
||||
setVisibility ({ commit }, show) {
|
||||
commit('SET_PHONE_VISIBILITY', show)
|
||||
},
|
||||
setZoon ({ commit }, zoom) {
|
||||
window.localStorage['gc_zoom'] = zoom
|
||||
commit('SET_ZOOM', zoom)
|
||||
},
|
||||
setBackground ({ commit }, background) {
|
||||
window.localStorage['gc_background'] = JSON.stringify(background)
|
||||
commit('SET_BACKGROUND', background)
|
||||
},
|
||||
setCoque ({ commit }, coque) {
|
||||
window.localStorage['gc_coque'] = JSON.stringify(coque)
|
||||
commit('SET_COQUE', coque)
|
||||
},
|
||||
setSonido ({ commit }, sonido) {
|
||||
window.localStorage['gc_sonido'] = JSON.stringify(sonido)
|
||||
commit('SET_SONIDO', sonido)
|
||||
},
|
||||
setVolume ({ commit }, volume) {
|
||||
window.localStorage['gc_volume'] = volume
|
||||
commit('SET_VOLUME', volume)
|
||||
},
|
||||
setLanguage ({ commit }, lang) {
|
||||
window.localStorage['gc_language'] = lang
|
||||
Vue.prototype.$timeago.setCurrentLocale(lang)
|
||||
commit('SET_LANGUAGE', lang)
|
||||
},
|
||||
setMouseSupport ({ commit }, value) {
|
||||
window.localStorage['gc_mouse'] = value
|
||||
PhoneAPI.setUseMouse(value)
|
||||
commit('SET_MOUSE_SUPPORT', value)
|
||||
},
|
||||
closePhone () {
|
||||
PhoneAPI.closePhone()
|
||||
},
|
||||
resetPhone ({ dispatch, getters }) {
|
||||
dispatch('setZoon', '100%')
|
||||
dispatch('setVolume', 1)
|
||||
dispatch('setBackground', getters.config.background_default)
|
||||
dispatch('setCoque', getters.config.coque_default)
|
||||
dispatch('setSonido', getters.config.sonido_default)
|
||||
dispatch('setLanguage', 'fr_FR')
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_CONFIG (state, config) {
|
||||
state.config = config
|
||||
},
|
||||
SET_APP_ENABLE (state, {appName, enable}) {
|
||||
const appIndex = state.config.apps.findIndex(app => app.name === appName)
|
||||
if (appIndex !== -1) {
|
||||
Vue.set(state.config.apps[appIndex], 'enabled', enable)
|
||||
}
|
||||
},
|
||||
SET_PHONE_VISIBILITY (state, show) {
|
||||
state.show = show
|
||||
state.tempoHide = false
|
||||
},
|
||||
SET_TEMPO_HIDE (state, hide) {
|
||||
state.tempoHide = hide
|
||||
},
|
||||
SET_MY_PHONE_NUMBER (state, myPhoneNumber) {
|
||||
state.myPhoneNumber = myPhoneNumber
|
||||
},
|
||||
SET_BACKGROUND (state, background) {
|
||||
state.background = background
|
||||
},
|
||||
SET_COQUE (state, coque) {
|
||||
state.coque = coque
|
||||
},
|
||||
SET_SONIDO (state, sonido) {
|
||||
state.sonido = sonido
|
||||
},
|
||||
SET_ZOOM (state, zoom) {
|
||||
state.zoom = zoom
|
||||
},
|
||||
SET_VOLUME (state, volume) {
|
||||
state.volume = volume
|
||||
},
|
||||
SET_LANGUAGE (state, lang) {
|
||||
state.lang = lang
|
||||
},
|
||||
SET_MOUSE_SUPPORT (state, value) {
|
||||
state.mouse = value
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
116
HTML/gcphone/src/store/modules/tchat.js
Normal file
116
HTML/gcphone/src/store/modules/tchat.js
Normal file
@@ -0,0 +1,116 @@
|
||||
import PhoneAPI from './../../PhoneAPI'
|
||||
const LOCAL_NAME = 'gc_tchat_channels'
|
||||
|
||||
let TchatAudio = null
|
||||
|
||||
const state = {
|
||||
channels: JSON.parse(localStorage[LOCAL_NAME] || null) || [],
|
||||
currentChannel: null,
|
||||
messagesChannel: []
|
||||
}
|
||||
|
||||
const getters = {
|
||||
tchatChannels: ({ channels }) => channels,
|
||||
tchatCurrentChannel: ({ currentChannel }) => currentChannel,
|
||||
tchatMessages: ({ messagesChannel }) => messagesChannel
|
||||
}
|
||||
|
||||
const actions = {
|
||||
tchatReset ({commit}) {
|
||||
commit('TCHAT_SET_MESSAGES', { messages: [] })
|
||||
commit('TCHAT_SET_CHANNEL', { channel: null })
|
||||
commit('TCHAT_REMOVES_ALL_CHANNELS')
|
||||
},
|
||||
tchatSetChannel ({ state, commit, dispatch }, { channel }) {
|
||||
if (state.currentChannel !== channel) {
|
||||
commit('TCHAT_SET_MESSAGES', { messages: [] })
|
||||
commit('TCHAT_SET_CHANNEL', { channel })
|
||||
dispatch('tchatGetMessagesChannel', { channel })
|
||||
}
|
||||
},
|
||||
tchatAddMessage ({ state, commit, getters }, { message }) {
|
||||
const channel = message.channel
|
||||
if (state.channels.find(e => e.channel === channel) !== undefined) {
|
||||
if (TchatAudio !== null) {
|
||||
TchatAudio.pause()
|
||||
TchatAudio = null
|
||||
}
|
||||
TchatAudio = new Audio('/html/static/sound/tchatNotification.ogg')
|
||||
TchatAudio.volume = getters.volume
|
||||
TchatAudio.play()
|
||||
}
|
||||
commit('TCHAT_ADD_MESSAGES', { message })
|
||||
},
|
||||
tchatAddChannel ({ commit }, { channel }) {
|
||||
commit('TCHAT_ADD_CHANNELS', { channel })
|
||||
},
|
||||
tchatRemoveChannel ({ commit }, { channel }) {
|
||||
commit('TCHAT_REMOVES_CHANNELS', { channel })
|
||||
},
|
||||
tchatGetMessagesChannel ({ commit }, { channel }) {
|
||||
PhoneAPI.tchatGetMessagesChannel(channel)
|
||||
},
|
||||
tchatSendMessage (state, { channel, message }) {
|
||||
PhoneAPI.tchatSendMessage(channel, message)
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
TCHAT_SET_CHANNEL (state, { channel }) {
|
||||
state.currentChannel = channel
|
||||
},
|
||||
TCHAT_ADD_CHANNELS (state, { channel }) {
|
||||
state.channels.push({
|
||||
channel
|
||||
})
|
||||
localStorage[LOCAL_NAME] = JSON.stringify(state.channels)
|
||||
},
|
||||
TCHAT_REMOVES_CHANNELS (state, { channel }) {
|
||||
state.channels = state.channels.filter(c => {
|
||||
return c.channel !== channel
|
||||
})
|
||||
localStorage[LOCAL_NAME] = JSON.stringify(state.channels)
|
||||
},
|
||||
TCHAT_REMOVES_ALL_CHANNELS (state) {
|
||||
state.channels = []
|
||||
localStorage[LOCAL_NAME] = JSON.stringify(state.channels)
|
||||
},
|
||||
TCHAT_ADD_MESSAGES (state, { message }) {
|
||||
if (message.channel === state.currentChannel) {
|
||||
state.messagesChannel.push(message)
|
||||
}
|
||||
},
|
||||
TCHAT_SET_MESSAGES (state, { messages }) {
|
||||
state.messagesChannel = messages
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
state.currentChannel = 'debug'
|
||||
state.messagesChannel = JSON.parse('[{"channel":"teste","message":"teste","id":6,"time":1528671680000},{"channel":"teste","message":"Hop","id":5,"time":1528671153000}]')
|
||||
for (let i = 0; i < 200; i++) {
|
||||
state.messagesChannel.push(Object.assign({}, state.messagesChannel[0], { id: 100 + i, message: 'mess ' + i }))
|
||||
}
|
||||
state.messagesChannel.push({
|
||||
message: 'Message sur plusieur ligne car il faut bien !!! Ok !',
|
||||
id: 5000,
|
||||
time: new Date().getTime()
|
||||
})
|
||||
state.messagesChannel.push({
|
||||
message: 'Message sur plusieur ligne car il faut bien !!! Ok !',
|
||||
id: 5000,
|
||||
time: new Date().getTime()
|
||||
})
|
||||
state.messagesChannel.push({
|
||||
message: 'Message sur plusieur ligne car il faut bien !!! Ok !',
|
||||
id: 5000,
|
||||
time: new Date(4567845).getTime()
|
||||
})
|
||||
}
|
||||
205
HTML/gcphone/src/store/modules/twitter.js
Normal file
205
HTML/gcphone/src/store/modules/twitter.js
Normal file
@@ -0,0 +1,205 @@
|
||||
import PhoneAPI from './../../PhoneAPI'
|
||||
import Vue from 'vue'
|
||||
|
||||
const state = {
|
||||
twitterUsername: localStorage['gcphone_twitter_username'],
|
||||
twitterPassword: localStorage['gcphone_twitter_password'],
|
||||
twitterAvatarUrl: localStorage['gcphone_twitter_avatarUrl'],
|
||||
twitterNotification: localStorage['gcphone_twitter_notif'] ? parseInt(localStorage['gcphone_twitter_notif']) : 1,
|
||||
twitterNotificationSound: localStorage['gcphone_twitter_notif_sound'] !== 'false',
|
||||
tweets: [],
|
||||
favoriteTweets: []
|
||||
}
|
||||
|
||||
const getters = {
|
||||
twitterUsername: ({ twitterUsername }) => twitterUsername,
|
||||
twitterPassword: ({ twitterPassword }) => twitterPassword,
|
||||
twitterAvatarUrl: ({ twitterAvatarUrl }) => twitterAvatarUrl,
|
||||
twitterNotification: ({ twitterNotification }) => twitterNotification,
|
||||
twitterNotificationSound: ({ twitterNotificationSound }) => twitterNotificationSound,
|
||||
tweets: ({ tweets }) => tweets,
|
||||
favoriteTweets: ({ favoriteTweets }) => favoriteTweets
|
||||
}
|
||||
|
||||
const actions = {
|
||||
twitterCreateNewAccount (_, {username, password, avatarUrl}) {
|
||||
PhoneAPI.twitter_createAccount(username, password, avatarUrl)
|
||||
},
|
||||
twitterLogin ({ commit }, { username, password }) {
|
||||
PhoneAPI.twitter_login(username, password)
|
||||
},
|
||||
twitterChangePassword ({ state }, newPassword) {
|
||||
PhoneAPI.twitter_changePassword(state.twitterUsername, state.twitterPassword, newPassword)
|
||||
},
|
||||
twitterLogout ({ commit }) {
|
||||
localStorage.removeItem('gcphone_twitter_username')
|
||||
localStorage.removeItem('gcphone_twitter_password')
|
||||
localStorage.removeItem('gcphone_twitter_avatarUrl')
|
||||
commit('UPDATE_ACCOUNT', {
|
||||
username: undefined,
|
||||
password: undefined,
|
||||
avatarUrl: undefined
|
||||
})
|
||||
},
|
||||
twitterSetAvatar ({ state }, { avatarUrl }) {
|
||||
PhoneAPI.twitter_setAvatar(state.twitterUsername, state.twitterPassword, avatarUrl)
|
||||
},
|
||||
twitterPostTweet ({ state, commit }, { message }) {
|
||||
if (/^https?:\/\/.*\.(png|jpg|jpeg|gif)$/.test(message)) {
|
||||
PhoneAPI.twitter_postTweetImg(state.twitterUsername, state.twitterPassword, message)
|
||||
} else {
|
||||
PhoneAPI.twitter_postTweet(state.twitterUsername, state.twitterPassword, PhoneAPI.convertEmoji(message))
|
||||
}
|
||||
},
|
||||
twitterToogleLike ({ state }, { tweetId }) {
|
||||
PhoneAPI.twitter_toggleLikeTweet(state.twitterUsername, state.twitterPassword, tweetId)
|
||||
},
|
||||
setAccount ({ commit }, data) {
|
||||
localStorage['gcphone_twitter_username'] = data.username
|
||||
localStorage['gcphone_twitter_password'] = data.password
|
||||
localStorage['gcphone_twitter_avatarUrl'] = data.avatarUrl
|
||||
commit('UPDATE_ACCOUNT', data)
|
||||
},
|
||||
addTweet ({ commit, state }, tweet) {
|
||||
let notif = state.twitterNotification === 2
|
||||
if (state.twitterNotification === 1) {
|
||||
notif = tweet.message && tweet.message.toLowerCase().indexOf(state.twitterUsername.toLowerCase()) !== -1
|
||||
}
|
||||
if (notif === true) {
|
||||
Vue.notify({
|
||||
message: tweet.message,
|
||||
title: tweet.author + ' :',
|
||||
icon: 'twitter',
|
||||
sound: state.twitterNotificationSound ? 'Twitter_Sound_Effect.ogg' : undefined
|
||||
})
|
||||
}
|
||||
commit('ADD_TWEET', { tweet })
|
||||
},
|
||||
fetchTweets ({ state }) {
|
||||
PhoneAPI.twitter_getTweets(state.twitterUsername, state.twitterPassword)
|
||||
},
|
||||
fetchFavoriteTweets ({ state }) {
|
||||
PhoneAPI.twitter_getFavoriteTweets(state.twitterUsername, state.twitterPassword)
|
||||
},
|
||||
setTwitterNotification ({ commit }, value) {
|
||||
localStorage['gcphone_twitter_notif'] = value
|
||||
commit('SET_TWITTER_NOTIFICATION', { notification: value })
|
||||
},
|
||||
setTwitterNotificationSound ({ commit }, value) {
|
||||
localStorage['gcphone_twitter_notif_sound'] = value
|
||||
commit('SET_TWITTER_NOTIFICATION_SOUND', { notificationSound: value })
|
||||
}
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_TWITTER_NOTIFICATION (state, { notification }) {
|
||||
state.twitterNotification = notification
|
||||
},
|
||||
SET_TWITTER_NOTIFICATION_SOUND (state, { notificationSound }) {
|
||||
state.twitterNotificationSound = notificationSound
|
||||
},
|
||||
UPDATE_ACCOUNT (state, { username, password, avatarUrl }) {
|
||||
state.twitterUsername = username
|
||||
state.twitterPassword = password
|
||||
state.twitterAvatarUrl = avatarUrl
|
||||
},
|
||||
SET_TWEETS (state, { tweets }) {
|
||||
state.tweets = tweets
|
||||
},
|
||||
SET_FAVORITE_TWEETS (state, { tweets }) {
|
||||
state.favoriteTweets = tweets
|
||||
},
|
||||
ADD_TWEET (state, { tweet }) {
|
||||
state.tweets = [tweet, ...state.tweets]
|
||||
},
|
||||
UPDATE_TWEET_LIKE (state, { tweetId, likes }) {
|
||||
const tweetIndex = state.tweets.findIndex(t => t.id === tweetId)
|
||||
if (tweetIndex !== -1) {
|
||||
state.tweets[tweetIndex].likes = likes
|
||||
}
|
||||
const tweetIndexFav = state.favoriteTweets.findIndex(t => t.id === tweetId)
|
||||
if (tweetIndexFav !== -1) {
|
||||
state.favoriteTweets[tweetIndexFav].likes = likes
|
||||
}
|
||||
},
|
||||
UPDATE_TWEET_ISLIKE (state, { tweetId, isLikes }) {
|
||||
const tweetIndex = state.tweets.findIndex(t => t.id === tweetId)
|
||||
if (tweetIndex !== -1) {
|
||||
Vue.set(state.tweets[tweetIndex], 'isLikes', isLikes)
|
||||
}
|
||||
const tweetIndexFav = state.favoriteTweets.findIndex(t => t.id === tweetId)
|
||||
if (tweetIndexFav !== -1) {
|
||||
Vue.set(state.favoriteTweets[tweetIndexFav], 'isLikes', isLikes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
state.favoriteTweets = [{
|
||||
id: 1,
|
||||
message: 'https://pbs.twimg.com/profile_images/702982240184107008/tUKxvkcs_400x400.jpg',
|
||||
author: 'Gannon',
|
||||
time: new Date(),
|
||||
likes: 3,
|
||||
isLikes: 60
|
||||
}, {
|
||||
id: 2,
|
||||
message: 'Borderlands 3 arrives on Xbox One, PS4, and PC on September 13, 2019! Tune in to the Gameplay Reveal Event on May 1st, where we’ll debut the first hands-on looks! Pre-order now to get the Gold Weapon Skins Pack! ➜ https://borderlands.com ',
|
||||
author: 'Gearbox Official',
|
||||
authorIcon: 'https://pbs.twimg.com/profile_images/702982240184107008/tUKxvkcs_400x400.jpg',
|
||||
time: new Date(),
|
||||
likes: 65
|
||||
}, {
|
||||
id: 3,
|
||||
message: '',
|
||||
img: 'https://cdn.discordapp.com/attachments/563443658192322576/563473765569396746/samurai-background-hd-1920x1200-45462.jpg',
|
||||
author: 'Gannon',
|
||||
time: new Date()
|
||||
}, {
|
||||
id: 4,
|
||||
message: 'Super Message de la mort.',
|
||||
author: 'Gannon',
|
||||
authorIcon: 'https://pbs.twimg.com/profile_images/986085090684960768/AcD9lOLw_bigger.jpg',
|
||||
likes: 0,
|
||||
time: new Date()
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
message: 'Super Message de la mort.',
|
||||
author: 'Gannon',
|
||||
authorIcon: 'https://pbs.twimg.com/profile_images/986085090684960768/AcD9lOLw_bigger.jpg',
|
||||
likes: 0,
|
||||
time: new Date()
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
message: 'Super Message de la mort.',
|
||||
author: 'Gannon',
|
||||
authorIcon: 'https://pbs.twimg.com/profile_images/986085090684960768/AcD9lOLw_bigger.jpg',
|
||||
likes: 0,
|
||||
time: new Date()
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
message: 'Super Message de la mort.',
|
||||
author: 'Gannon',
|
||||
authorIcon: 'https://pbs.twimg.com/profile_images/986085090684960768/AcD9lOLw_bigger.jpg',
|
||||
likes: 0,
|
||||
time: new Date()
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
message: 'Super Message de la mort.',
|
||||
author: 'Gannon',
|
||||
authorIcon: 'https://pbs.twimg.com/profile_images/986085090684960768/AcD9lOLw_bigger.jpg',
|
||||
likes: 0,
|
||||
time: new Date()
|
||||
}]
|
||||
}
|
||||
Reference in New Issue
Block a user